addons portados en el repo de ecocentral
This commit is contained in:
parent
f2194c5367
commit
65818b0155
72 changed files with 2474 additions and 3 deletions
34
pos_full_refund/static/src/js/pos_full_refund.esm.js
Normal file
34
pos_full_refund/static/src/js/pos_full_refund.esm.js
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
import { TicketScreen } from "@point_of_sale/app/screens/ticket_screen/ticket_screen";
|
||||
import { patch } from "@web/core/utils/patch";
|
||||
|
||||
patch(TicketScreen.prototype, {
|
||||
/**
|
||||
* Mark every refundable line of the selected order for a full refund and
|
||||
* trigger the standard refund flow.
|
||||
*
|
||||
* `onDoRefund` is what the "Refund" action of the ticket screen calls: it
|
||||
* builds the negative lines, links the combo children, carries over the
|
||||
* fiscal position and the partner, and switches to the destination order.
|
||||
*/
|
||||
async onDoFullRefund() {
|
||||
const order = this.getSelectedOrder();
|
||||
if (!order) {
|
||||
return;
|
||||
}
|
||||
for (const line of order.lines) {
|
||||
const toRefundDetails = line
|
||||
.getAllLinesInCombo()
|
||||
.map((comboLine) => this.getToRefundDetail(comboLine));
|
||||
for (const toRefundDetail of toRefundDetails) {
|
||||
// Per line, and net of what was already refunded: the same
|
||||
// guard the core applies in `_onUpdateSelectedOrderline`.
|
||||
const refundableQty =
|
||||
toRefundDetail.line.qty - toRefundDetail.line.refunded_qty;
|
||||
if (refundableQty > 0) {
|
||||
toRefundDetail.qty = refundableQty;
|
||||
}
|
||||
}
|
||||
}
|
||||
await this.onDoRefund();
|
||||
},
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue