Skip to content

Bank Accounts

Bank accounts represent the company's accounts at financial institutions. Each bank account is linked to a GL account in the chart of accounts, ensuring that all bank transactions are automatically reflected in the general ledger. Bank accounts are also linked to a currency and can be associated with multiple company branches.

Purpose

  • Register and manage the company's bank accounts
  • Link each bank account to a GL account for automatic ledger integration
  • Track bank account details: IBAN, SWIFT code, account number
  • Associate bank accounts with a specific currency
  • Assign bank accounts to one or more company branches (multi-branch support)
  • Serve as the foundation for checks management, account transfers, and bank reconciliation

Entity Attributes

Bank Account

FieldTypeDescription
idbigintPrimary key
company_idbigintFK to companies
bank_namestringEnglish bank name
bank_name_arstring?Arabic bank name
account_numberstringBank account number
ibanstring?International Bank Account Number
swift_codestring?SWIFT/BIC code
currency_idbigint?FK to currencies
account_idbigintFK to accounts (linked GL account)
is_activebooleanWhether the bank account is active
created_attimestampCreation timestamp
updated_attimestampLast update timestamp
deleted_attimestamp?Soft-delete timestamp

Bank Account Branch (Pivot)

FieldTypeDescription
bank_account_idbigintFK to bank_accounts
branch_idbigintFK to branches
is_primarybooleanWhether this is the primary branch

Relationships

API Endpoints

MethodPathDescription
GET/api/accounting/bank-accountsList bank accounts (paginated)
POST/api/accounting/bank-accountsCreate a new bank account
GET/api/accounting/bank-accounts/{id}Get a single bank account
PUT/api/accounting/bank-accounts/{id}Update a bank account
DELETE/api/accounting/bank-accounts/{id}Soft-delete a bank account

Request/Response Examples

Create Bank Account

Request POST /api/accounting/bank-accounts

bash
curl -X POST https://moon-erp.test/api/accounting/bank-accounts \
  -H "Authorization: Bearer {token}" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -d '{
    "bank_name": "National Bank of Kuwait",
    "bank_name_ar": "بنك الكويت الوطني",
    "account_number": "0012345678",
    "iban": "KW81CBKU0000000000001234560101",
    "swift_code": "NBOKKWKW",
    "currency_id": 1,
    "account_id": 4,
    "branch_ids": [1, 2],
    "is_active": true
  }'
dart
final response = await http.post(
  Uri.parse('https://moon-erp.test/api/accounting/bank-accounts'),
  headers: {
    'Authorization': 'Bearer $token',
    'Content-Type': 'application/json',
    'Accept': 'application/json',
  },
  body: jsonEncode({
    'bank_name': 'National Bank of Kuwait',
    'bank_name_ar': 'بنك الكويت الوطني',
    'account_number': '0012345678',
    'iban': 'KW81CBKU0000000000001234560101',
    'swift_code': 'NBOKKWKW',
    'currency_id': 1,
    'account_id': 4,
    'branch_ids': [1, 2],
    'is_active': true,
  }),
);

Request Fields:

FieldTypeRequiredDescription
bank_namestringYesEnglish bank name
bank_name_arstringNoArabic bank name
account_numberstringYesBank account number
ibanstringNoInternational Bank Account Number
swift_codestringNoSWIFT/BIC code
currency_idintegerNoFK to currencies
account_idintegerNoFK to accounts. If omitted, auto-created under 1102.
branch_idsinteger[]NoArray of branch IDs. First element is the primary branch.
is_activebooleanNoDefaults to true

Response 201 Created

json
{
  "data": {
    "id": 1,
    "company_id": 1,
    "bank_name": "National Bank of Kuwait",
    "bank_name_ar": "بنك الكويت الوطني",
    "account_number": "0012345678",
    "iban": "KW81CBKU0000000000001234560101",
    "swift_code": "NBOKKWKW",
    "currency_id": 1,
    "currency": {
      "id": 1,
      "code": "KWD",
      "name": "دينار كويتي",
      "symbol": "د.ك"
    },
    "account_id": 4,
    "account": {
      "id": 4,
      "code": "1102",
      "name": "Cash at Bank",
      "name_ar": "النقدية بالبنك"
    },
    "branches": [
      { "id": 1, "name": "Main Branch", "name_ar": "الفرع الرئيسي" },
      { "id": 2, "name": "South Branch", "name_ar": "الفرع الجنوبي" }
    ],
    "is_active": true,
    "created_at": "2026-02-16T12:00:00.000000Z",
    "updated_at": "2026-02-16T12:00:00.000000Z"
  }
}

List Bank Accounts

Request GET /api/accounting/bank-accounts

Response 200 OK

json
{
  "data": [
    {
      "id": 1,
      "bank_name": "بنك الكويت الوطني",
      "account_number": "0012345678",
      "iban": "KW81CBKU0000000000001234560101",
      "swift_code": "NBOKKWKW",
      "currency": { "code": "KWD", "symbol": "د.ك" },
      "account": { "code": "1102", "name": "النقدية بالبنك" },
      "branches": [
        { "id": 1, "name": "الفرع الرئيسي" }
      ],
      "is_active": true
    },
    {
      "id": 2,
      "bank_name": "البنك الأهلي المصري",
      "account_number": "9876543210",
      "currency": { "code": "EGP", "symbol": "ج.م" },
      "account": { "code": "1102", "name": "النقدية بالبنك" },
      "branches": [],
      "is_active": true
    }
  ],
  "links": { "first": "...", "last": "...", "prev": null, "next": null },
  "meta": { "current_page": 1, "last_page": 1, "per_page": 25, "total": 2 }
}

Update Bank Account Branches

Request PUT /api/accounting/bank-accounts/1

json
{
  "branch_ids": [2, 3]
}

Replaces all existing branch assignments. First element (2) becomes the primary branch. Send an empty array to remove all branch assignments.

Business Rules

  1. GL account required -- Every bank account must be linked to a detail-level GL account (typically under "Cash at Bank" or a sub-account). If account_id is omitted, a sub-account is auto-created under code 1102.
  2. One GL account per bank -- Each bank account should link to a unique GL account to maintain clear audit trails. Multiple bank accounts should not share the same GL account.
  3. Currency assignment -- The currency assigned to a bank account determines the currency of checks issued/received and bank reconciliation for that account.
  4. Multi-branch support -- Bank accounts can be assigned to multiple branches via branch_ids. The first element in the array is the primary branch. An empty array means the bank account is accessible from all branches.
  5. Branch sync -- When updating branch_ids, the provided array replaces all existing branch assignments (sync, not merge).
  6. Cannot delete active accounts -- Bank accounts with associated checks, transfers, or reconciliations cannot be deleted.
  7. Active status -- Only active bank accounts can be used for new checks and transfers.

How Bank Accounts Connect to Other Features

Moon ERP API Documentation