(20250225) FML
This commit is contained in:
@@ -376,39 +376,29 @@ class PaymentsController(CoreAuthTokenController, ABC):
|
||||
:return: True is the receipt was added, else False.
|
||||
"""
|
||||
|
||||
# If this is not an against-sale kind of transaction:
|
||||
if not payment.metadata.reference.strip().lower().find("against sale") >= 0:
|
||||
return True
|
||||
|
||||
# If this is against some sale:
|
||||
success = False
|
||||
api_input_json = {
|
||||
"transactionDate": date_time.get_current_ist_date_time().strftime("%Y-%m-%d"),
|
||||
"clientId": payment.metadata.idClient,
|
||||
"clientName": payment.metadata.clientName,
|
||||
"clientAddress": None,
|
||||
"deliveryAddress": None,
|
||||
"total": payment.amount,
|
||||
"documentUrl": None,
|
||||
"invoiceNo": None,
|
||||
"deliveryBoyId": None,
|
||||
"deliveryBoyName": None,
|
||||
"lineItems": payment.metadata.againstReference
|
||||
}
|
||||
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
|
||||
# Call the database's procedure:
|
||||
sql_json = await self.call_procedure(
|
||||
sql_conn = sql_conn,
|
||||
proc_name = "sales_transaction_add",
|
||||
proc_args = (
|
||||
payment.user.userId, # ................................................. p_user_id
|
||||
payment.user.billingAccountId, # ....................................... _billing_account_id
|
||||
date_time.get_current_ist_date_time().strftime("%Y-%m-%d"), # .......... _transaction_date
|
||||
payment.metadata.idClient, # ........................................... _client_id
|
||||
payment.amount, # ...................................................... p_amount
|
||||
None, # ................................................................ p_document_url
|
||||
json.to_string(payment.metadata.againstReference, no_space = True) # ... p_description
|
||||
),
|
||||
retry_count = 1,
|
||||
backoff_seconds = 0.5,
|
||||
backoff_multiplier = 1.1,
|
||||
session_token = session_token,
|
||||
alert_on_all_failures = True
|
||||
)
|
||||
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 success
|
||||
# Return the response:
|
||||
if sql_json["status"] == 1: return True
|
||||
else: return False
|
||||
|
||||
async def add_event_by_payment_id(
|
||||
self,
|
||||
|
||||
Reference in New Issue
Block a user