From 31f97d0f39518c36e661954681f9c74c6f501abf Mon Sep 17 00:00:00 2001 From: AbleKSaju <126228406+AbleKSaju@users.noreply.github.com> Date: Thu, 22 Aug 2024 16:06:19 +0530 Subject: [PATCH] feat: hide loyaltyProgram and loyaltyPoints in party when not enabled --- models/index.ts | 6 ++++++ models/regionalModels/in/Party.ts | 12 ++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/models/index.ts b/models/index.ts index dd940dc9..ace9901e 100644 --- a/models/index.ts +++ b/models/index.ts @@ -9,6 +9,9 @@ import { JournalEntry } from './baseModels/JournalEntry/JournalEntry'; import { JournalEntryAccount } from './baseModels/JournalEntryAccount/JournalEntryAccount'; import { Misc } from './baseModels/Misc'; import { Party } from './baseModels/Party/Party'; +import { LoyaltyProgram } from './baseModels/LoyaltyProgram/LoyaltyProgram'; +import { LoyaltyPointEntry } from './baseModels/LoyaltyPointEntry/LoyaltyPointEntry'; +import { CollectionRulesItems } from './baseModels/CollectionRulesItems/CollectionRulesItems'; import { Lead } from './baseModels/Lead/Lead'; import { Payment } from './baseModels/Payment/Payment'; import { PaymentFor } from './baseModels/PaymentFor/PaymentFor'; @@ -58,6 +61,9 @@ export const models = { Misc, Lead, Party, + LoyaltyProgram, + LoyaltyPointEntry, + CollectionRulesItems, Payment, PaymentFor, PrintSettings, diff --git a/models/regionalModels/in/Party.ts b/models/regionalModels/in/Party.ts index cd560cd5..0d64a9d0 100644 --- a/models/regionalModels/in/Party.ts +++ b/models/regionalModels/in/Party.ts @@ -1,11 +1,13 @@ import { HiddenMap } from 'fyo/model/types'; import { Party as BaseParty } from 'models/baseModels/Party/Party'; import { GSTType } from './types'; +import { PartyRole } from 'models/baseModels/Party/types'; export class Party extends BaseParty { gstin?: string; - fromLead?: string; + role?: PartyRole; gstType?: GSTType; + loyaltyProgram?: string; // eslint-disable-next-line @typescript-eslint/require-await async beforeSync() { @@ -19,6 +21,12 @@ export class Party extends BaseParty { hidden: HiddenMap = { gstin: () => (this.gstType as GSTType) !== 'Registered Regular', - fromLead: () => !this.fromLead, + loyaltyProgram: () => { + if (!this.fyo.singles.AccountingSettings?.enableLoyaltyProgram) { + return true; + } + return this.role === 'Supplier'; + }, + loyaltyPoints: () => !this.loyaltyProgram || this.role === 'Supplier', }; }