price adjustment and stock adjustments
This commit is contained in:
@@ -4,6 +4,68 @@ Legend: `[ ]` not started · `[~]` in progress · `[x]` done
|
||||
Spec: `docs/20-FRONTEND.md` (flows + rules) · `docs/11-BACKEND-PHASE1.md` (API contract)
|
||||
Convention: `docs/01-DOC-GUIDE.md §6`. Update this file in the **same commit** as the code. When ticking `[x]`, append a short note + any deviation.
|
||||
|
||||
## Dual approval — stock & price adjustments (2026-10-12) — `docs/DUAL_APPROVAL_PLAN.md`
|
||||
|
||||
- [x] **Approvals inbox** (`app/dashboard/approvals`, sidebar entry for everyone with a badge of actionable requests):
|
||||
"Waiting for you" (Approve / Approve & apply / Reject with reason) and "Waiting for others" (your own requests, with why).
|
||||
- [x] **Stock → Adjustments**: status filter, rows open the new detail page `adjustments/[id]` (lines, requested serials,
|
||||
approval timeline, Approve / Reject / Withdraw via `components/approvals/ApprovalPanel.tsx`). New adjustment, Wastage and
|
||||
Count post now say "submitted for approval" with a link when the result is pending. Wastage list hides rejected/withdrawn
|
||||
requests and tags pending ones. `AdjustmentStatusBadge` covers the new statuses.
|
||||
- [x] **Products → Price Adjustments** (list, `new` — add items, edit new min/max/flat from the current prices, reason —
|
||||
and `[id]` with old → new, a stale-request warning and the approval panel). Item page: selling prices read-only in Edit
|
||||
while price approval is on, "Request price change" links, and a Price history panel.
|
||||
- [x] **Settings → Approvals** (`app/dashboard/settings/approvals`): levels per document, thresholds, level-2 roles.
|
||||
- [x] Types `types/approvals.ts`, API `lib/api/approvals.ts`; `lib/api/stock-adjustments.ts` gains approve/reject/cancel.
|
||||
`tsc` clean; no new lint errors (the setState-in-effect errors in touched pages were already there).
|
||||
|
||||
## Bank Deposit module (2026-10-08) — `docs/BANK_DEPOSIT_MODULE_PLAN.md`
|
||||
|
||||
- [x] **Accounts → Bank Deposits** (`app/dashboard/accounts/bank-deposits`): list (search, status, business-date range,
|
||||
bank-account filter, server total in the footer, CSV export) with a "Cash in hand by day" view (opening, cash in,
|
||||
cash out, deposited, closing; the filter's range capped at 92 days, default last 30). Cards: deposited (filtered),
|
||||
cash in hand now, net cash today. Admins' header branch switcher is sent as `branchId` (totals are server-side).
|
||||
- [x] `new/`: branch (admins), business date, deposit date, from cash account (preselects `defaultCashAccountCode`),
|
||||
to bank account, amount (defaults to "available to deposit", blocked above it), slip no., depositor, remarks; a cash
|
||||
position panel beside it. `[id]/`: details + cancel with reason (reverses GL). `lib/api/bank-deposits.ts`,
|
||||
`types/bank-deposits.ts`, `components/accounts/bank-deposit-badges.tsx`. Sidebar + Accounts hub card added.
|
||||
- [x] **Day-End Report**: the one-line "Net cash in hand" became a Cash in hand group (opening, net cash today,
|
||||
deposited to bank, remaining — amber while > 0) with the day's deposits table; the daily table adds Deposited and
|
||||
Cash in hand columns. PDFs: single day adds the cash block + deposits; day-wise adds a separate "Cash in hand and bank
|
||||
deposits" table. **Deviation:** not two more columns on the day-wise PDF table — A4 portrait is already full at 9 columns.
|
||||
|
||||
## Day-End Sales Report (2026-10-08) — `docs/DAY_END_SALES_REPORT_PLAN.md`
|
||||
|
||||
- [x] Sales payment method: `PaymentLinesEditor` takes optional `methodOptions`/`methodForAccount` and shows a Method column
|
||||
(picking a Cash account sets Cash, a Bank account sets Card; changeable). Used by `SalesInvoicePaymentDialog` and
|
||||
`SalesInvoiceBulkPaymentDialog` only — the expense/purchase dialogs are unchanged. Types in `types/sales.ts`, `types/bundles.ts`.
|
||||
- [x] **Sales → Day-End Report** (`app/dashboard/sales/day-end-report`): business-date picker, sales/payment/count cards,
|
||||
Income card (sales − expenses), the day's expenses, and a day-wise section (from/to, default last 30 days) with an
|
||||
income/sales/expenses line chart (`components/sales/DayEndIncomeChart.tsx`) and a daily table with totals (click a
|
||||
row to open that day). Admins follow the header branch switcher. `lib/api/day-end-report.ts`.
|
||||
- [x] PDFs (`lib/pdf/day-end-report-pdf.ts`): day-wise income (totals, chart, paginated daily table + totals row) and
|
||||
single day (figures, counts, expense list). **Deviation:** tables drawn with plain `jspdf` instead of adding
|
||||
`jspdf-autotable`; the chart is rendered offscreen in light colours for print.
|
||||
- [x] Sidebar entry (`sales.day-end-report`) and header title.
|
||||
- [x] **Sales table + profit/loss** (2026-10-08): the day view lists every sale (time, no., type, customer, paid by, total,
|
||||
paid, due, cost, profit; invoices link to their page) and ends with a statement — sales − cost of goods sold = gross
|
||||
profit − expenses = **Net profit** (green) or **Net loss** (red, shown as a positive amount labelled Loss;
|
||||
`profitOrLoss()` in `lib/format.ts`). Day-wise table, chart and both PDFs gain a Profit / loss column/line.
|
||||
|
||||
- [x] `types/expenses.ts`, `lib/api/expenses.ts` (`expensesApi`, `expenseSetupApi`).
|
||||
- [x] **Accounts → Expenses** (`app/dashboard/accounts/expenses`): list with period summary cards (posted, unpaid,
|
||||
outstanding, overdue), by-category breakdown, filters (status tabs, payment status incl. Overdue, category → title,
|
||||
date range, search), CSV export of all pages, row Post / Pay / Post & Pay. `new`, `[id]` (detail, payments, cancel
|
||||
with reason, delete draft) and `[id]/edit` (Draft only), sharing `components/accounts/ExpenseForm.tsx`.
|
||||
"Save & pay" lands on the detail page with `?pay=1`, which opens the payment dialog once.
|
||||
- [x] `components/accounts/ExpensePaymentDialog.tsx` reuses `PaymentLinesEditor` (split across cash/bank accounts) plus
|
||||
payment method and cheque no. A Draft goes through the single-transaction `post-and-pay` endpoint, unlike
|
||||
`PurchaseInvoicePaymentDialog`'s post-then-pay-per-line loop.
|
||||
- [x] **Accounts → Expense Setup** (`app/dashboard/accounts/expense-setup`): categories → titles, add category/title,
|
||||
edit (built-in names locked), GL code per title, activate/deactivate. Shows the Salaries/payroll double-count warning
|
||||
(plan §10 Q4). The expense form has an inline "Add title" for users with `accounts.expense-setup`.
|
||||
- [x] Sidebar (`AppSidebar.tsx`), header titles (`Header.tsx`) and the Accounts hub page list the two new screens.
|
||||
|
||||
## 0. Foundation
|
||||
- [x] **Transport: same-origin Next `rewrites()` proxy** (`next.config.ts`, `/api/*` → `BACKEND_ORIGIN`, default `http://localhost:5224`). `BACKEND_ORIGIN` in `.env.local` / `.env.local.example` — **not** `NEXT_PUBLIC_*`; the browser never sees the backend URL. Chosen over backend CORS because it makes the API same-origin, so CORS and the Secure/SameSite=Strict session cookies stop being problems at all. (`.gitignore`'s `.env*` was silently swallowing the example file — added a `!.env.local.example` negation.)
|
||||
- [x] **Typed API client rebuilt** (`lib/api-client.ts`, 2026-07-17) — recovered the pre-deletion version from git (`0e4bcf1^`) and adapted: relative `/api/v1` base, **`credentials: "include"`** (never present before), `ApiResult`/`ProblemDetails` imported from `@/types/common` rather than redeclared, `readCsrfToken()` for the eight `[ValidateCsrf]` auth actions. `ApiError`, `apiRequest`, `apiRequestWithETag`, `buildQuery`, `ifMatch`/`idempotencyKey` all carried over.
|
||||
|
||||
Reference in New Issue
Block a user