@lyxa.ai/core 1.0.311 → 1.0.313
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/libraries/mongo/models/embedded/customer-support-batches.model.d.ts +2 -2
- package/dist/libraries/mongo/models/embedded/customer-support-batches.model.js +8 -8
- package/dist/libraries/mongo/models/embedded/customer-support-batches.model.js.map +1 -1
- package/dist/libraries/mongo/models/service-promotion.model.js.map +1 -1
- package/dist/types/README.md +1 -1
- package/dist/types/package.json +1 -1
- package/dist/utilities/currency.d.ts +1 -1
- package/dist/utilities/currency.js +1 -1
- package/dist/utilities/currency.js.map +1 -1
- package/package.json +1 -1
|
@@ -12,16 +12,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.CustomerSupportBatchesSettings = void 0;
|
|
13
13
|
const typegoose_1 = require("@typegoose/typegoose");
|
|
14
14
|
class CustomerSupportBatchesSettings {
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
customerBatch;
|
|
16
|
+
delayTime;
|
|
17
17
|
}
|
|
18
18
|
exports.CustomerSupportBatchesSettings = CustomerSupportBatchesSettings;
|
|
19
19
|
__decorate([
|
|
20
|
-
(0, typegoose_1.prop)({ type:
|
|
21
|
-
__metadata("design:type",
|
|
22
|
-
], CustomerSupportBatchesSettings.prototype, "
|
|
20
|
+
(0, typegoose_1.prop)({ type: Number, default: 0, min: 0 }),
|
|
21
|
+
__metadata("design:type", Number)
|
|
22
|
+
], CustomerSupportBatchesSettings.prototype, "customerBatch", void 0);
|
|
23
23
|
__decorate([
|
|
24
|
-
(0, typegoose_1.prop)({ type:
|
|
25
|
-
__metadata("design:type",
|
|
26
|
-
], CustomerSupportBatchesSettings.prototype, "
|
|
24
|
+
(0, typegoose_1.prop)({ type: Number, default: 0, min: 0 }),
|
|
25
|
+
__metadata("design:type", Number)
|
|
26
|
+
], CustomerSupportBatchesSettings.prototype, "delayTime", void 0);
|
|
27
27
|
//# sourceMappingURL=customer-support-batches.model.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"customer-support-batches.model.js","sourceRoot":"/","sources":["libraries/mongo/models/embedded/customer-support-batches.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA4C;AAE5C,MAAa,8BAA8B;
|
|
1
|
+
{"version":3,"file":"customer-support-batches.model.js","sourceRoot":"/","sources":["libraries/mongo/models/embedded/customer-support-batches.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA4C;AAE5C,MAAa,8BAA8B;IAE1C,aAAa,CAAU;IAGvB,SAAS,CAAU;CACnB;AAND,wEAMC;AAJA;IADC,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC;;qEACpB;AAGvB;IADC,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC;;iEACxB","sourcesContent":["import { prop } from '@typegoose/typegoose';\n\nexport class CustomerSupportBatchesSettings {\n\t@prop({ type: Number, default: 0, min: 0 })\n\tcustomerBatch?: number;\n\n\t@prop({ type: Number, default: 0, min: 0 })\n\tdelayTime?: number; // in mins\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service-promotion.model.js","sourceRoot":"/","sources":["libraries/mongo/models/service-promotion.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA+D;AAC/D,iDAAwC;AACxC,kDAAoF;AACpF,gFAAsE;AACtE,mEAAyD;AACzD,8DAAwD;AAGjD,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IAElB,MAAM,CAAe;IAGrB,aAAa,CAAiB;IAO9B,MAAM,CAAmB;IAGzB,QAAQ,CAAoB;IAG5B,eAAe,CAAwB;IAGvC,UAAU,CAAkB;IAG5B,UAAU,CAAU;IAGpB,WAAW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AAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;4DACY;AAG5B;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,EAAE,CAAC;;qDACvB;2BAvCnB,gBAAgB;IAD5B,IAAA,wBAAY,EAAC,EAAE,aAAa,EAAE,EAAE,UAAU,EAAE,mBAAmB,EAAE,EAAE,CAAC;GACxD,gBAAgB,CAwC5B","sourcesContent":["import { modelOptions, prop, Ref } from '@typegoose/typegoose';\nimport { Vendor } from './vendor.model';\nimport { MarketingStatus, PromotionType, ValueType } from '../../../utilities/enum';\nimport { PromotionDuration } from './shared/promotion-duration.model';\nimport { ServicePackage } from './service-package.model';\nimport { StartEndTime } from './shared/work-hour.model';\n\n@modelOptions({ schemaOptions: { collection: 'servicePromotions' } })\nexport class ServicePromotion {\n @prop({ ref: () => Vendor, required: true })\n public vendor!: Ref<Vendor>;\n\n @prop({ enum: PromotionType, required: true })\n public promotionType!: PromotionType;\n\n @prop({\n type: String,\n enum: MarketingStatus,\n default: MarketingStatus.ACTIVE,\n })\n public status?: MarketingStatus
|
|
1
|
+
{"version":3,"file":"service-promotion.model.js","sourceRoot":"/","sources":["libraries/mongo/models/service-promotion.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA+D;AAC/D,iDAAwC;AACxC,kDAAoF;AACpF,gFAAsE;AACtE,mEAAyD;AACzD,8DAAwD;AAGjD,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IAElB,MAAM,CAAe;IAGrB,aAAa,CAAiB;IAO9B,MAAM,CAAmB;IAGzB,QAAQ,CAAoB;IAG5B,eAAe,CAAwB;IAGvC,UAAU,CAAkB;IAG5B,UAAU,CAAU;IAGpB,WAAW,CAAU;IAGrB,SAAS,CAAa;IAGtB,KAAK,CAAU;IAGf,kBAAkB,CAAU;IAG5B,WAAW,CAAU;CAC/B,CAAA;AAxCY,4CAAgB;AA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AAI,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,EAAE,CAAC;;qDACvB;2BAvCnB,gBAAgB;IAD5B,IAAA,wBAAY,EAAC,EAAE,aAAa,EAAE,EAAE,UAAU,EAAE,mBAAmB,EAAE,EAAE,CAAC;GACxD,gBAAgB,CAwC5B","sourcesContent":["import { modelOptions, prop, Ref } from '@typegoose/typegoose';\nimport { Vendor } from './vendor.model';\nimport { MarketingStatus, PromotionType, ValueType } from '../../../utilities/enum';\nimport { PromotionDuration } from './shared/promotion-duration.model';\nimport { ServicePackage } from './service-package.model';\nimport { StartEndTime } from './shared/work-hour.model';\n\n@modelOptions({ schemaOptions: { collection: 'servicePromotions' } })\nexport class ServicePromotion {\n @prop({ ref: () => Vendor, required: true })\n public vendor!: Ref<Vendor>;\n\n @prop({ enum: PromotionType, required: true })\n public promotionType!: PromotionType;\n\n @prop({\n type: String,\n enum: MarketingStatus,\n default: MarketingStatus.ACTIVE,\n })\n public status?: MarketingStatus; \n\n @prop({ required: true, type: PromotionDuration })\n public duration!: PromotionDuration\n\n @prop({ ref: () => ServicePackage, required: true })\n public servicePackages?: Ref<ServicePackage>[]\n\n @prop({ type: () => [StartEndTime] })\n public slotRanges?: StartEndTime[];\n\n @prop({ type: Number, min: 0 })\n public spendLimit?: number;\n\n @prop({ type: Number, default: 0, min: 0 })\n public spendAmount?: number;\n\n @prop({ type: String, enum: ValueType })\n public valueType?: ValueType;\n\n @prop({ type: Number })\n public value?: number;\n\n @prop({ type: String })\n public deactivationReason?: string;\n\n @prop({ type: String, trim: true, maxlength: 500 })\n public description?: string;\n}\n"]}
|
package/dist/types/README.md
CHANGED
package/dist/types/package.json
CHANGED
|
@@ -4,4 +4,4 @@ export declare const getExchangeRate: () => Promise<number>;
|
|
|
4
4
|
export declare const roundCurrency: (amount: number, currency: PaidCurrency, roundingFactor?: number) => Promise<number>;
|
|
5
5
|
export declare const roundCurrencySync: (amount: number, roundingFactor: number) => number;
|
|
6
6
|
export declare const convertToSecondary: (amount: number, exchangeRate?: number, roundTo?: number) => Promise<number>;
|
|
7
|
-
export declare const convertToSecondarySync: (price: number, exchangeRate: number, roundTo: number) => number |
|
|
7
|
+
export declare const convertToSecondarySync: (price: number, exchangeRate: number, roundTo: number) => number | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"currency.js","sourceRoot":"/","sources":["utilities/currency.ts"],"names":[],"mappings":";;;AAEA,0BAAkC;AAGlC,iCAAsC;AAEtC,MAAM,uBAAuB,GAAG,GAAG,CAAC;AACpC,MAAM,qBAAqB,GAAG,CAAC,CAAC;AAEzB,MAAM,iBAAiB,GAAG,KAAK,EAAE,QAAsB,EAAmB,EAAE;IAClF,MAAM,OAAO,GAAG,CAAC,MAAM,IAAA,gBAAY,GAAE,CAAC,wBAAwB,EAAE,CAAC,WAAW,EAAE,CAAY,CAAC;IAC3F,MAAM,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC;IAChD,IAAI,cAAkC,CAAC;IACvC,IAAI,eAAe,EAAE,CAAC;QACrB,QAAQ,QAAQ,EAAE,CAAC;YAClB,KAAK,mBAAY,CAAC,IAAI;gBACrB,cAAc,GAAG,eAAe,CAAC,YAAY,EAAE,OAAO,CAAC;gBACvD,MAAM;YACP,KAAK,mBAAY,CAAC,SAAS;gBAC1B,cAAc,GAAG,eAAe,CAAC,iBAAiB,EAAE,OAAO,CAAC;gBAC5D,MAAM;YACP;gBACC,cAAc,GAAG,uBAAuB,CAAC;gBACzC,MAAM;QACR,CAAC;IACF,CAAC;IACD,OAAO,cAAc,IAAI,uBAAuB,CAAC;AAClD,CAAC,CAAC;AAlBW,QAAA,iBAAiB,qBAkB5B;AAEK,MAAM,eAAe,GAAG,KAAK,IAAqB,EAAE;IAC1D,MAAM,QAAQ,GAAG,CAAC,MAAM,IAAA,gBAAY,GAAE,CAAC,wBAAwB,EAAE,CAAC,WAAW,EAAE,CAAY,CAAC;IAC5F,MAAM,eAAe,GAAG,QAAQ,CAAC,eAAe,C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CAAC;AARW,QAAA,kBAAkB,sBAQ7B;AAEK,MAAM,sBAAsB,GAAG,CAAC,KAAa,EAAE,YAAoB,EAAE,OAAe,EAAE,EAAE;IAC9F,IAAI,KAAK,IAAI,CAAC;QAAE,OAAO,CAAC,CAAC;IACzB,IAAI,KAAK,IAAI,IAAI;QAAE,OAAO,SAAS,CAAA;IACnC,MAAM,MAAM,GAAG,KAAK,GAAG,YAAY,CAAC;IACpC,IAAI,CAAC,OAAO;QAAE,OAAO,MAAM,CAAC;IAC5B,OAAO,IAAA,yBAAiB,EAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAC3C,CAAC,CAAC;AANW,QAAA,sBAAsB,0BAMjC","sourcesContent":["// In the future, we need to move this in the currency folder and there we need to make a seperation between sync and async functions\n\nimport { getLibraries } from '..';\n\nimport { Setting } from '../libraries/mongo/models';\nimport { PaidCurrency } from './enum';\n\nconst DEFAULT_ROUNDING_FACTOR = 0.1;\nconst DEFAULT_EXCHANGE_RATE = 1;\n\nexport const getRoundingFactor = async (currency: PaidCurrency): Promise<number> => {\n\tconst setting = (await getLibraries().getCachedSettingsService().getSettings()) as Setting;\n\tconst currencySetting = setting.currencySetting;\n\tlet roundingFactor: number | undefined;\n\tif (currencySetting) {\n\t\tswitch (currency) {\n\t\t\tcase PaidCurrency.BASE:\n\t\t\t\troundingFactor = currencySetting.baseCurrency?.roundTo;\n\t\t\t\tbreak;\n\t\t\tcase PaidCurrency.SECONDARY:\n\t\t\t\troundingFactor = currencySetting.secondaryCurrency?.roundTo;\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\troundingFactor = DEFAULT_ROUNDING_FACTOR;\n\t\t\t\tbreak;\n\t\t}\n\t}\n\treturn roundingFactor || DEFAULT_ROUNDING_FACTOR;\n};\n\nexport const getExchangeRate = async (): Promise<number> => {\n\tconst settings = (await getLibraries().getCachedSettingsService().getSettings()) as Setting;\n\tconst currencySetting = settings.currencySetting;\n\treturn currencySetting?.exchangeRate || DEFAULT_EXCHANGE_RATE;\n};\n\nexport const roundCurrency = async (\n\tamount: number,\n\tcurrency: PaidCurrency,\n\troundingFactor?: number\n): Promise<number> => {\n\tif (amount == 0) return 0;\n\troundingFactor = roundingFactor ?? (await getRoundingFactor(currency));\n\treturn roundCurrencySync(amount, roundingFactor);\n};\n\nexport const roundCurrencySync = (amount: number, roundingFactor: number): number => {\n\tif (amount == 0) return 0;\n\tconst rounded = Math.ceil(amount / roundingFactor) * roundingFactor;\n\tconst decimals = (roundingFactor.toString().split('.')[1] || '').length;\n\treturn Number(rounded.toFixed(decimals));\n};\n\nexport const convertToSecondary = async (\n\tamount: number,\n\texchangeRate?: number,\n\troundTo?: number\n): Promise<number> => {\n\tif (amount == 0) return 0;\n\texchangeRate = exchangeRate ?? (await getExchangeRate());\n\treturn roundCurrency(amount * exchangeRate, PaidCurrency.SECONDARY, roundTo);\n};\n\nexport const convertToSecondarySync = (price: number, exchangeRate: number, roundTo: number) => {\n\tif (price == 0) return 0;\n\tif (price == null) return undefined\n\tconst amount = price * exchangeRate;\n\tif (!roundTo) return amount;\n\treturn roundCurrencySync(amount, roundTo);\n};\n"]}
|