From f762f9b32ebaed20def97a6eb9c4b43568bfe792 Mon Sep 17 00:00:00 2001 From: AbleKSaju <126228406+AbleKSaju@users.noreply.github.com> Date: Fri, 27 Sep 2024 17:23:29 +0530 Subject: [PATCH] feat: toggle button for redeeming loyalty points --- src/pages/POS/POS.vue | 126 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 116 insertions(+), 10 deletions(-) diff --git a/src/pages/POS/POS.vue b/src/pages/POS/POS.vue index df899668..42bba95a 100644 --- a/src/pages/POS/POS.vue +++ b/src/pages/POS/POS.vue @@ -22,6 +22,14 @@ @toggle-modal="toggleModal" /> + + -
- + +
+
+
+ +
+ + {{ tableView ? 'Grid View' : 'List View' }} + +
+ +
+
+ + + +
+ + + Loyalty Program + +
@@ -125,7 +208,7 @@ :border="true" :value="sinvDoc.party" :df="sinvDoc.fieldMap.party" - @change="(value:string) => (sinvDoc.party = value)" + @change="(value:string) => setCustomer(value)" /> @@ -270,7 +353,8 @@ import { validateSinv, } from 'src/utils/pos'; import Barcode from 'src/components/Controls/Barcode.vue'; -import { getPricingRule } from 'models/helpers'; +import { getAddedLPWithGrandTotal, getPricingRule } from 'models/helpers'; +import LoyaltyProgramModal from './LoyaltyprogramModal.vue'; export default defineComponent({ name: 'POS', @@ -285,6 +369,7 @@ export default defineComponent({ OpenPOSShiftModal, PageHeader, PaymentModal, + LoyaltyProgramModal, SelectedItemTable, Barcode, }, @@ -311,6 +396,7 @@ export default defineComponent({ isItemsSeeded: false, openPaymentModal: false, + openLoyaltyProgramModal: false, openShiftCloseModal: false, openShiftOpenModal: false, @@ -322,6 +408,10 @@ export default defineComponent({ totalQuantity: 0, + loyaltyPoints: 0, + appliedLoyaltyPoints: 0, + loyaltyProgram: '' as string, + defaultCustomer: undefined as string | undefined, itemSearchTerm: '', transferRefNo: undefined as string | undefined, @@ -385,6 +475,22 @@ export default defineComponent({ toggleSidebar(true); }, methods: { + async setCustomer(value: string) { + if (!value) { + this.sinvDoc.party = ''; + return; + } + + this.sinvDoc.party = value; + + const party = await this.fyo.db.getAll(ModelNameEnum.Party, { + fields: ['loyaltyProgram', 'loyaltyPoints'], + filters: { name: value as string }, + }); + + this.loyaltyProgram = party[0]?.loyaltyProgram as string; + this.loyaltyPoints = party[0].loyaltyPoints as number; + }, async setItems() { const items = (await fyo.db.getAll(ModelNameEnum.Item, { fields: [],