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();
|
||||
},
|
||||
});
|
||||
21
pos_full_refund/static/src/xml/pos_full_refund.xml
Normal file
21
pos_full_refund/static/src/xml/pos_full_refund.xml
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<templates id="template" xml:space="preserve">
|
||||
|
||||
<t
|
||||
t-name="pos_full_refund.TicketScreen"
|
||||
t-inherit="point_of_sale.TicketScreen"
|
||||
t-inherit-mode="extension"
|
||||
>
|
||||
<xpath expr="//InvoiceButton" position="before">
|
||||
<button
|
||||
id="set_full_refund_button"
|
||||
class="control-button btn btn-light btn-lg lh-lg flex-grow-1 flex-shrink-1"
|
||||
t-on-click="() => this.onDoFullRefund()"
|
||||
>
|
||||
<i class="fa fa-cart-arrow-down me-1" />
|
||||
Do Full Refund
|
||||
</button>
|
||||
</xpath>
|
||||
</t>
|
||||
|
||||
</templates>
|
||||
Loading…
Add table
Add a link
Reference in a new issue