diff --git a/src/components/POS/types.ts b/src/components/POS/types.ts
index bc96bebed..a88c0ae51 100644
--- a/src/components/POS/types.ts
+++ b/src/components/POS/types.ts
@@ -8,7 +8,7 @@ export type ItemSerialNumbers = { [item: string]: string };
export type DiscountType = "percent" | "amount";
-export type ModalName = 'ShiftOpen' | 'ShiftClose' | 'Payment'
+export type ModalName = 'ShiftOpen' | 'ShiftClose' | 'Payment' | 'LoyaltyProgram'
export interface POSItem {
image?:string,
diff --git a/src/pages/POS/LoyaltyprogramModal.vue b/src/pages/POS/LoyaltyprogramModal.vue
new file mode 100644
index 000000000..c4fd5a5f4
--- /dev/null
+++ b/src/pages/POS/LoyaltyprogramModal.vue
@@ -0,0 +1,166 @@
+
+
+ Redeem Loyalty Points
+
+
+
+
+
+
+
{{ loyaltyPoints }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/pages/POS/POS.vue b/src/pages/POS/POS.vue
index df899668f..5f0e31fed 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 +211,7 @@
:border="true"
:value="sinvDoc.party"
:df="sinvDoc.fieldMap.party"
- @change="(value:string) => (sinvDoc.party = value)"
+ @change="(value:string) => setCustomer(value)"
/>
@@ -270,7 +356,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 +372,7 @@ export default defineComponent({
OpenPOSShiftModal,
PageHeader,
PaymentModal,
+ LoyaltyProgramModal,
SelectedItemTable,
Barcode,
},
@@ -311,6 +399,7 @@ export default defineComponent({
isItemsSeeded: false,
openPaymentModal: false,
+ openLoyaltyProgramModal: false,
openShiftCloseModal: false,
openShiftOpenModal: false,
@@ -322,6 +411,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 +478,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 },
+ });
+
+ 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: [],
@@ -447,6 +556,23 @@ export default defineComponent({
setTotalTaxedAmount() {
this.totalTaxedAmount = getTotalTaxedAmount(this.sinvDoc as SalesInvoice);
},
+ async setLoyaltyPoints(value: number) {
+ this.appliedLoyaltyPoints = value;
+
+ this.sinvDoc.redeemLoyaltyPoints = true;
+
+ const totalLotaltyAmount = await getAddedLPWithGrandTotal(
+ this.fyo,
+ this.loyaltyProgram,
+ value
+ );
+
+ const total = totalLotaltyAmount
+ .sub(this.sinvDoc.baseGrandTotal as Money)
+ .abs();
+
+ this.sinvDoc.grandTotal = total;
+ },
setTransferAmount(amount: Money = fyo.pesa(0)) {
this.transferAmount = amount;
},