Accounting
Accounting (owner/manager only) is a tabbed page: Expenses, Payments Collected, and Payments Due. A Monthly/Yearly switcher above the tabs controls the period the P&L tiles and Payments Collected tab cover.
Expenses tab
- Dynamic Expense Calculations: Operating expense totals in P&L reports are calculated dynamically from actual payment records in the
operating_expense_paymentsledger. - One-off expenses: Includes a
"Mark as Paid Immediately"option. If unchecked, the expense is recorded as pending without an immediate cash outflow entry. Editing a non-recurring expense automatically updates its linked payment entry. - Recurring expenses: Configured with interval and next-due-date fields. When editing a recurring bill template, an optional
"Apply changes to past payments too"toggle allows staff to choose whether to update past historical payments or preserve historical records while updating future cycles. - Hard-Delete Payment Removal: Deleting an expense performs a hard deletion on all related
operating_expense_paymentsrecords, immediately updating P&L operating expense totals. - Expense Payment Editing & Deletion (Current Month Policy):
- Staff with
EXPENSE_MANAGEauthority can modify or delete individual payment records from the “Month’s Expenses” table (PUT /api/v1/accounting/expenses/payments/{paymentId}andDELETE /api/v1/accounting/expenses/payments/{paymentId}). - Accounting Period Lockdown: For financial integrity and P&L audit trail safety, payments from previous closed calendar months (
Asia/Colombotimezone) cannot be edited or deleted. Action buttons in the monthly table are active only for expenses recorded or paid in the current calendar month. - Flexible Payment Date Updates: When editing an eligible payment, staff can update the payment date (
paidAt) to any past or future date (e.g. to correct data entry oversights or record advance disbursements). - Ledger & Entity Synchronization: Updating a payment updates both the payment transaction and parent expense entity (amount, category, description, and paid date). Deleting the final payment of a one-off expense automatically soft-deletes the parent expense.
- Staff with
- A recurring-bill reminder email (staff/owner, configurable lead time).
Always shows all expenses regardless of the Monthly/Yearly switcher above — expenses aren’t period-scoped.
Payments Collected tab
A read-only feed of receipts for the selected period — customer, invoice, service (Visa/Flight/Tour/General), amount, payment method, reference, and collection date. It shares the same period picker as the P&L tiles above it, and surfaces the exact same underlying receipt data those figures are already computed from — there’s no separate ledger or sync mechanism behind it, just a visible list over existing data.
- Server-Side Pagination (
GET /api/v1/accounting/payments-collected/paged): Queries receipts via Spring DataPageablewith 20 items per page. The backend query usesLEFT JOIN FETCH r.invoiceto completely eliminate N+1 queries when reading linked invoices, and batches customer lookups. - Monthly & Yearly Support: Supports both monthly filters (
year,month) and yearly overviews (year), with page-by-page navigation and table shimmer loading skeletons. - Live Count Badges: Displays total receipts collected in both the tab selector pill (
Payments Collected (N)) and the table section header.
No export or drill-down into the invoice itself; use the Finance & Invoicing screens for that.
Payments Due tab
A read-only list of unpaid and partially-paid invoices — customer, invoice, service (Visa/Flight/Tour/General), total, paid, balance, status, and date. Unlike the other two tabs, this always shows every outstanding invoice regardless of the Monthly/Yearly switcher, since an overdue balance from an earlier period is still due today.
- Dedicated Paged Endpoint (
GET /api/v1/invoices/due): Rather than fetching all historical company invoices into client memory, uses a dedicated indexed database query (findByStatusInAndDeletedAtIsNull(['unpaid', 'partial'])) with 15 items per page and server-side sorting (createdAt,desc). - Live Count Badges: Real-time count badges displayed in both the tab pill (
Payments Due (N)) and table section header. - Table Shimmer Loading: Displays animated skeleton rows during page transitions to prevent layout shifts.
Monthly vs. Yearly view
- Monthly — the default. P&L tiles and Payments Collected cover the selected calendar month, with the usual month-by-month navigation.
- Yearly — P&L tiles are summed for the whole selected year, and a Jan–Dec breakdown table appears underneath showing Total Invoiced and Gross Profit for each month side by side. Payments Collected switches to the full year’s receipts.
P&L figures are always accurate
The Total Invoiced, Cost of Sale, Gross Profit, Operating Expenses, and Net Profit figures shown at the top of the Accounting page are computed live from invoices, costs, receipts, and expense ledgers — not from anything entered on either tab. The Cost of Sale KPI card is located on the Accounting page alongside Gross Profit, Operating Expenses, and Net Profit.
How Profit is calculated
Profit isn’t simply revenue minus cost — visa and flight/ticket invoices are counted differently, since only one of them has a real, agency-set margin line:
- Visa invoices — profit is the Consulting Fee line item only. The Visa Fee line item is a pass-through cost remitted to the embassy or vendor, not agency margin, so it’s excluded from profit even though it’s part of the invoice total. (See Quotations for where Visa Fee / Consulting Fee are set as pricing-template fields.)
- Flight/ticket invoices — profit is Total Amount − Cost Amount (the markup over what was actually paid to the airline/consolidator).
- Tour invoices — same as flight: Total Amount − Cost Amount (what was actually paid to the guider/vendor for that tour). Cost Amount is collected on every tour invoice at issue time — templated and manual tours alike — via the same internal-only “Cost Amount” field flight invoices use.
This same formula applies everywhere Profit is shown — the P&L tiles here, the Financial Dashboard, the per-staff breakdown, Company Statistics, and the Monthly Executive Digest email & CSV reports — all driven by the same calculation rules, so these can never drift apart from each other. Every invoice carries a persisted service type (Visa, Flight, or Tour) recorded when it’s issued, Flight, or Tour) recorded when it’s issued, rather than being guessed later from which kind of request it’s linked to — this is what makes Tour’s profit figure (and its own revenue tile below) reliable rather than silently folded into another category.
Fee breakdown
Alongside the top-level P&L tiles, the underlying report breaks Total Invoiced down into:
- Visa Fees: Embassy and visa processing fees.
- Consulting Fees: Service charges for visa handling.
- Flight Ticket Breakdown:
- Ticket Sale: Total flight invoice revenue.
- Cost of Sale: Total airline and consolidator procurement costs.
- Flight Profit: Net flight margin (
Ticket Sale − Cost of Sale).
- Tour Revenue: Package and custom tour inquiry revenue.
- Other Fees: Isolated to genuine miscellaneous service line items (e.g. Courier, Insurance, Office Charges, Clearing Charges, Fresh Passport) on Visa or General invoices. Ticket prices and flight/tour charges are strictly excluded to prevent double-counting.
- Tax and Discount: Period tax and discount totals netted into final invoices.
This reconciles directly:
Total Invoiced = Visa Fees + Consulting Fees + Other Fees + Flight Ticket Sales + Tour Revenue + Tax - DiscountFlight Profit Breakdown Drawer
Clicking on the Flight Tickets card or the “View Table →” action on the Accounting page opens the Flight Profit Breakdown Drawer (<FlightProfitDetailDrawer />).
This interactive drawer gives accounting and management full audit visibility into every flight ticket billed during the selected accounting period (monthly or yearly):
- Customer & Invoice Details: Displays the customer name and linked invoice reference code.
- Flight & Route Metadata: Displays the passenger name, flight route (e.g.
CMB → DXB), airline, and airline booking PNR reference. - Financial Breakdown Columns:
- Ticket Sale (LKR): Gross invoice amount billed to the client for the ticket.
- Cost of Sale (LKR): Direct procurement cost paid to the airline, consolidator, or GDS supplier.
- Flight Profit (LKR): Net agency gross margin (
Ticket Sale − Cost of Sale), highlighted in emerald green.
- Top Summary KPIs: Dynamically sums the Ticket Sale, Cost of Sale, and Flight Profit for the currently filtered view.
- Real-Time Search: Filters rows instantly across customer names, passenger names, invoice numbers, route destinations, airlines, and PNR codes.
- Pagination: High-performance paginated table with 10 records per page.
Other Fees Detail Drawer
Clicking the Other Fees card or the “View Table →” action opens the Other Fees Detail Drawer (<OtherFeesDetailDrawer />).
- Isolated Miscellaneous Fees: Displays individual line-item charges for non-core services (e.g., Office Charges, Courier, Clearing Fees, Document Translation, VIP Lounge, Fast-Track).
- Zero Double-Counting: Flight ticket prices and tour charges are strictly excluded at the database repository query level (
fieldName <> 'Ticket Price'andserviceType NOT IN ('TOUR', 'FLIGHT')), guaranteeing that Other Fees contains only pure auxiliary fees. - Reconciliation Transparency: Enables auditors to cross-examine every rupee in the “Other Fees” KPI against client invoices and receipts.
Date Range & Timezone Preservation
All monthly and yearly date bounds on the Accounting dashboard are computed with explicit local calendar day boundaries in Sri Lanka Standard Time (Asia/Colombo, UTC+05:30):
- Start of Period: Evaluated as
${year}-${month}-01(00:00:00 local). - End of Period: Evaluated as the exact calendar last day of the month using local
.getDate()(e.g.2026-09-30), preventing UTC-shift truncation where late-evening transactions on the 30th/31st would otherwise be omitted from drill-down drawer queries.