disburse_funds_from_bank
Trigger
disburse_funds_from_bank API invoked by disburse_funds_from_bank_worker (Celery worker task)
Worker invoked by
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'
Pick up eligible disbursement_envelopes
For each disbursement_envelope
Pick up all the bank_disbursement_batch_status records where disbursement_status = PENDING
For each bank_disbursement_batch_status record
Delegate task to disburse_funds_from_bank_worker
Payload -- bank_disbursement_batch_id
disburse_funds_from_bank_worker
Payload -- bank_disbursement_batch_id
Get the benefit_program_configuration (for remitting account details)
For this bank_disbursement_batch_id, get the disbursement_envelope_id from bank_disbursement_batch_status
Get the records - disbursement_envelope & disbursement_envelope_batch_status
For this bank_disbursement_batch_id, create a List<disbursement_id> from disbursement_batch_control
create List<Disbursement> with select from disbursements for this List<disbursement_id>
get the instance of BankConnector (implementing BankConnectorInterface) from BankConnectorFactory
BankConnectorInterface - There will be a connector (implementation of the BankConnectorInterface) for every Sponsor Bank
Invoke - Disburse API
SUCCESS
update bank_disbursement_batch_status
disbursement_status = 'PROCESSED'
disbursement_timestamp = now()
disbursement_attempts+ = 1
FAILURE
update bank_disbursement_batch_status
disbursement_status = 'PENDING'
disbursement_timestamp = now()
latest_error_code = as received from sponsor bank API response
disbursement_attempts+ = 1
Last updated