> ## Documentation Index
> Fetch the complete documentation index at: https://lationscripts.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Banking - Business accounts

> Give a player-owned business an account at the bank from your own resource

A business account is money the bank holds for another resource: a player-owned shop, a garage, a dealership. Your resource opens it, names the owner and the staff, and moves the money. The bank shows it to the player under **Business accounts** with a number, a PIN and a history; customers can transfer to it; nothing about it is managed from the bank.

<Note>
  lation\_shops does all of this out of the box, see [lation\_shops](#lation-shops) below.
</Note>

## Integrate your resource

<Steps>
  <Step title="Open the account">
    Once per business, under an id of your own. Prefix it with your resource so it can never collide with a job name or an account number.

    ```lua theme={null}
    exports.lation_banking:CreateAccount({
        id = 'myshop:24_7', type = 'business', name = 'Grove Street Market',
        owner = identifier,   -- nil while nobody owns it
        balance = 0
    })
    ```

    [CreateAccount](/docs/banking/exports/server#createaccount) answers `nil, 'exists'` when the account is already open, so this is safe to run on every start. The account exports wait for the bank to finish loading before they answer.
  </Step>

  <Step title="Move the money through the bank">
    ```lua theme={null}
    exports.lation_banking:AddAccountMoney('myshop:24_7', 240, 'Sale: 3x Water')

    if not exports.lation_banking:RemoveAccountMoney('myshop:24_7', 1500, 'Stock order') then
        -- not enough in the account, or an admin froze it
    end

    local balance = exports.lation_banking:GetAccountBalance('myshop:24_7')
    ```

    The note is the line the owner reads in the history. [RemoveAccountMoney](/docs/banking/exports/server#removeaccountmoney) is atomic and never lets a balance go negative.
  </Step>

  <Step title="Keep the owner and the staff in step">
    ```lua theme={null}
    -- sold, transferred, repossessed: nil while the business has no owner
    exports.lation_banking:SetAccountOwner('myshop:24_7', newIdentifier)

    -- staff: deposit, withdraw and transfer; manage is never given on a business account
    exports.lation_banking:AddAccountMember('myshop:24_7', identifier, { deposit = true, withdraw = false, transfer = false })
    exports.lation_banking:UpdateAccountMember('myshop:24_7', identifier, { deposit = true, withdraw = true, transfer = true })
    exports.lation_banking:RemoveAccountMember('myshop:24_7', identifier)
    exports.lation_banking:ClearAccountMembers('myshop:24_7')

    -- renamed, or gone (move the money first: a closed account returns nothing to anyone)
    exports.lation_banking:RenameAccount('myshop:24_7', 'Grove Street Market')
    exports.lation_banking:DeleteAccount('myshop:24_7')
    ```

    Staff who should see the account but touch nothing are members with every permission `false`. Staff who should not see it are not members.
  </Step>

  <Step title="Mirror moves made at the bank">
    Only if your resource keeps its own balance. Money also moves without you: the owner withdraws at an ATM, a customer transfers in. Follow the bank's ledger so your own UI shows the same figure.

    ```lua theme={null}
    AddEventHandler('lation_banking:transaction', function(tx)
        if tx.actorName == GetCurrentResourceName() then return end   -- your own moves, already recorded
        local shopId = tx.accountId:match('^myshop:(.+)$')
        if shopId then
            MyShops.SetBalance(shopId, tx.balanceAfter)
        end
    end)
    ```

    The event and its fields are on the [server exports](/docs/banking/exports/server#lation_banking-transaction) page.
  </Step>
</Steps>

## What the player gets

| Who | At the bank |
| :- | :- |
| Owner | Sees the account, pays in, takes out and transfers, sets its PIN, reads the history. |
| Staff | Whatever you gave them: view only, deposit, or withdraw and transfer. |
| Customers | Transfer to its account number like any other. |
| Admins | View it, freeze it, adjust its balance with a reason and clear its PIN from the admin panel. Frozen, it still takes money in but pays nothing out, from the bank and from your resource alike. |

## lation\_shops

With lation\_shops 1.9.0 and lation\_banking 1.1.0 both running, every shop's balance is a business account named after the shop, id `shop:<shopId>`. Nothing to set up: banking on `auto` finds the bank, and the first start opens the accounts with the balances the shops already hold.

| In the shop | At the bank |
| :- | :- |
| Sale, sell-back, stock order, refund, bonus, deposit, withdrawal | A ledger line saying what moved. |
| Bought, abandoned, transferred, assigned, repossessed | The owner follows, or nobody while the shop is for sale. The money stays with the shop. |
| Hired, fired, permissions changed | `view_finances` sees the account, `deposit_funds` pays in, `withdraw_funds` takes out and transfers. Staff with no finance permission do not see it. |
| Renamed, deleted | Renamed, closed. |
| Withdrawn at an ATM, transferred in | Mirrored to the shop's balance and its ledger the moment it happens. |

The shop keeps its own balance in step the whole time, so its dashboard shows what the bank shows, and switching to another banking system later loses nothing. Turn it off under Administration → Config → Finances → **Bank accounts**.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.