Repository navigation
feat(reports): date-range daily sales export - #1391
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
PR Summary by QodoAdd date-range daily sales exports with per-tax-rate summaries
AI Description
Diagram
High-Level Assessment
Files changed (31)
|
Code Review by Qodo
1.
|
0311df6 to
0f16cfe
Compare
Add inclusive from/to business-date range support (up to 93 calendar days) to GET /api/reports/daily-sales/export with Daily and per-tax-rate Taxes sheets/CSV parts, historical tax snapshot reconstruction, shared-base non-additive flags, incomplete-detail reconciliation warnings, dashboard range export controls, docs, and tests. Fixes #1335
0f16cfe to
e80f9f1
Compare
Fixes #1335
Intent
Implement and verify issue #1335 (
feat(reports): date-range daily sales export with per-tax-rate summary for accountants) and open a PR targetingmainwithout merging it:GET /reports/daily-sales/export(main/routes/reports.ts~L1410).from/tobusiness-date parameters (YYYY-MM-DD, store timezone and business-day cutoff respected), capped at 93 calendar days per request so memory stays bounded.date=).to < from), and oversized ranges (> 93days) with HTTP 400 and a clear message.[from, to]. Recompute period margins and coverage from underlying amounts rather than averaging percentages.to < from, return 400 with a clear message.docs/reference/daily-sales-export.mdin the same PR.What Changed
GET /api/reports/daily-sales/export(main/routes/reports.ts,main/services/daily-sales-export.ts,main/services/daily-sales-export-files.ts) to support inclusivefromandtobusiness-date ranges (capped at 93 calendar days) in addition to single-daydate, returning HTTP 400 on invalid, incomplete, mixed, reversed, or oversized ranges and recomputing period profitability margins and cost coverage from summed underlying amounts.Daily(part=daily) and per-tax-rateTaxes(part=taxes) XLSX sheets and CSV parts built from stored bill and order-item tax snapshots and breakdowns, preserving separate named tax components, marking shared non-additive taxable bases (shared_base,base_additive), and flagging incomplete historical tax detail (incomplete_detail,warning,tax_detail_complete,tax_detail_warning) while reconciling tax totals toSummary.tax_total.frontend/src/app/(dashboard)/dashboard/page.tsx),/api/reports/insights(start_dateandend_datequery support), locale message catalogs, reference documentation (docs/reference/daily-sales-export.md,docs/reference/api.md), andtests/daily-sales-export.test.tsto cover multi-day exports and all five CSV parts (summary,daily,taxes,items,payments).Risk Assessment
✅ Low: The branch cleanly implements single-day and date-range daily sales exports (XLSX and 5-part CSV) with per-tax-rate breakdowns, refund reconciliation, strict calendar-date and 93-day range validation, range query hoisting, dashboard period controls (Day, Month, Custom Range), translations across all 24 locales, documentation updates, and end-to-end HTTP/workbook tests. Prior review feedback regarding historical tax edge cases, calendar date validation in report routes, range query hoisting, and removal of the unrequested tax_summary rollup has been resolved.
Testing
Ran the focused integration suites (
test:daily-sales-export,test:ingredient-cost,test:reports-insights,test:reports-export, andtest:customer-sales-export), built the backend and static frontend, and stood up an isolated FloCafe instance on local ports with a disposable SQLite database to drive all six scenarios live via HTTP and Playwright Chromium, capturing dashboard screenshots and downloaded XLSX/CSV export artifacts. All scenarios and assertions passed.npm run test:daily-sales-exportnpm run test:daily-sales-export~/.no-mistakes/evidence/01M625JJHCZ90BE3228D5JS8H3/daily-sales-2026-10-20_to_2026-10-22.xlsx)Evidence: Multi-day range Summary CSV downloaded from Dashboard UI
metric,value business_date,2026-10-20..2026-10-22 from_date,2026-10-20 to_date,2026-10-22 day_count,3 timezone,Asia/Kolkata business_day_start,04:00 currency,INR order_count,4 paid_bill_count,4 gross_collected,462.5 refunds_issued,10 net_collected,452.5 tax_total,32.5 discount_total,0 service_charge_total,4 packaging_charge_total,1 delivery_charge_total,0 known_cost_net_item_sales,405 ingredient_cost_total,144 gross_profit_total,261 gross_margin_percent,64.44 cost_coverage_status,partial tax_detail_complete,false tax_detail_warning,Incomplete historical tax detail: one or more historical records lacked rate or taxable base breakdown; stored tax amounts are included in tax_total. payment_cash,352.5 payment_card,100Evidence: Multi-day range Daily CSV downloaded from Dashboard UI
business_date,order_count,paid_bill_count,gross_collected,refunds_issued,net_collected,tax_total,discount_total,service_charge_total,packaging_charge_total,delivery_charge_total,known_cost_net_item_sales,ingredient_cost_total,gross_profit_total,gross_margin_percent,cost_coverage_status 2026-10-20,2,2,320,0,320,20,0,0,0,0,300,90,210,70,known 2026-10-21,1,1,60,10,50,5,0,4,1,0,30,24,6,20,partial 2026-10-22,1,1,82.5,0,82.5,7.5,0,0,0,0,75,30,45,60,knownEvidence: Multi-day range Taxes CSV downloaded from Dashboard UI
business_date,tax_name,tax_rate,taxable_base,tax_amount,gross_amount,shared_base,base_additive,incomplete_detail,warning 2026-10-20,VAT,10,100,10,110,false,true,false, 2026-10-20,CGST,2.5,200,5,205,true,false,false, 2026-10-20,SGST,2.5,200,5,205,true,false,false, 2026-10-21,VAT,10,50,5,55,false,true,false, 2026-10-22,Unknown,,,7.5,,false,false,true,Incomplete historical tax detail: rate or taxable base was not stored; tax_amount is included in reconciliation.Evidence: Multi-day range Items CSV downloaded from Dashboard UI
Evidence: Multi-day range Payments CSV downloaded from Dashboard UI
Evidence: Single-day Summary CSV (2026-10-20)
Evidence: Single-day Taxes CSV (2026-10-20)
Evidence: Multi-day range reconciliation and adversarial HTTP 400 validation responses
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
✅ **Review** - passed
✅ No issues found.
✅ **Test** - passed
✅ No issues found.
npm run test:daily-sales-exportnpm run test:daily-sales-exportnpm run test:daily-sales-exportnpm run test:ingredient-costnpm run test:reports-insightsnpm run test:reports-exportnpm run test:customer-sales-exportnpm run build && npm run build:frontendLive isolated FloCafe server (:4301) + Playwright Chromium verification of GET /api/reports/daily-sales/export (single-day, multi-day range, adversarial 400 checks) and /dashboard Range picker + XLSX/CSV downloads✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.