(20250102) Print statement removed.

This commit is contained in:
2025-01-02 10:12:05 +00:00
parent 2f563b2a0e
commit 7f98f1f662
5 changed files with 108 additions and 49 deletions
@@ -36,6 +36,7 @@ sys.path.append(".")
sys.path.append("..")
# My async utils:
from utils_v2.string import json
from utils_v2.database.async_mysql_v2 import AsyncMySQL
from utils_v2.database.async_mongo_v2 import AsyncMongo
from utils_v2.cache.async_redis_cache_v2 import AsyncRedisCache
@@ -310,6 +311,51 @@ class PaymentsController(CoreAuthTokenController, ABC):
# We don't support updating payments themselves,
# but we will allow updating fields like tags, adding events, etc.
async def add_receipt(
self,
sql_conn: AsyncMySQL,
mongo_data_conn: AsyncMongo,
payment: CorePaymentModel,
session_token: str = None
) -> bool:
"""
The API endpoint that initiates the payment request will send details for calling this procedure in the
'metadata' field. We take those values and invoke the procedure to add a receipt in the database's records.
:param sql_conn: The database connection to use to perform this activity.
:param mongo_data_conn: The database connection to use to perform this activity.
:param payment: The record of the payment whose details need to be added as a receipt.
:param session_token: The session token of the user to identify whose request caused this receipt update.
:return: True is the receipt was added, else False.
"""
# Call the database's procedure:
sql_json = await self.call_procedure(
sql_conn = sql_conn,
proc_name = "accounting_receipt_add",
proc_args = (
payment.metadata["idClient"],
payment.metadata["date"],
payment.metadata["source"],
payment.metadata["amount"],
payment.metadata["reference"],
payment.metadata["inAccount"],
payment.metadata["idUser"],
payment.metadata["documentUrl"],
payment.metadata["notes"]
),
retry_count = 1,
backoff_seconds = 0.5,
backoff_multiplier = 1.1,
session_token = session_token
)
print("RECEIPT ADD SQL JSON:", json.to_string(sql_json, default=str))
# Return the response:
if sql_json["status"] == 1: return True
else: return False
async def add_event_by_payment_id(
self,
mongo_data_conn: AsyncMongo,