(20250225) FML :')

This commit is contained in:
2025-02-25 17:07:56 +05:30
parent e1a42aae32
commit 16d2d53700
2 changed files with 31 additions and 14 deletions
+17 -6
View File
@@ -377,14 +377,12 @@ class PaymentsController(CoreAuthTokenController, ABC):
""" """
# If this is not an against-sale kind of transaction: # If this is not an against-sale kind of transaction:
if not payment.metadata.reference.strip().lower().find("against sale"): if not payment.metadata.againstReference.get("against", "MKC").strip().lower().find("against sale") >= 0:
return True return True
# If this is against some sale: # If this is against some sale:
api_response = await current_app.http_client.post( success = False
url = "https://api.thecaoffice.com/account/sales/transaction/add", api_input_json = {
headers = {"X-Session-Token": session_token},
json = {
"transactionDate": date_time.get_current_ist_date_time().strftime("%Y-%m-%d"), "transactionDate": date_time.get_current_ist_date_time().strftime("%Y-%m-%d"),
"clientId": payment.metadata.idClient, "clientId": payment.metadata.idClient,
"clientName": payment.metadata.clientName, "clientName": payment.metadata.clientName,
@@ -395,9 +393,22 @@ class PaymentsController(CoreAuthTokenController, ABC):
"invoiceNo": None, "invoiceNo": None,
"deliveryBoyId": None, "deliveryBoyId": None,
"deliveryBoyName": None, "deliveryBoyName": None,
"lineItems": payment.metadata.againstReference "lineItems": payment.metadata.againstReference["salesItems"]
} }
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 success
async def add_event_by_payment_id( async def add_event_by_payment_id(
self, self,
@@ -383,6 +383,12 @@ class SafaricomMPesaExpressPaymentsController(PaymentsController):
payment = payment, payment = payment,
session_token = None session_token = None
) )
sales_transaction_added = await self.add_sales_transaction(
sql_conn = sql_conn,
mongo_data_conn = mongo_data_conn,
payment = payment,
session_token = None
)
# Done here: # Done here:
if event_note_success: if event_note_success: