| 1 |
|
| 2 |
|
| 3 |
import { PosOrder } from "@point_of_sale/app/models/pos_order"; |
| 4 |
import { patch } from "@web/core/utils/patch"; |
| 5 |
import { qrCodeSrc } from "@point_of_sale/utils"; |
| 6 |
|
| 7 |
patch(PosOrder.prototype, { |
| 8 |
setup() { |
| 9 |
super.setup(...arguments); |
| 10 |
if (this.isInvoiceMandatoryForSA()) { |
| 11 |
this.to_invoice = true; |
| 12 |
} |
| 13 |
}, |
| 14 |
|
| 15 |
isInvoiceMandatoryForSA() { |
| 16 |
|
| 17 |
|
| 18 |
return this.isSACompany() && !this.is_settling_account; |
| 19 |
}, |
| 20 |
|
| 21 |
isToInvoice() { |
| 22 |
if (this.isInvoiceMandatoryForSA()) { |
| 23 |
return true; |
| 24 |
} |
| 25 |
return super.isToInvoice(...arguments); |
| 26 |
}, |
| 27 |
setToInvoice(to_invoice) { |
| 28 |
if (this.isInvoiceMandatoryForSA()) { |
| 29 |
this.assertEditable(); |
| 30 |
this.to_invoice = true; |
| 31 |
} else { |
| 32 |
super.setToInvoice(...arguments); |
| 33 |
} |
| 34 |
}, |
| 35 |
|
| 36 |
setPartner(partner) { |
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
super.setPartner(partner); |
| 43 |
if (this.is_settling_account) { |
| 44 |
this.setToInvoice(false); |
| 45 |
} |
| 46 |
}, |
| 47 |
|
| 48 |
get notLegal() { |
| 49 |
return !this.l10n_sa_invoice_qr_code_str; |
| 50 |
}, |
| 51 |
generateQrcode() { |
| 52 |
if (!this.notLegal && this.isSACompany()) { |
| 53 |
return qrCodeSrc(this.l10n_sa_invoice_qr_code_str); |
| 54 |
} |
| 55 |
return false; |
| 56 |
}, |
| 57 |
}); |