From 906f3535ab6d708e278a3a4f9a6903629d086b00 Mon Sep 17 00:00:00 2001 From: PSNAppZ Date: Wed, 18 Sep 2024 11:27:17 +0530 Subject: [PATCH] Fix formatting for USSD responses --- .../controllers/ussd_controller.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/openg2p-g2p-bridge-example-bank-api/src/openg2p_g2p_bridge_example_bank_api/controllers/ussd_controller.py b/openg2p-g2p-bridge-example-bank-api/src/openg2p_g2p_bridge_example_bank_api/controllers/ussd_controller.py index 0bce829..6e7d0a9 100644 --- a/openg2p-g2p-bridge-example-bank-api/src/openg2p_g2p_bridge_example_bank_api/controllers/ussd_controller.py +++ b/openg2p-g2p-bridge-example-bank-api/src/openg2p_g2p_bridge_example_bank_api/controllers/ussd_controller.py @@ -40,9 +40,10 @@ async def ussd( response: str = "" _logger.info(f"Your input is {text}") if text == "": - response = "CON What do you want to do \n" + response = "CON Welcome to Example Bank. What do you want to do? \n" response += "1. Get account balance \n" response += "2. Initiate transfer" + response += "3. Request account statement" elif text == "1": response = await self.get_account_balance(phoneNumber) elif text == "2": @@ -70,4 +71,7 @@ async def get_account_balance(self, phone_number: str) -> str: _logger.error("Account not found") return f"END Account not found for this phone number: {phone_number}" - return f"END Available balance is {account.available_balance}" + return ( + f"END Available balance in account ending with {account.account_number[-4:]} is" + f" ₹{account.available_balance:,.2f}" + )