Files
wms-app/docs/reviewing/accounting.md
T

9.7 KiB

Accounting Features

Accounting Dashboard

Routes:

  • app/ac_dashboard/index.php
  • app/ac_dashboard/api/engine/by_source.php
  • app/ac_dashboard/api/engine/journals.php
  • app/ac_dashboard/api/engine/pl.php
  • app/ac_dashboard/api/engine/posting_window.php
  • app/ac_dashboard/api/engine/recent.php
  • app/ac_dashboard/api/engine/trend.php

The accounting dashboard summarizes accounting KPIs, posting window status, and high-level financial indicators.

Backend support:

  • ac_dashboard/api/engine/*
  • FinancialReports
  • CompanySettingManager

Revenue Documents

Routes:

  • app/revenue/quotation.php
  • app/revenue/manage_quotation.php
  • app/revenue/order.php
  • app/revenue/manage_order.php
  • app/revenue/invoice.php
  • app/revenue/manage_invoice.php
  • app/revenue/manage_credit_note.php
  • app/revenue/view_invoice.php
  • app/revenue/receipt.php

Revenue workflows include quotations, sales orders, sales invoices, and customer credit notes. Quotations can be converted forward, sales documents support inline tax, and invoices can be posted to the GL.

Backend support:

  • QuotationManager
  • OrderManager
  • InvoiceManager
  • revenue/api/engine/*

Expense Documents

Routes:

  • app/expense/purchase_request.php
  • app/expense/manage_purchase_request.php
  • app/expense/purchase_order.php
  • app/expense/manage_purchase_order.php
  • app/expense/purchase_invoice.php
  • app/expense/manage_purchase_invoice.php
  • app/expense/manage_supplier_credit_note.php
  • app/expense/payment.php

Expense workflows include purchase requests, purchase orders, purchase invoices, and supplier credit notes. Purchase requests can be submitted, approved, rejected, reopened, cancelled, and converted to purchase orders. Purchase documents support inline tax and accounting formula assignment.

Backend support:

  • PurchaseRequestManager
  • PurchaseOrderManager
  • InvoiceManager
  • expense/api/engine/*

Receipt Billing And Receipts

Routes:

  • app/finance/receipt_billing.php
  • app/finance/manage_receipt_billing.php
  • app/finance/receipt.php
  • app/finance/manage_receipt.php

Receipt Billing groups customer invoices for collection. Receipts allocate cash against open customer documents, refresh invoice settlement status, and can be assigned formulas for GL posting.

Backend support:

  • ReceiptBillingManager
  • ReceiptManager

Payment Billing And Payments

Routes:

  • app/finance/payment_billing.php
  • app/finance/manage_payment_billing.php
  • app/finance/payment.php
  • app/finance/manage_payment.php

Payment Billing groups supplier invoices for payment. Payments allocate cash against open supplier documents, refresh settlement status, and can be assigned formulas for GL posting.

Backend support:

  • PaymentBillingManager
  • PaymentManager

Chart Of Accounts

Routes:

  • app/accounting/chart_of_accounts.php
  • app/accounting/manage_account.php
  • app/accounting/api/engine/account.php
  • app/accounting/api/engine/manage_account.php

The chart of accounts manages account code, account name, account type, account category, parent account, posting flag, and status. Account categories are used by reports such as VAT.

Backend support:

  • ChartOfAccounts::getAll()
  • ChartOfAccounts::create()
  • ChartOfAccounts::update()
  • ChartOfAccounts::isPostingAccount()

Departments

Routes:

  • app/accounting/departments.php
  • app/accounting/manage_department.php
  • app/accounting/api/engine/department.php

Departments are optional dimensions on journal lines and accounting reports. Reports can filter by department where supported.

Backend support:

  • DepartmentManager

Account Formulas

Routes:

  • app/accounting/account_formulas.php
  • app/accounting/api/engine/account_formula.php

Account Formulas define GL posting templates by document type. A formula consists of debit/credit lines, account codes, amount keys, descriptions, status, and default flag.

Supported amount keys:

  • grand_total: final document total.
  • total: pre-tax/subtotal-style amount, split by SKU when Product Account Mapping applies.
  • tax: document tax amount.
  • amount: receipt or payment amount.

Backend support:

  • AccountFormulaManager
  • BasePosting::resolveFormula()

Product Account Mapping

Routes:

  • app/accounting/account_formulas.php
  • app/accounting/api/engine/product_account_mapping.php
  • app/inventory/manage_product.php

Product Account Mapping assigns sales and purchase GL accounts to each product/SKU. It is used when an account formula line uses total.

The Product Accounts tab inside Account Formulas is an accounting-only maintenance view. The pencil action opens a modal that edits only sales_account_code and purchase_account_code; full product master data remains in the product maintenance page.

Posting behavior:

  • Sales invoice and credit note total lines use sales_account_code.
  • Purchase invoice and supplier credit note total lines use purchase_account_code.
  • If a product mapping is blank, posting falls back to the formula account for that line.
  • Batch GL posting checks loaded invoice documents and blocks Run when product mappings are missing for formulas that use total.

Backend support:

  • ProductManager::updateAccountMapping()
  • BasePosting::buildSkuTotalLines()
  • InvoicePosting
  • CreditNotePosting
  • PurchaseInvoicePosting
  • SupplierCreditNotePosting

Manual GL Journal

Routes:

  • app/accounting/journal_listing.php
  • app/journal/index.php
  • app/journal/new.php
  • app/accounting/api/engine/save_manual_journal.php
  • app/accounting/api/engine/get_journal_listing.php
  • app/accounting/api/engine/get_journal_detail.php

Manual GL Journals allow users to create or edit journal entries outside source documents. Journal lines include account code, department, debit, credit, and description.

Backend support:

  • GlManager::postManual()
  • GlManager::replaceManual()

Source Document GL Posting

Routes:

  • app/accounting/api/engine/post_gl_entry.php

Source document posting builds journal lines from a source document and selected/default formula, then writes or replaces td_gl and td_gl_item.

Supported source types:

  • invoice
  • credit_note
  • purchase_invoice
  • supplier_credit_note
  • receipt
  • payment

Posting behavior:

  • First post: GlManager::post() creates td_gl and td_gl_item rows.
  • Re-post: GlManager::replace() snapshots the current lines as JSON into td_gl.history, increments td_gl.current_version, then writes new lines. Full version history is preserved.
  • Void: calls GlManager::delete() which hard-deletes the td_gl and td_gl_item rows. No reversal entry is created (future work).

Backend support:

  • BasePosting
  • InvoicePosting
  • CreditNotePosting
  • PurchaseInvoicePosting
  • SupplierCreditNotePosting
  • ReceiptPosting
  • PaymentPosting
  • GlManager::post()
  • GlManager::replace()

Planned — not yet implemented: PostingManager (app/assets/utils/classes/PostingManager.php) is a stub intended as the sole bridge between WMS engine files and the accounting engine. WMS endpoints would call PostingManager::postInvoice() etc. instead of importing accounting classes directly. All methods are TODO — GL posting is currently triggered manually from gl_entries.php, not automatically from WMS saves.

Batch GL Entries

Routes:

  • app/accounting/gl_entries.php
  • app/accounting/api/engine/get_gl_documents.php
  • app/accounting/api/engine/post_gl_entry.php
  • app/accounting/api/engine/acquire_op_lock.php
  • app/accounting/api/engine/release_op_lock.php
  • app/accounting/api/engine/log_batch_action.php

Batch GL Entries load documents by date range and formula, then post or replace GL entries one document at a time. A DB lock prevents overlapping batch posting jobs across tabs/users.

Current safeguards:

  • Requires formula selection.
  • Uses operation locks for gl_post via OperationLockManager — prevents two users running overlapping batch jobs.
  • Uses retry behavior through batch_process().
  • Blocks Run when Product Account Mapping is incomplete for selected formula/document set.
  • Shows Product Accounts status per loaded invoice document.
  • Logs batch totals and failed IDs via BatchActionManager — records start time, end time, total processed, failed IDs, and result message into batch_action_log.

Backend support:

  • OperationLockManager
  • BatchActionManager::log(array $data)

Posting Window

Routes:

  • app/accounting/posting_window.php
  • app/accounting/api/engine/posting_window.php

The posting window controls which dates are open for accounting postings and approved inventory entries. It supports open-from and open-to boundaries.

Backend support:

  • CompanySettingManager
  • PostingWindowGuard::assertOpenDate()
  • GlManager posting validation
  • ReceiptManager and PaymentManager date validation

Financial Reports

Routes:

  • app/accounting/trial_balance.php
  • app/accounting/pl_statement.php
  • app/accounting/balance_sheet.php
  • app/accounting/gl_movement.php
  • app/accounting/vat_report.php
  • app/accounting/api/engine/get_trial_balance.php
  • app/accounting/api/engine/get_pl_statement.php
  • app/accounting/api/engine/get_balance_sheet.php
  • app/accounting/api/engine/get_gl_movement.php
  • app/accounting/api/engine/get_vat_report.php

Reports are generated from td_gl, td_gl_item, md_account, and optional departments.

Report behavior:

  • Date filters use full dates (YYYY-MM-DD payload, dd/mm/yyyy UI).
  • Trial Balance shows opening, movement, and closing balances.
  • P&L shows revenue, expenses, and net profit.
  • Balance Sheet shows asset, liability, equity, and retained earnings.
  • GL Movement shows account-level journal movement.
  • VAT Report uses account categories such as sales_tax and purchase_tax.

Backend support:

  • FinancialReports
  • TaxReportManager