@lyxa.ai/core 1.0.329 → 1.0.331
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/marketing-cut.model.d.ts +0 -5
- package/dist/libraries/mongo/models/embedded/marketing-cut.model.js +1 -19
- package/dist/libraries/mongo/models/embedded/marketing-cut.model.js.map +1 -1
- package/dist/libraries/mongo/models/embedded/order-pricing.model.d.ts +0 -2
- package/dist/libraries/mongo/models/embedded/order-pricing.model.js +0 -10
- package/dist/libraries/mongo/models/embedded/order-pricing.model.js.map +1 -1
- package/dist/libraries/mongo/models/embedded/regular-order-finance.model.d.ts +1 -2
- package/dist/libraries/mongo/models/embedded/regular-order-finance.model.js +0 -5
- package/dist/libraries/mongo/models/embedded/regular-order-finance.model.js.map +1 -1
- package/dist/libraries/mongo/models/index.d.ts +0 -9
- package/dist/libraries/mongo/models/index.js +2 -11
- package/dist/libraries/mongo/models/index.js.map +1 -1
- package/dist/libraries/mongo/models/product-marketing.model.d.ts +0 -2
- package/dist/libraries/mongo/models/product-marketing.model.js +0 -6
- package/dist/libraries/mongo/models/product-marketing.model.js.map +1 -1
- package/dist/libraries/mongo/models/providers/regular-order.model.d.ts +0 -1
- package/dist/libraries/mongo/models/providers/regular-order.model.js +0 -5
- package/dist/libraries/mongo/models/providers/regular-order.model.js.map +1 -1
- package/dist/libraries/mongo/models/providers/shop-payout.model.d.ts +0 -1
- package/dist/libraries/mongo/models/providers/shop-payout.model.js +0 -5
- package/dist/libraries/mongo/models/providers/shop-payout.model.js.map +1 -1
- package/dist/types/README.md +1 -1
- package/dist/types/package.json +1 -1
- package/dist/types/utilities/enum.d.ts +4 -2
- package/dist/types/utilities/enum.js +6 -3
- package/dist/types/utilities/enum.js.map +1 -1
- package/dist/utilities/enum.d.ts +4 -2
- package/dist/utilities/enum.js +6 -3
- package/dist/utilities/enum.js.map +1 -1
- package/dist/utilities/pipelines/product-pipeline-stages.js +0 -1
- package/dist/utilities/pipelines/product-pipeline-stages.js.map +1 -1
- package/package.json +1 -1
- package/dist/libraries/mongo/models/loyalty-point-category.model.d.ts +0 -7
- package/dist/libraries/mongo/models/loyalty-point-category.model.js +0 -62
- package/dist/libraries/mongo/models/loyalty-point-category.model.js.map +0 -1
- package/dist/libraries/mongo/models/loyalty-point-setting.model.d.ts +0 -7
- package/dist/libraries/mongo/models/loyalty-point-setting.model.js +0 -41
- package/dist/libraries/mongo/models/loyalty-point-setting.model.js.map +0 -1
- package/dist/libraries/mongo/models/loyalty-point.model.d.ts +0 -20
- package/dist/libraries/mongo/models/loyalty-point.model.js +0 -84
- package/dist/libraries/mongo/models/loyalty-point.model.js.map +0 -1
- package/dist/libraries/mongo/models/providers/loyalty-point-marketing.model.d.ts +0 -14
- package/dist/libraries/mongo/models/providers/loyalty-point-marketing.model.js +0 -56
- package/dist/libraries/mongo/models/providers/loyalty-point-marketing.model.js.map +0 -1
|
@@ -103,7 +103,6 @@ function addProductMarketingInfo(exchangeRate, secondaryCurrencyRoundTo, seconda
|
|
|
103
103
|
{
|
|
104
104
|
$project: {
|
|
105
105
|
marketing: '$marketing._id',
|
|
106
|
-
loyaltyPointCategory: '$loyaltyPointCategory',
|
|
107
106
|
isBuy1Get1: '$isBuy1Get1',
|
|
108
107
|
valueType: '$valueType',
|
|
109
108
|
value: '$value',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"product-pipeline-stages.js","sourceRoot":"/","sources":["utilities/pipelines/product-pipeline-stages.ts"],"names":[],"mappings":";;AAIA,0DAuHC;AAED,sFAgDC;AAED,kFAkEC;AAhPD,2EAAwE;AACxE,kCAAmD;AAEnD,SAAgB,uBAAuB,CACtC,YAAoB,EACpB,wBAAgC,EAChC,qBAA6B;IAE7B,OAAO;QACN;YACC,OAAO,EAAE;gBACR,IAAI,EAAE,mBAAmB;gBACzB,GAAG,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,IAAI,EA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D;iDACD;6CACD;yCACD;wCACD,UAAU;qCACV;iCACD;gCAED,eAAe,EAAE;oCAChB,KAAK,EAAE;wCACN,EAAE,GAAG,EAAE,CAAC,mBAAmB,EAAE,IAAI,CAAC,EAAE;wCACpC;4CACC,SAAS,EAAE;gDACV,mBAAmB;gDACnB;oDACC,KAAK,EAAE;wDACN,EAAE,GAAG,EAAE,CAAC,6BAA6B,EAAE,gBAAS,CAAC,KAAK,CAAC,EAAE;wDACzD,yBAAyB;wDACzB;4DACC,SAAS,EAAE;gEACV,yBAAyB;gEACzB;oEACC,OAAO,EAAE,CAAC,mBAAmB,EAAE,GAAG,CAAC;iEACnC;6DACD;yDACD;qDACD;iDACD;6CACD;yCACD;wCACD,UAAU;qCACV;iCACD;6BACD;yBACD;qBACD;iBACD;aACD;SACD;KACD,CAAC;AACH,CAAC","sourcesContent":["import { PipelineStage } from 'mongoose';\nimport { getSecondaryCurrencyStage } from './common-pipeline-functions';\nimport { MarketingType, ValueType } from '../enum';\n\nexport function addProductMarketingInfo(\n\texchangeRate: number,\n\tsecondaryCurrencyRoundTo: number,\n\tsecondaryCurrencyName: string\n): PipelineStage[] {\n\treturn [\n\t\t{\n\t\t\t$lookup: {\n\t\t\t\tfrom: 'productMarketings',\n\t\t\t\tlet: { productId: '$_id', now: new Date() },\n\t\t\t\tpipeline: [\n\t\t\t\t\t{\n\t\t\t\t\t\t$match: {\n\t\t\t\t\t\t\t$expr: { $eq: ['$product', '$$productId'] },\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t$lookup: {\n\t\t\t\t\t\t\tfrom: 'marketings',\n\t\t\t\t\t\t\tlocalField: 'marketing',\n\t\t\t\t\t\t\tforeignField: '_id',\n\t\t\t\t\t\t\tas: 'marketing',\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t$unwind: '$marketing',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t$match: {\n\t\t\t\t\t\t\t$expr: {\n\t\t\t\t\t\t\t\t$and: [\n\t\t\t\t\t\t\t\t\t{ $eq: ['$marketing.status', 'active'] },\n\t\t\t\t\t\t\t\t\t{ $eq: ['$marketing.pausedAt', null] },\n\t\t\t\t\t\t\t\t\t{ $lte: ['$marketing.duration.start', '$$now'] },\n\t\t\t\t\t\t\t\t\t{ $gte: ['$marketing.duration.end', '$$now'] },\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t// Compute and add secondary currency values to coupon documents\n\t\t\t\t\t{\n\t\t\t\t\t\t$addFields: {\n\t\t\t\t\t\t\tsecondaryCurrencyValue: {\n\t\t\t\t\t\t\t\t$cond: [\n\t\t\t\t\t\t\t\t\t{ $eq: ['$valueType', 'fixed'] },\n\t\t\t\t\t\t\t\t\tgetSecondaryCurrencyStage({\n\t\t\t\t\t\t\t\t\t\tvaluePath: '$value',\n\t\t\t\t\t\t\t\t\t\texchangeRate,\n\t\t\t\t\t\t\t\t\t\troundTo: secondaryCurrencyRoundTo,\n\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t\t'$$REMOVE', // Removes field if condition not met\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t$addFields: {\n\t\t\t\t\t\t\tlabel: {\n\t\t\t\t\t\t\t\t$switch: {\n\t\t\t\t\t\t\t\t\tbranches: [\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\tcase: { $eq: ['$marketing.marketingType', MarketingType.BUY1GET1] },\n\t\t\t\t\t\t\t\t\t\t\tthen: 'Buy 1 Get 1',\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\tcase: { $eq: ['$marketing.marketingType', MarketingType.PUNCH_MARKETING] },\n\t\t\t\t\t\t\t\t\t\t\tthen: 'Punch',\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\tcase: { $eq: ['$marketing.marketingType', MarketingType.DISCOUNT] },\n\t\t\t\t\t\t\t\t\t\t\tthen: {\n\t\t\t\t\t\t\t\t\t\t\t\t$switch: {\n\t\t\t\t\t\t\t\t\t\t\t\t\tbranches: [\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tcase: { $eq: ['$valueType', ValueType.FIXED] },\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tthen: {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$concat: [\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tsecondaryCurrencyName,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t' ',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t{ $toString: '$secondaryCurrencyValue' },\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tcase: { $eq: ['$valueType', ValueType.PERCENTAGE] },\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tthen: {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$concat: [{ $toString: '$value' }, '%'],\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\t\t\t\t\tdefault: 'Discount',\n\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\tdefault: '$marketing.marketingType',\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t$project: {\n\t\t\t\t\t\t\tmarketing: '$marketing._id',\n\t\t\t\t\t\t\tloyaltyPointCategory: '$loyaltyPointCategory',\n\t\t\t\t\t\t\tisBuy1Get1: '$isBuy1Get1',\n\t\t\t\t\t\t\tvalueType: '$valueType',\n\t\t\t\t\t\t\tvalue: '$value',\n\t\t\t\t\t\t\tsecondaryCurrencyValue: '$secondaryCurrencyValue',\n\t\t\t\t\t\t\tlabel: '$label',\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tas: 'productMarketing',\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\t$unwind: { path: '$productMarketing', preserveNullAndEmptyArrays: true },\n\t\t},\n\t];\n}\n\nexport function addSecondaryCurrencyToPriceBreakdowns(\n\texchangeRate: number,\n\tsecondaryCurrencyRoundTo: number\n): PipelineStage {\n\treturn {\n\t\t$addFields: {\n\t\t\tpriceBreakdowns: {\n\t\t\t\t$map: {\n\t\t\t\t\tinput: '$priceBreakdowns',\n\t\t\t\t\tas: 'breakdown',\n\t\t\t\t\tin: {\n\t\t\t\t\t\t$mergeObjects: [\n\t\t\t\t\t\t\t'$$breakdown',\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tsecondaryPrice: getSecondaryCurrencyStage({\n\t\t\t\t\t\t\t\t\tvaluePath: '$$breakdown.price',\n\t\t\t\t\t\t\t\t\texchangeRate,\n\t\t\t\t\t\t\t\t\troundTo: secondaryCurrencyRoundTo,\n\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\tsecondaryDiscountAmount: {\n\t\t\t\t\t\t\t\t\t$cond: [\n\t\t\t\t\t\t\t\t\t\t{ $gt: ['$productMarketing', null] },\n\t\t\t\t\t\t\t\t\t\tgetSecondaryCurrencyStage({\n\t\t\t\t\t\t\t\t\t\t\tvaluePath: '$$breakdown.discountAmount',\n\t\t\t\t\t\t\t\t\t\t\texchangeRate,\n\t\t\t\t\t\t\t\t\t\t\troundTo: secondaryCurrencyRoundTo,\n\t\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t\t\t'$$REMOVE', // Removes field if condition not met\n\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tsecondaryDiscountedPrice: {\n\t\t\t\t\t\t\t\t\t$cond: [\n\t\t\t\t\t\t\t\t\t\t{ $gt: ['$productMarketing', null] },\n\t\t\t\t\t\t\t\t\t\tgetSecondaryCurrencyStage({\n\t\t\t\t\t\t\t\t\t\t\tvaluePath: '$$breakdown.discountedPrice',\n\t\t\t\t\t\t\t\t\t\t\texchangeRate,\n\t\t\t\t\t\t\t\t\t\t\troundTo: secondaryCurrencyRoundTo,\n\t\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t\t\t'$$REMOVE', // Removes field if condition not met\n\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t};\n}\n\nexport function addDiscountAmountsToPriceBreakdowns(): PipelineStage {\n\treturn {\n\t\t$addFields: {\n\t\t\tpriceBreakdowns: {\n\t\t\t\t$map: {\n\t\t\t\t\tinput: '$priceBreakdowns',\n\t\t\t\t\tas: 'breakdown',\n\t\t\t\t\tin: {\n\t\t\t\t\t\t$mergeObjects: [\n\t\t\t\t\t\t\t'$$breakdown',\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tdiscountAmount: {\n\t\t\t\t\t\t\t\t\t$cond: [\n\t\t\t\t\t\t\t\t\t\t{ $gt: ['$productMarketing', null] }, // checks existence\n\t\t\t\t\t\t\t\t\t\t// if valueType is fixed, use value directly\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t$cond: [\n\t\t\t\t\t\t\t\t\t\t\t\t{ $eq: ['$productMarketing.valueType', ValueType.FIXED] },\n\t\t\t\t\t\t\t\t\t\t\t\t'$productMarketing.value',\n\t\t\t\t\t\t\t\t\t\t\t\t// if valueType is percentage, calculate percentage of price\n\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t$multiply: [\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'$productMarketing.value',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$divide: ['$$breakdown.price', 100],\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t'$$REMOVE', // omit field if productMarketing is missing\n\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t// Add discounted price\n\t\t\t\t\t\t\t\tdiscountedPrice: {\n\t\t\t\t\t\t\t\t\t$cond: [\n\t\t\t\t\t\t\t\t\t\t{ $gt: ['$productMarketing', null] }, // checks existence\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t$subtract: [\n\t\t\t\t\t\t\t\t\t\t\t\t'$$breakdown.price',\n\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t$cond: [\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t{ $eq: ['$productMarketing.valueType', ValueType.FIXED] },\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'$productMarketing.value',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$multiply: [\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'$productMarketing.value',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$divide: ['$$breakdown.price', 100],\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t'$$REMOVE', // omit field if productMarketing is missing\n\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t};\n}\n"]}
|
|
1
|
+
{"version":3,"file":"product-pipeline-stages.js","sourceRoot":"/","sources":["utilities/pipelines/product-pipeline-stages.ts"],"names":[],"mappings":";;AAIA,0DAsHC;AAED,sFAgDC;AAED,kFAkEC;AA/OD,2EAAwE;AACxE,kCAAmD;AAEnD,SAAgB,uBAAuB,CACtC,YAAoB,EACpB,wBAAgC,EAChC,qBAA6B;IAE7B,OAAO;QACN;YACC,OAAO,EAAE;gBACR,IAAI,EAAE,mBAAmB;gBACzB,GAAG,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,IAAI,EAAE,EAAE;gBAC3C,QAAQ,EAAE;oBACT;wBACC,MAAM,EAAE;4BACP,KAAK,EAAE,EAAE,GAAG,EAAE,CAAC,UAAU,EAAE,aAAa,CAAC,EAAE;yBAC3C;qBACD;oBACD;wBACC,OAAO,EAAE;4BACR,IAAI,EAAE,YAAY;4BAClB,UAAU,EA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C,6BAA6B,EAAE,gBAAS,CAAC,KAAK,CAAC,EAAE;wDACzD,yBAAyB;wDACzB;4DACC,SAAS,EAAE;gEACV,yBAAyB;gEACzB;oEACC,OAAO,EAAE,CAAC,mBAAmB,EAAE,GAAG,CAAC;iEACnC;6DACD;yDACD;qDACD;iDACD;6CACD;yCACD;wCACD,UAAU;qCACV;iCACD;6BACD;yBACD;qBACD;iBACD;aACD;SACD;KACD,CAAC;AACH,CAAC","sourcesContent":["import { PipelineStage } from 'mongoose';\nimport { getSecondaryCurrencyStage } from './common-pipeline-functions';\nimport { MarketingType, ValueType } from '../enum';\n\nexport function addProductMarketingInfo(\n\texchangeRate: number,\n\tsecondaryCurrencyRoundTo: number,\n\tsecondaryCurrencyName: string\n): PipelineStage[] {\n\treturn [\n\t\t{\n\t\t\t$lookup: {\n\t\t\t\tfrom: 'productMarketings',\n\t\t\t\tlet: { productId: '$_id', now: new Date() },\n\t\t\t\tpipeline: [\n\t\t\t\t\t{\n\t\t\t\t\t\t$match: {\n\t\t\t\t\t\t\t$expr: { $eq: ['$product', '$$productId'] },\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t$lookup: {\n\t\t\t\t\t\t\tfrom: 'marketings',\n\t\t\t\t\t\t\tlocalField: 'marketing',\n\t\t\t\t\t\t\tforeignField: '_id',\n\t\t\t\t\t\t\tas: 'marketing',\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t$unwind: '$marketing',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t$match: {\n\t\t\t\t\t\t\t$expr: {\n\t\t\t\t\t\t\t\t$and: [\n\t\t\t\t\t\t\t\t\t{ $eq: ['$marketing.status', 'active'] },\n\t\t\t\t\t\t\t\t\t{ $eq: ['$marketing.pausedAt', null] },\n\t\t\t\t\t\t\t\t\t{ $lte: ['$marketing.duration.start', '$$now'] },\n\t\t\t\t\t\t\t\t\t{ $gte: ['$marketing.duration.end', '$$now'] },\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t// Compute and add secondary currency values to coupon documents\n\t\t\t\t\t{\n\t\t\t\t\t\t$addFields: {\n\t\t\t\t\t\t\tsecondaryCurrencyValue: {\n\t\t\t\t\t\t\t\t$cond: [\n\t\t\t\t\t\t\t\t\t{ $eq: ['$valueType', 'fixed'] },\n\t\t\t\t\t\t\t\t\tgetSecondaryCurrencyStage({\n\t\t\t\t\t\t\t\t\t\tvaluePath: '$value',\n\t\t\t\t\t\t\t\t\t\texchangeRate,\n\t\t\t\t\t\t\t\t\t\troundTo: secondaryCurrencyRoundTo,\n\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t\t'$$REMOVE', // Removes field if condition not met\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t$addFields: {\n\t\t\t\t\t\t\tlabel: {\n\t\t\t\t\t\t\t\t$switch: {\n\t\t\t\t\t\t\t\t\tbranches: [\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\tcase: { $eq: ['$marketing.marketingType', MarketingType.BUY1GET1] },\n\t\t\t\t\t\t\t\t\t\t\tthen: 'Buy 1 Get 1',\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\tcase: { $eq: ['$marketing.marketingType', MarketingType.PUNCH_MARKETING] },\n\t\t\t\t\t\t\t\t\t\t\tthen: 'Punch',\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\tcase: { $eq: ['$marketing.marketingType', MarketingType.DISCOUNT] },\n\t\t\t\t\t\t\t\t\t\t\tthen: {\n\t\t\t\t\t\t\t\t\t\t\t\t$switch: {\n\t\t\t\t\t\t\t\t\t\t\t\t\tbranches: [\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tcase: { $eq: ['$valueType', ValueType.FIXED] },\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tthen: {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$concat: [\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tsecondaryCurrencyName,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t' ',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t{ $toString: '$secondaryCurrencyValue' },\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tcase: { $eq: ['$valueType', ValueType.PERCENTAGE] },\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tthen: {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$concat: [{ $toString: '$value' }, '%'],\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\t\t\t\t\tdefault: 'Discount',\n\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\tdefault: '$marketing.marketingType',\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t$project: {\n\t\t\t\t\t\t\tmarketing: '$marketing._id',\n\t\t\t\t\t\t\tisBuy1Get1: '$isBuy1Get1',\n\t\t\t\t\t\t\tvalueType: '$valueType',\n\t\t\t\t\t\t\tvalue: '$value',\n\t\t\t\t\t\t\tsecondaryCurrencyValue: '$secondaryCurrencyValue',\n\t\t\t\t\t\t\tlabel: '$label',\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tas: 'productMarketing',\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\t$unwind: { path: '$productMarketing', preserveNullAndEmptyArrays: true },\n\t\t},\n\t];\n}\n\nexport function addSecondaryCurrencyToPriceBreakdowns(\n\texchangeRate: number,\n\tsecondaryCurrencyRoundTo: number\n): PipelineStage {\n\treturn {\n\t\t$addFields: {\n\t\t\tpriceBreakdowns: {\n\t\t\t\t$map: {\n\t\t\t\t\tinput: '$priceBreakdowns',\n\t\t\t\t\tas: 'breakdown',\n\t\t\t\t\tin: {\n\t\t\t\t\t\t$mergeObjects: [\n\t\t\t\t\t\t\t'$$breakdown',\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tsecondaryPrice: getSecondaryCurrencyStage({\n\t\t\t\t\t\t\t\t\tvaluePath: '$$breakdown.price',\n\t\t\t\t\t\t\t\t\texchangeRate,\n\t\t\t\t\t\t\t\t\troundTo: secondaryCurrencyRoundTo,\n\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\tsecondaryDiscountAmount: {\n\t\t\t\t\t\t\t\t\t$cond: [\n\t\t\t\t\t\t\t\t\t\t{ $gt: ['$productMarketing', null] },\n\t\t\t\t\t\t\t\t\t\tgetSecondaryCurrencyStage({\n\t\t\t\t\t\t\t\t\t\t\tvaluePath: '$$breakdown.discountAmount',\n\t\t\t\t\t\t\t\t\t\t\texchangeRate,\n\t\t\t\t\t\t\t\t\t\t\troundTo: secondaryCurrencyRoundTo,\n\t\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t\t\t'$$REMOVE', // Removes field if condition not met\n\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tsecondaryDiscountedPrice: {\n\t\t\t\t\t\t\t\t\t$cond: [\n\t\t\t\t\t\t\t\t\t\t{ $gt: ['$productMarketing', null] },\n\t\t\t\t\t\t\t\t\t\tgetSecondaryCurrencyStage({\n\t\t\t\t\t\t\t\t\t\t\tvaluePath: '$$breakdown.discountedPrice',\n\t\t\t\t\t\t\t\t\t\t\texchangeRate,\n\t\t\t\t\t\t\t\t\t\t\troundTo: secondaryCurrencyRoundTo,\n\t\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t\t\t'$$REMOVE', // Removes field if condition not met\n\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t};\n}\n\nexport function addDiscountAmountsToPriceBreakdowns(): PipelineStage {\n\treturn {\n\t\t$addFields: {\n\t\t\tpriceBreakdowns: {\n\t\t\t\t$map: {\n\t\t\t\t\tinput: '$priceBreakdowns',\n\t\t\t\t\tas: 'breakdown',\n\t\t\t\t\tin: {\n\t\t\t\t\t\t$mergeObjects: [\n\t\t\t\t\t\t\t'$$breakdown',\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tdiscountAmount: {\n\t\t\t\t\t\t\t\t\t$cond: [\n\t\t\t\t\t\t\t\t\t\t{ $gt: ['$productMarketing', null] }, // checks existence\n\t\t\t\t\t\t\t\t\t\t// if valueType is fixed, use value directly\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t$cond: [\n\t\t\t\t\t\t\t\t\t\t\t\t{ $eq: ['$productMarketing.valueType', ValueType.FIXED] },\n\t\t\t\t\t\t\t\t\t\t\t\t'$productMarketing.value',\n\t\t\t\t\t\t\t\t\t\t\t\t// if valueType is percentage, calculate percentage of price\n\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t$multiply: [\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'$productMarketing.value',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$divide: ['$$breakdown.price', 100],\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t'$$REMOVE', // omit field if productMarketing is missing\n\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t// Add discounted price\n\t\t\t\t\t\t\t\tdiscountedPrice: {\n\t\t\t\t\t\t\t\t\t$cond: [\n\t\t\t\t\t\t\t\t\t\t{ $gt: ['$productMarketing', null] }, // checks existence\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t$subtract: [\n\t\t\t\t\t\t\t\t\t\t\t\t'$$breakdown.price',\n\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t$cond: [\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t{ $eq: ['$productMarketing.valueType', ValueType.FIXED] },\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'$productMarketing.value',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$multiply: [\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'$productMarketing.value',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t$divide: ['$$breakdown.price', 100],\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t'$$REMOVE', // omit field if productMarketing is missing\n\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t};\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.LoyaltyPointCategory = void 0;
|
|
13
|
-
const typegoose_1 = require("@typegoose/typegoose");
|
|
14
|
-
const defaultClasses_1 = require("@typegoose/typegoose/lib/defaultClasses");
|
|
15
|
-
const enum_1 = require("../../../utilities/enum");
|
|
16
|
-
const _1 = require(".");
|
|
17
|
-
let LoyaltyPointCategory = class LoyaltyPointCategory extends defaultClasses_1.TimeStamps {
|
|
18
|
-
name;
|
|
19
|
-
status;
|
|
20
|
-
sortingOrder;
|
|
21
|
-
};
|
|
22
|
-
exports.LoyaltyPointCategory = LoyaltyPointCategory;
|
|
23
|
-
__decorate([
|
|
24
|
-
(0, typegoose_1.prop)({ required: true, type: String }),
|
|
25
|
-
__metadata("design:type", String)
|
|
26
|
-
], LoyaltyPointCategory.prototype, "name", void 0);
|
|
27
|
-
__decorate([
|
|
28
|
-
(0, typegoose_1.prop)({ type: String, enum: enum_1.Status, default: enum_1.Status.ACTIVE }),
|
|
29
|
-
__metadata("design:type", String)
|
|
30
|
-
], LoyaltyPointCategory.prototype, "status", void 0);
|
|
31
|
-
__decorate([
|
|
32
|
-
(0, typegoose_1.prop)({ type: Number }),
|
|
33
|
-
__metadata("design:type", Number)
|
|
34
|
-
], LoyaltyPointCategory.prototype, "sortingOrder", void 0);
|
|
35
|
-
exports.LoyaltyPointCategory = LoyaltyPointCategory = __decorate([
|
|
36
|
-
(0, typegoose_1.modelOptions)({ schemaOptions: { collection: 'loyaltyPointCategories' } }),
|
|
37
|
-
(0, typegoose_1.pre)('save', async function (next) {
|
|
38
|
-
if (this.isNew || typeof this.sortingOrder === 'undefined') {
|
|
39
|
-
try {
|
|
40
|
-
const maxSortingOrder = await _1.LoyaltyPointCategoryModel.aggregate([
|
|
41
|
-
{
|
|
42
|
-
$match: {
|
|
43
|
-
deletedAt: null,
|
|
44
|
-
},
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
$group: {
|
|
48
|
-
_id: null,
|
|
49
|
-
maxSortingOrder: { $max: '$sortingOrder' },
|
|
50
|
-
},
|
|
51
|
-
},
|
|
52
|
-
]).exec();
|
|
53
|
-
this.sortingOrder = (maxSortingOrder[0]?.maxSortingOrder ?? -1) + 1;
|
|
54
|
-
}
|
|
55
|
-
catch (error) {
|
|
56
|
-
return next(error);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
next();
|
|
60
|
-
})
|
|
61
|
-
], LoyaltyPointCategory);
|
|
62
|
-
//# sourceMappingURL=loyalty-point-category.model.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"loyalty-point-category.model.js","sourceRoot":"/","sources":["libraries/mongo/models/loyalty-point-category.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA+D;AAC/D,4EAAqE;AACrE,kDAAiD;AACjD,wBAA8C;AA8BvC,IAAM,oBAAoB,GAA1B,MAAM,oBAAqB,SAAQ,2BAAU;IAE5C,IAAI,CAAU;IAGd,MAAM,CAAU;IAGhB,YAAY,CAAU;CAC7B,CAAA;AATY,oDAAoB;AAEzB;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;kDAClB;AAGd;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,aAAM,EAAE,OAAO,EAAE,aAAM,CAAC,MAAM,EAAE,CAAC;;oDACtC;AAGhB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;0DACM;+BARjB,oBAAoB;IA5BhC,IAAA,wBAAY,EAAC,EAAE,aAAa,EAAE,EAAE,UAAU,EAAE,wBAAwB,EAAE,EAAE,CAAC;IACzE,IAAA,eAAG,EAAuB,MAAM,EAAE,KAAK,WAAW,IAAI;QAEtD,IAAI,IAAI,CAAC,KAAK,IAAI,OAAO,IAAI,CAAC,YAAY,KAAK,WAAW,EAAE,CAAC;YAC5D,IAAI,CAAC;gBAEJ,MAAM,eAAe,GAAG,MAAM,4BAAyB,CAAC,SAAS,CAA8B;oBAC9F;wBACC,MAAM,EAAE;4BACP,SAAS,EAAE,IAAI;yBACf;qBACD;oBACD;wBACC,MAAM,EAAE;4BACP,GAAG,EAAE,IAAI;4BACT,eAAe,EAAE,EAAE,IAAI,EAAE,eAAe,EAAE;yBAC1C;qBACD;iBACD,CAAC,CAAC,IAAI,EAAE,CAAC;gBAGV,IAAI,CAAC,YAAY,GAAG,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,eAAe,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;YACrE,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBAChB,OAAO,IAAI,CAAC,KAAc,CAAC,CAAC;YAC7B,CAAC;QACF,CAAC;QACD,IAAI,EAAE,CAAC;IACR,CAAC,CAAC;GACW,oBAAoB,CAShC","sourcesContent":["import { modelOptions, pre, prop } from '@typegoose/typegoose';\nimport { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';\nimport { Status } from '../../../utilities/enum';\nimport { LoyaltyPointCategoryModel } from '.';\n\n@modelOptions({ schemaOptions: { collection: 'loyaltyPointCategories' } })\n@pre<LoyaltyPointCategory>('save', async function (next) {\n\t// Only set sortingOrder if it's a new document or sortingOrder is not set\n\tif (this.isNew || typeof this.sortingOrder === 'undefined') {\n\t\ttry {\n\t\t\t// Find the maximum sortingOrder that aren't deleted\n\t\t\tconst maxSortingOrder = await LoyaltyPointCategoryModel.aggregate<{ maxSortingOrder: number }>([\n\t\t\t\t{\n\t\t\t\t\t$match: {\n\t\t\t\t\t\tdeletedAt: null,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t$group: {\n\t\t\t\t\t\t_id: null,\n\t\t\t\t\t\tmaxSortingOrder: { $max: '$sortingOrder' },\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t]).exec();\n\n\t\t\t// Set the new sortingOrder to max + 1 (or 0 if no items found)\n\t\t\tthis.sortingOrder = (maxSortingOrder[0]?.maxSortingOrder ?? -1) + 1;\n\t\t} catch (error) {\n\t\t\treturn next(error as Error);\n\t\t}\n\t}\n\tnext();\n})\nexport class LoyaltyPointCategory extends TimeStamps {\n\t@prop({ required: true, type: String })\n\tpublic name!: string;\n\n\t@prop({ type: String, enum: Status, default: Status.ACTIVE })\n\tpublic status?: Status;\n\n\t@prop({ type: Number })\n\tpublic sortingOrder?: number;\n}\n"]}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.LoyaltyPointSetting = void 0;
|
|
13
|
-
const typegoose_1 = require("@typegoose/typegoose");
|
|
14
|
-
const defaultClasses_1 = require("@typegoose/typegoose/lib/defaultClasses");
|
|
15
|
-
let LoyaltyPointSetting = class LoyaltyPointSetting extends defaultClasses_1.TimeStamps {
|
|
16
|
-
earnedValue;
|
|
17
|
-
usedValue;
|
|
18
|
-
rewardBundles;
|
|
19
|
-
expirationInDays;
|
|
20
|
-
};
|
|
21
|
-
exports.LoyaltyPointSetting = LoyaltyPointSetting;
|
|
22
|
-
__decorate([
|
|
23
|
-
(0, typegoose_1.prop)({ required: true, type: Number }),
|
|
24
|
-
__metadata("design:type", Number)
|
|
25
|
-
], LoyaltyPointSetting.prototype, "earnedValue", void 0);
|
|
26
|
-
__decorate([
|
|
27
|
-
(0, typegoose_1.prop)({ required: true, type: Number }),
|
|
28
|
-
__metadata("design:type", Number)
|
|
29
|
-
], LoyaltyPointSetting.prototype, "usedValue", void 0);
|
|
30
|
-
__decorate([
|
|
31
|
-
(0, typegoose_1.prop)({ required: true, type: [Number] }),
|
|
32
|
-
__metadata("design:type", Array)
|
|
33
|
-
], LoyaltyPointSetting.prototype, "rewardBundles", void 0);
|
|
34
|
-
__decorate([
|
|
35
|
-
(0, typegoose_1.prop)({ type: Number, default: 1 }),
|
|
36
|
-
__metadata("design:type", Number)
|
|
37
|
-
], LoyaltyPointSetting.prototype, "expirationInDays", void 0);
|
|
38
|
-
exports.LoyaltyPointSetting = LoyaltyPointSetting = __decorate([
|
|
39
|
-
(0, typegoose_1.modelOptions)({ schemaOptions: { collection: 'loyaltyPointSettings' } })
|
|
40
|
-
], LoyaltyPointSetting);
|
|
41
|
-
//# sourceMappingURL=loyalty-point-setting.model.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"loyalty-point-setting.model.js","sourceRoot":"/","sources":["libraries/mongo/models/loyalty-point-setting.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA0D;AAC1D,4EAAqE;AAG9D,IAAM,mBAAmB,GAAzB,MAAM,mBAAoB,SAAQ,2BAAU;IAE3C,WAAW,CAAU;IAGrB,SAAS,CAAU;IAGnB,aAAa,CAAY;IAGzB,gBAAgB,CAAU;CACjC,CAAA;AAZY,kDAAmB;AAExB;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;wDACX;AAGrB;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;sDACb;AAGnB;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC;;0DACT;AAGzB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;6DACF;8BAXrB,mBAAmB;IAD/B,IAAA,wBAAY,EAAC,EAAE,aAAa,EAAE,EAAE,UAAU,EAAE,sBAAsB,EAAE,EAAE,CAAC;GAC3D,mBAAmB,CAY/B","sourcesContent":["import { modelOptions, prop } from '@typegoose/typegoose';\nimport { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';\n\n@modelOptions({ schemaOptions: { collection: 'loyaltyPointSettings' } })\nexport class LoyaltyPointSetting extends TimeStamps {\n\t@prop({ required: true, type: Number })\n\tpublic earnedValue!: number;\n\n\t@prop({ required: true, type: Number })\n\tpublic usedValue!: number;\n\n\t@prop({ required: true, type: [Number] })\n\tpublic rewardBundles!: number[];\n\n\t@prop({ type: Number, default: 1 })\n\tpublic expirationInDays?: number;\n}\n"]}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { Ref, mongoose } from '@typegoose/typegoose';
|
|
2
|
-
import { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';
|
|
3
|
-
import { CoreUser } from './core-user.model';
|
|
4
|
-
declare class UsedPoint {
|
|
5
|
-
amountUsed: number;
|
|
6
|
-
dateUsed: Date;
|
|
7
|
-
}
|
|
8
|
-
export declare class LoyaltyPoint extends TimeStamps {
|
|
9
|
-
points: number;
|
|
10
|
-
dateGenerated: Date;
|
|
11
|
-
dateExpiry: Date;
|
|
12
|
-
coreUser: Ref<CoreUser>;
|
|
13
|
-
shopId: mongoose.Types.ObjectId;
|
|
14
|
-
shopName: string;
|
|
15
|
-
shopLogo: string;
|
|
16
|
-
tenant: string;
|
|
17
|
-
orderId: mongoose.Types.ObjectId;
|
|
18
|
-
usedPoints: UsedPoint[];
|
|
19
|
-
}
|
|
20
|
-
export {};
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.LoyaltyPoint = void 0;
|
|
13
|
-
const typegoose_1 = require("@typegoose/typegoose");
|
|
14
|
-
const defaultClasses_1 = require("@typegoose/typegoose/lib/defaultClasses");
|
|
15
|
-
const core_user_model_1 = require("./core-user.model");
|
|
16
|
-
class UsedPoint {
|
|
17
|
-
amountUsed;
|
|
18
|
-
dateUsed;
|
|
19
|
-
}
|
|
20
|
-
__decorate([
|
|
21
|
-
(0, typegoose_1.prop)({ required: true }),
|
|
22
|
-
__metadata("design:type", Number)
|
|
23
|
-
], UsedPoint.prototype, "amountUsed", void 0);
|
|
24
|
-
__decorate([
|
|
25
|
-
(0, typegoose_1.prop)({ required: true }),
|
|
26
|
-
__metadata("design:type", Date)
|
|
27
|
-
], UsedPoint.prototype, "dateUsed", void 0);
|
|
28
|
-
let LoyaltyPoint = class LoyaltyPoint extends defaultClasses_1.TimeStamps {
|
|
29
|
-
points;
|
|
30
|
-
dateGenerated;
|
|
31
|
-
dateExpiry;
|
|
32
|
-
coreUser;
|
|
33
|
-
shopId;
|
|
34
|
-
shopName;
|
|
35
|
-
shopLogo;
|
|
36
|
-
tenant;
|
|
37
|
-
orderId;
|
|
38
|
-
usedPoints;
|
|
39
|
-
};
|
|
40
|
-
exports.LoyaltyPoint = LoyaltyPoint;
|
|
41
|
-
__decorate([
|
|
42
|
-
(0, typegoose_1.prop)({ required: true }),
|
|
43
|
-
__metadata("design:type", Number)
|
|
44
|
-
], LoyaltyPoint.prototype, "points", void 0);
|
|
45
|
-
__decorate([
|
|
46
|
-
(0, typegoose_1.prop)({ required: true }),
|
|
47
|
-
__metadata("design:type", Date)
|
|
48
|
-
], LoyaltyPoint.prototype, "dateGenerated", void 0);
|
|
49
|
-
__decorate([
|
|
50
|
-
(0, typegoose_1.prop)({ required: true }),
|
|
51
|
-
__metadata("design:type", Date)
|
|
52
|
-
], LoyaltyPoint.prototype, "dateExpiry", void 0);
|
|
53
|
-
__decorate([
|
|
54
|
-
(0, typegoose_1.prop)({ required: true, ref: () => core_user_model_1.CoreUser }),
|
|
55
|
-
__metadata("design:type", Object)
|
|
56
|
-
], LoyaltyPoint.prototype, "coreUser", void 0);
|
|
57
|
-
__decorate([
|
|
58
|
-
(0, typegoose_1.prop)({ required: true, type: typegoose_1.mongoose.Schema.Types.ObjectId }),
|
|
59
|
-
__metadata("design:type", typegoose_1.mongoose.Types.ObjectId)
|
|
60
|
-
], LoyaltyPoint.prototype, "shopId", void 0);
|
|
61
|
-
__decorate([
|
|
62
|
-
(0, typegoose_1.prop)({ required: true }),
|
|
63
|
-
__metadata("design:type", String)
|
|
64
|
-
], LoyaltyPoint.prototype, "shopName", void 0);
|
|
65
|
-
__decorate([
|
|
66
|
-
(0, typegoose_1.prop)({ required: true }),
|
|
67
|
-
__metadata("design:type", String)
|
|
68
|
-
], LoyaltyPoint.prototype, "shopLogo", void 0);
|
|
69
|
-
__decorate([
|
|
70
|
-
(0, typegoose_1.prop)({ required: true }),
|
|
71
|
-
__metadata("design:type", String)
|
|
72
|
-
], LoyaltyPoint.prototype, "tenant", void 0);
|
|
73
|
-
__decorate([
|
|
74
|
-
(0, typegoose_1.prop)({ required: true, type: typegoose_1.mongoose.Schema.Types.ObjectId }),
|
|
75
|
-
__metadata("design:type", typegoose_1.mongoose.Types.ObjectId)
|
|
76
|
-
], LoyaltyPoint.prototype, "orderId", void 0);
|
|
77
|
-
__decorate([
|
|
78
|
-
(0, typegoose_1.prop)({ type: () => [UsedPoint], default: [] }),
|
|
79
|
-
__metadata("design:type", Array)
|
|
80
|
-
], LoyaltyPoint.prototype, "usedPoints", void 0);
|
|
81
|
-
exports.LoyaltyPoint = LoyaltyPoint = __decorate([
|
|
82
|
-
(0, typegoose_1.modelOptions)({ schemaOptions: { collection: 'loyaltyPoints' } })
|
|
83
|
-
], LoyaltyPoint);
|
|
84
|
-
//# sourceMappingURL=loyalty-point.model.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"loyalty-point.model.js","sourceRoot":"/","sources":["libraries/mongo/models/loyalty-point.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAAyE;AACzE,4EAAqE;AAErE,uDAA6C;AAE7C,MAAM,SAAS;IAEP,UAAU,CAAU;IAGpB,QAAQ,CAAQ;CACvB;AAJO;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;6CACE;AAGpB;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;8BACP,IAAI;2CAAC;AAIjB,IAAM,YAAY,GAAlB,MAAM,YAAa,SAAQ,2BAAU;IAEpC,MAAM,CAAU;IAGhB,aAAa,CAAQ;IAGrB,UAAU,CAAQ;IAGlB,QAAQ,CAAiB;IAGzB,MAAM,CAA2B;IAGjC,QAAQ,CAAU;IAGlB,QAAQ,CAAU;IAGlB,MAAM,CAAU;IAGhB,OAAO,CAA2B;IAGlC,UAAU,CAAe;CAChC,CAAA;AA9BY,oCAAY;AAEjB;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;4CACF;AAGhB;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;8BACF,IAAI;mDAAC;AAGrB;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;8BACL,IAAI;gDAAC;AAGlB;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,0BAAQ,EAAE,CAAC;;8CACd;AAGzB;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,oBAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;8BAC/C,oBAAQ,CAAC,KAAK,CAAC,QAAQ;4CAAC;AAGjC;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;8CACA;AAGlB;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;8CACA;AAGlB;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;4CACF;AAGhB;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,oBAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;8BAC9C,oBAAQ,CAAC,KAAK,CAAC,QAAQ;6CAAC;AAGlC;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;;gDACf;uBA7BpB,YAAY;IADxB,IAAA,wBAAY,EAAC,EAAE,aAAa,EAAE,EAAE,UAAU,EAAE,eAAe,EAAE,EAAE,CAAC;GACpD,YAAY,CA8BxB","sourcesContent":["import { modelOptions, prop, Ref, mongoose } from '@typegoose/typegoose';\nimport { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';\n\nimport { CoreUser } from './core-user.model';\n\nclass UsedPoint {\n\t@prop({ required: true })\n\tpublic amountUsed!: number;\n\n\t@prop({ required: true })\n\tpublic dateUsed!: Date;\n}\n\n@modelOptions({ schemaOptions: { collection: 'loyaltyPoints' } })\nexport class LoyaltyPoint extends TimeStamps {\n\t@prop({ required: true })\n\tpublic points!: number;\n\n\t@prop({ required: true })\n\tpublic dateGenerated!: Date;\n\n\t@prop({ required: true })\n\tpublic dateExpiry!: Date;\n\n\t@prop({ required: true, ref: () => CoreUser })\n\tpublic coreUser!: Ref<CoreUser>;\n\n\t@prop({ required: true, type: mongoose.Schema.Types.ObjectId })\n\tpublic shopId!: mongoose.Types.ObjectId;\n\n\t@prop({ required: true })\n\tpublic shopName!: string;\n\n\t@prop({ required: true })\n\tpublic shopLogo!: string;\n\n\t@prop({ required: true })\n\tpublic tenant!: string;\n\n\t@prop({ required: true, type: mongoose.Schema.Types.ObjectId })\n\tpublic orderId!: mongoose.Types.ObjectId;\n\n\t@prop({ type: () => [UsedPoint], default: [] })\n\tpublic usedPoints!: UsedPoint[];\n}\n"]}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { Ref } from '@typegoose/typegoose';
|
|
2
|
-
import { MarketingType, ValueType } from '../../../../utilities/enum';
|
|
3
|
-
import { Marketing } from '../marketing.model';
|
|
4
|
-
import { LoyaltyPointCategory } from '../loyalty-point-category.model';
|
|
5
|
-
import { ProductMarketing } from '../product-marketing.model';
|
|
6
|
-
export declare class LoyaltyPointMarketing extends Marketing {
|
|
7
|
-
marketingType: MarketingType.LOYALTY_POINT;
|
|
8
|
-
isEntireMenu?: boolean;
|
|
9
|
-
valueType?: ValueType;
|
|
10
|
-
value?: number;
|
|
11
|
-
category?: Ref<LoyaltyPointCategory>;
|
|
12
|
-
products: Ref<ProductMarketing>;
|
|
13
|
-
spendLimit?: number;
|
|
14
|
-
}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.LoyaltyPointMarketing = void 0;
|
|
13
|
-
const typegoose_1 = require("@typegoose/typegoose");
|
|
14
|
-
const enum_1 = require("../../../../utilities/enum");
|
|
15
|
-
const marketing_model_1 = require("../marketing.model");
|
|
16
|
-
const loyalty_point_category_model_1 = require("../loyalty-point-category.model");
|
|
17
|
-
const product_marketing_model_1 = require("../product-marketing.model");
|
|
18
|
-
class LoyaltyPointMarketing extends marketing_model_1.Marketing {
|
|
19
|
-
marketingType = enum_1.MarketingType.LOYALTY_POINT;
|
|
20
|
-
isEntireMenu;
|
|
21
|
-
valueType;
|
|
22
|
-
value;
|
|
23
|
-
category;
|
|
24
|
-
products;
|
|
25
|
-
spendLimit;
|
|
26
|
-
}
|
|
27
|
-
exports.LoyaltyPointMarketing = LoyaltyPointMarketing;
|
|
28
|
-
__decorate([
|
|
29
|
-
(0, typegoose_1.prop)({ type: Boolean, default: false }),
|
|
30
|
-
__metadata("design:type", Boolean)
|
|
31
|
-
], LoyaltyPointMarketing.prototype, "isEntireMenu", void 0);
|
|
32
|
-
__decorate([
|
|
33
|
-
(0, typegoose_1.prop)({ type: String, enum: enum_1.ValueType }),
|
|
34
|
-
__metadata("design:type", String)
|
|
35
|
-
], LoyaltyPointMarketing.prototype, "valueType", void 0);
|
|
36
|
-
__decorate([
|
|
37
|
-
(0, typegoose_1.prop)({ type: Number }),
|
|
38
|
-
__metadata("design:type", Number)
|
|
39
|
-
], LoyaltyPointMarketing.prototype, "value", void 0);
|
|
40
|
-
__decorate([
|
|
41
|
-
(0, typegoose_1.prop)({ ref: () => loyalty_point_category_model_1.LoyaltyPointCategory }),
|
|
42
|
-
__metadata("design:type", Object)
|
|
43
|
-
], LoyaltyPointMarketing.prototype, "category", void 0);
|
|
44
|
-
__decorate([
|
|
45
|
-
(0, typegoose_1.prop)({
|
|
46
|
-
ref: () => product_marketing_model_1.ProductMarketing,
|
|
47
|
-
foreignField: 'marketing',
|
|
48
|
-
localField: '_id',
|
|
49
|
-
}),
|
|
50
|
-
__metadata("design:type", Object)
|
|
51
|
-
], LoyaltyPointMarketing.prototype, "products", void 0);
|
|
52
|
-
__decorate([
|
|
53
|
-
(0, typegoose_1.prop)({ type: Number, default: 0 }),
|
|
54
|
-
__metadata("design:type", Number)
|
|
55
|
-
], LoyaltyPointMarketing.prototype, "spendLimit", void 0);
|
|
56
|
-
//# sourceMappingURL=loyalty-point-marketing.model.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"loyalty-point-marketing.model.js","sourceRoot":"/","sources":["libraries/mongo/models/providers/loyalty-point-marketing.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAAiD;AACjD,qDAAsE;AACtE,wDAA+C;AAC/C,kFAAuE;AACvE,wEAA8D;AAE9D,MAAa,qBAAsB,SAAQ,2BAAS;IAC5C,aAAa,GAAG,oBAAa,CAAC,aAAsB,CAAC;IAGrD,YAAY,CAAW;IAGvB,SAAS,CAAa;IAGtB,KAAK,CAAU;IAGf,QAAQ,CAA6B;IAOrC,QAAQ,CAAwB;IAGhC,UAAU,CAAU;CAC3B;AAxBD,sDAwBC;AApBO;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;;2DACV;AAGvB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,gBAAS,EAAE,CAAC;;wDACX;AAGtB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;oDACD;AAGf;IADN,IAAA,gBAAI,EAAC,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,mDAAoB,EAAE,CAAC;;uDACE;AAOrC;IALN,IAAA,gBAAI,EAAC;QACL,GAAG,EAAE,GAAG,EAAE,CAAC,0CAAgB;QAC3B,YAAY,EAAE,WAAW;QACzB,UAAU,EAAE,KAAK;KACjB,CAAC;;uDACqC;AAGhC;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;yDACR","sourcesContent":["import { prop, Ref } from '@typegoose/typegoose';\nimport { MarketingType, ValueType } from '../../../../utilities/enum';\nimport { Marketing } from '../marketing.model';\nimport { LoyaltyPointCategory } from '../loyalty-point-category.model';\nimport { ProductMarketing } from '../product-marketing.model';\n\nexport class LoyaltyPointMarketing extends Marketing {\n\tpublic marketingType = MarketingType.LOYALTY_POINT as const;\n\n\t@prop({ type: Boolean, default: false })\n\tpublic isEntireMenu?: boolean;\n\n\t@prop({ type: String, enum: ValueType })\n\tpublic valueType?: ValueType;\n\n\t@prop({ type: Number })\n\tpublic value?: number;\n\n\t@prop({ ref: () => LoyaltyPointCategory })\n\tpublic category?: Ref<LoyaltyPointCategory>;\n\n\t@prop({\n\t\tref: () => ProductMarketing,\n\t\tforeignField: 'marketing',\n\t\tlocalField: '_id',\n\t})\n\tpublic products: Ref<ProductMarketing>;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic spendLimit?: number;\n}\n"]}
|