Skip to main content

📒 General Ledger Module (gl_*)

Modul GL adalah jantung keuangan ERP Schema V2. Semua transaksi AR, AP, kas, payroll, dan transaksi lain bermuara ke Universal Journal.

1. Module Purpose

  • Menyimpan Chart of Accounts (COA) per company.
  • Menyimpan header journal (gl_entry) sebagai dokumen keuangan.
  • Menyimpan detail baris jurnal (gl_line) sebagai universal journal line.
  • Menjadi single source of truth untuk laporan keuangan dan audit.

2. Tables & Structure


3. Key Fields & Relationships

3.1 gl_coa

  • Fields utama:
    • company_idcore_company.id
    • code (unique per company)
    • name
    • type (asset, liability, equity, revenue, expense)
    • is_postable (boleh dipost langsung atau hanya header)

3.2 gl_entry

  • Fields utama:
    • company_idcore_company.id
    • entry_date
    • ref_type (mis. AR_INV, AP_INV, CASH_TX, PAYROLL)
    • ref_id (FK logis ke tabel sumber)
    • note

3.3 gl_line

  • Fields utama:
    • entry_idgl_entry.id
    • coa_idgl_coa.id
    • debit, credit
    • branch_id (opsional, untuk segmentasi per cabang)
    • cost_center_id (opsional jika ada dimensi tambahan)
  • Aturan kunci:
    • Untuk setiap entry_id, total SUM(debit) = SUM(credit).

4. Business Flows

4.1 Posting AR Invoice

  1. AR invoice dibuat di fi_ar_inv.
  2. Sistem generate gl_entry dengan ref_type = 'AR_INV', ref_id = fi_ar_inv.id.
  3. Sistem generate gl_line:
    • Debit: Piutang usaha (COA AR)
    • Kredit: Pendapatan (COA revenue)

4.2 Posting AP Invoice

  1. AP invoice dibuat di fi_ap_inv.
  2. Sistem generate gl_entry (ref_type = 'AP_INV').
  3. gl_line:
    • Debit: Beban/Inventory
    • Kredit: Hutang usaha.

4.3 Posting Payment

  • Payment AR/AP atau cash transaction memicu gl_entry baru dengan kombinasi debit/kredit sesuai mapping COA.

5. Example Reports (SQL)

Query di bawah ini adalah contoh SELECT untuk laporan keuangan dasar.

5.1 Trial Balance per Periode

5.2 General Ledger Detail per Account

5.3 Balance Sheet Snapshot (Sederhana)