> For the complete documentation index, see [llms.txt](https://code-after-sex.gitbook.io/script-documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://code-after-sex.gitbook.io/script-documentation/cas-advanced-gang/playing/treasury.md).

# The treasury

The gang treasury in CAS Advanced Gang System: paying in, drawing out, requests the leader allows or refuses, weekly upkeep and money from other scripts.

The **Ledger** tab is the gang's money. Every movement is written into the book with a name, an amount, a note and the balance after it.

## Paying in

Any member can pay in from their own money, with a note if they like. It counts toward the rider's *Contributed* total on the roster and toward the gang's `treasuryEarned` challenge. If the camp owes upkeep, the payment clears the debt first.

## Drawing out

Drawing out needs `treasuryWithdraw`. The server checks, in order:

1. the camp isn't contested (when `Config.Territory.lockStores` is on),
2. the camp owes no upkeep,
3. the treasury holds that much,
4. the draw fits your rank's daily ceiling.

The **daily ceiling** (`treasuryCeiling`, `0` = none) counts the whole day's draws, so small withdrawals can't add up past it. The tab shows what you have left today.

Money drawn out also comes off the gang's `treasuryEarned` progress, so paying in and drawing straight back out builds nothing toward a tier.

## Requests

A draw that would take a rider past their ceiling becomes a **request** instead of a refusal:

* The leader (the rank holding `disband`) is told, and sees it on the Ledger tab with **Allow** and **Refuse**.
* The money goes into the rider's own purse, so **Allow** only works while they're on the server. While they're away the request is marked *away* and waits. **Refuse** works at any time.
* If the treasury is short, the camp owes upkeep or the camp is contested when the leader allows it, the leader is told why and the request stays open.
* The rider is told whether it was allowed or refused.
* Requests are saved in the database, so they wait through a restart.
* A rider who leaves or is kicked takes their open requests with them.

With `Config.ApprovalQueue = false` there are no requests. The draw is refused, and the tab says so before the button is pressed.

## Upkeep

Every week (`Config.Upkeep.intervalMinutes`) the camp pays its tier's upkeep from the treasury. The Camp and Ledger tabs show when it's next due. If the treasury can't cover it, `Config.Upkeep.onUnpaid` decides:

| Value         | Result                                                                                                                                      |
| ------------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
| `'debt'`      | The treasury pays what it holds and the rest is carried as debt. Until it's paid, nothing leaves the treasury and the camp can't be raised. |
| `'downgrade'` | The camp drops a tier. A tier I camp can't drop, so it carries the debt.                                                                    |

See [Treasury and upkeep](/script-documentation/cas-advanced-gang/configuration/treasury-and-upkeep.md).

## Money from other scripts

Heist, job or bounty scripts can pay straight into a gang's treasury with the `AddToTreasury` export. It writes a ledger entry under the name you pass. See [Exports](/script-documentation/cas-advanced-gang/developers/exports.md#addtotreasury).
