Tower: upload laundry_management 19.0.19.0.4 (via marketplace)

This commit is contained in:
2026-05-01 15:00:23 +00:00
parent 100198bd1f
commit 795d6e7d9d

View File

@@ -0,0 +1,47 @@
/** @odoo-module
*
* Pricing hook (PREPARE-ONLY).
*
* Reads the per-type and per-attribute extra_price values for the
* current order. Returned values are NEVER applied to the order.
* This module exists so future pricing logic can plug into a single
* stable surface without touching order.lines / pricing / taxes today.
*
* Usage example (NOT wired anywhere):
* import { computeLaundryExtras } from "@laundry_management/js/laundry_pricing_hook";
* const { typeExtra, attributeExtras, total } = computeLaundryExtras(pos, order);
*/
export function computeLaundryExtras(pos, order) {
const empty = { typeExtra: 0, attributeExtras: [], total: 0 };
if (!pos || !order) return empty;
const typeId = order.laundry_order_type_id;
const attrIds = Array.isArray(order.laundry_order_attribute_ids)
? order.laundry_order_attribute_ids
: [];
let typeExtra = 0;
if (typeId) {
const type = pos.models["laundry.order.type"]?.get(typeId);
typeExtra = Number(type?.extra_price) || 0;
}
const attrModel = pos.models["laundry.order.attribute"];
const attributeExtras = [];
let attrTotal = 0;
for (const id of attrIds) {
const rec = attrModel?.get(id);
const price = Number(rec?.extra_price) || 0;
if (price) {
attributeExtras.push({ id, name: rec?.name || "", price });
attrTotal += price;
}
}
return {
typeExtra,
attributeExtras,
total: typeExtra + attrTotal,
};
}