Skip to main content

🏢 Intercompany Module (ic_*)

Modul Intercompany digunakan untuk mengelola entitas dalam grup dan transaksi antar entitas (mis. penjualan antar company holding).

1. Module Purpose

  • Mendefinisikan entitas intercompany dalam satu tenant.
  • Menyimpan transaksi intercompany (IC transaction).

2. Tables & Structure

TabelDeskripsi singkat
ic_entityEntity dalam grup (anak perusahaan, dsb.)
ic_txTransaksi antar entity

3. Key Fields & Relationships

3.1 ic_entity

  • Fields: tenant_id, company_id, code, name, type (holding, subsidiary, branch_entity).
  • FK: tenant_idcore_tenant.id, company_idcore_company.id.

3.2 ic_tx

  • Fields: tenant_id, from_entity_id, to_entity_id, tx_date, amount, currency, description, status.
  • FK: from_entity_id, to_entity_idic_entity.id.

4. Business Flows

4.1 Billing Intercompany

  1. Company A menjual barang/jasa ke Company B (keduanya dalam satu tenant).
  2. Transaksi tercatat di ic_tx sebagai intercompany transaction.
  3. GL masing-masing company tetap tercatat di gl_entry + gl_line dengan COA khusus IC.

5. Example Reports (SQL)

Contoh SELECT untuk laporan intercompany.

5.1 Ringkasan Transaksi Intercompany per Pasangan Entity

SELECT
  e1.code AS from_entity,
  e2.code AS to_entity,
  SUM(t.amount) AS total_amount
FROM ic_tx t
JOIN ic_entity e1 ON e1.id = t.from_entity_id
JOIN ic_entity e2 ON e2.id = t.to_entity_id
WHERE t.tenant_id = :tenant_id
  AND t.tx_date BETWEEN :start_date AND :end_date
GROUP BY e1.code, e2.code;

5.2 Outstanding IC Transactions

SELECT
  t.id,
  e1.code AS from_entity,
  e2.code AS to_entity,
  t.tx_date,
  t.amount,
  t.status
FROM ic_tx t
JOIN ic_entity e1 ON e1.id = t.from_entity_id
JOIN ic_entity e2 ON e2.id = t.to_entity_id
WHERE t.tenant_id = :tenant_id
  AND t.status <> 'settled';