disburse_funds_from_bank

Trigger

  • disburse_funds_from_bank API invoked by disburse_funds_from_bank_worker (Celery worker task)

  • Worker invoked by

    1. disburse_funds_from_bank_beat_producer (Celery beat producer)

disburse_funds_from_bank_beat_producer

Business logic

frequency

hourly (specified by configuration yml)

attempts

yes. subject to a configurable limit specified by configuration yml

driving table

bank_disbursement_batch_status

eligible envelopes

disbursement_schedule_date <= today

AND

cancellation_status = 'NOT_CANCELLED'

AND

number_of_disbursements = number_of_disbursements_received AND

funds_blocked_status = 'FUNDS_BLOCK_SUCCESS'

  1. Pick up eligible disbursement_envelopes

  2. For each disbursement_envelope

    1. Pick up all the bank_disbursement_batch_status records where disbursement_status = PENDING

    2. For each bank_disbursement_batch_status record

      1. Delegate task to disburse_funds_from_bank_worker

      2. Payload -- bank_disbursement_batch_id

disburse_funds_from_bank_worker

  1. Payload -- bank_disbursement_batch_id

  2. Get the benefit_program_configuration (for remitting account details)

  3. For this bank_disbursement_batch_id, get the disbursement_envelope_id from bank_disbursement_batch_status

  4. Get the records - disbursement_envelope & disbursement_envelope_batch_status

  5. For this bank_disbursement_batch_id, create a List<disbursement_id> from disbursement_batch_control

  6. create List<Disbursement> with select from disbursements for this List<disbursement_id>

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

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

  9. Invoke - Disburse API

SUCCESS

update bank_disbursement_batch_status

  1. disbursement_status = 'PROCESSED'

  2. disbursement_timestamp = now()

  3. disbursement_attempts+ = 1

FAILURE

update bank_disbursement_batch_status

  1. disbursement_status = 'PENDING'

  2. disbursement_timestamp = now()

  3. latest_error_code = as received from sponsor bank API response

  4. disbursement_attempts+ = 1

Last updated

Logo

Copyright © OpenG2P. This work is licensed under Creative Common Attribution (CC-BY-4.0) International license unless otherwise noted.