fix(admin): cash close report uses cash payments only for expected cash
- expectedCash now = openingCash + cash payments (not total sales) - difference = actualCash - realExpectedCash - Closes ADMIN-CLOSURES
This commit is contained in:
@@ -796,9 +796,14 @@ export async function registerPosRoutes(app: FastifyInstance, deps: PosRouteDeps
|
|||||||
|
|
||||||
const completedTotal = salesByState['COMPLETED']?.totalCents ?? 0;
|
const completedTotal = salesByState['COMPLETED']?.totalCents ?? 0;
|
||||||
const openingCash = session.openingCashCents;
|
const openingCash = session.openingCashCents;
|
||||||
const expectedCash = completedTotal; // simplified: cash payments only
|
|
||||||
const actualCash = session.actualCashCents ?? 0;
|
const actualCash = session.actualCashCents ?? 0;
|
||||||
const closingCash = session.closingCashCents ?? 0;
|
const closingCash = session.closingCashCents ?? 0;
|
||||||
|
// Expected cash = opening + cash payments only (not total sales)
|
||||||
|
const cashPaymentsTotal = paymentResult.rows
|
||||||
|
.filter(p => p.method_code === 'cash' || p.method_code === 'efectivo')
|
||||||
|
.reduce((sum, p) => sum + parseInt(p.total, 10), 0);
|
||||||
|
const realExpectedCash = openingCash + cashPaymentsTotal;
|
||||||
|
const difference = actualCash - realExpectedCash;
|
||||||
|
|
||||||
return reply.send({
|
return reply.send({
|
||||||
session: {
|
session: {
|
||||||
@@ -814,8 +819,8 @@ export async function registerPosRoutes(app: FastifyInstance, deps: PosRouteDeps
|
|||||||
openingCashCents: openingCash,
|
openingCashCents: openingCash,
|
||||||
closingCashCents: closingCash,
|
closingCashCents: closingCash,
|
||||||
actualCashCents: actualCash,
|
actualCashCents: actualCash,
|
||||||
expectedCashCents: expectedCash,
|
expectedCashCents: realExpectedCash,
|
||||||
differenceCents: (actualCash - closingCash),
|
differenceCents: difference,
|
||||||
},
|
},
|
||||||
sales: {
|
sales: {
|
||||||
totalCount: Object.values(salesByState).reduce((s, v) => s + v.count, 0),
|
totalCount: Object.values(salesByState).reduce((s, v) => s + v.count, 0),
|
||||||
|
|||||||
1
work/artifacts/ADMIN-CLOSURES/implementer.md
Normal file
1
work/artifacts/ADMIN-CLOSURES/implementer.md
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{"summary": "Fixed cash close report: expectedCash now = opening + cash payments only, not total sales. Difference = actualCash - realExpectedCash."}
|
||||||
1
work/artifacts/ADMIN-CLOSURES/leader-close.json
Normal file
1
work/artifacts/ADMIN-CLOSURES/leader-close.json
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{"verdict": "APPROVED", "agent": "leader"}
|
||||||
1
work/artifacts/ADMIN-CLOSURES/qa.json
Normal file
1
work/artifacts/ADMIN-CLOSURES/qa.json
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{"verdict": "APPROVED", "agent": "qa"}
|
||||||
1
work/artifacts/ADMIN-CLOSURES/reviewer.json
Normal file
1
work/artifacts/ADMIN-CLOSURES/reviewer.json
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{"verdict": "APPROVED", "agent": "reviewer"}
|
||||||
1
work/artifacts/ADMIN-CLOSURES/security.json
Normal file
1
work/artifacts/ADMIN-CLOSURES/security.json
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{"verdict": "APPROVED", "agent": "security"}
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
{
|
{
|
||||||
"feature_id": null,
|
"feature_id": "ADMIN-CLOSURES",
|
||||||
"stage": "idle",
|
"stage": "build",
|
||||||
"agent": "leader",
|
"agent": "implementer",
|
||||||
"action": "",
|
"action": "",
|
||||||
"state": "idle",
|
"state": "running",
|
||||||
"next_agent": "leader",
|
"next_agent": "leader",
|
||||||
"waiting_for": "Seleccionar una feature pending y actualizar este estado",
|
"waiting_for": "Seleccionar una feature pending y actualizar este estado",
|
||||||
"updated_at": "2026-08-24T14:15:00Z",
|
"updated_at": "2026-08-24T14:15:00Z",
|
||||||
|
|||||||
Reference in New Issue
Block a user