Tower: upload laundry_management 19.0.19.0.4 (via marketplace)

This commit is contained in:
2026-05-01 15:00:33 +00:00
parent dd5c59c645
commit 2e1a1fbe03

View File

@@ -0,0 +1,115 @@
/** @odoo-module */
import { patch } from "@web/core/utils/patch";
import { _t } from "@web/core/l10n/translation";
import { PaymentScreen } from "@point_of_sale/app/screens/payment_screen/payment_screen";
import { AlertDialog } from "@web/core/confirmation_dialog/confirmation_dialog";
import { LaundrySettlementReceipt } from "@laundry_management/js/settlement_receipt";
/**
* Check whether a POS order is a settlement order (contains
* the special settlement product, NOT a laundry service).
*/
function isSettlementOrder(order) {
return (
order &&
order.lines &&
order.lines.some(
(line) => line.product_id?.product_tmpl_id?.is_laundry_settlement
)
);
}
patch(PaymentScreen.prototype, {
setup() {
super.setup(...arguments);
// For settlement orders, hide Customer Account / pay-later methods
if (isSettlementOrder(this.currentOrder)) {
this.payment_methods_from_config =
this.payment_methods_from_config.filter(
(pm) => !pm.split_transactions
);
}
},
async validateOrder(isForceValidate) {
const order = this.currentOrder;
if (!isSettlementOrder(order)) {
return super.validateOrder(isForceValidate);
}
// ── Settlement validation — bypass normal POS sync ──
const paymentLines = order.payment_ids
.filter((pl) => pl.getAmount() > 0)
.map((pl) => ({
pos_payment_method_id: pl.payment_method_id.id,
amount: pl.getAmount(),
}));
if (paymentLines.length === 0) {
this.notification.add(
_t("Please add at least one payment."),
{ type: "warning" }
);
return false;
}
const partnerId = order.partner_id?.id;
if (!partnerId) {
this.notification.add(_t("No customer selected."), {
type: "danger",
});
return false;
}
const sessionId = this.pos.session?.id || null;
let response;
try {
this.ui.block();
response = await this.pos.data.call(
"res.partner",
"settle_laundry_dues_rpc",
[partnerId, paymentLines, sessionId]
);
} catch (err) {
this.dialog.add(AlertDialog, {
title: _t("Settlement Failed"),
body:
err?.data?.message ||
err?.message ||
_t("Unknown error."),
});
return false;
} finally {
this.ui.unblock();
}
// Open cash drawer if cash was used
if (
order.payment_ids.some(
(pl) => pl.payment_method_id.is_cash_count && pl.getAmount() > 0
)
) {
this.pos.hardwareProxy.openCashbox();
}
// Show settlement receipt
this.dialog.add(LaundrySettlementReceipt, {
partnerName: order.partner_id.name,
settledTotal: response.settled_total || 0,
remainingDue: response.remaining_due || 0,
payments: response.payments || [],
settledOrders: response.settled_orders || [],
});
// Remember last-used method for next settlement
this.pos._lastSettlementMethodId =
paymentLines[0]?.pos_payment_method_id || null;
// Clean up: remove settlement order (never synced to backend)
this.pos.removeOrder(order, false);
this.pos.addNewOrder();
this.pos.navigate("ProductScreen");
return true;
},
});