Skip to content

Billing, Refunds & Accountant Verification ​

Coming soon

Day-to-day billing/refund staff procedures are still being written. What's below — the AI-assisted accountant verification process — is documented first since it maps directly to existing code and the quickbooks_verification SOP.

Querying bookings, claims, expenses & transactions ​

These all use the same query shape — GET routes that accept search, filters, joins, order_by, group_by, fields, page, per_page (MongoDB-aggregation-backed, so filters can be fairly rich):

RouteReturns
GET /api/get-bookingsBookings (server/src/api/routes/get-bookings.js)
GET /api/get-claimsClaims (get-claims.js)
GET /api/get-expensesExpenses (get-expenses.js)
GET /api/get-transactionsLedger transactions (get-transactions.js)
GET /api/get-settingsSettings, including the chart of accounts (get-settings.js)

The same filters work whether a human is querying through the dashboard or the AI assistant is querying on a staff member's behalf — there's no separate "AI query" endpoint, the agent calls these same routes as tools.

Accountant verification (AI-assisted) ​

CBS can verify a booking's accounting end-to-end using AI, driven by the quickbooks_verification SOP (server/src/sops/sops.json). It's triggered three ways:

  1. On demand — POST /api/post-booking-verify-quickbooks ({ "BOOKING_ID": "..." }) queues the verification as an async task.
  2. From the dashboard — the Accountant Verification dialog (covered by task__accountant-verification-e2e-test.js) lets an accountant open a booking, see per-item checkboxes (QuickBooks tab, Commissions tab), and trigger/re-trigger verification.
  3. On a schedule — the dynamic scheduler can trigger checks on completed/active bookings automatically.

What the AI actually checks, step by step:

  1. Confirms the booking is in a valid state (active/completed/etc.) for verification.
  2. Sums all debits (charges, fees, add-ons) and credits (payments, discounts, refunds) and checks they balance.
  3. Checks the booking total against the sum of payments/receipts.
  4. Verifies security/rental deposits (pre-auth, capture, release) against the contract — if no explicit deposit is on the invoice, confirms at least one deposit payment was recorded.
  5. For every uploaded payment receipt, runs the speedia_ocr_image tool over it to read the receipt text, and matches the OCR'd amount/type against the correct invoice (booking → booking invoice, extension → extensions invoice).
  6. Confirms transactions map to the right QuickBooks accounts (credit/debit accounts, deposit liabilities, accounts receivable) — see Transactions & Settings below.
  7. OCRs any attached invoice/receipt/contract images and cross-checks amounts, dates, and signee names against the database records.
  8. Confirms booking, payment, extension, and addendum contracts are fully signed (a signature.url present on the document counts as signed).
  9. Collects any discrepancies (balance mismatches, wrong entries, missing deposits, missing signatures).
  10. Writes the result back onto the booking via the patch_booking_allowlisted_fields tool: quickbooks_ai_verification_status, quickbooks_verified_items (a flat map of individual checks, e.g. booking_invoice__balance, payment-receipt__all, booking_contract__all), quickbooks_ai_feedback, quickbooks_last_ai_verification_run, quickbooks_ai_verifier_version.
  11. Optionally raises an alert if discrepancies were found.

Example AI responses from the SOP:

  • Discrepancy: "Booking total is $500, but total payments reconciled sum to $450. Contract is fully signed."
  • Clean: "All payments ($500) match the booking total ($500), security deposits are fully authorized, and all contracts are fully signed."

Transactions & Settings ​

  • Transactions (server/src/domain/transaction.js) are double-entry ledger records: transaction_id, category, status, credit_account / debit_account, amount, currency_code, date_disbursed, reference. Creating one resolves both accounts against the chart of accounts and falls back to a default operating/petty-cash account if a specific one isn't found. Managed via GET /api/get-transactions, POST /api/post-transaction, PATCH /api/patch-transaction.
  • Settings (GET /api/get-settings, PATCH /api/patch-setting) is a MongoDB-backed settings object (looked up by env.SETTINGS_ID) that holds the chart of accounts (per-office accounts with id, category, current balance, disabled flag) plus document/email templates and business rules that the booking/transaction/verification logic above all read from.

Global Rates & Fees Configuration ​

Global default rates and fee policies are configured under settings.rates:

  • Standard Fee Defaults: Standard fees (booking_fee, motor_vehicle_registration_fee, cleaning_fee) default to apply_tax: true. Insurance fee (insurance_fee) defaults to apply_tax: false.
  • Tax Toggle Locking: To ensure consistent accounting and tax filing compliance, apply_tax checkboxes for standard fees are locked in the Rates & Fees UI by default. They can only be modified if booking.allow_fee_tax_toggling is set to true in system settings.
  • 5% Bank Processing Fee: Configured as a 5% fee rate (bank_processing_fee). Automatically injected onto invoice subtotals for new bookings when enabled in settings. Historical/legacy bookings are protected and require explicit staff opt-in via the Apply Bank Processing Fee (5%) checkbox in the Rates & Fees dialog.
  • Royalties Accounting: Royalties (royalties_fee) are maintained as a backend/accounting rate setting for QuickBooks verification calculations. Royalties are never added as line items on customer booking invoices.

Zero-Balance Invoice Settlement & Reconciliation ​

CBS provides automated mathematical reconciliation to carry invoice balances down to an exact $0.00 (Paid) state:

  • Booking Invoice Settlement: Adjusts the base daily rental rate and fee such that the post-tax booking total precisely reconciles with recorded booking payments and credits.
  • Extensions Invoice Settlement: Adjusts the latest extension daily rate and fee to reconcile remaining extension balances down to $0.00, accounting for GCT tax and optional 5% processing fees.
  • Payment & Credit Safeguard: Settlement is gated to prevent unauthorized balance zeroing without recorded financial intake. An invoice can only be settled if at least one non-deposit, non-refunded payment or credit exists matching the target scope (booking or extension).

Offset Fee & Rate Settlement Formula (CSR / Staff Reference) ​

When staff or CSRs calculate an Offset Fee or manual booking fee adjustment when the 5% Bank / Transaction Fee and 15% GCT are enabled:

Effective Divisor = 1 + GCT Rate (0.15) + Transaction Fee Rate (0.05) = 1.20
Offset Amount = - (Balance Due) ÷ 1.20

Practical Examples: Overpaid vs. Partially Paid Invoices ​

1. Overpaid Invoice (Negative Balance Due) ​
  • Scenario: The customer paid more than the recorded invoice (e.g. Booking Total = $1,031.88, Payment Received = $1,034.00, leaving Balance Due = -$2.12).
  • Resolution: Absorb the $2.12 into the base booking fee so the invoice matches recorded payment intake.
  • Math:
    • Base Adjustment = $2.12 ÷ 1.20 = +$1.77
    • Booking Fee increases by +$1.77
    • GCT (15%) increases by +$0.27
    • 5% Bank Fee increases by +$0.08
    • Total Increase: +$1.77 + $0.27 + $0.08 = +$2.12
    • New Invoice Total: $1,034.00, Balance Due: $0.00 (Paid).
2. Partially Paid / Underpaid Invoice (Positive Balance Due to Settle) ​
  • Scenario: The customer paid an agreed down payment or settled amount (e.g. Original Invoice = $4,000.00, Customer paid = $1,000.00, or a negotiated write-off of +$48.00 remaining balance).
  • Resolution:
    • Auto-Settlement: Click Settle to $0.00 Balance to instantly reduce the booking fee and rates to match the exact $1,000.00 collected.
    • Manual Offset Discount: To discount $48.00, calculate the pre-tax offset: -$48.00 ÷ 1.20 = -$40.00. Enter -$40.00 as an Offset Fee. GCT drops by -$6.00 and the 5% processing fee drops by -$2.00, zeroing the $48.00 balance.
    • Credit Write-Off: Under Fees → Credits & Debits, add an approved company Credit for the post-tax dollar amount ($48.00) to settle the balance 1:1.

Bulk monthly car insurance expense automation (POST /api/post-automate-car-insurance-expenses) is fleet maintenance, not a billing workflow — see the Fleet KB for details.


Day-to-day expenses management ​

Here is the step-by-step workflow for creating and submitting a new expense in CBS:

  1. Log into the system and navigate to the Expenses list to view existing recorded expenses. Expenses List
  2. Click the create button to start the Create Expense wizard. Create Expense Wizard
  3. Select the expense category (e.g. Insurance). Expense Category Selection
  4. Choose the specific Car to associate with the expense. Car Selection
  5. Select the Recipient or vendor (this step can be skipped if paid directly from a company account). Recipient Selection
  6. Add the individual expense items, specifying names, descriptions, unit prices, and quantities. Add Expense Items
  7. Review the expense details in the pre-submit step. Review Expense
  8. Submit the expense to finalize transaction details and post it to the ledger. Submit Expense
  9. The new expense will now appear in the refreshed expenses list. Updated Expenses List

Expense Metadata and UI Iconography ​

To improve visual scanning and reporting in the Expenses dashboard, the list view incorporates category-specific styling and comprehensive column filtering:

Category Iconography & Colors ​

Each expense category is associated with a distinct Material icon and color theme (defined in shared/src/expenses/categories.js):

  • Repairs & Maintenance: build icon (Warning Gold)
  • Insurance: shield icon (Accent Purple)
  • Licensing: assignment_turned_in icon (Primary Blue)
  • Claims: gavel icon (Danger Red)
  • Fuel: local_gas_station icon (Success Green)
  • Utilities: bolt icon (Info Light Blue)
  • General / Others: receipt_long / settings / directions_car / payments / more_horiz (Secondary Slate)

Searchable Metadata Fields ​

Expense records expose structured metadata fields for granular search and table columns:

  • Vendors: Automatically extracted and deduplicated from the itemized lines (vendor.name).
  • Invoice Columns: Supports sorting/filtering by Invoice Number, Invoice Due Date, Total, Status, Total Payments, and Currency.
  • Bill Columns: Supports sorting/filtering by Bill Number, Bill To (Company), Bill Due Date, Total, Status, Total Payments, and Currency.

Daily Cash Float & Staff Float Management ​

Cash float workflows provide accountability for physical cash balances held by staff members across branch offices:

  1. Disbursement: Cash is transferred from the office's parent petty cash account to a specific staff member's petty cash account (POST /api/post-transaction, category: cash_float_disbursement, status: pending_acceptance).
  2. Staff Acceptance Gate: The recipient acknowledges and accepts the float on the dashboard or via PATCH /api/patch-transaction (status: "completed"). This records date_accepted and makes the float available for petty cash expenditures.
  3. Expense Receipt Auto-Deductions: Submitting petty cash expense receipts automatically matches against the staff user's active petty cash float account, deducting expenses in real-time.
  4. End-of-Day Return: Remaining unused cash is returned to the main office float (category: cash_float_return), reconciling balances back to baseline.
  5. Real-Time Synchronisation: Every status transition, acceptance, or return emits WebSocket broadcasts (transactions stream), updating accounting KPI balance chips, transaction badges, and notifications across active dashboard sessions immediately.