mirror of
https://github.com/frappe/books.git
synced 2025-01-03 07:12:21 +00:00
feat: Coupon Codes
This commit is contained in:
parent
f717533730
commit
1e30784324
@ -16,6 +16,7 @@ export class AccountingSettings extends Doc {
|
|||||||
enableInventory?: boolean;
|
enableInventory?: boolean;
|
||||||
enablePriceList?: boolean;
|
enablePriceList?: boolean;
|
||||||
enableLead?: boolean;
|
enableLead?: boolean;
|
||||||
|
enableCouponCode?: boolean;
|
||||||
enableFormCustomization?: boolean;
|
enableFormCustomization?: boolean;
|
||||||
enableInvoiceReturns?: boolean;
|
enableInvoiceReturns?: boolean;
|
||||||
enableLoyaltyProgram?: boolean;
|
enableLoyaltyProgram?: boolean;
|
||||||
@ -67,6 +68,8 @@ export class AccountingSettings extends Doc {
|
|||||||
gstin: () => this.fyo.singles.SystemSettings?.countryCode !== 'in',
|
gstin: () => this.fyo.singles.SystemSettings?.countryCode !== 'in',
|
||||||
enablePricingRule: () =>
|
enablePricingRule: () =>
|
||||||
!this.fyo.singles.AccountingSettings?.enableDiscounting,
|
!this.fyo.singles.AccountingSettings?.enableDiscounting,
|
||||||
|
enableCouponCode: () =>
|
||||||
|
!this.fyo.singles.AccountingSettings?.enablePricingRule,
|
||||||
};
|
};
|
||||||
|
|
||||||
async change(ch: ChangeArg) {
|
async change(ch: ChangeArg) {
|
||||||
|
32
models/baseModels/CouponCode/CouponCode.ts
Normal file
32
models/baseModels/CouponCode/CouponCode.ts
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
import { Doc } from 'fyo/model/doc';
|
||||||
|
import { FormulaMap, ListViewSettings, ValidationMap } from 'fyo/model/types';
|
||||||
|
import { Money } from 'pesa';
|
||||||
|
|
||||||
|
export class CouponCode extends Doc {
|
||||||
|
name?: string;
|
||||||
|
couponName?: string;
|
||||||
|
pricingRule?: string;
|
||||||
|
|
||||||
|
validFrom?: Date;
|
||||||
|
validTo?: Date;
|
||||||
|
|
||||||
|
minAmount?: Money;
|
||||||
|
maxAmount?: Money;
|
||||||
|
|
||||||
|
formulas: FormulaMap = {
|
||||||
|
name: {
|
||||||
|
formula: () => {
|
||||||
|
return this.couponName?.replace(/\s+/g, '').toUpperCase().slice(0, 8);
|
||||||
|
},
|
||||||
|
dependsOn: ['couponName'],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
validations: ValidationMap = {};
|
||||||
|
|
||||||
|
static getListViewSettings(): ListViewSettings {
|
||||||
|
return {
|
||||||
|
columns: ['name', 'couponName', 'pricingRule', 'maximumUse', 'used'],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
@ -13,6 +13,7 @@ import { LoyaltyProgram } from './baseModels/LoyaltyProgram/LoyaltyProgram';
|
|||||||
import { LoyaltyPointEntry } from './baseModels/LoyaltyPointEntry/LoyaltyPointEntry';
|
import { LoyaltyPointEntry } from './baseModels/LoyaltyPointEntry/LoyaltyPointEntry';
|
||||||
import { CollectionRulesItems } from './baseModels/CollectionRulesItems/CollectionRulesItems';
|
import { CollectionRulesItems } from './baseModels/CollectionRulesItems/CollectionRulesItems';
|
||||||
import { Lead } from './baseModels/Lead/Lead';
|
import { Lead } from './baseModels/Lead/Lead';
|
||||||
|
import { CouponCode } from './baseModels/CouponCode/CouponCode';
|
||||||
import { Payment } from './baseModels/Payment/Payment';
|
import { Payment } from './baseModels/Payment/Payment';
|
||||||
import { PaymentFor } from './baseModels/PaymentFor/PaymentFor';
|
import { PaymentFor } from './baseModels/PaymentFor/PaymentFor';
|
||||||
import { PriceList } from './baseModels/PriceList/PriceList';
|
import { PriceList } from './baseModels/PriceList/PriceList';
|
||||||
@ -64,6 +65,7 @@ export const models = {
|
|||||||
LoyaltyProgram,
|
LoyaltyProgram,
|
||||||
LoyaltyPointEntry,
|
LoyaltyPointEntry,
|
||||||
CollectionRulesItems,
|
CollectionRulesItems,
|
||||||
|
CouponCode,
|
||||||
Payment,
|
Payment,
|
||||||
PaymentFor,
|
PaymentFor,
|
||||||
PrintSettings,
|
PrintSettings,
|
||||||
|
@ -22,6 +22,7 @@ export enum ModelNameEnum {
|
|||||||
LoyaltyProgram = 'LoyaltyProgram',
|
LoyaltyProgram = 'LoyaltyProgram',
|
||||||
LoyaltyPointEntry = 'LoyaltyPointEntry',
|
LoyaltyPointEntry = 'LoyaltyPointEntry',
|
||||||
CollectionRulesItems = 'CollectionRulesItems',
|
CollectionRulesItems = 'CollectionRulesItems',
|
||||||
|
CouponCode = 'CouponCode',
|
||||||
Payment = 'Payment',
|
Payment = 'Payment',
|
||||||
PaymentFor = 'PaymentFor',
|
PaymentFor = 'PaymentFor',
|
||||||
PriceList = 'PriceList',
|
PriceList = 'PriceList',
|
||||||
|
@ -6,18 +6,18 @@
|
|||||||
"fields": [
|
"fields": [
|
||||||
{
|
{
|
||||||
"fieldname": "name",
|
"fieldname": "name",
|
||||||
|
"label": "Coupon Code",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "couponName",
|
||||||
"label": "Name",
|
"label": "Name",
|
||||||
"fieldtype": "Data",
|
"fieldtype": "Data",
|
||||||
"required": true,
|
"required": true,
|
||||||
"placeholder": "Coupon Name",
|
"placeholder": "Coupon Name",
|
||||||
"section": "Default"
|
"section": "Default"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"fieldname": "couponCode",
|
|
||||||
"label": "Coupon Code",
|
|
||||||
"fieldtype": "Data",
|
|
||||||
"required": true
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"fieldname": "pricingRule",
|
"fieldname": "pricingRule",
|
||||||
"label": "Pricing Rule",
|
"label": "Pricing Rule",
|
||||||
|
Loading…
Reference in New Issue
Block a user