Knowing a customer’s total balance tells only part of the story. TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/arsinousltd-sudo/Arsinous-V8-Sales/llms.txt
Use this file to discover all available pages before exploring further.
accoutsReceivable custom formula goes further by working backwards through the transaction history to identify which specific invoices are still outstanding, then sorting them into five aging buckets based on how many days have elapsed since each invoice date. The result is a compact 3×4 grid that gives you an instant read on the age of the money owed.
The function is spelled
accoutsReceivable (missing the second c in “accounts”) in the source code — this is an intentional quirk of the original implementation. Always use this exact spelling when entering it as a formula or calling it from script.How accoutsReceivable Works
The function accepts a range of transaction rows and a reference date, then returns a 3-row × 4-column array placed directly in the sheet.
Input Parameters
| Parameter | Type | Description |
|---|---|---|
transactions | Range / Array | Rows of [date-string, type, name, amount] — matches columns A–D of the Balance sheet from row 11 downward |
date | Date | Reference date used to compute how many days ago each invoice was raised |
transactions from A11:D and date from C2.
Output Grid
The function returns a 3-row × 4-column array structured as follows:| Row | Column A (label) | Column B (amount) | Column C (label) | Column D (amount) |
|---|---|---|---|---|
| 1 | TOTAL | <net total> | 60-90 days | <amount> |
| 2 | 0-30 days | <amount> | 90-120 days | <amount> |
| 3 | 30-60 days | <amount> | over 120 days | <amount> |
If there are transactions before the filtered date range that contribute to the outstanding balance (i.e., the walked-back unpaid total is less than the net total), a fourth row is appended automatically with the label
Opening and the residual amount. This row does not appear if all unpaid invoices are found within the transaction list.Aging Bucket Logic
The function uses millisecond arithmetic to compare each unpaid invoice date against the reference date. The boundary for each bucket is a multiple of30 × 24 × 60 × 60 × 1000 milliseconds (30 days):
| Elapsed time since invoice date | Bucket |
|---|---|
| Less than 30 days | 0-30 days |
| 30 days or more, less than 60 days | 30-60 days |
| 60 days or more, less than 90 days | 60-90 days |
| 90 days or more, less than 120 days | 90-120 days |
| 120 days or more | over 120 days |
"YYYY-MM-DD" strings using .split("-") and then constructed as new Date(year, month - 1, day).
Step-by-Step Algorithm
Filter empty rows
The input
transactions array is filtered to remove any row where the first element (date) is an empty string. This handles the tail end of an open-ended range like A11:D.Compute the net total receivable
All
amount values (column D / index 3) in the filtered transactions are summed. This becomes the TOTAL value in the output grid. Both positive (invoice) and negative (payment) amounts are included, so the total reflects the true net balance owed.Walk backwards to find unpaid invoices
Starting from the most recent transaction and moving backwards, the function accumulates positive-amount rows (invoices) until the running sum of those invoices reaches or exceeds the net total. This identifies which invoices have not yet been covered by payments.
Adjust for partial coverage
- If
unpaidTotal > total: the oldest walked-back invoice is only partially unpaid. Its amount is reduced by the difference (unpaidTotal - total) before aging. - If
unpaidTotal < total: anOpeningrow is appended to the output representing the portion of the balance that predates the available transaction history.
Full Source
Using the Formula in the Sheet
Enter the formula in any empty cell. It returns a spilled array, so leave the surrounding 3×4 area (or 4×4 if an Opening row is expected) clear.Calling Programmatically from Apps Script
Expected Date Format
Thetransactions range must supply dates in the "YYYY-MM-DD" string format (the default format used by MySQL DATE columns). The function splits on - and constructs a JavaScript Date object: