> For the complete documentation index, see [llms.txt](https://docs.openg2p.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.openg2p.org/~/changes/xKUM0sBXFkyR8F24yAMq/g2p-bridge/development/design-specifications/out-apis-to-bank/check_funds_with_bank.md).

# check\_funds\_with\_bank

### driver condition

<table><thead><tr><th width="235"></th><th></th></tr></thead><tbody><tr><td>frequency</td><td>hourly (specified by configuration yml)</td></tr><tr><td>retries</td><td>yes. subject to a configurable limit specified by  configuration yml</td></tr><tr><td>driving table</td><td>disbursement_envelope_batch_status</td></tr><tr><td>eligible envelopes</td><td><p><mark style="color:blue;">envelope</mark>.<mark style="color:blue;">disbursement_schedule_date &#x3C; today</mark><br><mark style="color:red;">AND</mark></p><p><mark style="color:blue;">envelope.cancellation_status = 'NOT_CANCELLED'</mark></p><p><mark style="color:red;">AND</mark></p><p><mark style="color:blue;">envelope.number_of_disbursements = batch_status.number_of_disbursements_received</mark></p><p><mark style="color:red;">AND</mark></p><p><mark style="color:blue;">envelope.total_disbursement_amount = batch_status.total_disbursement_amount_received</mark></p><p><mark style="color:red;">AND</mark></p><p>(<br><mark style="color:blue;">( funds_available_status = "pending_check"</mark> <mark style="color:purple;">AND</mark> <mark style="color:blue;">funds_available_retries &#x3C; retry_limit)</mark><br><mark style="color:orange;">OR</mark> <br><mark style="color:blue;">( funds_available_status = 'not_available"</mark> <mark style="color:purple;">AND</mark> <mark style="color:blue;">funds_available_retries &#x3C; retry_limit)</mark><br>) </p></td></tr></tbody></table>

### Business Logic

Pick up Eligible - disbursement\_envelope

Pick up Bank Details from table - benefit\_program

Get Bank Connector Instance - from Bank Connector Factory

Invoke - Check Funds API

**If Success and Funds are 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\_retries = +1

**If Success and Funds are 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\_retries = +1

**If 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\_retries = +1


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.openg2p.org/~/changes/xKUM0sBXFkyR8F24yAMq/g2p-bridge/development/design-specifications/out-apis-to-bank/check_funds_with_bank.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
