Merge pull request #1422 from Gadha2311/loyaltypoint-salesinvoice

fix:add loyaltypoint in salesinvoice
This commit is contained in:
Able k Saju
2026-01-23 11:12:01 +05:30
committed by GitHub
8 changed files with 59 additions and 12 deletions
@@ -1,6 +1,6 @@
import { Doc } from 'fyo/model/doc';
import { ChangeArg, HiddenMap } from 'fyo/model/types';
import { initERPNSync } from 'src/utils/erpnextSync';
import { initERPNSync, syncDocumentsToERPNext } from 'src/utils/erpnextSync';
export class ERPNextSyncSettings extends Doc {
deviceID?: string;
@@ -12,6 +12,7 @@ export class ERPNextSyncSettings extends Doc {
dataSyncInterval?: string;
syncDataFromServer?: boolean;
syncDataToServer?: boolean;
registerInstance?: string;
syncSettings?: string;
@@ -44,6 +45,9 @@ export class ERPNextSyncSettings extends Doc {
if (ch.changed === 'syncDataFromServer') {
await initERPNSync(this.fyo);
ipc.reloadWindow();
} else if (ch.changed === 'syncDataToServer') {
await syncDocumentsToERPNext(this.fyo);
ipc.reloadWindow();
}
}
}
+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 loyaltyPoints = await this.fyo.getValue(
ModelNameEnum.Party,
this.party,
'loyaltyPoints'
);
return 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,
+6
View File
@@ -51,6 +51,12 @@
"fieldtype": "Button",
"section": "Default"
},
{
"label": "Sync Data To Server",
"fieldname": "syncDataToServer",
"fieldtype": "Button",
"section": "Default"
},
{
"label": "Register Instance",
"fieldname": "registerInstance",
+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,11 +67,12 @@ 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
sub_label?: string;
filters?: Record<string, string>;
getOptions?: () => Promise<{ label: string; value: string }[]>;
getOptions?: () => Promise<{ label: string; value: string }[]>;
}
export type SelectOption = { value: string; label: string };
+16 -8
View File
@@ -3,7 +3,6 @@
:class="[containerClasses]"
class="
mt-6
p-2
w-full
text-gray-900
dark:text-gray-100
@@ -11,16 +10,25 @@
focus:outline-none
"
>
<label class="flex items-center justify-between w-full">
<div v-if="showLabel && !labelRight" :class="labelClasses">
{{ df.label }}
</div>
<label class="flex w-full">
<button
:class="['flex items-center justify-center']"
type="button"
@click="onClick"
:disabled="isReadOnly"
type="button"
></button>
class="
w-full
flex
items-center
justify-center
p-2
rounded-md
bg-blue-300
hover:bg-blue-400 hover:shadow-md hover:-translate-y-[1px]
transition
"
>
{{ df.label }}
</button>
</label>
</div>
</template>
+3 -1
View File
@@ -17,7 +17,9 @@
/>
</svg>
<p class="dark:text-gray-100">{{ loyaltyPoints }}</p>
<p class="dark:text-gray-100 pr-6">
{{ loyaltyPoints }} - ({{ loyaltyProgram }})
</p>
</div>
<Int
+2
View File
@@ -20,6 +20,7 @@
:total-quantity="totalQuantity"
:item-quantity-qap="itemQtyMap"
:loyalty-points="loyaltyPoints"
:loyalty-program="loyaltyProgram"
:open-alert-modal="openAlertModal"
:default-customer="defaultCustomer"
:item-search-term="itemSearchTerm"
@@ -75,6 +76,7 @@
:total-quantity="totalQuantity"
:item-quantity-qap="itemQtyMap"
:loyalty-points="loyaltyPoints"
:loyalty-program="loyaltyProgram"
:open-alert-modal="openAlertModal"
:default-customer="defaultCustomer"
:item-search-term="itemSearchTerm"