Debian Codegraph @

addons/l10n_sa_pos/static/src/overrides/models/pos_order.js

raw
1 import { PosOrder } from "@point_of_sale/app/models/pos_order";
2 import { patch } from "@web/core/utils/patch";
3 import { computeSAQRCode } from "@l10n_sa_pos/app/utils/qr";
4
5 patch(PosOrder.prototype, {
6 isSACompany() {
7 return this.company.country_id?.code === "SA";
8 },
9
10 generateQrcode() {
11 if (this.isSACompany()) {
12 if (!this.isSettlement()) {
13 const company = this.company;
14 const codeWriter = new window.ZXing.BrowserQRCodeSvgWriter();
15 const qr_values = this.compute_sa_qr_code(
16 company.name,
17 company.vat,
18 this.date_order,
19 this.priceIncl,
20 this.amountTaxes
21 );
22 const qr_code_svg = new XMLSerializer().serializeToString(
23 codeWriter.write(qr_values, 200, 200)
24 );
25 return "data:image/svg+xml;base64," + window.btoa(qr_code_svg);
26 }
27 }
28 return false;
29 },
30 compute_sa_qr_code(name, vat, date_isostring, amount_total, amount_tax) {
31 return computeSAQRCode(name, vat, date_isostring, amount_total, amount_tax);
32 },
33 get isSimplified() {
34 return !this?.partner_id?.is_company && this.company_id.country_id?.code === "SA";
35 },
36 });