From 7eddbfd981bec0af870bea52a07f170b951f1907 Mon Sep 17 00:00:00 2001 From: vlst Date: Thu, 15 Jun 2023 07:28:09 +0000 Subject: [PATCH] [IMP] pos*: add tax info on receipt pos*: point_of_sale,l10n_ae_pos, l10n_gcc_pos Currently, the pos receipt shows the total amount of taxes paid. Different localisations require more information regarding the taxes to be shown on the receipt. In this PR we improve the receipt by adding specific information for each of the applied taxes and a mechanism that would allow each localization to more easily display the proper tax information. This change makes it so the pos is in accordance with the United Arab Emirates regulations by default. This means that we are removing the `l10n_ae_pos` module, as we no longer need it. closes odoo/odoo#125418 Task: 3305403 Related: odoo/upgrade#4858 Signed-off-by: Joseph Caburnay (jcb) --- addons/l10n_ae_pos/__init__.py | 0 addons/l10n_ae_pos/__manifest__.py | 20 ---------- .../order_receipt/order_receipt.xml | 12 ------ .../order_receipt/order_receipt.xml | 11 ++---- .../screens/receipt_screen/receipt/receipt.js | 17 +++++++++ .../receipt_screen/receipt/receipt.xml | 38 ++++++++++++------- .../static/src/app/store/models.js | 14 +++++-- .../static/src/css/pos_receipts.css | 12 ++++++ 8 files changed, 67 insertions(+), 57 deletions(-) delete mode 100644 addons/l10n_ae_pos/__init__.py delete mode 100644 addons/l10n_ae_pos/__manifest__.py delete mode 100644 addons/l10n_ae_pos/static/src/overrides/components/order_receipt/order_receipt.xml diff --git a/addons/l10n_ae_pos/__init__.py b/addons/l10n_ae_pos/__init__.py deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/addons/l10n_ae_pos/__manifest__.py b/addons/l10n_ae_pos/__manifest__.py deleted file mode 100644 index 8e7eb4214c6..00000000000 --- a/addons/l10n_ae_pos/__manifest__.py +++ /dev/null @@ -1,20 +0,0 @@ -# -*- coding: utf-8 -*- -# Part of Odoo. See LICENSE file for full copyright and licensing details. -{ - 'name': 'United Arab Emirates - Point of Sale', - 'countries': ['ae'], - 'author': 'Odoo PS', - 'category': 'Accounting/Localizations/Point of Sale', - 'description': """ -United Arab Emirates POS Localization -======================================================= - """, - 'depends': ['l10n_ae', 'point_of_sale'], - 'auto_install': True, - 'license': 'LGPL-3', - 'assets': { - 'point_of_sale._assets_pos': [ - 'l10n_ae_pos/static/src/**/*', - ], - }, -} diff --git a/addons/l10n_ae_pos/static/src/overrides/components/order_receipt/order_receipt.xml b/addons/l10n_ae_pos/static/src/overrides/components/order_receipt/order_receipt.xml deleted file mode 100644 index 8b01e246d78..00000000000 --- a/addons/l10n_ae_pos/static/src/overrides/components/order_receipt/order_receipt.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - -
- VAT - Total Taxes - -
-
-
-
diff --git a/addons/l10n_gcc_pos/static/src/overrides/components/order_receipt/order_receipt.xml b/addons/l10n_gcc_pos/static/src/overrides/components/order_receipt/order_receipt.xml index 94536b3a16d..8f6d556e4b9 100644 --- a/addons/l10n_gcc_pos/static/src/overrides/components/order_receipt/order_receipt.xml +++ b/addons/l10n_gcc_pos/static/src/overrides/components/order_receipt/order_receipt.xml @@ -84,14 +84,9 @@ - - !receipt.is_gcc_country - - -
- Total Taxes / إجمالي الضرائب - -
+ + Total Taxes / إجمالي الضرائب + Total diff --git a/addons/point_of_sale/static/src/app/screens/receipt_screen/receipt/receipt.js b/addons/point_of_sale/static/src/app/screens/receipt_screen/receipt/receipt.js index ff1aee82e90..d3aea179a13 100644 --- a/addons/point_of_sale/static/src/app/screens/receipt_screen/receipt/receipt.js +++ b/addons/point_of_sale/static/src/app/screens/receipt_screen/receipt/receipt.js @@ -34,4 +34,21 @@ export class OrderReceipt extends Component { get shippingDate() { return this.receiptEnv.shippingDate; } + + /** + * @param {object} line item of the array given by `this.receiptEnv.orderlines` + * @returns {object} the corresponding tax objects from `pos.taxes_by_id` + */ + getOrderlineTaxes(line) { + return Object.keys(line.tax_details).map((taxId) => this.pos.taxes_by_id[taxId]); + } + + /** + * Override this method to customize the tax letter mapping. + * @param {array} taxes array of tax objects from `pos.taxes_by_id` + * @returns {string} the tax letter + */ + getTaxLetter(...taxes) { + return ""; + } } diff --git a/addons/point_of_sale/static/src/app/screens/receipt_screen/receipt/receipt.xml b/addons/point_of_sale/static/src/app/screens/receipt_screen/receipt/receipt.xml index b53f8f90635..7ba7fe90e2a 100644 --- a/addons/point_of_sale/static/src/app/screens/receipt_screen/receipt/receipt.xml +++ b/addons/point_of_sale/static/src/app/screens/receipt_screen/receipt/receipt.xml @@ -104,18 +104,27 @@ - - -
- - -
+
+ + VAT% + VAT + ExVAT + Total + + + % + + + -
- Total Taxes - -
- + + + + + + + +
diff --git a/addons/point_of_sale/static/src/app/store/models.js b/addons/point_of_sale/static/src/app/store/models.js index 066eb51595e..8d9a4fbf183 100644 --- a/addons/point_of_sale/static/src/app/store/models.js +++ b/addons/point_of_sale/static/src/app/store/models.js @@ -778,6 +778,7 @@ export class Orderline extends PosModel { price_without_tax: this.get_price_without_tax(), price_with_tax_before_discount: this.get_price_with_tax_before_discount(), tax: this.get_tax(), + tax_details: this.get_tax_details(), product_description: this.get_product().description, product_description_sale: this.get_product().description_sale, pack_lot_lines: this.get_lot_lines(), @@ -995,7 +996,10 @@ export class Orderline extends PosModel { ); all_taxes.taxes.forEach(function (tax) { taxtotal += tax.amount; - taxdetail[tax.id] = tax.amount; + taxdetail[tax.id] = { + amount: tax.amount, + base: tax.base, + }; }); return { @@ -2299,7 +2303,10 @@ export class Order extends PosModel { var ldetails = line.get_tax_details(); for (var id in ldetails) { if (Object.hasOwnProperty.call(ldetails, id)) { - details[id] = (details[id] || 0) + ldetails[id]; + details[id] = { + amount: (details[id]?.amount || 0) + ldetails[id].amount, + base: (details[id]?.base || 0) + ldetails[id].base, + }; } } }); @@ -2307,7 +2314,8 @@ export class Order extends PosModel { for (var id in details) { if (Object.hasOwnProperty.call(details, id)) { fulldetails.push({ - amount: details[id], + amount: details[id].amount, + base: details[id].base, tax: this.pos.taxes_by_id[id], name: this.pos.taxes_by_id[id].name, }); diff --git a/addons/point_of_sale/static/src/css/pos_receipts.css b/addons/point_of_sale/static/src/css/pos_receipts.css index 9ac97fdb1bc..cb76d7d8dde 100644 --- a/addons/point_of_sale/static/src/css/pos_receipts.css +++ b/addons/point_of_sale/static/src/css/pos_receipts.css @@ -13,6 +13,11 @@ .pos-receipt .pos-receipt-right-align { float: right; + display: flex; +} + +.pos-receipt .pos-receipt-right-align .tax-letter{ + margin-left: 0.5em; } .pos-receipt .pos-receipt-center-align { @@ -81,3 +86,10 @@ .responsive-price > .pos-receipt-right-align { margin-left: auto; } + +.pos-receipt .pos-receipt-taxes { + display: grid; + grid-template-columns: min-content min-content auto auto auto; + width: 100%; + justify-items: end; +}