mirror of
https://github.com/frappe/books.git
synced 2026-08-24 02:24:17 -05:00
Merge pull request #1422 from Gadha2311/loyaltypoint-salesinvoice
fix:add loyaltypoint in salesinvoice
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -51,6 +51,12 @@
|
||||
"fieldtype": "Button",
|
||||
"section": "Default"
|
||||
},
|
||||
{
|
||||
"label": "Sync Data To Server",
|
||||
"fieldname": "syncDataToServer",
|
||||
"fieldtype": "Button",
|
||||
"section": "Default"
|
||||
},
|
||||
{
|
||||
"label": "Register Instance",
|
||||
"fieldname": "registerInstance",
|
||||
|
||||
@@ -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
@@ -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 };
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user