fix: add loyaltypoint in salesinvoice

This commit is contained in:
Gadha2311
2026-01-12 11:47:40 +05:30
parent 1bb09890e3
commit 2a449725b6
5 changed files with 30 additions and 4 deletions
+17
View File
@@ -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,
+2 -1
View File
@@ -49,7 +49,8 @@
"label": "Sync Data From Server",
"fieldname": "syncDataFromServer",
"fieldtype": "Button",
"section": "Default"
"section": "Default",
"bold": true
},
{
"label": "Register Instance",
+7
View File
@@ -85,6 +85,13 @@
"section": "References",
"readOnly": true
},
{
"fieldname": "availableLoyaltyPoints",
"fieldtype": "Int",
"label": "Available Loyalty Points",
"readOnly": true,
"section": "References"
},
{
"fieldname": "redeemLoyaltyPoints",
"fieldtype": "Check",
+3 -2
View File
@@ -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<string, string>;
getOptions?: () => Promise<{ label: string; value: string }[]>;
getOptions?: () => Promise<{ label: string; value: string }[]>;
}
export type SelectOption = { value: string; label: string };
+1 -1
View File
@@ -13,7 +13,7 @@
>
<label class="flex items-center justify-between w-full">
<div v-if="showLabel && !labelRight" :class="labelClasses">
{{ df.label }}
<span :class="{ 'font-bold': df.bold }">{{ df.label }}</span>
</div>
<button
:class="['flex items-center justify-center']"