| 1 |
import { PosOrderline } from "@point_of_sale/app/models/pos_order_line"; |
| 2 |
import { formatCurrency } from "@point_of_sale/app/models/utils/currency"; |
| 3 |
import { patch } from "@web/core/utils/patch"; |
| 4 |
|
| 5 |
patch(PosOrderline.prototype, { |
| 6 |
setup(_defaultObj) { |
| 7 |
super.setup(...arguments); |
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
if (this.sale_order_origin_id?.shipping_date) { |
| 13 |
this.order_id.setShippingDate(this.sale_order_origin_id.shipping_date); |
| 14 |
} |
| 15 |
}, |
| 16 |
get saleDetails() { |
| 17 |
let down_payment_details = []; |
| 18 |
|
| 19 |
|
| 20 |
try { |
| 21 |
down_payment_details = JSON.parse(this.down_payment_details); |
| 22 |
} catch { |
| 23 |
down_payment_details = this.down_payment_details; |
| 24 |
} |
| 25 |
return down_payment_details?.map?.((detail) => ({ |
| 26 |
product_uom_qty: detail.product_uom_qty, |
| 27 |
product_name: detail.product_name, |
| 28 |
total: formatCurrency(detail.total, this.currency), |
| 29 |
})); |
| 30 |
}, |
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
async setQuantityFromSOL(saleOrderLine) { |
| 36 |
if ( |
| 37 |
this.product_id.type === "service" && |
| 38 |
!["sent", "draft"].includes(this.sale_order_origin_id.state) |
| 39 |
) { |
| 40 |
this.setQuantity(saleOrderLine.qty_to_invoice); |
| 41 |
} else { |
| 42 |
this.setQuantity( |
| 43 |
saleOrderLine.product_uom_qty - |
| 44 |
Math.max(saleOrderLine.qty_delivered, saleOrderLine.qty_invoiced) |
| 45 |
); |
| 46 |
} |
| 47 |
}, |
| 48 |
}); |