diff --git a/addons/l10n_sa_pos/static/src/js/models.js b/addons/l10n_sa_pos/static/src/js/models.js index 9806a8704d7..952e616f24d 100644 --- a/addons/l10n_sa_pos/static/src/js/models.js +++ b/addons/l10n_sa_pos/static/src/js/models.js @@ -6,15 +6,31 @@ var Registries = require('point_of_sale.Registries'); const PosL10nSAOrder = (Order) => class PosL10nSAOrder extends Order { export_for_printing() { - var result = super.export_for_printing(...arguments); - if (this.pos.company.country.code === 'SA') { - const codeWriter = new window.ZXing.BrowserQRCodeSvgWriter() - let qr_values = this.compute_sa_qr_code(result.company.name, result.company.vat, result.date.isostring, result.total_with_tax, result.total_tax); - let qr_code_svg = new XMLSerializer().serializeToString(codeWriter.write(qr_values, 150, 150)); - result.qr_code = "data:image/svg+xml;base64,"+ window.btoa(qr_code_svg); - } - return result; + var result = super.export_for_printing(...arguments); + if (this.pos.company.country.code === 'SA') { + result.is_settlement = this.is_settlement(); + if (!result.is_settlement) { + const codeWriter = new window.ZXing.BrowserQRCodeSvgWriter() + let qr_values = this.compute_sa_qr_code(result.company.name, result.company.vat, result.date.isostring, result.total_with_tax, result.total_tax); + let qr_code_svg = new XMLSerializer().serializeToString(codeWriter.write(qr_values, 150, 150)); + result.qr_code = "data:image/svg+xml;base64," + window.btoa(qr_code_svg); + } + } + return result; } + /** + * If the order is empty (there are no products) + * and all "pay_later" payments are negative, + * we are settling a customer's account. + * If the module pos_settle_due is not installed, + * the function always returns false (since "pay_later" doesn't exist) + * @returns {boolean} true if the current order is a settlement, else false + */ + is_settlement() { + return this.is_empty() && + !!this.paymentlines.filter(paymentline => paymentline.payment_method.type === "pay_later" && paymentline.amount < 0).length; + } + compute_sa_qr_code(name, vat, date_isostring, amount_total, amount_tax) { /* Generate the qr code for Saudi e-invoicing. Specs are available at the following link at page 23 https://zatca.gov.sa/ar/E-Invoicing/SystemsDevelopers/Documents/20210528_ZATCA_Electronic_Invoice_Security_Features_Implementation_Standards_vShared.pdf diff --git a/addons/l10n_sa_pos/static/src/xml/OrderReceipt.xml b/addons/l10n_sa_pos/static/src/xml/OrderReceipt.xml index 78fdfaa2f84..6b6551f6fe5 100644 --- a/addons/l10n_sa_pos/static/src/xml/OrderReceipt.xml +++ b/addons/l10n_sa_pos/static/src/xml/OrderReceipt.xml @@ -2,18 +2,22 @@ - +
- Simplified Tax Invoice + + Simplified Tax Invoice + - فاتورة ضريبية مبسطة + + فاتورة ضريبية مبسطة +