(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
+25 -14
View File
@@ -377,27 +377,38 @@ class PaymentsController(CoreAuthTokenController, ABC):
"""
# 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
# 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["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 = {
"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
}
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(
self,
@@ -383,6 +383,12 @@ class SafaricomMPesaExpressPaymentsController(PaymentsController):
payment = payment,
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:
if event_note_success: