diff --git a/apps/cic-ussd/cic_ussd/processor.py b/apps/cic-ussd/cic_ussd/processor.py index 864cd53f..b31564ca 100644 --- a/apps/cic-ussd/cic_ussd/processor.py +++ b/apps/cic-ussd/cic_ussd/processor.py @@ -270,7 +270,24 @@ def process_display_user_metadata(user: Account, display_key: str): products=products ) else: - raise MetadataNotFoundError(f'Expected person metadata but found none in cache for key: {key}') + # TODO [Philip]: All these translations could be moved to translation files. + logg.warning(f'Expected person metadata but found none in cache for key: {key}') + + absent = '' + if user.preferred_language == 'en': + absent = 'Not provided' + elif user.preferred_language == 'sw': + absent = 'Haijawekwa' + + return translation_for( + key=display_key, + preferred_language=user.preferred_language, + full_name=absent, + gender=absent, + location=absent, + products=absent + ) + def process_account_statement(user: Account, display_key: str, ussd_session: dict): diff --git a/apps/cic-ussd/cic_ussd/state_machine/logic/transaction.py b/apps/cic-ussd/cic_ussd/state_machine/logic/transaction.py index 2c4bbf02..84c866ee 100644 --- a/apps/cic-ussd/cic_ussd/state_machine/logic/transaction.py +++ b/apps/cic-ussd/cic_ussd/state_machine/logic/transaction.py @@ -11,7 +11,7 @@ from cic_ussd.balance import BalanceManager, compute_operational_balance from cic_ussd.chain import Chain from cic_ussd.db.models.account import AccountStatus, Account from cic_ussd.operations import save_to_in_memory_ussd_session_data -from cic_ussd.phone_number import get_user_by_phone_number +from cic_ussd.phone_number import get_user_by_phone_number, process_phone_number from cic_ussd.processor import retrieve_token_symbol from cic_ussd.redis import create_cached_data_key, get_cached_data from cic_ussd.transactions import OutgoingTransactionProcessor @@ -30,7 +30,7 @@ def is_valid_recipient(state_machine_data: Tuple[str, dict, Account]) -> bool: """ user_input, ussd_session, user = state_machine_data recipient = get_user_by_phone_number(phone_number=user_input) - is_not_initiator = user_input != user.phone_number + is_not_initiator = process_phone_number(user_input, 'KE') != user.phone_number has_active_account_status = user.get_account_status() == AccountStatus.ACTIVE.name return is_not_initiator and has_active_account_status and recipient is not None diff --git a/apps/cic-ussd/transitions/signup_transitions.json b/apps/cic-ussd/transitions/signup_transitions.json index 193ec132..731c8131 100644 --- a/apps/cic-ussd/transitions/signup_transitions.json +++ b/apps/cic-ussd/transitions/signup_transitions.json @@ -36,26 +36,12 @@ "source": "initial_pin_entry", "dest": "exit_invalid_pin" }, - { - "trigger": "scan_data", - "source": "initial_pin_confirmation", - "dest": "start", - "conditions": [ - "cic_ussd.state_machine.logic.pin.pins_match", - "cic_ussd.state_machine.logic.validator.has_cached_user_metadata" - ], - "after": [ - "cic_ussd.state_machine.logic.pin.complete_pin_change", - "cic_ussd.state_machine.logic.user.get_user_metadata", - "cic_ussd.state_machine.logic.user.update_account_status_to_active" - ] - }, { "trigger": "scan_data", "source": "initial_pin_confirmation", "unless": "cic_ussd.state_machine.logic.validator.has_cached_user_metadata", "conditions": "cic_ussd.state_machine.logic.pin.pins_match", - "dest": "enter_given_name", + "dest": "start", "after": [ "cic_ussd.state_machine.logic.pin.complete_pin_change", "cic_ussd.state_machine.logic.user.update_account_status_to_active"