check_funds_with_bank

Trigger

  • check_funds_with_bank API invoked by check_funds_with_bank_worker (Celery worker task)

  • Worker invoked by

    1. check_funds_with_bank_beat_producer (Celery beat producer)

check_funds_with_bank_beat_producer

Business logic

frequency

hourly (specified by configuration yml)

retries

yes. subject to a configurable limit specified by configuration yml

driving table

disbursement_envelope_batch_status

eligible envelopes

envelope.disbursement_schedule_date < today AND

envelope.cancellation_status = 'NOT_CANCELLED'

AND

envelope.number_of_disbursements = batch_status.number_of_disbursements_received

AND

envelope.total_disbursement_amount = batch_status.total_disbursement_amount_received

AND

( ( funds_available_status = "pending_check" AND funds_available_attempts < retry_limit) OR ( funds_available_status = 'not_available" AND funds_available_attempts < retry_limit) )

  1. Pick up Eligible - disbursement_envelope

  2. Delegate a task to bank_check_funds_worker

  3. Payload - disbursement_envelope_id

check_funds_with_bank_worker

  1. Payload - disbursement_envelope_id

  2. get the details of the disbursement_envelope - total funds needed for this envelope

  3. get details from benefit_program_configuration

  4. get the instance of BankConnector (implementing BankConnectorInterface) from BankConnectorFactory

  5. BankConnectorInterface - There will be a connector (implementation of the BankConnectorInterface) for every Sponsor Bank

  6. Invoke - Check Funds API

SUCCESS and FUNDS_AVAILABLE, update the following

  1. disbursement_envelope_batch_status.funds_available_with_bank = funds_available

  2. disbursement_envelope_batch_status.funds_available_latest_timestamp = now()

  3. disbursement_envelope_batch_status.funds_available_latest_error_code = null

  4. disbursement_envelope_batch_status.funds_available_attempts+ = 1

SUCCESS and FUNDS_UNAVAILABLE, update the following

  1. disbursement_envelope_batch_status.funds_available_with_bank = funds_not_available

  2. disbursement_envelope_batch_status.funds_available_latest_timestamp = now()

  3. disbursement_envelope_batch_status.funds_available_latest_error_code = null

  4. disbursement_envelope_batch_status.funds_available_attempts+ = 1

FAILURE, update the following

  1. disbursement_envelope_batch_status.funds_available_with_bank = pending_check

  2. disbursement_envelope_batch_status.funds_available_latest_timestamp = now()

  3. disbursement_envelope_batch_status.funds_available_latest_error_code = error_code

  4. disbursement_envelope_batch_status.funds_available_attempts+ = 1

Last updated

Logo

Copyright © 2024 OpenG2P. This work is licensed under Creative Commons Attribution International LicenseCC-BY-4.0 unless otherwise noted.