diff --git a/advanced_loyalty_management/README.rst b/advanced_loyalty_management/README.rst new file mode 100644 index 000000000..123d69b6b --- /dev/null +++ b/advanced_loyalty_management/README.rst @@ -0,0 +1,50 @@ +.. image:: https://img.shields.io/badge/license-LGPL--3-green.svg + :target: https://www.gnu.org/licenses/lgpl-3.0-standalone.html + :alt: License: LGPL-3 + +Advanced Loyalty Management +=========================== +* In this module we can deduct the loyalty points when order is refunded, we can convert the change into loyalty points, History of claimed rewards can be seen in customer's page.And introduced new reward type , in which we can redeem our points. + +Configuration +============ + - www.odoo.com/documentation/15.0/setup/install.html + - Install our custom addon + +Company +------- +* `Cybrosys Techno Solutions `__ + +License +------- +General Public License, Version 3 (LGPL v3). +(https://www.gnu.org/licenses/lgpl-3.0-standalone.html) + +Credits +------- +* Developer: (V17) NIHALA KP, + (V16) NIHALA KP, + (V15) Adarsh K, + Contact: odoo@cybrosys.com + +Contacts +-------- +* Mail Contact : odoo@cybrosys.com +* Website : https://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 +-------- +This module is maintained by Cybrosys Technologies. + +For support and more information, please visit https://www.cybrosys.com + +.. image:: https://cybrosys.com/images/logo.png + :target: https://cybrosys.com" + +Further Information +----------- +HTML Description: ``__ diff --git a/advanced_loyalty_management/__init__.py b/advanced_loyalty_management/__init__.py new file mode 100644 index 000000000..097bdb395 --- /dev/null +++ b/advanced_loyalty_management/__init__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies() +# Author: Cybrosys Techno Solutions() +# +# You can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL 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 LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# (LGPL v3) along with this program. +# If not, see . +# +############################################################################# +from . import models diff --git a/advanced_loyalty_management/__manifest__.py b/advanced_loyalty_management/__manifest__.py new file mode 100644 index 000000000..ea5d3c058 --- /dev/null +++ b/advanced_loyalty_management/__manifest__.py @@ -0,0 +1,64 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies() +# Author: Cybrosys Techno Solutions() +# +# You can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL 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 LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# (LGPL v3) along with this program. +# If not, see . +# +############################################################################# +{ + 'name': 'Advanced Loyalty Management', + 'version': '15.0.1.0.0', + 'category': 'Point of Sale', + 'summary': 'Enhanced Loyalty Program Features', + 'description': """In this module, we have incorporated new features such as + converting changes into loyalty points, displaying claimed rewards history, and + introducing a new type of reward. These enhancements aim to provide a more + comprehensive and rewarding experience for customers engaging with the loyalty + program.""", + 'author': 'Cybrosys Techno Solutions', + 'company': 'Cybrosys Techno Solutions', + 'maintainer': 'Cybrosys Techno Solutions', + 'website': 'https://www.cybrosys.com', + 'depends': ['point_of_sale', 'pos_loyalty', 'base', 'sale_management'], + 'data': [ + 'views/res_partner_views.xml', + 'views/loyalty_rewards_views.xml', + 'views/loyalty_program_views.xml', + ], + 'assets': { + 'point_of_sale.assets': [ + 'advanced_loyalty_management/static/src/js/pos_payment_screen.js', + 'advanced_loyalty_management/static/src/js/pos_change_popup.js', + 'advanced_loyalty_management/static/src/js/pos_order_line.js', + 'advanced_loyalty_management/static/src/js/pos_order.js', + 'advanced_loyalty_management/static/src/js/rewardbutton.js', + 'advanced_loyalty_management/static/src/js/reward_popup.js', + ], + 'web.assets_qweb': [ + 'advanced_loyalty_management/static/src/xml/pos_loyalty_change.xml', + 'advanced_loyalty_management/static/src/xml/pos_change_popup.xml', + 'advanced_loyalty_management/static/src/xml/reward_popup.xml', + ], + }, + 'images': [ + 'static/description/banner.png', + ], + 'license': 'LGPL-3', + 'installable': True, + 'auto_install': False, + 'application': False, +} diff --git a/advanced_loyalty_management/doc/RELEASE_NOTES.md b/advanced_loyalty_management/doc/RELEASE_NOTES.md new file mode 100644 index 000000000..1566e97cb --- /dev/null +++ b/advanced_loyalty_management/doc/RELEASE_NOTES.md @@ -0,0 +1,6 @@ +## Module + +#### 23.07.2024 +#### Version 15.0.1.0.0 +#### ADD +- Initial Commit Advanced Loyalty Management diff --git a/advanced_loyalty_management/models/__init__.py b/advanced_loyalty_management/models/__init__.py new file mode 100644 index 000000000..9ff414360 --- /dev/null +++ b/advanced_loyalty_management/models/__init__.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies() +# Author: Cybrosys Techno Solutions() +# +# You can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL 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 LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# (LGPL v3) along with this program. +# If not, see . +# +############################################################################# +from . import loyalty_program +from . import loyalty_reward +from . import res_partner +from . import pos_order_line diff --git a/advanced_loyalty_management/models/loyalty_program.py b/advanced_loyalty_management/models/loyalty_program.py new file mode 100644 index 000000000..c9377c080 --- /dev/null +++ b/advanced_loyalty_management/models/loyalty_program.py @@ -0,0 +1,37 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies() +# Author: Cybrosys Techno Solutions() +# +# You can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL 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 LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# (LGPL v3) along with this program. +# If not, see . +# +############################################################################# +from odoo import fields, models + + +class LoyaltyProgram(models.Model): + """To load more fields in loyalty program and loyalty model""" + _inherit = 'loyalty.program' + + point_rate = fields.Integer(string='Point Rate', + help="Points corresponding to each unit", + default=1, required=True) + change_rate = fields.Monetary(string='Change Rate', default=1, + readonly=True, + help="Unit of money per points cost") + currency_id = fields.Many2one('res.currency', string='Currency', + default=lambda self: self.env.user.company_id.currency_id, + help="Symbol of Currency") diff --git a/advanced_loyalty_management/models/loyalty_reward.py b/advanced_loyalty_management/models/loyalty_reward.py new file mode 100644 index 000000000..3e14f42b8 --- /dev/null +++ b/advanced_loyalty_management/models/loyalty_reward.py @@ -0,0 +1,77 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies() +# Author: Cybrosys Techno Solutions() +# +# You can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL 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 LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# (LGPL v3) along with this program. +# If not, see . +# +############################################################################# +from odoo import api, fields, models + + +class LoyaltyReward(models.Model): + """To add a new reward type in loyalty reward""" + _inherit = 'loyalty.reward' + + reward_type = fields.Selection(selection_add=[ + ('redemption', 'Redemption') + ], ondelete={'redemption': 'set default'}, + help="A new reward type is added") + redemption_point = fields.Integer(string='Redemption Point', default=1.0, + readonly=True, + help="No of points redeemed according " + "to the redemption amount") + redemption_amount = fields.Float(string='Maximum Redemption per Point', + default=1.00, required=True, + help="Maximum Redemption per redemption " + "point") + max_redemption_type = fields.Selection( + [('amount', 'Amount'), ('percent', 'Percentage'), ('points', 'Points')], + default="amount", + required=True, + help="Redemption type based on Fixed Amount,percentage or Point wise") + max_redemption_amount = fields.Float(string='Max Redemption Amount', + default=10, required=True, + help="Maximum redemption amount " + "given to an order") + redemption_frequency = fields.Integer(string='Redemption Frequency', + default=1, required=True, + help="Number of times this reward " + "can be claimed") + redemption_frequency_unit = fields.Selection([('day', 'Daily'), + ('week', 'Weekly'), + ('month', 'Monthly'), + ('year', 'Yearly')], + default='day', required=True, + string='Redemption Frequency' + 'Unit', + help="Choose the frequency " + "for claiming the reward") + redemption_eligibility = fields.Float(string="Redemption Eligibility", + default=200, + help="points required for claiming " + "the reward") + + @api.model + def create(self, vals): + """creation of new reward product""" + product = self.env['product.product'].create({ + 'name': vals['name'], + 'detailed_type': 'service', + 'available_in_pos': True, + }) + vals['discount_product_id'] = product.id + return super(LoyaltyReward, self).create(vals) diff --git a/advanced_loyalty_management/models/pos_order_line.py b/advanced_loyalty_management/models/pos_order_line.py new file mode 100644 index 000000000..14eccdf55 --- /dev/null +++ b/advanced_loyalty_management/models/pos_order_line.py @@ -0,0 +1,30 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies() +# Author: Cybrosys Techno Solutions() +# +# You can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL 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 LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# (LGPL v3) along with this program. +# If not, see . +# +############################################################################# +from odoo import fields, models + + +class PosOrderLine(models.Model): + """New boolean field is added to filter rewards from order line""" + _inherit = 'pos.order.line' + + is_reward_line = fields.Boolean( + help="Whether this line is part of a reward or not.") diff --git a/advanced_loyalty_management/models/res_partner.py b/advanced_loyalty_management/models/res_partner.py new file mode 100644 index 000000000..bb5d3df13 --- /dev/null +++ b/advanced_loyalty_management/models/res_partner.py @@ -0,0 +1,54 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies() +# Author: Cybrosys Techno Solutions() +# +# You can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL 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 LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# (LGPL v3) along with this program. +# If not, see . +# +############################################################################# +from odoo import api, models + + +class ResPartner(models.Model): + """Add loyalty in view_partner_form""" + _inherit = 'res.partner' + + def action_view_claimed_rewards(self): + """a smart button is created to view the claimed the rewards""" + order_id = self.env['pos.order'].search( + [('partner_id', '=', self.id)]).ids + return { + 'type': 'ir.actions.act_window', + 'name': 'Claimed Rewards', + 'view_mode': 'tree,form', + 'res_model': 'pos.order.line', + 'domain': [('is_reward_line', '=', True), + ('order_id', 'in', order_id)], + 'context': "{'create': False}" + } + + @api.model + def check_redemption(self, partner_id): + """To check number of times the reward is claimed""" + order = self.env['pos.order'].search([('partner_id', '=', partner_id)]) + data = [] + date = [] + order_line = self.env['pos.order.line'].search( + [('is_reward_line', '=', 'true'), ('order_id', 'in', order.ids)]) + for line in order_line: + data.append(line.order_id.id) + date.append(line.create_date.date()) + return data, date diff --git a/advanced_loyalty_management/static/description/assets/icons/check.png b/advanced_loyalty_management/static/description/assets/icons/check.png new file mode 100644 index 000000000..c8e85f51d Binary files /dev/null and b/advanced_loyalty_management/static/description/assets/icons/check.png differ diff --git a/advanced_loyalty_management/static/description/assets/icons/chevron.png b/advanced_loyalty_management/static/description/assets/icons/chevron.png new file mode 100644 index 000000000..2089293d6 Binary files /dev/null and b/advanced_loyalty_management/static/description/assets/icons/chevron.png differ diff --git a/advanced_loyalty_management/static/description/assets/icons/cogs.png b/advanced_loyalty_management/static/description/assets/icons/cogs.png new file mode 100644 index 000000000..95d0bad62 Binary files /dev/null and b/advanced_loyalty_management/static/description/assets/icons/cogs.png differ diff --git a/advanced_loyalty_management/static/description/assets/icons/consultation.png b/advanced_loyalty_management/static/description/assets/icons/consultation.png new file mode 100644 index 000000000..8319d4baa Binary files /dev/null and b/advanced_loyalty_management/static/description/assets/icons/consultation.png differ diff --git a/advanced_loyalty_management/static/description/assets/icons/ecom-black.png b/advanced_loyalty_management/static/description/assets/icons/ecom-black.png new file mode 100644 index 000000000..a9385ff13 Binary files /dev/null and b/advanced_loyalty_management/static/description/assets/icons/ecom-black.png differ diff --git a/advanced_loyalty_management/static/description/assets/icons/education-black.png b/advanced_loyalty_management/static/description/assets/icons/education-black.png new file mode 100644 index 000000000..3eb09b27b Binary files /dev/null and b/advanced_loyalty_management/static/description/assets/icons/education-black.png differ diff --git a/advanced_loyalty_management/static/description/assets/icons/hotel-black.png b/advanced_loyalty_management/static/description/assets/icons/hotel-black.png new file mode 100644 index 000000000..130f613be Binary files /dev/null and b/advanced_loyalty_management/static/description/assets/icons/hotel-black.png differ diff --git a/advanced_loyalty_management/static/description/assets/icons/license.png b/advanced_loyalty_management/static/description/assets/icons/license.png new file mode 100644 index 000000000..a5869797e Binary files /dev/null and b/advanced_loyalty_management/static/description/assets/icons/license.png differ diff --git a/advanced_loyalty_management/static/description/assets/icons/lifebuoy.png b/advanced_loyalty_management/static/description/assets/icons/lifebuoy.png new file mode 100644 index 000000000..658d56ccc Binary files /dev/null and b/advanced_loyalty_management/static/description/assets/icons/lifebuoy.png differ diff --git a/advanced_loyalty_management/static/description/assets/icons/manufacturing-black.png b/advanced_loyalty_management/static/description/assets/icons/manufacturing-black.png new file mode 100644 index 000000000..697eb0e9f Binary files /dev/null and b/advanced_loyalty_management/static/description/assets/icons/manufacturing-black.png differ diff --git a/advanced_loyalty_management/static/description/assets/icons/pos-black.png b/advanced_loyalty_management/static/description/assets/icons/pos-black.png new file mode 100644 index 000000000..97c0f90c1 Binary files /dev/null and b/advanced_loyalty_management/static/description/assets/icons/pos-black.png differ diff --git a/advanced_loyalty_management/static/description/assets/icons/puzzle.png b/advanced_loyalty_management/static/description/assets/icons/puzzle.png new file mode 100644 index 000000000..65cf854e7 Binary files /dev/null and b/advanced_loyalty_management/static/description/assets/icons/puzzle.png differ diff --git a/advanced_loyalty_management/static/description/assets/icons/restaurant-black.png b/advanced_loyalty_management/static/description/assets/icons/restaurant-black.png new file mode 100644 index 000000000..4a35eb939 Binary files /dev/null and b/advanced_loyalty_management/static/description/assets/icons/restaurant-black.png differ diff --git a/advanced_loyalty_management/static/description/assets/icons/service-black.png b/advanced_loyalty_management/static/description/assets/icons/service-black.png new file mode 100644 index 000000000..301ab51cb Binary files /dev/null and b/advanced_loyalty_management/static/description/assets/icons/service-black.png differ diff --git a/advanced_loyalty_management/static/description/assets/icons/trading-black.png b/advanced_loyalty_management/static/description/assets/icons/trading-black.png new file mode 100644 index 000000000..9398ba2f1 Binary files /dev/null and b/advanced_loyalty_management/static/description/assets/icons/trading-black.png differ diff --git a/advanced_loyalty_management/static/description/assets/icons/training.png b/advanced_loyalty_management/static/description/assets/icons/training.png new file mode 100644 index 000000000..884ca024d Binary files /dev/null and b/advanced_loyalty_management/static/description/assets/icons/training.png differ diff --git a/advanced_loyalty_management/static/description/assets/icons/update.png b/advanced_loyalty_management/static/description/assets/icons/update.png new file mode 100644 index 000000000..ecbc5a01a Binary files /dev/null and b/advanced_loyalty_management/static/description/assets/icons/update.png differ diff --git a/advanced_loyalty_management/static/description/assets/icons/user.png b/advanced_loyalty_management/static/description/assets/icons/user.png new file mode 100644 index 000000000..6ffb23d9f Binary files /dev/null and b/advanced_loyalty_management/static/description/assets/icons/user.png differ diff --git a/advanced_loyalty_management/static/description/assets/icons/wrench.png b/advanced_loyalty_management/static/description/assets/icons/wrench.png new file mode 100644 index 000000000..6c04dea0f Binary files /dev/null and b/advanced_loyalty_management/static/description/assets/icons/wrench.png differ diff --git a/advanced_loyalty_management/static/description/assets/misc/categories.png b/advanced_loyalty_management/static/description/assets/misc/categories.png new file mode 100644 index 000000000..bedf1e0b1 Binary files /dev/null and b/advanced_loyalty_management/static/description/assets/misc/categories.png differ diff --git a/advanced_loyalty_management/static/description/assets/misc/check-box.png b/advanced_loyalty_management/static/description/assets/misc/check-box.png new file mode 100644 index 000000000..42caf24b9 Binary files /dev/null and b/advanced_loyalty_management/static/description/assets/misc/check-box.png differ diff --git a/advanced_loyalty_management/static/description/assets/misc/compass.png b/advanced_loyalty_management/static/description/assets/misc/compass.png new file mode 100644 index 000000000..d5fed8faa Binary files /dev/null and b/advanced_loyalty_management/static/description/assets/misc/compass.png differ diff --git a/advanced_loyalty_management/static/description/assets/misc/corporate.png b/advanced_loyalty_management/static/description/assets/misc/corporate.png new file mode 100644 index 000000000..2eb13edbf Binary files /dev/null and b/advanced_loyalty_management/static/description/assets/misc/corporate.png differ diff --git a/advanced_loyalty_management/static/description/assets/misc/customer-support.png b/advanced_loyalty_management/static/description/assets/misc/customer-support.png new file mode 100644 index 000000000..79efc72ed Binary files /dev/null and b/advanced_loyalty_management/static/description/assets/misc/customer-support.png differ diff --git a/advanced_loyalty_management/static/description/assets/misc/cybrosys-logo.png b/advanced_loyalty_management/static/description/assets/misc/cybrosys-logo.png new file mode 100644 index 000000000..cc3cc0ccf Binary files /dev/null and b/advanced_loyalty_management/static/description/assets/misc/cybrosys-logo.png differ diff --git a/advanced_loyalty_management/static/description/assets/misc/features.png b/advanced_loyalty_management/static/description/assets/misc/features.png new file mode 100644 index 000000000..b41769f77 Binary files /dev/null and b/advanced_loyalty_management/static/description/assets/misc/features.png differ diff --git a/advanced_loyalty_management/static/description/assets/misc/logo.png b/advanced_loyalty_management/static/description/assets/misc/logo.png new file mode 100644 index 000000000..478462d3e Binary files /dev/null and b/advanced_loyalty_management/static/description/assets/misc/logo.png differ diff --git a/advanced_loyalty_management/static/description/assets/misc/pictures.png b/advanced_loyalty_management/static/description/assets/misc/pictures.png new file mode 100644 index 000000000..56d255fe9 Binary files /dev/null and b/advanced_loyalty_management/static/description/assets/misc/pictures.png differ diff --git a/advanced_loyalty_management/static/description/assets/misc/pie-chart.png b/advanced_loyalty_management/static/description/assets/misc/pie-chart.png new file mode 100644 index 000000000..426e05244 Binary files /dev/null and b/advanced_loyalty_management/static/description/assets/misc/pie-chart.png differ diff --git a/advanced_loyalty_management/static/description/assets/misc/right-arrow.png b/advanced_loyalty_management/static/description/assets/misc/right-arrow.png new file mode 100644 index 000000000..730984a06 Binary files /dev/null and b/advanced_loyalty_management/static/description/assets/misc/right-arrow.png differ diff --git a/advanced_loyalty_management/static/description/assets/misc/star.png b/advanced_loyalty_management/static/description/assets/misc/star.png new file mode 100644 index 000000000..2eb9ab29f Binary files /dev/null and b/advanced_loyalty_management/static/description/assets/misc/star.png differ diff --git a/advanced_loyalty_management/static/description/assets/misc/support.png b/advanced_loyalty_management/static/description/assets/misc/support.png new file mode 100644 index 000000000..4f18b8b82 Binary files /dev/null and b/advanced_loyalty_management/static/description/assets/misc/support.png differ diff --git a/advanced_loyalty_management/static/description/assets/misc/whatsapp.png b/advanced_loyalty_management/static/description/assets/misc/whatsapp.png new file mode 100644 index 000000000..d513a5356 Binary files /dev/null and b/advanced_loyalty_management/static/description/assets/misc/whatsapp.png differ diff --git a/advanced_loyalty_management/static/description/assets/modules/1.jpg b/advanced_loyalty_management/static/description/assets/modules/1.jpg new file mode 100644 index 000000000..8890ee31d Binary files /dev/null and b/advanced_loyalty_management/static/description/assets/modules/1.jpg differ diff --git a/advanced_loyalty_management/static/description/assets/modules/2.jpg b/advanced_loyalty_management/static/description/assets/modules/2.jpg new file mode 100644 index 000000000..96fc90703 Binary files /dev/null and b/advanced_loyalty_management/static/description/assets/modules/2.jpg differ diff --git a/advanced_loyalty_management/static/description/assets/modules/3.jpg b/advanced_loyalty_management/static/description/assets/modules/3.jpg new file mode 100644 index 000000000..158fefab6 Binary files /dev/null and b/advanced_loyalty_management/static/description/assets/modules/3.jpg differ diff --git a/advanced_loyalty_management/static/description/assets/modules/4.png b/advanced_loyalty_management/static/description/assets/modules/4.png new file mode 100644 index 000000000..33f803afd Binary files /dev/null and b/advanced_loyalty_management/static/description/assets/modules/4.png differ diff --git a/advanced_loyalty_management/static/description/assets/modules/5.png b/advanced_loyalty_management/static/description/assets/modules/5.png new file mode 100644 index 000000000..be8dd200b Binary files /dev/null and b/advanced_loyalty_management/static/description/assets/modules/5.png differ diff --git a/advanced_loyalty_management/static/description/assets/modules/6.png b/advanced_loyalty_management/static/description/assets/modules/6.png new file mode 100644 index 000000000..6d4cb94bb Binary files /dev/null and b/advanced_loyalty_management/static/description/assets/modules/6.png differ diff --git a/advanced_loyalty_management/static/description/assets/screenshots/1.png b/advanced_loyalty_management/static/description/assets/screenshots/1.png new file mode 100644 index 000000000..51bfcb3a0 Binary files /dev/null and b/advanced_loyalty_management/static/description/assets/screenshots/1.png differ diff --git a/advanced_loyalty_management/static/description/assets/screenshots/10.png b/advanced_loyalty_management/static/description/assets/screenshots/10.png new file mode 100644 index 000000000..8aedb2cce Binary files /dev/null and b/advanced_loyalty_management/static/description/assets/screenshots/10.png differ diff --git a/advanced_loyalty_management/static/description/assets/screenshots/11.png b/advanced_loyalty_management/static/description/assets/screenshots/11.png new file mode 100644 index 000000000..41cb818f9 Binary files /dev/null and b/advanced_loyalty_management/static/description/assets/screenshots/11.png differ diff --git a/advanced_loyalty_management/static/description/assets/screenshots/12.png b/advanced_loyalty_management/static/description/assets/screenshots/12.png new file mode 100644 index 000000000..432126c43 Binary files /dev/null and b/advanced_loyalty_management/static/description/assets/screenshots/12.png differ diff --git a/advanced_loyalty_management/static/description/assets/screenshots/13.png b/advanced_loyalty_management/static/description/assets/screenshots/13.png new file mode 100644 index 000000000..f8b4019f6 Binary files /dev/null and b/advanced_loyalty_management/static/description/assets/screenshots/13.png differ diff --git a/advanced_loyalty_management/static/description/assets/screenshots/14.png b/advanced_loyalty_management/static/description/assets/screenshots/14.png new file mode 100644 index 000000000..fd813ed59 Binary files /dev/null and b/advanced_loyalty_management/static/description/assets/screenshots/14.png differ diff --git a/advanced_loyalty_management/static/description/assets/screenshots/15.png b/advanced_loyalty_management/static/description/assets/screenshots/15.png new file mode 100644 index 000000000..a3255d03c Binary files /dev/null and b/advanced_loyalty_management/static/description/assets/screenshots/15.png differ diff --git a/advanced_loyalty_management/static/description/assets/screenshots/16.png b/advanced_loyalty_management/static/description/assets/screenshots/16.png new file mode 100644 index 000000000..f7de3bc4b Binary files /dev/null and b/advanced_loyalty_management/static/description/assets/screenshots/16.png differ diff --git a/advanced_loyalty_management/static/description/assets/screenshots/17.png b/advanced_loyalty_management/static/description/assets/screenshots/17.png new file mode 100644 index 000000000..743a5a208 Binary files /dev/null and b/advanced_loyalty_management/static/description/assets/screenshots/17.png differ diff --git a/advanced_loyalty_management/static/description/assets/screenshots/18.png b/advanced_loyalty_management/static/description/assets/screenshots/18.png new file mode 100644 index 000000000..dc766b0c2 Binary files /dev/null and b/advanced_loyalty_management/static/description/assets/screenshots/18.png differ diff --git a/advanced_loyalty_management/static/description/assets/screenshots/19.png b/advanced_loyalty_management/static/description/assets/screenshots/19.png new file mode 100644 index 000000000..5d021c536 Binary files /dev/null and b/advanced_loyalty_management/static/description/assets/screenshots/19.png differ diff --git a/advanced_loyalty_management/static/description/assets/screenshots/2.png b/advanced_loyalty_management/static/description/assets/screenshots/2.png new file mode 100644 index 000000000..6071117da Binary files /dev/null and b/advanced_loyalty_management/static/description/assets/screenshots/2.png differ diff --git a/advanced_loyalty_management/static/description/assets/screenshots/20.png b/advanced_loyalty_management/static/description/assets/screenshots/20.png new file mode 100644 index 000000000..2a905354f Binary files /dev/null and b/advanced_loyalty_management/static/description/assets/screenshots/20.png differ diff --git a/advanced_loyalty_management/static/description/assets/screenshots/21.png b/advanced_loyalty_management/static/description/assets/screenshots/21.png new file mode 100644 index 000000000..f55e104f8 Binary files /dev/null and b/advanced_loyalty_management/static/description/assets/screenshots/21.png differ diff --git a/advanced_loyalty_management/static/description/assets/screenshots/22.png b/advanced_loyalty_management/static/description/assets/screenshots/22.png new file mode 100644 index 000000000..9559beded Binary files /dev/null and b/advanced_loyalty_management/static/description/assets/screenshots/22.png differ diff --git a/advanced_loyalty_management/static/description/assets/screenshots/23.png b/advanced_loyalty_management/static/description/assets/screenshots/23.png new file mode 100644 index 000000000..993e45092 Binary files /dev/null and b/advanced_loyalty_management/static/description/assets/screenshots/23.png differ diff --git a/advanced_loyalty_management/static/description/assets/screenshots/3.png b/advanced_loyalty_management/static/description/assets/screenshots/3.png new file mode 100644 index 000000000..24cd3b169 Binary files /dev/null and b/advanced_loyalty_management/static/description/assets/screenshots/3.png differ diff --git a/advanced_loyalty_management/static/description/assets/screenshots/4.png b/advanced_loyalty_management/static/description/assets/screenshots/4.png new file mode 100644 index 000000000..ecc658614 Binary files /dev/null and b/advanced_loyalty_management/static/description/assets/screenshots/4.png differ diff --git a/advanced_loyalty_management/static/description/assets/screenshots/5.png b/advanced_loyalty_management/static/description/assets/screenshots/5.png new file mode 100644 index 000000000..936d560e2 Binary files /dev/null and b/advanced_loyalty_management/static/description/assets/screenshots/5.png differ diff --git a/advanced_loyalty_management/static/description/assets/screenshots/6.png b/advanced_loyalty_management/static/description/assets/screenshots/6.png new file mode 100644 index 000000000..6dffcb904 Binary files /dev/null and b/advanced_loyalty_management/static/description/assets/screenshots/6.png differ diff --git a/advanced_loyalty_management/static/description/assets/screenshots/7.png b/advanced_loyalty_management/static/description/assets/screenshots/7.png new file mode 100644 index 000000000..3895f902b Binary files /dev/null and b/advanced_loyalty_management/static/description/assets/screenshots/7.png differ diff --git a/advanced_loyalty_management/static/description/assets/screenshots/8.png b/advanced_loyalty_management/static/description/assets/screenshots/8.png new file mode 100644 index 000000000..fb760fc74 Binary files /dev/null and b/advanced_loyalty_management/static/description/assets/screenshots/8.png differ diff --git a/advanced_loyalty_management/static/description/assets/screenshots/9.png b/advanced_loyalty_management/static/description/assets/screenshots/9.png new file mode 100644 index 000000000..28178fbc3 Binary files /dev/null and b/advanced_loyalty_management/static/description/assets/screenshots/9.png differ diff --git a/advanced_loyalty_management/static/description/assets/screenshots/v15-hero.gif b/advanced_loyalty_management/static/description/assets/screenshots/v15-hero.gif new file mode 100644 index 000000000..9c580322d Binary files /dev/null and b/advanced_loyalty_management/static/description/assets/screenshots/v15-hero.gif differ diff --git a/advanced_loyalty_management/static/description/banner.png b/advanced_loyalty_management/static/description/banner.png new file mode 100644 index 000000000..a93dfd98a Binary files /dev/null and b/advanced_loyalty_management/static/description/banner.png differ diff --git a/advanced_loyalty_management/static/description/icon.png b/advanced_loyalty_management/static/description/icon.png new file mode 100644 index 000000000..c8ddb4f72 Binary files /dev/null and b/advanced_loyalty_management/static/description/icon.png differ diff --git a/advanced_loyalty_management/static/description/index.html b/advanced_loyalty_management/static/description/index.html new file mode 100644 index 000000000..cc97dbde0 --- /dev/null +++ b/advanced_loyalty_management/static/description/index.html @@ -0,0 +1,715 @@ +
+ +
+ +
+
+ Enterprise +
+
+ Odoo.sh +
+
+
+ +
+
+
+ +

+ Advanced Loyalty Management

+

+ In This Module, We have Incorporated new Features such as + Converting Changes into Loyalty Points, Displaying Claimed Rewards History, and + Introducing a new Type of Reward + +

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

+ Explore This + Module

+
+ + + + +
+
+ +
+

+ Overview +

+
+
+
+ In this module, we have implemented the functionality to convert change + into loyalty points. Customers can conveniently view their claimed rewards + history on their respective pages. Furthermore, we've introduced a new reward type, + allowing users to redeem their accumulated points. +
+
+ + + +
+
+ +
+

+ Features +

+
+
+
+
+ + We can convert the change into Loyalty Points. +
+
+ + History of claimed Rewards can be seen in the customer's page +
+
+ + A new loyalty reward type is introduced, where we can redeem the points +
+ +
+
+ + + +
+
+ +
+

+ Screenshots +

+
+
+
+ +
+

+ We have the capability to convert the change to loyalty points.To facilitate this, we have introduced + a new field in the loyalty program for the conversion rate per dollar. +

+ + +
+ +
+

+ Initially, we can select a customer, whose loyalty points are set to zero. +

+ +
+ +
+

+ Then we can create a sales order directly from the POS interface. +

+ +
+ +
+

+ We create a button under the change to convert the loyalty. +

+ +
+
+

+ When the popup is clicked, the loyalty program allocated for the POS session + will become visible here.Clicking the ADD button will convert changes, and the + change amount will reset to zero. +

+ + + + +
+
+

+ Now let's check new reward type and how its works +

+ +
+
+

+ In this type of reward, customers can only claim the reward if they are making + a second purchase or if they have existing loyalty points. +

+ +
+
+

+ If the same customer do the purchase for the second time, they are eligible for claiming the reward +

+ +
+
+

+ Upon selecting the reward a popup showing how many points we can redeem +

+ +
+
+

+ Then we can see that it is applied to reward line +

+ + +
+
+

+ If the same customer come again he cannot claim it again, While configuring the rewards , + we give the condition Daily 1 +

+ + +
+
+

+ If maximum redemption amount type is given in percentage, We can redeem the 10% of the order's subtotal +

+ + +
+ +
+

+ If maximum redemption amount type is given in Points, We can redeem that much points as + maximum redemption points +

+ + +
+
+

+ Next we can see the history of claimed rewards in the customer's page. +

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

+ Related + 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

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

+ Support +

+
+
+
+
+
+
+ +
+
+

Need Help?

+

Got questions or need help? + Get in touch.

+ +

+ odoo@cybrosys.com

+
+
+
+
+
+
+
+ +
+
+

WhatsApp

+

Say hi to us on WhatsApp!

+ +

+ +91 86068 + 27707

+
+
+
+
+
+
+
+ +
+
+
+ \ No newline at end of file diff --git a/advanced_loyalty_management/static/src/js/pos_change_popup.js b/advanced_loyalty_management/static/src/js/pos_change_popup.js new file mode 100644 index 000000000..469a46873 --- /dev/null +++ b/advanced_loyalty_management/static/src/js/pos_change_popup.js @@ -0,0 +1,42 @@ +odoo.define('advanced_loyalty_management.LoyaltyPrograms', function (require) { + "use strict"; + + const AbstractAwaitablePopup = require('point_of_sale.AbstractAwaitablePopup'); + const Registries = require('point_of_sale.Registries'); + const rpc = require('web.rpc'); + const { _t } = require('web.core'); + + class LoyaltyPrograms extends AbstractAwaitablePopup { + constructor() { + super(...arguments); + } + async convertToLoyalty(props, programId) { + const change = props.change; + const order = props.Order; + const loyalty = props.Loyalty + + // Resets the change by adjusting the payment + if (change > 0) { + const lastPaymentLine = props.Order.get_paymentlines().slice(-1)[0]; + if (lastPaymentLine) { + lastPaymentLine.set_amount(lastPaymentLine.get_amount() - change); + } + order.change_to_loyalty = change * loyalty.point_rate; + } + + this.trigger('confirm'); + } + } + + LoyaltyPrograms.template = 'LoyaltyPrograms'; + LoyaltyPrograms.defaultProps = { + confirmText: _t('Confirm'), + cancelText: _t('Cancel'), + title: _t('Loyalty Programs'), + body: '', + }; + + Registries.Component.add(LoyaltyPrograms); + + return LoyaltyPrograms; +}); diff --git a/advanced_loyalty_management/static/src/js/pos_order.js b/advanced_loyalty_management/static/src/js/pos_order.js new file mode 100644 index 000000000..abd6a0b8e --- /dev/null +++ b/advanced_loyalty_management/static/src/js/pos_order.js @@ -0,0 +1,82 @@ +odoo.define('advanced_loyalty_management.Order', function(require) { + "use strict"; + + const models = require('point_of_sale.models'); + const _super_Order = models.Order.prototype; + const { patch } = require('web.utils'); + const ProductScreen = require('point_of_sale.ProductScreen'); + + + models.Order = models.Order.extend({ + initialize: function(attributes, options) { + _super_Order.initialize.apply(this, arguments); + if (options?.json?.lines.length === 0) { + this.additional_redeemed_points = 0; + this.pointsWon = 0; + this.selected_reward = null; + } + }, + + get_won_points: function() { + const wonPoints = _super_Order.get_won_points.apply(this, arguments); + if (this.selected_reward && this.selected_reward.reward_type === 'redemption') { + return Math.max(0, this.pointsWon - this.additional_redeemed_points); + } + return wonPoints; + }, + + get_spent_points: function() { + const spentPoints = _super_Order.get_spent_points.apply(this, arguments); + return spentPoints + this.additional_redeemed_points; + }, + + get_new_points: function() { + const newPoints = _super_Order.get_new_points.apply(this, arguments); + if (this.selected_reward && this.selected_reward.reward_type === 'redemption') { + return Math.max(0, this.pointsWon - this.additional_redeemed_points); + } + return newPoints; + }, + // Ensure pointsWon, additional_redeemed_points, selected_reward is also persisted + export_as_JSON: function() { + const json = _super_Order.export_as_JSON.apply(this, arguments); + json.additional_redeemed_points = this.additional_redeemed_points; + json.selected_reward = this.selected_reward; + json.pointsWon = this.pointsWon; + return json; + }, + // Restore pointsWon, additional_redeemed_points, selected_reward + init_from_JSON: function(json) { + _super_Order.init_from_JSON.apply(this, arguments); + this.additional_redeemed_points = json.additional_redeemed_points || 0; + this.selected_reward = json.selected_reward || null; + this.pointsWon = json.pointsWon || 0; + }, + + applyRedeemPoints: function(pointsToRedeem, selectedReward, pointsWon) { + this.additional_redeemed_points += pointsToRedeem; + this.selected_reward = selectedReward; + this.pointsWon = pointsWon; + }, + resetRedemptionPoints: function() { + this.additional_redeemed_points = 0; + this.pointsWon = 0; + this.selected_reward = null; + } + }); + // Resets the loyalty points on clicking backspace + patch(ProductScreen.prototype, 'advanced_loyalty_management.ProductScreen', { + _updateSelectedOrderline: function (event) { + let screen = this._super(...arguments); + const order = this.env.pos.get_order() + const selectedLine = order?.selected_orderline?.get_reward()?.reward_type; + if (selectedLine === 'redemption') { + order.resetRedemptionPoints(); + this.render(); + } + return screen; + }, + }); + + return models; +}); diff --git a/advanced_loyalty_management/static/src/js/pos_order_line.js b/advanced_loyalty_management/static/src/js/pos_order_line.js new file mode 100644 index 000000000..84d949334 --- /dev/null +++ b/advanced_loyalty_management/static/src/js/pos_order_line.js @@ -0,0 +1,20 @@ +odoo.define('advanced_loyalty_management.OrderLine', function (require) { + "use strict"; + var models = require('point_of_sale.models'); + var _super_orderline = models.Orderline.prototype; + + models.Orderline = models.Orderline.extend({ +// To include a is_reward_line flag for reward lines, during initialization and JSON export + initialize: function(attr, options) { + _super_orderline.initialize.apply(this, arguments); + if (options.extras && options.extras.is_reward_line) { + this.is_reward_line = options.extras.is_reward_line; + } + }, + export_as_JSON: function() { + var json = _super_orderline.export_as_JSON.apply(this, arguments); + json.is_reward_line = this.is_reward_line || false; + return json; + }, + }); +}); diff --git a/advanced_loyalty_management/static/src/js/pos_payment_screen.js b/advanced_loyalty_management/static/src/js/pos_payment_screen.js new file mode 100644 index 000000000..80ca4056c --- /dev/null +++ b/advanced_loyalty_management/static/src/js/pos_payment_screen.js @@ -0,0 +1,38 @@ +odoo.define('advanced_loyalty_management.ChangeLoyalty', function (require) { + "use strict"; + const { patch } = require('web.utils'); + const PaymentScreenStatus = require('point_of_sale.PaymentScreenStatus'); + const { Gui } = require('point_of_sale.Gui'); + + patch(PaymentScreenStatus.prototype, 'point_of_sale/static/src/js/Screens/PaymentScreen/PaymentScreenStatus.js', { + async convertLoyalty() { + var order = this.env.pos.get_order(); + const result = await Gui.showPopup('LoyaltyPrograms', { + title: this.env._t('Convert Change'), + cancelText: this.env._t("Cancel"), + confirmText: this.env._t("Confirm"), + Order: order, + Loyalty: this.env.pos.loyalty, + LoyaltyPoints: order.get_won_points(), + change: order.get_change(), + }); + }, + + showLoyaltyButton: function() { + var order = this.env.pos.get_order(); + const showButton = order.get_change() > 0 && order.get_won_points() > 0 + return showButton; + }, + }); + // Patch the Order prototype to modify get_won_points and adds the change + const Order = require('point_of_sale.models').Order; + patch(Order.prototype, 'advanced_loyalty_management.Order', { + get_won_points: function () { + let points = this._super(...arguments); + if (this.change_to_loyalty) { + points += this.change_to_loyalty; + } + return points; + }, + }); +}); diff --git a/advanced_loyalty_management/static/src/js/reward_popup.js b/advanced_loyalty_management/static/src/js/reward_popup.js new file mode 100644 index 000000000..fb5f1e465 --- /dev/null +++ b/advanced_loyalty_management/static/src/js/reward_popup.js @@ -0,0 +1,62 @@ +odoo.define('advanced_loyalty_management.RewardPopup', function (require) { + "use strict"; + + const AbstractAwaitablePopup = require('point_of_sale.AbstractAwaitablePopup'); + const Registries = require('point_of_sale.Registries'); + const { _t } = require('web.core'); + const { hooks } = owl; + const { useState, useRef } = hooks; + + class RewardPopup extends AbstractAwaitablePopup { + setup() { + this.state = useState({ + value: '', + redeemPoints: '' + }); + this.points = useRef("points"); + } + + toRedeem(ev) { + this.state.redeemPoints = this.points.el.value; + } + + save(props, ev) { + const pointsToRedeem = parseInt(this.state.redeemPoints); + if (isNaN(pointsToRedeem)) { + this.showPopup('ErrorPopup', { + title: _t('Error'), + body: _t('Please enter a valid number'), + }); + return; + } + + if (props.max_redemption_points < pointsToRedeem) { + this.showPopup('ErrorPopup', { + title: _t('Error'), + body: _t('Points to redeem should be less than Maximum Redemption Point.'), + }); + return; + } + + const selectedReward = props.selected_reward; + selectedReward.pointsToRedeem = parseInt(this.state.redeemPoints); + const pointsWon = props.order.get_won_points(); + props.order.point_cost = pointsToRedeem; + ev.confirm(); + props.property.apply_reward(selectedReward); + props.order.applyRedeemPoints(pointsToRedeem, selectedReward, pointsWon); + } + } + + RewardPopup.template = 'RewardPopup'; + RewardPopup.defaultProps = { + confirmText: _t('Confirm'), + cancelText: _t('Cancel'), + title: _t('Reward'), + body: '', + }; + + Registries.Component.add(RewardPopup); + + return RewardPopup; +}); diff --git a/advanced_loyalty_management/static/src/js/rewardbutton.js b/advanced_loyalty_management/static/src/js/rewardbutton.js new file mode 100644 index 000000000..052129e17 --- /dev/null +++ b/advanced_loyalty_management/static/src/js/rewardbutton.js @@ -0,0 +1,287 @@ +odoo.define('advanced_loyalty_management.RewardButton', function (require) { + "use strict"; +const { patch } = require('web.utils'); +const { useListener } = require('web.custom_hooks'); +const RewardButton = require('pos_loyalty.RewardButton'); +const { Gui } = require('point_of_sale.Gui'); +const { _t } = require('web.core'); +const { useState } = owl; +var models = require('point_of_sale.models'); +var rpc = require('web.rpc'); +var utils = require('web.utils'); +var round_pr = utils.round_precision; +models.load_fields("loyalty.reward", + ["max_redemption_amount", "redemption_point", "redemption_amount","redemption_frequency","redemption_frequency_unit", + "redemption_eligibility", "max_redemption_type"]); +models.load_fields("loyalty.program", + ["point_rate"]); + +patch(RewardButton.prototype, "pos_loyalty/static/src/js/RewardButton.js", { + setup() { + useListener('click', this.onClick); + this.state = useState({ + frequency : 0, + }); + }, + async apply_reward(reward) { + const order = this.env.pos.get_order(); + var client = order.get_client(); + var product, product_price, order_total, spendable; + var crounding; + + if (!client) { + return; + } else if (reward.reward_type === 'gift') { + product = order.pos.db.get_product_by_id(reward.gift_product_id[0]); + + if (!product) { + return; + } + + let options = await order._getAddProductOptions(product); + await order.add_product(product, { + ...options, + price: 0, + quantity: 1, + merge: false, + extras: { reward_id: reward.id, price_manually_set: true, is_reward_line: true }, + }); + + } else if (reward.reward_type === 'discount') { + + crounding = order.pos.currency.rounding; + spendable = order.get_spendable_points(); + order_total = order.get_total_with_tax(); + var discount = 0; + + product = order.pos.db.get_product_by_id(reward.discount_product_id[0]); + + if (!product) { + return; + } + + if (reward.discount_type === "percentage") { + if (reward.discount_apply_on === "on_order") { + discount += round_pr(order_total * (reward.discount_percentage / 100), crounding); + } + + if (reward.discount_apply_on === "specific_products") { + for (var prod of reward.discount_specific_product_ids) { + var specific_products = order.pos.db.get_product_by_id(prod); + + if (!specific_products) + return; + + for (var line of order.get_orderlines()) { + if (line.product.id === specific_products.id) + discount += round_pr(line.get_price_with_tax() * (reward.discount_percentage / 100), crounding); + } + } + } + + if (reward.discount_apply_on === "cheapest_product") { + var price; + for (var line of order.get_orderlines()) { + if ((!price || price > line.get_unit_price()) && line.product.id !== product.id) { + discount = round_pr(line.get_price_with_tax() * (reward.discount_percentage / 100), crounding); + price = line.get_unit_price(); + } + } + } + if (reward.discount_max_amount !== 0 && discount > reward.discount_max_amount) + discount = reward.discount_max_amount; + + let options = await order._getAddProductOptions(product); + await order.add_product(product, { + ...options, + price: -discount, + quantity: 1, + merge: false, + extras: { reward_id: reward.id, price_manually_set: true, is_reward_line: true }, + }); + } + if (reward.discount_type == "fixed_amount") { + let discount_fixed_amount = reward.discount_fixed_amount; + let point_cost = reward.point_cost; + let quantity_to_apply = Math.floor(spendable / point_cost); + let amount_discounted = discount_fixed_amount * quantity_to_apply; + + if (amount_discounted > order_total) { + quantity_to_apply = Math.floor(order_total / discount_fixed_amount); + } + + let options = await order._getAddProductOptions(product); + await order.add_product(product, { + ...options, + price: -discount_fixed_amount, + quantity: quantity_to_apply, + merge: false, + extras: { reward_id: reward.id, price_manually_set: true, is_reward_line: true }, + }); + } + } + // Start of new condition for reward_type 'redemption' + else if (reward.reward_type === 'redemption') { + if (order.get_client() != null) { + await this.check(reward, order.get_client().id); + } + + if (reward.redemption_frequency > this.state.frequency) { + product = this.env.pos.db.get_product_by_id(reward.discount_product_id[0]); + if (!product) { + return; + } + + let options = await order._getAddProductOptions(product); + await order.add_product(product, { + ...options, + price: -reward.pointsToRedeem, + quantity: 1, + merge: false, + extras: { reward_id: reward.id, price_manually_set: true, is_reward_line: true }, + }); + } else { + this.showPopup('ErrorPopup', { + title: _t("REDEMPTION LIMIT REACHED"), + body: _t("You have reached the redemption limit for this period."), + }); + } + } + }, + + async check(reward, partnerId){ + //---To check how many times the reward is claimed + let count = 0; + var checkRedemption = await rpc.query({ + model:'res.partner', + method:'check_redemption', + args:[partnerId] + }) + .then((result)=>{ + const today = new Date() + const year = today.getFullYear(); + const month = String(today.getMonth() + 1).padStart(2, '0'); + const day = String(today.getDate()).padStart(2, '0'); + const formattedDate = `${year}-${month}-${day}`; + const currentWeekStart = new Date(today.getFullYear(), today.getMonth(), today.getDate() - today.getDay()); + const currentWeekEnd = new Date(today.getFullYear(), today.getMonth(), today.getDate() + (6 - today.getDay())); + const formattedCurrentWeekStart = currentWeekStart.toISOString().split('T')[0]; + const formattedCurrentWeekEnd = currentWeekEnd.toISOString().split('T')[0]; + const currentMonthStart = new Date(today.getFullYear(), today.getMonth(), 1); + const currentMonthEnd = new Date(today.getFullYear(), today.getMonth() + 1, 0); // Last day of current month + const formattedCurrentMonthStart = currentMonthStart.toISOString().split('T')[0]; + const formattedCurrentMonthEnd = currentMonthEnd.toISOString().split('T')[0]; + const currentYearStart = new Date(today.getFullYear(), 0, 1); + const currentYearEnd = new Date(today.getFullYear(), 11, 31); + const formattedCurrentYearStart = currentYearStart.toISOString().split('T')[0]; + const formattedCurrentYearEnd = currentYearEnd.toISOString().split('T')[0]; + if(reward.redemption_frequency_unit === 'day'){ + for (let i = 0; i < result[1].length; i++) { + if (result[1][i] === formattedDate) { + count ++; + } + } + } + else if(reward.redemption_frequency_unit === 'week'){ + for (let i = 0; i < result[1].length; i++) { + const date =(result[1][i]); + if (date >= formattedCurrentWeekStart && date <= formattedCurrentWeekEnd) { + count++; + } + } + } + else if(reward.redemption_frequency_unit === 'month'){ + for (let i = 0; i < result[1].length; i++) { + const date =(result[1][i]); + if (date >= formattedCurrentMonthStart && date <= formattedCurrentMonthEnd) { + count++; + } + } + } + else if(reward.redemption_frequency_unit === 'year'){ + for (let i = 0; i < result[1].length; i++) { + const date =(result[1][i]); + if (date >= formattedCurrentYearStart && date <= formattedCurrentYearEnd) { + count ++ + + } + } + } + return count + }) + this.state.frequency = checkRedemption + }, + async onClick() { + const order = this.env.pos.get_order(); + const rewards = order.get_available_rewards(); + const client = order.get_client(); + + if (rewards.length === 0) { + await this.showPopup('ErrorPopup', { + title: this.env._t('No rewards available.'), + body: this.env._t('There are no rewards claimable for this customer.') + }); + return false; + } + + let rewardPoints = 0; + if (client) { + rewardPoints = client.loyalty_points || 0; + } + + const filteredRewards = rewards.filter(reward => { + if (reward.reward_type === 'redemption') { + return rewardPoints > 0; + } + return true; + }); + + if (filteredRewards.length === 0) { + await this.showPopup('ErrorPopup', { + title: this.env._t('No claimable rewards.'), + body: this.env._t('There are no rewards claimable for this customer.') + }); + return false; + } + + const rewardsList = filteredRewards.map((reward) => ({ + id: reward.id, + label: reward.name, + item: reward, + })); + + const { confirmed, payload: selectedReward } = await this.showPopup('SelectionPopup', { + title: this.env._t('Please select a reward'), + list: rewardsList, + }); + + if (confirmed) { + if (selectedReward.reward_type == "redemption") { + var points = []; + if (selectedReward.max_redemption_type == 'points') { + points.push(selectedReward.max_redemption_amount / selectedReward.redemption_amount); + } else if (selectedReward.max_redemption_type == 'amount') { + points.push(selectedReward.max_redemption_amount / selectedReward.redemption_amount); + } else if (selectedReward.max_redemption_type == 'percent') { + var totalAmount = order.get_total_with_tax(); + var maxRedemption = totalAmount * selectedReward.max_redemption_amount / 100; + points.push(maxRedemption / selectedReward.redemption_amount); + } + Gui.showPopup('RewardPopup', { + title: this.env._t('Reward'), + cancelText: this.env._t("Cancel"), + confirmText: this.env._t("Confirm"), + rewards: rewards, + selected_reward: selectedReward, + order: order, + max_redemption_points: points[0], + property: this + }); + } else { + return this.apply_reward(selectedReward); + } + } + return false; + } + }) +}) diff --git a/advanced_loyalty_management/static/src/xml/pos_change_popup.xml b/advanced_loyalty_management/static/src/xml/pos_change_popup.xml new file mode 100644 index 000000000..2f33d4c49 --- /dev/null +++ b/advanced_loyalty_management/static/src/xml/pos_change_popup.xml @@ -0,0 +1,31 @@ + + + + + + + diff --git a/advanced_loyalty_management/static/src/xml/pos_loyalty_change.xml b/advanced_loyalty_management/static/src/xml/pos_loyalty_change.xml new file mode 100644 index 000000000..d97e0a296 --- /dev/null +++ b/advanced_loyalty_management/static/src/xml/pos_loyalty_change.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + diff --git a/advanced_loyalty_management/static/src/xml/reward_popup.xml b/advanced_loyalty_management/static/src/xml/reward_popup.xml new file mode 100644 index 000000000..010195994 --- /dev/null +++ b/advanced_loyalty_management/static/src/xml/reward_popup.xml @@ -0,0 +1,43 @@ + + + + + + + \ No newline at end of file diff --git a/advanced_loyalty_management/views/loyalty_program_views.xml b/advanced_loyalty_management/views/loyalty_program_views.xml new file mode 100644 index 000000000..b7a05da8d --- /dev/null +++ b/advanced_loyalty_management/views/loyalty_program_views.xml @@ -0,0 +1,24 @@ + + + + + loyalty.program.view.form.inherit.advanced.loyalty.management + loyalty.program + + + +
+
+
+
+
+
+
+
diff --git a/advanced_loyalty_management/views/loyalty_rewards_views.xml b/advanced_loyalty_management/views/loyalty_rewards_views.xml new file mode 100644 index 000000000..b1cd2036a --- /dev/null +++ b/advanced_loyalty_management/views/loyalty_rewards_views.xml @@ -0,0 +1,56 @@ + + + + + + loyalty.reward.view.form.inherit.advanced.loyalty.management + + loyalty.reward + + + + + + + + + + + + + + + + + + + if 0, no limit + + + + diff --git a/advanced_loyalty_management/views/res_partner_views.xml b/advanced_loyalty_management/views/res_partner_views.xml new file mode 100644 index 000000000..fd0addf72 --- /dev/null +++ b/advanced_loyalty_management/views/res_partner_views.xml @@ -0,0 +1,20 @@ + + + + + res.partner.view.form.inherit.advanced.loyalty.management + res.partner + + + + + + + +