Repository navigation
Finance: expense and income tracking, books (ledger, VAT, cheques, receivables, bills) and year-end close - #37
Merged
Conversation
Bank and cash accounts with balances worked out from the opening balance, entries and transfers; expense and income categories managed in Settings; transfers between accounts. Manager and Administrator edit, the Partner reads with account numbers masked, other roles have no access. - API: /api/finance accounts, categories and transfers, FinanceCalculator with shared test vectors, Fin* tables and the AddFinance migration - Web: Accounts page (total panel, account cards, recent transfers), account and transfer dialogs, Settings finance categories card - Docs: Phase 3 stage 3 build plan Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Record, list and filter expenses. A receipt (PDF, JPEG or PNG, up to 5 MB, at most 5 files, judged by content) is required; files are kept in a server folder and only their details in the database. - API: /api/finance/expenses (create as multipart, list with filters and server-side total, get, paid-to suggestions) and receipt download; FinAttachments table and EXP/INC number sequences (AddFinAttachments) - Web: Expenses page (period chips, search, filters, table and phone cards), Add expense form with camera capture, receipt viewer dialog - Deploy: Finance__ReceiptsPath documented; App_Data ignored Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Income entries share the expense page and dialog. Entries and transfers are never deleted: they are voided with a reason, or corrected by voiding the original and adding a linked replacement. Managers can lock a month (and unlock it with a reason); locked months reject every change. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
New /finance page: net result for the last 7, 30 or 365 days against the days before, income and expenses by day or month, spending by category, balances today and the latest entries. All figures come from one server-side /api/finance/dashboard endpoint. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…shboard replies Corrections claim the original entry or transfer inside the transaction, so two simultaneous corrections cannot both succeed. The dashboard shows only the reply to the latest period click. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…, F6) New /finance/reports page: a period statement per account (opening, income, expenses, transfers, closing) and by category, downloadable as Excel, PDF or CSV from one server-side calculation. The staff export code gained a multi-table PDF and a shared workbook builder so finance reuses the company letterhead. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The client will enter everything by hand and may reconsider an import later. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Partners page with each partner's exact capital and two-decimal share that always adds up to 100.00. Capital added or returned raises or lowers an account balance but is never income or expense; it can be voided, corrected and month-locked like other entries. The report statement gains a Capital column and a Partners' capital section in the screen, Excel, PDF and CSV. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Each calendar month of the period gets its own entries, income, expenses, net, capital and Locked or Open marker, with a total row, on screen and in the Excel, PDF and CSV files. Also stops the CSV from altering negative numbers. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…wn, nav fixes) Entry tables keep their row tools in view and sort by any column; expense and income lists download as CSV; account cards link to their entries; the overview gains Add income and Add expense, change against the previous period and a labelled chart axis. The menu highlight, breadcrumb and tab title now pick the longest matching path, and the tab title no longer shows a stray character. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
A name such as ..\..\evil.pdf kept its dots on Linux because only / is a path separator there. Backslashes are now treated as separators on every host. Fixes the failing API test on CI. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ta Sans, softer surfaces, motion) Shared tokens and kit components only: Solid button style, Inter body with Plus Jakarta Sans for titles and key figures, mint-tinted surfaces, layered card shadows, a custom select chevron, animated dialogs, shimmer skeletons and gentle reveals, all honouring reduced motion. Also fixes literal placeholder text in the receipt help line. design-system.md updated. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Category shares are worked out to one decimal with the largest-remainder rule so they add up to exactly 100.0 (whole numbers gave 101). Bars are drawn as the share of the total, not relative to the biggest item. The overview shows the money in the accounts under the net result, a Partners' capital card with exact shares, and capital entries in the latest list. Account cards use exact one-decimal shares too. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Amount and counterparty lead, date second, notes, account and reference quieter, actions quietest with Void in red. Applied to expense and income cards and rows, partner movements, transfers, latest entries, account and partner cards and the report statements, where zero amounts are muted so the figures that moved stand out. Also fixes the settings category rows, whose names collapsed to one letter per line on a phone. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…enses, staff entry with approval, petty cash, Excel import, more reports) Cheque register (tracking only), saved payees, expenses split between categories, staff expense submission with Manager approval and an Entered by column, petty cash as custody accounts, Excel import with row checks, and reports by payee, by person, cash flow and day/week/year views. Four migrations. Adds an end-to-end scenario test on the client's real kind of data. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…urnals, safety checks, Books screen) Every entry, transfer, capital movement and opening balance posts a balanced journal by itself; voids post reversals. Journals are derived and idempotent, so they sync after every finance write and before every read. Safety checks compare the books with the finance screens. Adds the Books page (trial balance, ledger, journals) and a migration. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…r the books (L2, L3) Add, rename and switch off ledger accounts; choose which ledger account each category, account and partner posts to (rebuilds the books, Administrator only, refused once a month is locked); manual journals that must balance, respect month locks and are undone by reversal; Excel, PDF and CSV of the trial balance, each ledger and the journals. The safety checks compare the records alone and count manual journals apart. Adds a migration. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Both statements come from the journals alone. The P&L net equals the finance report net for the same period, and total assets equal the sum of the account balances; journals posted by hand are included and counted on the statement. Excel, PDF and CSV downloads and two new Books tabs. API suite 1,394 passing; web suite 787 passing, with one timing-dependent test (App.test or Layout.phone, a different one each full run) failing under whole-suite load and passing alone. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ivable until they clear - Tax types (Standard, Zero, Exempt, Reverse Charge, Intra GCC) per entry, with a category default; inclusive or added on top - VAT posted to the ledger; VAT return report with Excel download and a VAT screen - Linked cheques post to Cheques payable/receivable at issue and clear to the bank; bank statement balance shown on accounts - Calculator vectors for VAT and allocation; API (1,430) and web (805) suites pass Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
- Closing a finished year locks its twelve months and posts one journal that moves income and expenses to Retained earnings - Years close in order; staff expenses still waiting for approval block the close; months of a closed year cannot be unlocked until the year is reopened - Administrator can reopen the latest closed year with a reason (reversing journal); Profit & Loss of a closed year still reads the same - Books > Year end tab; API (1,433) and web (809) suites pass Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
- Issuing an invoice posts receivable, sales and output VAT; cancelling reverses it - A payment on an invoice now picks the bank or cash account and adds an income entry that clears the receivable (not new revenue); removing it voids that entry; such an entry cannot be voided or corrected on its own - Books > Receivables: aging by how late, total equals the receivables account; new safety check compares the ledger with unpaid invoices - VAT return counts an invoice once, from its issue date - Invoices cannot be issued, and payments cannot be recorded, in a locked month - API (1,436) and web (814) suites pass Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Decisions needed, what to collect from Daftra, entering the opening position, dry run, release and rollback, checks, parallel month, switch-off. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
- Finance > Bills: enter a supplier bill (lines by category, VAT type); it books the cost, VAT and payable at once and moves no bank balance - Pay a bill (all or part) from a bank or cash account: adds an expense entry that clears the payable, not a second cost; take a payment back with a reason; void a bill while nothing is paid - Payment entries cannot be voided or corrected on their own; locked months refuse bills and payments - Books > Payables aging, new Payables safety check, VAT return counts bill VAT once from the bill date (reverse charge posts the input/output pair) - API (1,439) and web (822) suites pass Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…k covers supplier bills The previous commit staged docs/ wholesale and pulled in quotations and sample files that do not belong to this change. They stay on disk, untracked. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
- The books start from a short standard chart (prepaid, deposits, fixed assets, accrued items, loans, named expense accounts); the starting categories post to their named accounts from the first day; the two capital categories make no empty accounts - Books > Monthly journals: set up a journal once (day of month, first and optional last month) and press Post due months; each month posts once as a manual journal, a locked month is left and reported, nothing posts in the background; covers prepaid spreading, depreciation and accruals - docs/finance-chart-of-accounts.md replaces the Daftra-shaped mapping: the chart, how each thing is booked, and a crosswalk used once for opening balances - API (1,444) and web (827) suites pass Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…red on every database - Bills keep PDF, JPEG or PNG files (judged by their bytes, 5 MB each, at most 5); view, add and remove from the bill or attach while entering it; a bill whose file upload fails is still saved and the user is told - Files cannot be added to a voided bill or changed in a locked month; the file lives in the receipts folder like every receipt - The standard chart accounts are created on every sync, so databases set up before it get them too (existing codes are left alone) - Monthly journals checked in the browser: template created, due month posted, books banner stayed green - API (1,446) and web (829) suites pass Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…with a timeline Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…funds - "VAT paid to tax authority" (expense) debits VAT payable; "VAT refund from tax authority" (income) credits VAT recoverable; the bank moves, nothing is a cost or income - They carry no VAT, are left out of the VAT return, cannot be split or used on supplier bills, and are not offered to staff; the entry form hides the VAT choice for them - Seeded by migration (ids 13 and 14); mapped to the system VAT accounts by id, so renaming them is safe - Docs: how a return is settled (net with a manual journal, then pay), and the VAT brought forward at 31 December - API (1,450) and web (831) suites pass Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
… do not block year-end close) - A cheque linked to an expense or income is booked in the ledger on its write, clear and cancel dates, so creating, editing or changing it in a locked month is now refused - A year that holds only opening balances no longer blocks closing the years after it - Runbook: check for invoices already issued in the app before entering the opening position, since they post to the books on their invoice date - API suite (1,452) passes Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…, recurring start month) - The VAT settlement categories take ids 13 and 14; the migration first moves any user category already on those ids to new ids and repoints entries, lines, bill lines and payees, so an already-migrated database can still upgrade (tried on a scratch database) - The bill list works out unpaid, overdue and paid before capping at 500, so a pile of newer paid bills cannot hide an old unpaid one - A monthly journal cannot start more than two years back, so one click cannot post hundreds of journals - API suite (1,454) passes Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…nd bill payments, explain accrual vs cash From the finance screen review: - A new entry no longer starts on "Standard rated". A category can say it never carries VAT (salaries, advances and government procedures are seeded that way), offer a VAT type first, or ask each time; the form remembers the choice per category and refuses to save until a type (or "no VAT") is chosen - Categories gain NoVat and IsSystem; the app's own categories (invoice and supplier bill payments) are kept off entry forms and refused on entries - Payments on tax invoices and supplier bills are tagged on the Income and Expenses lists and offer no Correct or Void there; the Income subtitle no longer says it is not linked to invoices - Books profit and loss and balance sheet say they count invoiced and billed amounts, so they can differ from the cash Finance screens - Settings shows system categories read-only; the VAT default picker gains "Never carries VAT" Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
From the finance screen review: - Books: the eleven views are grouped into Statements, Owed, Records and Setup, so none is hidden off the end of a scrolling strip - Month lock: "Lock every month up to" (asks first, oldest month first), a plain "Locked up to ..." line, and a warning when a month is open although a later one is locked; Expenses and Income say why an old month cannot be changed - Where records post: bank, cash and partner rows offer only ledger accounts they can take and that no other row uses; "Custody" reads "Petty cash"; a sentence says what changing it does Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
From the finance screen review: - Finance > Setup (Manager and Administrator): categories with their VAT, the month lock and the staff who may enter expenses, moved out of the HR Settings page, which now links to it - Finance overview: a Needs attention panel with overdue and due-this-week bills, cheques and invoices, staff expenses to approve, a finished month still open, and the next VAT return date (new endpoint /api/finance/attention) - API and web tests added for both Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
From the finance screen review: - VAT page: This quarter, Last quarter and This year; says when the quarter's return is due; downloads sit under the figures - Add expense and income: date and who first, then amount, category and account; Save stays at the foot of the dialog; "Save and add another" keeps the date, account, category and VAT; the camera button shows only on phones Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
… in due order From the finance screen review: - The phone More sheet has headings where the finance screens begin and end - On a phone, Download CSV and Import wait behind "More tools", so the expense list starts higher - Bills: owed, overdue and due-in-7-days figures above the unpaid list, which reads in the order the bills fall due - API (1,458) and web (850) suites pass Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
- Finance roles can search entries, supplier bills, cheques and tax invoices by number, name (spaces ignored, so "msk" finds "M S K Luxuries"), reference or exact amount (new endpoint /api/finance/search) - Picking a result opens its list on that record, across all dates and whether or not it is paid or cleared - Web (854) and API search tests pass Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
- Meta text on the finance screens goes from 12px to 13px - Expenses and Income say what Correct and Void do; the ledger picker says "Ledger account" - The income and expenses chart shows a pair's figures when pointed at or tapped, and the legend says which bar is which - First-run "Get started" checklist on the finance overview, ticked off from what exists, hideable, gone when done - Web suite (857) passes Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…arry less - Changing or resetting a password ends the sign-ins made before it. The person changing it is given a new token and stays signed in. Existing sessions carry on after the upgrade until their password changes. Adds a Users.SecurityStamp column. - The options for staff expense entry send only what the form needs. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ments up to date - The VAT return download's first note was broken mid-sentence. - Runbook: how to clear invoice payments made before they were linked to an account, the VAT period step, current migrations and what turns the books banner red. A test follows the journal the runbook describes. - Chart of accounts: salary advances are an asset cleared by journal, customer advances, VAT recovery. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
A staff submission is saved at 100 percent and refused if it asks for anything else; the field is not on the staff form. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ries off bills - Page and card actions sit top right; one control for period switches; one toolbar for Reports and VAT; downloads in the card header in Books. - Layouts that broke at desktop widths: the entries table, the VAT tables, category rows in Finance setup, the report dates, bill rows. - Voiding a bill or taking back a payment uses the danger button. - A bill or a payee can no longer use a category the app posts to itself; the server refuses it on a bill. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…aders - One page header: actions level with the title, the description under both, and a rule before the content. - Month fields and their buttons share a toolbar on the payroll and deductions pages; the staff payroll table fits the page. - Petty cash shows its totals as figures; Finance setup and Settings use the same section links. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…t into the Letters header - Accounts: bank and cash sections, banks-versus-cash bar, masked IBAN, pending cheque notice, quieter transfer voiding with a required reason, card actions in a menu. - Dashboard: "attendance not marked" state, waiting items oldest first with late tags, clearer chart, invoice aging, pay by name behind a toggle. The bell counts decisions waiting; each menu entry counts its own module. - Staff Leave: tabs, decision context (balance, overlap, document), reject reason, filters, sorting and paging, rename and confirm for leave types. The leave export takes optional status, search and date filters. - HR Letters: "New request" sits in the page header. - Dialogs that are removed return focus to their opener. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
… Finance - Each invoice has one VAT type: Standard 5%, Zero rated or Exempt. The screen, PDF and VAT report follow it, and an exempt document is headed "Invoice". - Finance income picks from the same client list as invoices, invoice payments are filed under their client, and Payees now holds only who the company pays. A name typed on an invoice joins the list. - The Income form warns when the client still owes on issued invoices. - Record payment offers the method as a list instead of free text. Two migrations: AddInvoiceVatTreatment (existing invoices stay standard rated) and ShareClientListWithFinance (links existing invoices and income to clients and switches off income payees). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Dashboard, finance, invoices, payroll and deductions screens now use motion for loading-to-content, chart and page transitions, and sonner for the results of actions. A figure that changes is underlined briefly; figures are never counted up. Field errors, failed loads and blocking errors stay inline. Everything is at rest with reduced motion and in print. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this adds
Phase 3 Stage 3 of quotation QTN-HR-2026-005 (expense and income tracking), plus the work that lets the client leave Daftra: a double-entry ledger, VAT, cheques, receivables, supplier bills and year-end close. The ledger and everything after it is outside the Phase 3 quotation (see
docs/phase4-ledger-plan.md).Who can use it: Manager and Administrator add and change; the Partner (Viewer) reads and changes nothing; HR and Supervisor have no access. Staff given the right can enter their own expenses (Employee role,
/api/finance/myonly).Tracking (the original scope)
Gaps found in the Daftra review (
docs/finance-client-roadmap.md)Payees, split expenses, cheque register, staff expense entry with approval, petty cash per staff member, Excel import, and more reports (by payee, by who entered it, cash flow, day/week/year).
The books (Phase 4,
docs/phase4-ledger-plan.md)docs/finance-chart-of-accounts.md.Also in this PR: app-wide design refinement
Not finance-specific; it changes the shared styles and kit so every screen picks it up (see
docs/design-system.md): Solid button style, Inter body text with Plus Jakarta Sans titles and money figures (new@fontsource-variablepackages), mint-tinted surfaces, layered card shadows, a custom select chevron, animated dialogs, shimmer skeletons and gentle reveals (all honouring reduced motion). Reviewers may want to look atapps/web/src/styles.cssandapps/web/src/ui/*first.Usability pass (from a review of every finance screen,
docs/finance-ux-review.mdis local only)GET /api/finance/attention).GET /api/finance/search) and opens the list on the record.Sessions and staff data (app-wide for sign-ins)
change-passwordreturns 200 with that session instead of 204. Nobody is signed out by the upgrade itself.Accounting controls (from a later review)
Desktop layout pass
PageHeaderandCardHeaderare shared, so HR screens change too). Month fields share a toolbar on the payroll and deductions pages; Petty cash shows totals as figures; Finance setup and Settings use the same section links.Screen reworks (HR and finance)
status,search,fromandto. No undo: a decided request cannot be reverted.Toasts and motion on money screens (
c3a4819)Dashboard, finance (not Finance setup), invoices, payroll and deductions screens. Adds two web dependencies,
sonnerandmotion(both MIT).docs/design-system.md.<AppToaster />. On this commit, locally: 902 web tests pass,tscclean, build succeeds.Things worth a reviewer's eye
AddFinance,AddFinAttachments,AddFinMonthLocks,AddFinPartnersAndCapital,AddFinPayeesAndEntryLines,AddFinCheques,AddStaffExpenseEntry,AddFinCustodyAccounts,AddLedger,AddLedgerManualJournals,AddVatAndChequeBooks,AddInvoiceReceivables,AddSupplierBills,AddRecurringJournals,AddBillAttachments,AddVatSettlementCategories,AddCategoryNoVatAndSystem,AddUserSecurityStamp,FinanceAccountantControls.AddVatAndChequeBookschanges a constraint on journals. Back up the database and the receipts folder first.FinanceCalculatoris the only place with balance, share, VAT and allocation arithmetic, pinned bydocs/finance-test-vectors.json.SyncAsyncruns after finance writes and before every ledger read. Never call it while holding the gate.Finance:ReceiptsPath, seedocs/DEPLOY.md). Back it up with the database.Verification
tscclean.App.test,Layout.phone) can fail under load and pass on their own.docs/finance-cutover-runbook.mdlists the steps. The accountant still needs to confirm the VAT type per category, reverse charge at 5%, prepaid rent, and the Daftra chart of accounts.🤖 Generated with Claude Code