From 743b0023876474a9313459628e5f9caaef0ecb26 Mon Sep 17 00:00:00 2001 From: git_admin Date: Fri, 1 May 2026 15:00:30 +0000 Subject: [PATCH] Tower: upload laundry_management 19.0.19.0.4 (via marketplace) --- .../static/src/js/settlement_receipt.js | 94 +++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 addons/laundry_management/static/src/js/settlement_receipt.js diff --git a/addons/laundry_management/static/src/js/settlement_receipt.js b/addons/laundry_management/static/src/js/settlement_receipt.js new file mode 100644 index 0000000..ec9bf0f --- /dev/null +++ b/addons/laundry_management/static/src/js/settlement_receipt.js @@ -0,0 +1,94 @@ +/** @odoo-module */ +import { Component } from "@odoo/owl"; +import { Dialog } from "@web/core/dialog/dialog"; + +// Sort priority: cash first, then bank, then others +const JOURNAL_ORDER = { cash: 0, bank: 1 }; + +export class LaundrySettlementReceipt extends Component { + static components = { Dialog }; + static template = "laundry_management.SettlementReceipt"; + static props = { + partnerName: { type: String }, + settledTotal: { type: Number }, + remainingDue: { type: Number }, + payments: { type: Array }, + settledOrders: { type: Array }, + close: { type: Function }, + }; + + get dateTime() { + return new Date().toLocaleString(); + } + + fmt(value) { + return parseFloat(value || 0).toFixed(2); + } + + /** Group payments by method name, merge duplicates, sort cash → bank → other. */ + get groupedPayments() { + const map = {}; + for (const p of this.props.payments) { + // Use method_name (from settlement_pos_pm_id) when available, + // fall back to journal_name for legacy payments without it. + const key = p.method_name || p.journal_name; + const jtype = p.journal_type || "other"; + if (!map[key]) { + map[key] = { name: key, amount: 0, _type: jtype }; + } + map[key].amount += p.amount; + } + return Object.values(map).sort( + (a, b) => (JOURNAL_ORDER[a._type] ?? 2) - (JOURNAL_ORDER[b._type] ?? 2) + ); + } + + /** Group settled orders by name, merge duplicates. */ + get groupedOrders() { + const map = {}; + for (const o of this.props.settledOrders) { + const key = o.name; + if (!map[key]) { + map[key] = { name: key, applied: 0, remaining_on_order: 0 }; + } + map[key].applied += o.applied; + map[key].remaining_on_order = o.remaining_on_order; + } + return Object.values(map); + } + + printReceipt() { + const receiptEl = document.querySelector(".settlement-receipt-content"); + if (!receiptEl) return; + const printWindow = window.open("", "_blank", "width=300,height=600"); + if (!printWindow) return; + printWindow.document.write(` + Settlement Receipt + + ${receiptEl.innerHTML} + + `); + printWindow.document.close(); + printWindow.focus(); + printWindow.print(); + printWindow.close(); + } +}