2
0
mirror of https://github.com/frappe/books.git synced 2024-12-22 10:58:59 +00:00

feat: hide loyaltyProgram and loyaltyPoints in party when not enabled

This commit is contained in:
AbleKSaju 2024-08-22 16:06:19 +05:30
parent f2c10a0724
commit 31f97d0f39
2 changed files with 16 additions and 2 deletions

View File

@ -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,

View File

@ -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',
};
}