(20250225) FML

This commit is contained in:
2025-02-25 18:30:04 +05:30
parent 7aea7e0270
commit ba3618c489
+21 -31
View File
@@ -376,39 +376,29 @@ class PaymentsController(CoreAuthTokenController, ABC):
:return: True is the receipt was added, else False. :return: True is the receipt was added, else False.
""" """
# If this is not an against-sale kind of transaction: # Call the database's procedure:
if not payment.metadata.reference.strip().lower().find("against sale") >= 0: sql_json = await self.call_procedure(
return True sql_conn = sql_conn,
proc_name = "sales_transaction_add",
# If this is against some sale: proc_args = (
success = False payment.user.userId, # ................................................. p_user_id
api_input_json = { payment.user.billingAccountId, # ....................................... _billing_account_id
"transactionDate": date_time.get_current_ist_date_time().strftime("%Y-%m-%d"), date_time.get_current_ist_date_time().strftime("%Y-%m-%d"), # .......... _transaction_date
"clientId": payment.metadata.idClient, payment.metadata.idClient, # ........................................... _client_id
"clientName": payment.metadata.clientName, payment.amount, # ...................................................... p_amount
"clientAddress": None, None, # ................................................................ p_document_url
"deliveryAddress": None, json.to_string(payment.metadata.againstReference, no_space = True) # ... p_description
"total": payment.amount, ),
"documentUrl": None, retry_count = 1,
"invoiceNo": None, backoff_seconds = 0.5,
"deliveryBoyId": None, backoff_multiplier = 1.1,
"deliveryBoyName": None, session_token = session_token,
"lineItems": payment.metadata.againstReference alert_on_all_failures = True
}
print("ADD SALES TXN INPUT JSON:", json.to_string(api_input_json))
api_response = await current_app.http_client.post(
url = "https://api.thecaoffice.com/account/sales/transaction/add",
headers = {"X-Session-Token": session_token},
json = api_input_json
) )
try: api_json = api_response.json()
except: api_json = {}
print(f"ADD SALES TXN ({api_response.status_code}):", api_response.content)
print("ADD SALES TXN:", json.to_string(api_json))
if api_response.is_success: success = True
# Done here: # Return the response:
return success if sql_json["status"] == 1: return True
else: return False
async def add_event_by_payment_id( async def add_event_by_payment_id(
self, self,