> 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/configuration/treasury-and-upkeep.md).

# Treasury and upkeep

Configure weekly upkeep and the treasury in CAS Advanced Gang System: running costs per tier, debt, treasury requests and ledger history.

## Upkeep

{% code title="config.lua" %}

```lua
Config.Upkeep = {
  enabled = true,
  intervalMinutes = 10080,                       -- 7 days
  cost = { 15.0, 45.0, 120.0, 300.0, 650.0 },   -- per tier; index = tier
  onUnpaid = 'debt',                             -- 'debt' or 'downgrade'
}
```

{% endcode %}

| Setting           | Meaning                                                                                                                                            |
| ----------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- |
| `enabled`         | `false` turns upkeep off. It's always off without a money framework.                                                                               |
| `intervalMinutes` | Time between payments. The server checks each camp's due time once a minute.                                                                       |
| `cost`            | What each tier pays per interval. A tier with no entry pays nothing.                                                                               |
| `onUnpaid`        | `'debt'`: the treasury pays what it can and the rest is carried as debt. `'downgrade'`: the camp drops a tier, and a tier I camp carries the debt. |

While a debt stands:

* nothing leaves the treasury, allowed requests included,
* the camp can't be raised,
* a kick refund isn't paid,
* the next money paid in, by a member or through `AddToTreasury`, clears the debt first,
* the Camp and Ledger tabs show what's owed.

## Treasury

What each member may draw is set per rank (`treasuryWithdraw` and `treasuryCeiling`, see [Ranks and permissions](/script-documentation/cas-advanced-gang/configuration/ranks.md)). Three more settings apply:

```lua
Config.ApprovalQueue = true       -- draws past the daily ceiling become requests; false = refused
Config.OnKick        = 'forfeit'  -- or 'refund'
Config.LedgerHistory = 200        -- ledger entries kept per gang
```

The ledger keeps the newest `LedgerHistory` entries per gang and trims older ones as new ones are written.
