check_funds_with_bank
Trigger
check_funds_with_bank API invoked by check_funds_with_bank_worker (Celery worker task)
Worker invoked by
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) )
Pick up Eligible - disbursement_envelope
Delegate a task to bank_check_funds_worker
Payload - disbursement_envelope_id
check_funds_with_bank_worker
Payload - disbursement_envelope_id
get the details of the disbursement_envelope - total funds needed for this envelope
get details from benefit_program_configuration
get the instance of BankConnector (implementing BankConnectorInterface) from BankConnectorFactory
BankConnectorInterface - There will be a connector (implementation of the BankConnectorInterface) for every Sponsor Bank
Invoke - Check Funds API
SUCCESS and FUNDS_AVAILABLE, update the following
disbursement_envelope_batch_status.funds_available_with_bank = funds_available
disbursement_envelope_batch_status.funds_available_latest_timestamp = now()
disbursement_envelope_batch_status.funds_available_latest_error_code = null
disbursement_envelope_batch_status.funds_available_attempts+ = 1
SUCCESS and FUNDS_UNAVAILABLE, update the following
disbursement_envelope_batch_status.funds_available_with_bank = funds_not_available
disbursement_envelope_batch_status.funds_available_latest_timestamp = now()
disbursement_envelope_batch_status.funds_available_latest_error_code = null
disbursement_envelope_batch_status.funds_available_attempts+ = 1
FAILURE, update the following
disbursement_envelope_batch_status.funds_available_with_bank = pending_check
disbursement_envelope_batch_status.funds_available_latest_timestamp = now()
disbursement_envelope_batch_status.funds_available_latest_error_code = error_code
disbursement_envelope_batch_status.funds_available_attempts+ = 1
Last updated