diff --git a/pos_discount_manager/README.rst b/pos_discount_manager/README.rst new file mode 100755 index 000000000..060f62020 --- /dev/null +++ b/pos_discount_manager/README.rst @@ -0,0 +1,40 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 + +POS Discount Manager Approval +============================= +This module helps to provide Discount limit for each employee in every pos + +Configuration +============= +* No additional configurations needed + +Company +------- +* `Cybrosys Techno Solutions `__ + +Credits +------- +* Developers: Sruthi pavithran v15 @ Cybrosys + +Contacts +-------- +* Mail Contact : odoo@cybrosys.com + +Bug Tracker +----------- +Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. + +Maintainer +========== +.. image:: https://cybrosys.com/images/logo.png + :target: https://cybrosys.com + +This module is maintained by Cybrosys Technologies. + +For support and more information, please visit `Our Website `__ + +Further information +=================== +HTML Description: ``__ \ No newline at end of file diff --git a/pos_discount_manager/__init__.py b/pos_discount_manager/__init__.py new file mode 100755 index 000000000..5e685ca20 --- /dev/null +++ b/pos_discount_manager/__init__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2023-TODAY Cybrosys Technologies(). +# Author: Cybrosys Techno Solutions(odoo@cybrosys.com) +# +# You can modify it under the terms of the GNU AFFERO +# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. +# +# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE +# (AGPL v3) along with this program. +# If not, see . +# +############################################################################# +from . import models diff --git a/pos_discount_manager/__manifest__.py b/pos_discount_manager/__manifest__.py new file mode 100755 index 000000000..8ab4a21d1 --- /dev/null +++ b/pos_discount_manager/__manifest__.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2023-TODAY Cybrosys Technologies(). +# Author: Cybrosys Techno Solutions(odoo@cybrosys.com) +# +# You can modify it under the terms of the GNU AFFERO +# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. +# +# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE +# (AGPL v3) along with this program. +# If not, see . +# +############################################################################# +{ + 'name': "POS Discount Manager Approval", + 'version': '15.0.1.0.0', + 'summary': """Discount limit for each employee in every point of sale""", + 'description': """"This module helps you to set a discount limit for each + employee in every point of sale. It facilitate the manager + approval when discount over the limit of employee""", + 'category': 'Point Of Sale', + 'author': 'Cybrosys Techno Solutions', + 'company': 'Cybrosys Techno Solutions', + 'maintainer': "Cybrosys Techno Solutions", + 'website': "http://www.cybrosys.com", + 'depends': ['point_of_sale', 'pos_discount', 'hr'], + 'data': [ + 'views/hr_employee_views.xml', + ], + 'assets': { + 'point_of_sale.assets': [ + 'pos_discount_manager/static/src/css/popup_size.css', + 'pos_discount_manager/static/src/js/DiscountButton.js', + 'pos_discount_manager/static/src/js/ValidateManager.js', + ], + 'web.assets_qweb': [ + 'pos_discount_manager/static/src/xml/NumberPopup.xml' + ], + }, + 'images': ['static/description/banner.png'], + 'license': 'AGPL-3', + 'installable': True, + 'application': False, + 'auto_install': False, +} diff --git a/pos_discount_manager/doc/RELEASE_NOTES.md b/pos_discount_manager/doc/RELEASE_NOTES.md new file mode 100755 index 000000000..0d5cd9f64 --- /dev/null +++ b/pos_discount_manager/doc/RELEASE_NOTES.md @@ -0,0 +1,6 @@ +## Module + +#### 30.06.2023 +#### Version 15.0.1.0.0 +#### ADD +- Initial commit for POS Discount Manager Approval diff --git a/pos_discount_manager/models/__init__.py b/pos_discount_manager/models/__init__.py new file mode 100755 index 000000000..77ee1761a --- /dev/null +++ b/pos_discount_manager/models/__init__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2023-TODAY Cybrosys Technologies(). +# Author: Cybrosys Techno Solutions(odoo@cybrosys.com) +# +# You can modify it under the terms of the GNU AFFERO +# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. +# +# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE +# (AGPL v3) along with this program. +# If not, see . +# +############################################################################# +from . import hr_employee diff --git a/pos_discount_manager/models/hr_employee.py b/pos_discount_manager/models/hr_employee.py new file mode 100755 index 000000000..2fec23c4a --- /dev/null +++ b/pos_discount_manager/models/hr_employee.py @@ -0,0 +1,30 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2023-TODAY Cybrosys Technologies(). +# Author: Cybrosys Techno Solutions(odoo@cybrosys.com) +# +# You can modify it under the terms of the GNU AFFERO +# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. +# +# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE +# (AGPL v3) along with this program. +# If not, see . +# +############################################################################# +from odoo import fields, models + + +class HrEmployee(models.Model): + """Add field into hr employee""" + _inherit = 'hr.employee' + + limited_discount = fields.Integer(string="Discount Limit", + help="Provide discount limit to each employee") diff --git a/pos_discount_manager/static/description/assets/icons/check.png b/pos_discount_manager/static/description/assets/icons/check.png new file mode 100755 index 000000000..c8e85f51d Binary files /dev/null and b/pos_discount_manager/static/description/assets/icons/check.png differ diff --git a/pos_discount_manager/static/description/assets/icons/chevron.png b/pos_discount_manager/static/description/assets/icons/chevron.png new file mode 100755 index 000000000..2089293d6 Binary files /dev/null and b/pos_discount_manager/static/description/assets/icons/chevron.png differ diff --git a/pos_discount_manager/static/description/assets/icons/cogs.png b/pos_discount_manager/static/description/assets/icons/cogs.png new file mode 100755 index 000000000..95d0bad62 Binary files /dev/null and b/pos_discount_manager/static/description/assets/icons/cogs.png differ diff --git a/pos_discount_manager/static/description/assets/icons/consultation.png b/pos_discount_manager/static/description/assets/icons/consultation.png new file mode 100755 index 000000000..8319d4baa Binary files /dev/null and b/pos_discount_manager/static/description/assets/icons/consultation.png differ diff --git a/pos_discount_manager/static/description/assets/icons/ecom-black.png b/pos_discount_manager/static/description/assets/icons/ecom-black.png new file mode 100755 index 000000000..a9385ff13 Binary files /dev/null and b/pos_discount_manager/static/description/assets/icons/ecom-black.png differ diff --git a/pos_discount_manager/static/description/assets/icons/education-black.png b/pos_discount_manager/static/description/assets/icons/education-black.png new file mode 100755 index 000000000..3eb09b27b Binary files /dev/null and b/pos_discount_manager/static/description/assets/icons/education-black.png differ diff --git a/pos_discount_manager/static/description/assets/icons/hotel-black.png b/pos_discount_manager/static/description/assets/icons/hotel-black.png new file mode 100755 index 000000000..130f613be Binary files /dev/null and b/pos_discount_manager/static/description/assets/icons/hotel-black.png differ diff --git a/pos_discount_manager/static/description/assets/icons/license.png b/pos_discount_manager/static/description/assets/icons/license.png new file mode 100755 index 000000000..a5869797e Binary files /dev/null and b/pos_discount_manager/static/description/assets/icons/license.png differ diff --git a/pos_discount_manager/static/description/assets/icons/lifebuoy.png b/pos_discount_manager/static/description/assets/icons/lifebuoy.png new file mode 100755 index 000000000..658d56ccc Binary files /dev/null and b/pos_discount_manager/static/description/assets/icons/lifebuoy.png differ diff --git a/pos_discount_manager/static/description/assets/icons/logo.png b/pos_discount_manager/static/description/assets/icons/logo.png new file mode 100755 index 000000000..478462d3e Binary files /dev/null and b/pos_discount_manager/static/description/assets/icons/logo.png differ diff --git a/pos_discount_manager/static/description/assets/icons/manufacturing-black.png b/pos_discount_manager/static/description/assets/icons/manufacturing-black.png new file mode 100755 index 000000000..697eb0e9f Binary files /dev/null and b/pos_discount_manager/static/description/assets/icons/manufacturing-black.png differ diff --git a/pos_discount_manager/static/description/assets/icons/pos-black.png b/pos_discount_manager/static/description/assets/icons/pos-black.png new file mode 100755 index 000000000..97c0f90c1 Binary files /dev/null and b/pos_discount_manager/static/description/assets/icons/pos-black.png differ diff --git a/pos_discount_manager/static/description/assets/icons/puzzle.png b/pos_discount_manager/static/description/assets/icons/puzzle.png new file mode 100755 index 000000000..65cf854e7 Binary files /dev/null and b/pos_discount_manager/static/description/assets/icons/puzzle.png differ diff --git a/pos_discount_manager/static/description/assets/icons/restaurant-black.png b/pos_discount_manager/static/description/assets/icons/restaurant-black.png new file mode 100755 index 000000000..4a35eb939 Binary files /dev/null and b/pos_discount_manager/static/description/assets/icons/restaurant-black.png differ diff --git a/pos_discount_manager/static/description/assets/icons/service-black.png b/pos_discount_manager/static/description/assets/icons/service-black.png new file mode 100755 index 000000000..301ab51cb Binary files /dev/null and b/pos_discount_manager/static/description/assets/icons/service-black.png differ diff --git a/pos_discount_manager/static/description/assets/icons/trading-black.png b/pos_discount_manager/static/description/assets/icons/trading-black.png new file mode 100755 index 000000000..9398ba2f1 Binary files /dev/null and b/pos_discount_manager/static/description/assets/icons/trading-black.png differ diff --git a/pos_discount_manager/static/description/assets/icons/training.png b/pos_discount_manager/static/description/assets/icons/training.png new file mode 100755 index 000000000..884ca024d Binary files /dev/null and b/pos_discount_manager/static/description/assets/icons/training.png differ diff --git a/pos_discount_manager/static/description/assets/icons/update.png b/pos_discount_manager/static/description/assets/icons/update.png new file mode 100755 index 000000000..ecbc5a01a Binary files /dev/null and b/pos_discount_manager/static/description/assets/icons/update.png differ diff --git a/pos_discount_manager/static/description/assets/icons/user.png b/pos_discount_manager/static/description/assets/icons/user.png new file mode 100755 index 000000000..6ffb23d9f Binary files /dev/null and b/pos_discount_manager/static/description/assets/icons/user.png differ diff --git a/pos_discount_manager/static/description/assets/icons/wrench.png b/pos_discount_manager/static/description/assets/icons/wrench.png new file mode 100755 index 000000000..6c04dea0f Binary files /dev/null and b/pos_discount_manager/static/description/assets/icons/wrench.png differ diff --git a/pos_discount_manager/static/description/assets/modules/1.png b/pos_discount_manager/static/description/assets/modules/1.png new file mode 100755 index 000000000..baaef2807 Binary files /dev/null and b/pos_discount_manager/static/description/assets/modules/1.png differ diff --git a/pos_discount_manager/static/description/assets/modules/2.png b/pos_discount_manager/static/description/assets/modules/2.png new file mode 100755 index 000000000..fb65048fe Binary files /dev/null and b/pos_discount_manager/static/description/assets/modules/2.png differ diff --git a/pos_discount_manager/static/description/assets/modules/3.png b/pos_discount_manager/static/description/assets/modules/3.png new file mode 100755 index 000000000..65f9d71a9 Binary files /dev/null and b/pos_discount_manager/static/description/assets/modules/3.png differ diff --git a/pos_discount_manager/static/description/assets/modules/4.png b/pos_discount_manager/static/description/assets/modules/4.png new file mode 100755 index 000000000..e9baebd5d Binary files /dev/null and b/pos_discount_manager/static/description/assets/modules/4.png differ diff --git a/pos_discount_manager/static/description/assets/modules/5.png b/pos_discount_manager/static/description/assets/modules/5.png new file mode 100755 index 000000000..5c8646fae Binary files /dev/null and b/pos_discount_manager/static/description/assets/modules/5.png differ diff --git a/pos_discount_manager/static/description/assets/modules/6.png b/pos_discount_manager/static/description/assets/modules/6.png new file mode 100755 index 000000000..be8dd200b Binary files /dev/null and b/pos_discount_manager/static/description/assets/modules/6.png differ diff --git a/pos_discount_manager/static/description/assets/screenshots/hero.gif b/pos_discount_manager/static/description/assets/screenshots/hero.gif new file mode 100644 index 000000000..d32eba395 Binary files /dev/null and b/pos_discount_manager/static/description/assets/screenshots/hero.gif differ diff --git a/pos_discount_manager/static/description/assets/screenshots/screen11.png b/pos_discount_manager/static/description/assets/screenshots/screen11.png new file mode 100644 index 000000000..7221ac9c5 Binary files /dev/null and b/pos_discount_manager/static/description/assets/screenshots/screen11.png differ diff --git a/pos_discount_manager/static/description/assets/screenshots/screen12.png b/pos_discount_manager/static/description/assets/screenshots/screen12.png new file mode 100644 index 000000000..2d0116d75 Binary files /dev/null and b/pos_discount_manager/static/description/assets/screenshots/screen12.png differ diff --git a/pos_discount_manager/static/description/assets/screenshots/screen13.png b/pos_discount_manager/static/description/assets/screenshots/screen13.png new file mode 100644 index 000000000..dad3ee5ec Binary files /dev/null and b/pos_discount_manager/static/description/assets/screenshots/screen13.png differ diff --git a/pos_discount_manager/static/description/assets/screenshots/screen4.png b/pos_discount_manager/static/description/assets/screenshots/screen4.png new file mode 100755 index 000000000..ac3cff710 Binary files /dev/null and b/pos_discount_manager/static/description/assets/screenshots/screen4.png differ diff --git a/pos_discount_manager/static/description/assets/screenshots/screen5.png b/pos_discount_manager/static/description/assets/screenshots/screen5.png new file mode 100644 index 000000000..940f6af71 Binary files /dev/null and b/pos_discount_manager/static/description/assets/screenshots/screen5.png differ diff --git a/pos_discount_manager/static/description/assets/screenshots/screen6.png b/pos_discount_manager/static/description/assets/screenshots/screen6.png new file mode 100755 index 000000000..01499a961 Binary files /dev/null and b/pos_discount_manager/static/description/assets/screenshots/screen6.png differ diff --git a/pos_discount_manager/static/description/assets/screenshots/screen7.png b/pos_discount_manager/static/description/assets/screenshots/screen7.png new file mode 100755 index 000000000..3173c5235 Binary files /dev/null and b/pos_discount_manager/static/description/assets/screenshots/screen7.png differ diff --git a/pos_discount_manager/static/description/banner.png b/pos_discount_manager/static/description/banner.png new file mode 100755 index 000000000..ebbbfb663 Binary files /dev/null and b/pos_discount_manager/static/description/banner.png differ diff --git a/pos_discount_manager/static/description/icon.png b/pos_discount_manager/static/description/icon.png new file mode 100755 index 000000000..0cccde13f Binary files /dev/null and b/pos_discount_manager/static/description/icon.png differ diff --git a/pos_discount_manager/static/description/index.html b/pos_discount_manager/static/description/index.html new file mode 100755 index 000000000..b7829a547 --- /dev/null +++ b/pos_discount_manager/static/description/index.html @@ -0,0 +1,595 @@ +
+
+
+
+ +
+
+
+ Community +
+
+ Enterprise +
+
+ Odoo.Sh +
+ +
+
+
+
+ +
+
+
+

+ POS Discount Manager Approval

+

+ Discount limit for each employee in every point of sale +

+ +
+
+ + + +
+
+

+ Overview +

+
+ +
+

+ This module helps you to set a discount limit for each employee in every point of sale. + It facilitate the manager approval when discount over the limit of employee.

+
+

+ +
+ + +
+
+

+ Features +

+
+ +
+
+ +
+
+

+ Sets discount limit for each employee.

+
+
+
+
+ +
+
+

+ Manager Can Set the PIN

+
+
+
+
+ +
+
+

+ Manager pin needed for approving the discount given by the employee.

+
+
+ + + +
+
+

+ Screenshots +

+
+
+

+ We can set discount limit for each employee.

+ +
+ +
+

+ Manager can set the pin for approving the discount

+ +
+ +
+

+ Set multiple employees per session in POS. Select the employee to whom we are giving the discount limit.

+ +
+ + +
+

+ Add a discount greater than the limit we are giving the employee.

+ +
+ + +
+

+ We have to enter the manager's pin to approve the discount limit

+ +
+ +
+

+ If we are entering the correct pin, we can successfully validate the payment.

+ +
+ +
+

+ If we are entering the wrong pin, it will show an error popup.

+ +
+ + + +
+
+

Suggested Products

+
+ + +
+
+ + + +
+
+
+

Our Services

+
+
+ +
+
+ +
+
+ Odoo + Customization
+
+ +
+
+ +
+
+ Odoo + Implementation
+
+ +
+
+ +
+
+ Odoo + Support
+
+ + +
+
+ +
+
+ Hire + Odoo + Developer
+
+ +
+
+ +
+
+ Odoo + Integration
+
+ +
+
+ +
+
+ Odoo + Migration
+
+ + +
+
+ +
+
+ Odoo + Consultancy
+
+ +
+
+ +
+
+ Odoo + Implementation
+
+ +
+
+ +
+
+ Odoo + Licensing Consultancy
+
+
+
+ + + +
+
+
+

Our Industries

+
+
+ +
+
+ +
+ Trading +
+

+ Easily procure + and + sell your products

+
+
+ +
+
+ +
+ POS +
+

+ Easy + configuration + and convivial experience

+
+
+ +
+
+ +
+ Education +
+

+ A platform for + educational management

+
+
+ +
+
+ +
+ Manufacturing +
+

+ Plan, track and + schedule your operations

+
+
+ +
+
+ +
+ E-commerce & Website +
+

+ Mobile + friendly, + awe-inspiring product pages

+
+
+ +
+
+ +
+ Service Management +
+

+ Keep track of + services and invoice

+
+
+ +
+
+ +
+ Restaurant +
+

+ Run your bar or + restaurant methodically

+
+
+ +
+
+ +
+ Hotel Management +
+

+ An + all-inclusive + hotel management application

+
+
+ +
+
+ + + + + +
+
+
+

Need Help?

+
+
+
+ + +
+ +
+ + +
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+
+
+ + +
+
+
diff --git a/pos_discount_manager/static/src/css/popup_size.css b/pos_discount_manager/static/src/css/popup_size.css new file mode 100755 index 000000000..8c2a00d8b --- /dev/null +++ b/pos_discount_manager/static/src/css/popup_size.css @@ -0,0 +1,6 @@ +.pos .popup.popup-number +{ +height:500px; +width:500px + +} \ No newline at end of file diff --git a/pos_discount_manager/static/src/js/DiscountButton.js b/pos_discount_manager/static/src/js/DiscountButton.js new file mode 100755 index 000000000..426f1b9e0 --- /dev/null +++ b/pos_discount_manager/static/src/js/DiscountButton.js @@ -0,0 +1,74 @@ +odoo.define('pos_discount_manager.DiscountButton', function(require) { + 'use strict'; + + const { useListener } = require('web.custom_hooks'); + const Registries = require('point_of_sale.Registries'); + var models = require('point_of_sale.models'); + var DiscountButton = require('pos_discount.DiscountButton') + models.load_fields('hr.employee', ['limited_discount']); + + const DiscountButtonManger = (DiscountButton) => + class extends DiscountButton { + /** + *Override discount button to check the limit + */ + async onClick() { + const { confirmed, payload } = await this.showPopup('NumberPopup',{ + title: this.env._t('Discount Percentage'), + startingValue: this.env.pos.config.discount_pc, + }); + if (confirmed) { + const val = Math.round(Math.max(0,Math.min(100,parseFloat(payload)))); + await self.apply_discount(val); + } + } + + async apply_discount(pc) { + var order = this.env.pos.get_order(); + var lines = order.get_orderlines(); + var product = this.env.pos.db.get_product_by_id(this.env.pos.config.discount_product_id[0]); + if (product === undefined) { + await this.showPopup('ErrorPopup', { + title : this.env._t("No discount product found"), + body : this.env._t("The discount product seems misconfigured.Make sure it is flagged as 'Can be Sold' and 'Available in Point of Sale'."), + }); + return; + } + /** + *Remove existing discounts + */ + var i = 0; + while ( i < lines.length ) { + if (lines[i].get_product() === product) { + order.remove_orderline(lines[i]); + } else { + i++; + } + } + //We add the price as manually set to avoid recomputation when changing customer. + var base_to_discount = order.get_total_without_tax(); + if (product.taxes_id.length){ + var first_tax = this.env.pos.taxes_by_id[product.taxes_id[0]]; + if (first_tax.price_include) { + base_to_discount = order.get_total_with_tax(); + } + } + var discount = - pc / 100.0 * base_to_discount; + + if( discount < 0 ){ + order.add_product(product, { + price: discount, + lst_price: discount, + extras: { + price_manually_set: true, + disc_percentage: pc, + }, + }); + } + } + }; + + Registries.Component.extend(DiscountButton, DiscountButtonManger); + + return DiscountButtonManger; +}); \ No newline at end of file diff --git a/pos_discount_manager/static/src/js/ValidateManager.js b/pos_discount_manager/static/src/js/ValidateManager.js new file mode 100755 index 000000000..c5682b835 --- /dev/null +++ b/pos_discount_manager/static/src/js/ValidateManager.js @@ -0,0 +1,110 @@ +odoo.define('pos_discount_manager.ValidateManager', function(require) { + 'use strict'; + + var models = require('point_of_sale.models'); + const Registries = require('point_of_sale.Registries'); + var PaymentScreen = require('point_of_sale.PaymentScreen') + + const ValidateManagers = (PaymentScreen) => + class extends PaymentScreen { + /** + *Override the validate button to approve discount limit + */ + async _finalizeValidation() { + if ((this.currentOrder.is_paid_with_cash() || this.currentOrder.get_change()) && this.env.pos.config.iface_cashdrawer) { + this.env.pos.proxy.printer.open_cashbox(); + } + + this.currentOrder.initialize_validation_date(); + + let syncedOrderBackendIds = []; + + try { + if (this.currentOrder.is_to_invoice()) { + syncedOrderBackendIds = await this.env.pos.push_and_invoice_order( + this.currentOrder + ); + } else { + syncedOrderBackendIds = await this.env.pos.push_single_order(this.currentOrder); + } + } catch (error) { + if (error instanceof Error) { + throw error; + } else { + await this._handlePushOrderError(error); + } + } + if (syncedOrderBackendIds.length && this.currentOrder.wait_for_push_order()) { + const result = await this._postPushOrderResolve( + this.currentOrder, + syncedOrderBackendIds + ); + if (!result) { + await this.showPopup('ErrorPopup', { + title: 'Error: no internet connection.', + body: error, + }); + } + } + var order = this.env.pos.get_order(); + var employee_dis = this.env.pos.get_cashier()['limited_discount']; + var employee_name = this.env.pos.get_cashier()['name'] + var flag = 1; + var global; + var dis = 0; + for (var i = 0; i < order.orderlines.length; i++) { + dis = dis + order.orderlines.models[i].discount; + if (order.orderlines.models[i].discount > employee_dis || order.orderlines.models[i].disc_percentage > employee_dis || dis > employee_dis) { + flag = 0; + } + } + if (flag != 1) { + const { + confirmed, + payload + } = await this.showPopup('NumberPopup', { + title: this.env._t(employee_name + ', your discount is over the limit. \n MANAGER pin for Approval'), + }); + if (confirmed) { + var output = this.env.pos.employees.filter((obj) => obj.role == 'manager'); + var pin = output[0].pin + + if (Sha1.hash(payload) == pin) { + this.showScreen(this.nextScreen); + } else { + this.showPopup('ErrorPopup', { + title: this.env._t(" MANAGER RESTRICTED YOUR DISCOUNT"), + body: this.env._t(employee_name + ", Your Manager pin is INCORRECT."), + }); + return false; + } + } + else { + return false; + } + + } + this.currentOrder.finalized = true; + this.showScreen(this.nextScreen); + // If we succeeded in syncing the current order, and + // there are still other orders that are left unsynced, + // we ask the user if he is willing to wait and sync them. + if (syncedOrderBackendIds.length && this.env.pos.db.get_orders().length) { + const { + confirmed + } = await this.showPopup('ConfirmPopup', { + title: this.env._t('Remaining unsynced orders'), + body: this.env._t( + 'There are unsynced orders. Do you want to sync these orders?' + ), + }); + if (confirmed) { + // Not yet sure if this should be awaited or not. + this.env.pos.push_orders(); + } + } + } + } + Registries.Component.extend(PaymentScreen, ValidateManagers); + return ValidateManagers; + }); \ No newline at end of file diff --git a/pos_discount_manager/static/src/xml/NumberPopup.xml b/pos_discount_manager/static/src/xml/NumberPopup.xml new file mode 100644 index 000000000..28b709f1b --- /dev/null +++ b/pos_discount_manager/static/src/xml/NumberPopup.xml @@ -0,0 +1,83 @@ + + + + + + + \ No newline at end of file diff --git a/pos_discount_manager/views/hr_employee_views.xml b/pos_discount_manager/views/hr_employee_views.xml new file mode 100755 index 000000000..350ef5fb5 --- /dev/null +++ b/pos_discount_manager/views/hr_employee_views.xml @@ -0,0 +1,14 @@ + + + + + hr.employee.view.form.inherit.pos.discount.manager + hr.employee + + + + + + + + \ No newline at end of file