Files
odoo-addons/addons/laundry_management/static/src/js/closing_popup_patch.js

53 lines
1.9 KiB
JavaScript

/** @odoo-module
*
* ClosePosPopup patch — surface a READ-ONLY Laundry Settlements panel
* in the POS closing popup so cashiers and managers can see how much
* was collected via the laundry settle-dues flow during this session,
* grouped per journal.
*
* NON-CASH settlements create account.payment records (not pos.payment),
* so they don't naturally appear in the closing popup's per-method
* breakdown. CASH settlements DO appear there (via statement_line_ids
* in expected cash). This panel makes both visible side-by-side so the
* cashier can reconcile drawer vs. settlement collections.
*
* IMPORTANT: this is purely informational. It does NOT inject into the
* cash-counted/expected math, does NOT create accounting entries, and
* does NOT modify settlement amounts.
*/
import { patch } from "@web/core/utils/patch";
import { onWillStart, useState } from "@odoo/owl";
import { ClosePosPopup } from "@point_of_sale/app/components/popups/closing_popup/closing_popup";
patch(ClosePosPopup.prototype, {
setup() {
super.setup();
this.laundrySettlements = useState({
loaded: false,
total: 0.0,
count: 0,
by_journal: [],
});
onWillStart(async () => {
const sessionId = this.pos?.session?.id;
if (!sessionId) {
this.laundrySettlements.loaded = true;
return;
}
try {
const data = await this.pos.data.call(
"res.partner",
"get_session_settlements",
[sessionId]
);
if (data) {
Object.assign(this.laundrySettlements, data, { loaded: true });
}
} catch {
// Read-only panel — silent failure is fine.
this.laundrySettlements.loaded = true;
}
});
},
});