From 2a449725b614c5ac5b95c38d309c7e5015997ef0 Mon Sep 17 00:00:00 2001 From: Gadha2311 Date: Mon, 12 Jan 2026 11:47:40 +0530 Subject: [PATCH 1/3] fix: add loyaltypoint in salesinvoice --- models/baseModels/Invoice/Invoice.ts | 17 +++++++++++++++++ schemas/app/ERPNextSyncSettings.json | 3 ++- schemas/app/SalesInvoice.json | 7 +++++++ schemas/types.ts | 5 +++-- src/components/Controls/Button.vue | 2 +- 5 files changed, 30 insertions(+), 4 deletions(-) diff --git a/models/baseModels/Invoice/Invoice.ts b/models/baseModels/Invoice/Invoice.ts index cacb4e0b..f8ae5765 100644 --- a/models/baseModels/Invoice/Invoice.ts +++ b/models/baseModels/Invoice/Invoice.ts @@ -94,6 +94,7 @@ export abstract class Invoice extends Transactional { discountAmount?: Money; discountPercent?: number; loyaltyPoints?: number; + availableLoyaltyPoints?: number; discountAfterTax?: boolean; stockNotTransferred?: number; loyaltyProgram?: string; @@ -992,6 +993,21 @@ export abstract class Invoice extends Transactional { }, dependsOn: ['party', 'name'], }, + availableLoyaltyPoints: { + formula: async () => { + if (!this.party) { + return 0; + } + + const partyDoc = (await this.fyo.doc.getDoc( + ModelNameEnum.Party, + this.party + )) as Party; + + return partyDoc?.loyaltyPoints || 0; + }, + dependsOn: ['party'], + }, currency: { formula: async () => { const currency = (await this.fyo.getValue( @@ -1181,6 +1197,7 @@ export abstract class Invoice extends Transactional { backReference: () => !this.backReference, quote: () => !this.quote, loyaltyProgram: () => !this.loyaltyProgram, + availableLoyaltyPoints: () => !this.loyaltyProgram || this.isReturn, loyaltyPoints: () => !this.redeemLoyaltyPoints || this.isReturn, redeemLoyaltyPoints: () => !this.loyaltyProgram || this.isReturn, coupons: () => this.isSubmitted && !this.coupons?.length, diff --git a/schemas/app/ERPNextSyncSettings.json b/schemas/app/ERPNextSyncSettings.json index 2913dc7e..9e629071 100644 --- a/schemas/app/ERPNextSyncSettings.json +++ b/schemas/app/ERPNextSyncSettings.json @@ -49,7 +49,8 @@ "label": "Sync Data From Server", "fieldname": "syncDataFromServer", "fieldtype": "Button", - "section": "Default" + "section": "Default", + "bold": true }, { "label": "Register Instance", diff --git a/schemas/app/SalesInvoice.json b/schemas/app/SalesInvoice.json index 2086377f..f372a543 100644 --- a/schemas/app/SalesInvoice.json +++ b/schemas/app/SalesInvoice.json @@ -85,6 +85,13 @@ "section": "References", "readOnly": true }, + { + "fieldname": "availableLoyaltyPoints", + "fieldtype": "Int", + "label": "Available Loyalty Points", + "readOnly": true, + "section": "References" + }, { "fieldname": "redeemLoyaltyPoints", "fieldtype": "Check", diff --git a/schemas/types.ts b/schemas/types.ts index 4fbbb9b5..552f8c18 100644 --- a/schemas/types.ts +++ b/schemas/types.ts @@ -67,10 +67,11 @@ export interface BaseField { computed?: boolean; // Computed values are not stored in the database. section?: string; // UI Facing config, for grouping by sections tab?: string; // UI Facing config, for grouping by tabs - abstract?: string; // Used to mark the location of a field in an Abstract schema + abstract?: string; // Used to mark the location of a field in an Abstract schema isCustom?: boolean; // Whether the field is a custom field + bold?: boolean; // UI Facing config, whether to make the label bold filters?: Record; - getOptions?: () => Promise<{ label: string; value: string }[]>; + getOptions?: () => Promise<{ label: string; value: string }[]>; } export type SelectOption = { value: string; label: string }; diff --git a/src/components/Controls/Button.vue b/src/components/Controls/Button.vue index f95bef29..3aef30e6 100644 --- a/src/components/Controls/Button.vue +++ b/src/components/Controls/Button.vue @@ -13,7 +13,7 @@ > From 95c88f77a85b6f9de6c4d9d8c13d47a3fb0953e1 Mon Sep 17 00:00:00 2001 From: Gadha2311 Date: Wed, 14 Jan 2026 17:00:27 +0530 Subject: [PATCH 3/3] fix: added loyaltyprogram in POS redeem loyalty --- src/pages/POS/LoyaltyProgramModal.vue | 4 +++- src/pages/POS/POS.vue | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/pages/POS/LoyaltyProgramModal.vue b/src/pages/POS/LoyaltyProgramModal.vue index afcb3568..a4e921d9 100644 --- a/src/pages/POS/LoyaltyProgramModal.vue +++ b/src/pages/POS/LoyaltyProgramModal.vue @@ -17,7 +17,9 @@ /> -

{{ loyaltyPoints }}

+

+ {{ loyaltyPoints }} - ({{ loyaltyProgram }}) +