b23-lib 2.0.0 → 2.0.1
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/Auth/index.js +1 -1
- package/dist/Auth/index.js.map +1 -1
- package/dist/Auth/index.mjs +1 -1
- package/dist/Auth/index.mjs.map +1 -1
- package/dist/Classes/Address.d.mts +1 -1
- package/dist/Classes/Address.d.ts +1 -1
- package/dist/Classes/Address.js.map +1 -1
- package/dist/Classes/Address.mjs +1 -1
- package/dist/Classes/Base.d.mts +5 -5
- package/dist/Classes/Base.d.ts +5 -5
- package/dist/Classes/Base.js.map +1 -1
- package/dist/Classes/Base.mjs +1 -1
- package/dist/Classes/Cart.d.mts +27 -12
- package/dist/Classes/Cart.d.ts +27 -12
- package/dist/Classes/Cart.js +1 -1
- package/dist/Classes/Cart.js.map +1 -1
- package/dist/Classes/Cart.mjs +1 -1
- package/dist/Classes/Cart.mjs.map +1 -1
- package/dist/Classes/Common.d.mts +2 -93
- package/dist/Classes/Common.d.ts +2 -93
- package/dist/Classes/Coupon.d.mts +33 -15
- package/dist/Classes/Coupon.d.ts +33 -15
- package/dist/Classes/Coupon.js +1 -1
- package/dist/Classes/Coupon.js.map +1 -1
- package/dist/Classes/Coupon.mjs +1 -1
- package/dist/Classes/Customer.d.mts +2 -2
- package/dist/Classes/Customer.d.ts +2 -2
- package/dist/Classes/Customer.js.map +1 -1
- package/dist/Classes/Customer.mjs +1 -1
- package/dist/Classes/Customer.mjs.map +1 -1
- package/dist/Classes/CustomerAddress.d.mts +1 -1
- package/dist/Classes/CustomerAddress.d.ts +1 -1
- package/dist/Classes/CustomerAddress.js.map +1 -1
- package/dist/Classes/CustomerAddress.mjs +1 -1
- package/dist/Classes/Enum.d.mts +43 -2
- package/dist/Classes/Enum.d.ts +43 -2
- package/dist/Classes/Enum.js +1 -1
- package/dist/Classes/Enum.js.map +1 -1
- package/dist/Classes/Enum.mjs +1 -1
- package/dist/Classes/Error.d.mts +59 -0
- package/dist/Classes/Error.d.ts +59 -0
- package/dist/Classes/Error.js +2 -0
- package/dist/Classes/Error.js.map +1 -0
- package/dist/Classes/Error.mjs +2 -0
- package/dist/Classes/Error.mjs.map +1 -0
- package/dist/Classes/ImageInfo.js +1 -1
- package/dist/Classes/ImageInfo.js.map +1 -1
- package/dist/Classes/ImageInfo.mjs +1 -1
- package/dist/Classes/Inventory.d.mts +25 -6
- package/dist/Classes/Inventory.d.ts +25 -6
- package/dist/Classes/Inventory.js +1 -1
- package/dist/Classes/Inventory.js.map +1 -1
- package/dist/Classes/Inventory.mjs +1 -1
- package/dist/Classes/Inventory.mjs.map +1 -1
- package/dist/Classes/LineItem.d.mts +140 -58
- package/dist/Classes/LineItem.d.ts +140 -58
- package/dist/Classes/LineItem.js +1 -1
- package/dist/Classes/LineItem.js.map +1 -1
- package/dist/Classes/LineItem.mjs +1 -1
- package/dist/Classes/Order.d.mts +7 -51
- package/dist/Classes/Order.d.ts +7 -51
- package/dist/Classes/Order.js +1 -1
- package/dist/Classes/Order.js.map +1 -1
- package/dist/Classes/Order.mjs +1 -1
- package/dist/Classes/Order.mjs.map +1 -1
- package/dist/Classes/Payment.d.mts +4 -4
- package/dist/Classes/Payment.d.ts +4 -4
- package/dist/Classes/Payment.js.map +1 -1
- package/dist/Classes/Payment.mjs +1 -1
- package/dist/Classes/Payment.mjs.map +1 -1
- package/dist/Classes/Price.d.mts +1 -82
- package/dist/Classes/Price.d.ts +1 -82
- package/dist/Classes/Price.js +1 -1
- package/dist/Classes/Price.js.map +1 -1
- package/dist/Classes/Price.mjs +1 -1
- package/dist/Classes/Product.d.mts +103 -85
- package/dist/Classes/Product.d.ts +103 -85
- package/dist/Classes/Product.js +1 -1
- package/dist/Classes/Product.js.map +1 -1
- package/dist/Classes/Product.mjs +1 -1
- package/dist/Classes/Product.mjs.map +1 -1
- package/dist/Classes/ShoppingContainer.d.mts +79 -63
- package/dist/Classes/ShoppingContainer.d.ts +79 -63
- package/dist/Classes/ShoppingContainer.js +1 -1
- package/dist/Classes/ShoppingContainer.js.map +1 -1
- package/dist/Classes/ShoppingContainer.mjs +1 -1
- package/dist/Classes/TaxRule.d.mts +63 -0
- package/dist/Classes/TaxRule.d.ts +63 -0
- package/dist/Classes/TaxRule.js +2 -0
- package/dist/Classes/TaxRule.js.map +1 -0
- package/dist/Classes/TaxRule.mjs +2 -0
- package/dist/Classes/TaxRule.mjs.map +1 -0
- package/dist/Classes/TieredPrice.d.mts +75 -0
- package/dist/Classes/TieredPrice.d.ts +75 -0
- package/dist/Classes/TieredPrice.js +2 -0
- package/dist/Classes/TieredPrice.js.map +1 -0
- package/dist/Classes/TieredPrice.mjs +2 -0
- package/dist/Classes/TieredPrice.mjs.map +1 -0
- package/dist/Common-D-UoxwM0.d.ts +210 -0
- package/dist/Common-FbQ5-3QN.d.mts +210 -0
- package/dist/chunk-2SGUPNWZ.mjs +2 -0
- package/dist/chunk-2SGUPNWZ.mjs.map +1 -0
- package/dist/chunk-54RUAXYE.mjs +2 -0
- package/dist/chunk-54RUAXYE.mjs.map +1 -0
- package/dist/{chunk-ATUUYYQT.mjs → chunk-55SOBG62.mjs} +2 -2
- package/dist/chunk-55SOBG62.mjs.map +1 -0
- package/dist/{chunk-H5GPM4LA.mjs → chunk-5KD2EW7O.mjs} +2 -2
- package/dist/{chunk-H5GPM4LA.mjs.map → chunk-5KD2EW7O.mjs.map} +1 -1
- package/dist/chunk-72DR3HF2.mjs +2 -0
- package/dist/chunk-72DR3HF2.mjs.map +1 -0
- package/dist/chunk-AMIRIUMH.mjs +2 -0
- package/dist/chunk-AMIRIUMH.mjs.map +1 -0
- package/dist/chunk-CEGQFFYZ.mjs +2 -0
- package/dist/chunk-CEGQFFYZ.mjs.map +1 -0
- package/dist/chunk-EP7WVZXC.mjs +2 -0
- package/dist/chunk-EP7WVZXC.mjs.map +1 -0
- package/dist/chunk-KWH7GE23.mjs +2 -0
- package/dist/chunk-KWH7GE23.mjs.map +1 -0
- package/dist/chunk-LNIZAPER.mjs +2 -0
- package/dist/chunk-LNIZAPER.mjs.map +1 -0
- package/dist/chunk-NJKSUUOB.mjs +2 -0
- package/dist/chunk-NJKSUUOB.mjs.map +1 -0
- package/dist/chunk-NUTKOIGY.mjs +2 -0
- package/dist/chunk-NUTKOIGY.mjs.map +1 -0
- package/dist/chunk-RBROVHJ4.mjs +2 -0
- package/dist/chunk-RBROVHJ4.mjs.map +1 -0
- package/dist/index.d.mts +9 -6
- package/dist/index.d.ts +9 -6
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-6PDP4ETM.mjs +0 -2
- package/dist/chunk-6PDP4ETM.mjs.map +0 -1
- package/dist/chunk-ATUUYYQT.mjs.map +0 -1
- package/dist/chunk-CKUUUEWT.mjs +0 -2
- package/dist/chunk-CKUUUEWT.mjs.map +0 -1
- package/dist/chunk-DKI6BDWK.mjs +0 -2
- package/dist/chunk-DKI6BDWK.mjs.map +0 -1
- package/dist/chunk-K3AXPTGG.mjs +0 -2
- package/dist/chunk-K3AXPTGG.mjs.map +0 -1
- package/dist/chunk-LMMJSJTO.mjs +0 -2
- package/dist/chunk-LMMJSJTO.mjs.map +0 -1
- package/dist/chunk-RWBNLNQ6.mjs +0 -2
- package/dist/chunk-RWBNLNQ6.mjs.map +0 -1
- package/dist/chunk-V4H3X4PI.mjs +0 -2
- package/dist/chunk-V4H3X4PI.mjs.map +0 -1
- package/dist/chunk-WOMA746Z.mjs +0 -2
- package/dist/chunk-WOMA746Z.mjs.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/Classes/Enum.ts","../../src/Classes/Error.ts","../../src/Classes/Price.ts","../../src/Classes/TieredPrice.ts"],"names":["CurrencySymbolMap","CurrencyLocaleMap","InvalidTaxCategoryError","message","InvalidMinQuantityError","InvalidTieredPriceError","InvalidQuantityError","NoApplicableTierError","quantity","InvalidPriceAmountError","InvalidCurrencyCodeError","CurrencyMismatchError","InvalidArgumentError","PriceModel","_PriceModel","data","priceModel","factor","divisor","priceModels","minPrice","currentPrice","maxPrice","amount","currency","options","locale","valueToFormat","fractionDigits","formattingOptions","error","numStr","parts","integerPart","decimalPart","decimalPlaces","multiplier","TieredPriceModel","baseUnitPrice","tiers","tier","a","b","t","hasDifferentCurrency","hasIrregularPricing","index","basePriceExceedsFirstTier","i","lowestTierPrice","basePrice"],"mappings":"aAsCO,IAAMA,CAAoB,CAAA,CAC9B,GAAiC,CAAA,QACpC,CAEaC,CAAAA,CAAAA,CAAoB,CAC9B,GAAA,CAAiC,OACpC,CAAA,CCYO,IAAMC,CAAAA,CAAN,cAAsC,KAAM,CAC/C,WAAA,CAAYC,CAAkB,CAAA,4BAAA,CAA8B,CACxD,KAAA,CAAM,CAAuBA,oBAAAA,EAAAA,CAAO,CAAE,CAAA,CAAA,CACtC,IAAK,CAAA,IAAA,CAAO,0BAChB,CACJ,EAEaC,CAAN,CAAA,cAAsC,KAAM,CAC/C,WAAYD,CAAAA,CAAAA,CAAkB,6CAA+C,CAAA,CACzE,KAAM,CAAA,CAAA,oBAAA,EAAuBA,CAAO,CAAA,CAAE,CACtC,CAAA,IAAA,CAAK,IAAO,CAAA,0BAChB,CACJ,CAAA,CAEaE,CAAN,CAAA,cAAsC,KAAM,CAC/C,WAAYF,CAAAA,CAAAA,CAAiB,CACzB,KAAA,CAAM,CAAuBA,oBAAAA,EAAAA,CAAO,CAAE,CAAA,CAAA,CACtC,IAAK,CAAA,IAAA,CAAO,0BAChB,CACJ,CAAA,CAEaG,CAAN,CAAA,cAAmC,KAAM,CAC5C,WAAYH,CAAAA,CAAAA,CAAkB,qCAAuC,CAAA,CACjE,KAAM,CAAA,CAAA,iBAAA,EAAoBA,CAAO,CAAA,CAAE,CACnC,CAAA,IAAA,CAAK,IAAO,CAAA,uBAChB,CACJ,CAAA,CAEaI,CAAN,CAAA,cAAoC,KAAM,CAC7C,WAAYC,C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KAAK,KAAM,CAAA,MAAA,CAAS,CAAC,CAAA,CAAE,SAAU,CAAA,SAAA,EAC9DC,CAAAA,CAAAA,CAAY,IAAK,CAAA,aAAA,CAAc,SAAU,EAAA,CAE/C,OAASA,CAAAA,CAAAA,CAAYD,CAAmBC,EAAAA,CAAAA,CAAa,GACvD,CACF","file":"TieredPrice.js","sourcesContent":["/**\r\n * Represents the countries where the application operates or products are available.\r\n */\r\nexport enum OperationalCountry {\r\n /** India */ IN = 'IN',\r\n}\r\n \r\nexport enum OperationalCountryCurrency {\r\n /** India */ INR = 'INR',\r\n}\r\n\r\nexport enum OperationalLocale {\r\n /** India */ 'en-IN' = 'en-IN',\r\n /** India ( Kannada) */ 'kn-IN' = 'kn-IN'\r\n}\r\n\r\nexport enum OperationalLanguage {\r\n en = 'en',\r\n kn = 'kn'\r\n}\r\n\r\nexport const LocaleLanguageMap: Record<OperationalLocale, OperationalLanguage> = {\r\n [OperationalLocale[\"en-IN\"]]: OperationalLanguage.en,\r\n [OperationalLocale[\"kn-IN\"]]: OperationalLanguage.kn,\r\n}\r\n\r\nexport const LocaleCountryMap: Record<OperationalLocale, OperationalCountry> = {\r\n [OperationalLocale[\"en-IN\"]]: OperationalCountry.IN,\r\n [OperationalLocale[\"kn-IN\"]]: OperationalCountry.IN,\r\n}\r\n\r\n/**\r\n * Defines the supported ISO 4217 currency codes as an enumeration.\r\n */\r\nexport const CountryCurrencyMap = {\r\n /** India */ [OperationalCountry.IN]: OperationalCountryCurrency.INR,\r\n};\r\n\r\nexport const CurrencySymbolMap = {\r\n [OperationalCountryCurrency.INR]: '₹',\r\n}\r\n\r\nexport const CurrencyLocaleMap = {\r\n [OperationalCountryCurrency.INR]: OperationalLocale[\"en-IN\"],\r\n}\r\n\r\n/**\r\n * Defines standard gender categories for product targeting.\r\n */\r\nexport enum GenderCategory {\r\n MALE = 'Male',\r\n FEMALE = 'Female',\r\n UNISEX = 'Unisex',\r\n KIDS = 'Kids',\r\n BOY = 'Boy',\r\n GIRL = 'Girl',\r\n GENERAL = 'General',\r\n}\r\n\r\nexport enum ImageCategory {\r\n PRIMARY = 'PRIMARY',\r\n GALLERY = 'GALLERY'\r\n}\r\n\r\nexport enum TaxCategory {\r\n APPAREL = 'apparel',\r\n EXEMPT = 'exempt'\r\n}\r\n\r\nexport enum TaxSystem {\r\n GST = 'GST',\r\n}\r\n\r\n/**\r\n * LineItemState\r\n * \r\n * INITIAL: Item added to order, not yet processed.\r\n * PROCESSING: Item is being prepared for shipment.\r\n * SHIPPED: Item dispatched to customer.\r\n * DELIVERED: Item delivered to customer.\r\n * CANCELLED: Item cancelled before shipment or delivery.\r\n * RETURN_REQUESTED: Customer requests to return item.\r\n * RETURNED: Item received back from customer.\r\n * REFUND_INITIATED: Refund initiated for item.\r\n * REFUNDED: Refund processed for item.\r\n * ON_HOLD: Item is paused due to payment, inventory, or other issues.\r\n */\r\nexport enum LineItemState {\r\n INITIAL = \"INITIAL\",\r\n PROCESSING = \"PROCESSING\",\r\n SHIPPED = \"SHIPPED\",\r\n DELIVERED = \"DELIVERED\",\r\n CANCELLED = \"CANCELLED\",\r\n RETURN_REQUESTED = \"RETURN_REQUESTED\",\r\n RETURNED = \"RETURNED\",\r\n REFUND_INITIATED = \"REFUND_INITIATED\",\r\n REFUNDED = \"REFUNDED\",\r\n ON_HOLD = \"ON_HOLD\",\r\n}","export class LineItemNotFoundError extends Error {\r\n constructor(lineItemId: string) {\r\n super(`Line item with ID '${lineItemId}' not found in the cart.`);\r\n this.name = 'LineItemNotFoundError';\r\n }\r\n}\r\n\r\nexport class DuplicateSizeError extends Error {\r\n constructor(size: string) {\r\n super(`Duplicate size found: ${size}`);\r\n this.name = 'DuplicateSizeError';\r\n }\r\n}\r\n\r\nexport class ProductMismatchError extends Error {\r\n constructor(message: string = \"Product and selection attributes do not match.\") {\r\n super(`ProductMismatch: ${message}`);\r\n this.name = 'ProductMismatchError';\r\n }\r\n}\r\n\r\nexport class ProductInactiveError extends Error {\r\n constructor(message: string = \"Product is not active.\") {\r\n super(`ProductInactive: ${message}`);\r\n this.name = 'ProductInactiveError';\r\n }\r\n}\r\n\r\nexport class SelectionAttributeParseError extends Error {\r\n constructor(message: string = \"Failed to parse selection attributes key.\") {\r\n super(`SelectionAttributeParseError: ${message}`);\r\n this.name = 'SelectionAttributeParseError';\r\n }\r\n}\r\n\r\nexport class SizeMismatchError extends Error {\r\n constructor(message: string = \"Size does not match.\") {\r\n super(`SizeMismatch: ${message}`);\r\n this.name = 'SizeMismatchError';\r\n }\r\n}\r\n\r\nexport class PricingNotFoundError extends Error {\r\n constructor(message: string = \"Pricing details not available for the product\") {\r\n super(`NotFound: ${message}`);\r\n this.name = 'PricingNotFoundError';\r\n }\r\n}\r\n\r\nexport class InvalidTaxRuleError extends Error {\r\n constructor(message: string = \"Tax rule category mismatch.\") {\r\n super(`InvalidTaxRule: ${message}`);\r\n this.name = 'InvalidTaxRuleError';\r\n }\r\n}\r\n\r\nexport class InvalidTaxCategoryError extends Error {\r\n constructor(message: string = \"Tax category is not valid.\") {\r\n super(`InvalidTaxCategory: ${message}`);\r\n this.name = 'InvalidTaxCategoryError';\r\n }\r\n}\r\n\r\nexport class InvalidMinQuantityError extends Error {\r\n constructor(message: string = \"Minimum quantity must be greater than zero.\") {\r\n super(`InvalidMinQuantity: ${message}`);\r\n this.name = 'InvalidMinQuantityError';\r\n }\r\n}\r\n\r\nexport class InvalidTieredPriceError extends Error {\r\n constructor(message: string) {\r\n super(`InvalidTieredPrice: ${message}`);\r\n this.name = 'InvalidTieredPriceError';\r\n }\r\n}\r\n\r\nexport class InvalidQuantityError extends Error {\r\n constructor(message: string = \"Quantity must be greater than zero.\") {\r\n super(`InvalidQuantity: ${message}`);\r\n this.name = 'InvalidQuantityError';\r\n }\r\n}\r\n\r\nexport class NoApplicableTierError extends Error {\r\n constructor(quantity: number) {\r\n super(`NoApplicableTier: Quantity ${quantity} does not meet the minimum purchase requirement.`);\r\n this.name = 'NoApplicableTierError';\r\n }\r\n}\r\n\r\nexport class TaxSlabNotFoundError extends Error {\r\n constructor(message: string = \"No applicable tax slab or multiple slabs found for the given unit price.\") {\r\n super(`TaxSlabNotFound: ${message}`);\r\n this.name = 'TaxSlabNotFoundError';\r\n }\r\n}\r\n\r\nexport class InvalidPriceAmountError extends Error {\r\n constructor(message: string = \"Amount cannot be negative.\") {\r\n super(`InvalidAmount: ${message}`);\r\n this.name = 'InvalidPriceAmountError';\r\n }\r\n}\r\n\r\nexport class InvalidCurrencyCodeError extends Error {\r\n constructor(message: string = \"Currency code is required.\") {\r\n super(`InvalidCurrency: ${message}`);\r\n this.name = 'InvalidCurrencyCodeError';\r\n }\r\n}\r\n\r\nexport class CurrencyMismatchError extends Error {\r\n constructor(message: string = \"Cannot perform operation on prices with different currencies.\") {\r\n super(`CurrencyMismatch: ${message}`);\r\n this.name = 'CurrencyMismatchError';\r\n }\r\n}\r\n\r\nexport class InvalidArgumentError extends Error {\r\n constructor(message: string) {\r\n super(`InvalidArgument: ${message}`);\r\n this.name = 'InvalidArgumentError';\r\n }\r\n}\r\n\r\nexport class InvalidImageSourceError extends Error {\r\n constructor(message: string = \"Invalid image source configuration.\") {\r\n super(`InvalidImageSource: ${message}`);\r\n this.name = 'InvalidImageSourceError';\r\n }\r\n}","import { CurrencyCode } from \"./Common\";\r\nimport { CurrencyLocaleMap, CurrencySymbolMap, OperationalCountryCurrency } from \"./Enum\";\r\nimport {\r\n InvalidPriceAmountError,\r\n InvalidCurrencyCodeError,\r\n CurrencyMismatchError,\r\n InvalidArgumentError\r\n} from \"./Error\";\r\n\r\nexport type PriceAttributes = {\r\n amount: number;\r\n currency: CurrencyCode;\r\n}\r\n\r\nexport type PriceData = PriceAttributes;\r\n\r\nexport default class PriceModel {\r\n protected amount: number;\r\n protected currency: CurrencyCode;\r\n\r\n /**\r\n * Creates an instance of PriceModel, storing the currency-correct rounded price.\r\n * @param amount - The initial price value.\r\n * @param currency - The currency code used for rounding and determining the currency symbol.\r\n * @throws {Error} If price is negative or country/currency mapping is missing.\r\n */\r\n constructor(data: PriceAttributes) {\r\n if (data.amount < 0) {\r\n throw new InvalidPriceAmountError(\"Amount cannot be negative.\");\r\n }\r\n\r\n if (!data.currency) {\r\n throw new InvalidCurrencyCodeError(\"Currency code is required.\");\r\n }\r\n\r\n this.amount = data.amount;\r\n this.currency = data.currency;\r\n }\r\n\r\n /**\r\n * Gets the currency associated with this price instance.\r\n * @returns The CurrencyCode enum value.\r\n */\r\n public getCurrency(): CurrencyCode {\r\n return this.currency;\r\n }\r\n\r\n /**\r\n * Returns the raw numeric price value.\r\n */\r\n public getAmount(): number {\r\n return this.amount;\r\n }\r\n\r\n /**\r\n *\r\n * @returns PriceData\r\n */\r\n public getDetails(): PriceData {\r\n return {\r\n amount: this.amount,\r\n currency: this.currency\r\n }\r\n }\r\n\r\n /**\r\n * Compares this price with another {@link PriceModel} instance.\r\n *\r\n * The comparison is performed using the numeric price value and is only valid\r\n * when both prices are expressed in the same currency.\r\n *\r\n * ### Comparison result:\r\n * - Returns a **negative number** if this price is **less than** `priceModel`\r\n * - Returns **zero** if both prices are **equal**\r\n * - Returns a **positive number** if this price is **greater than** `priceModel`\r\n *\r\n * @param priceModel - The {@link PriceModel} instance to compare against.\r\n *\r\n * @returns\r\n * A signed number representing the comparison result:\r\n * - `< 0` → this price is lower\r\n * - `0` → prices are equal\r\n * - `> 0` → this price is higher\r\n *\r\n * @throws {Error}\r\n * Throws an error if:\r\n * - `priceModel` is not an instance of {@link PriceModel}\r\n * - The currencies of the two prices do not match\r\n *\r\n * @example\r\n * ```ts\r\n * const a = new PriceModel(\"USD\", 100);\r\n * const b = new PriceModel(\"USD\", 150);\r\n *\r\n * a.compareTo(b); // -50\r\n * b.compareTo(a); // 50\r\n * a.compareTo(a); // 0\r\n * ```\r\n */\r\n public compareTo(priceModel: PriceModel): number {\r\n if (!(priceModel instanceof PriceModel)) {\r\n throw new InvalidArgumentError(\"Must be a PriceModel instance.\");\r\n } else if (this.currency !== priceModel.getCurrency()) {\r\n throw new CurrencyMismatchError(\"Cannot compare prices in different currencies.\");\r\n }\r\n\r\n return this.amount - priceModel.getAmount();\r\n }\r\n\r\n public add(priceModel: PriceModel): PriceModel {\r\n if (!(priceModel instanceof PriceModel)) {\r\n throw new InvalidArgumentError(\"Must be a PriceModel instance.\");\r\n } else if (this.currency !== priceModel.getCurrency()) {\r\n throw new CurrencyMismatchError(\"Cannot add prices in different currencies.\");\r\n }\r\n\r\n return new PriceModel({\r\n amount: this.amount + priceModel.getAmount(),\r\n currency: this.currency\r\n });\r\n }\r\n\r\n public subtract(priceModel: PriceModel): PriceModel {\r\n if (!(priceModel instanceof PriceModel)) {\r\n throw new InvalidArgumentError(\"Must be a PriceModel instance.\");\r\n } else if (this.currency !== priceModel.getCurrency()) {\r\n throw new CurrencyMismatchError(\"Cannot subtract prices in different currencies.\");\r\n }\r\n\r\n return new PriceModel({\r\n amount: this.amount - priceModel.getAmount(),\r\n currency: this.currency\r\n });\r\n }\r\n\r\n public multiply(factor: number | PriceModel): PriceModel {\r\n if (factor instanceof PriceModel) {\r\n if (this.currency !== factor.getCurrency()) {\r\n throw new CurrencyMismatchError(\"Cannot multiply prices in different currencies.\");\r\n }\r\n return new PriceModel({\r\n amount: this.amount * factor.getAmount(),\r\n currency: this.currency\r\n });\r\n } else if (typeof factor === \"number\" && factor >= 0) {\r\n return new PriceModel({\r\n amount: this.amount * factor,\r\n currency: this.currency\r\n });\r\n }\r\n\r\n throw new InvalidArgumentError(\"Must be a non-negative number.\");\r\n }\r\n\r\n public divide(divisor: number | PriceModel): PriceModel {\r\n if (divisor instanceof PriceModel) {\r\n if (this.currency !== divisor.getCurrency()) {\r\n throw new CurrencyMismatchError(\"Cannot divide prices in different currencies.\");\r\n }\r\n return new PriceModel({\r\n amount: this.amount / divisor.getAmount(),\r\n currency: this.currency\r\n });\r\n } else if (typeof divisor === \"number\" && divisor > 0) {\r\n return new PriceModel({\r\n amount: this.amount / divisor,\r\n currency: this.currency\r\n });\r\n }\r\n\r\n throw new InvalidArgumentError(\"Must be a positive number.\");\r\n }\r\n\r\n public min(...priceModels: PriceModel[]): PriceModel {\r\n if (priceModels.length === 0) {\r\n throw new InvalidArgumentError(\"Must provide at least one PriceModel.\");\r\n }\r\n\r\n return priceModels.reduce((minPrice, currentPrice) => {\r\n if (!(currentPrice instanceof PriceModel)) {\r\n throw new InvalidArgumentError(\"Must be a PriceModel instance.\");\r\n } else if (minPrice.getCurrency() !== currentPrice.getCurrency()) {\r\n throw new CurrencyMismatchError(\"Cannot compare prices in different currencies.\");\r\n }\r\n\r\n return minPrice.compareTo(currentPrice) < 0 ? minPrice : currentPrice;\r\n });\r\n }\r\n\r\n public max(...priceModels: PriceModel[]): PriceModel {\r\n if (priceModels.length === 0) {\r\n throw new InvalidArgumentError(\"Must provide at least one PriceModel.\");\r\n }\r\n\r\n return priceModels.reduce((maxPrice, currentPrice) => {\r\n if (!(currentPrice instanceof PriceModel)) {\r\n throw new InvalidArgumentError(\"Must be a PriceModel instance.\");\r\n } else if (maxPrice.getCurrency() !== currentPrice.getCurrency()) {\r\n throw new CurrencyMismatchError(\"Cannot compare prices in different currencies.\");\r\n }\r\n\r\n return maxPrice.compareTo(currentPrice) > 0 ? maxPrice : currentPrice;\r\n });\r\n }\r\n\r\n /**\r\n * Gets a zero value PriceModel for the same currency.\r\n * @returns A PriceModel instance representing zero in the same currency.\r\n */\r\n public zero(): PriceModel {\r\n return new PriceModel({\r\n currency: this.currency,\r\n amount: 0\r\n });\r\n }\r\n\r\n /**\r\n * Checks if the price is zero.\r\n * @returns True if the price is zero, false otherwise.\r\n */\r\n public isZero(): boolean {\r\n return this.amount === 0;\r\n }\r\n\r\n\r\n public round(): PriceModel {\r\n return new PriceModel({\r\n currency: this.currency,\r\n amount: this.getRoundedAmount()\r\n });\r\n }\r\n /**\r\n * Gets the rounded price value based on standard currency rules.\r\n * @returns The numeric price, rounded according to its currency's typical decimal places.\r\n */\r\n public getRoundedAmount(): number {\r\n return PriceModel.getRoundedAmount(this.amount, this.currency);\r\n }\r\n\r\n /**\r\n * Gets a locale-aware formatted display string for the price stored in this instance.\r\n * Uses the static `PriceModel.getFormattedString` method for the actual formatting.\r\n * @returns The formatted price string according to locale rules.\r\n */\r\n public getFormattedString() {\r\n return PriceModel.getFormattedString(this.amount, this.currency);\r\n }\r\n\r\n\r\n /**\r\n * Gets a locale-aware formatted display string for the amount.\r\n * Uses Intl.NumberFormat for accurate formatting based on locale and currency.\r\n * @param amount - The initial amount value.\r\n * @param currency - The currency code for formatting.\r\n * @param options - Configuration options for formatting.\r\n * @param options.displayAsInteger - If true, the formatted string will show the amount rounded to the next nearest integer (no decimals). Defaults to false.\r\n * @param options.style - The style of formatting, either 'currency' or 'decimal'. Defaults to 'currency'.\r\n * @param options.currencyDisplay - The display format for the currency symbol. Options are 'symbol', 'narrowSymbol', 'code', or 'name'. Defaults to 'symbol'.\r\n * @returns The formatted price string according to locale rules.\r\n * @throws {Error} If currency code is invalid.\r\n */\r\n static getFormattedString(amount: number, currency: CurrencyCode, options: {\r\n displayAsInteger?: boolean,\r\n style?: 'currency' | 'decimal',\r\n currencyDisplay?: 'symbol' | 'narrowSymbol' | 'code' | 'name'\r\n } = {\r\n displayAsInteger: false,\r\n style: 'currency',\r\n currencyDisplay: 'symbol'\r\n }): string {\r\n\r\n const locale = CurrencyLocaleMap[currency];\r\n if (!currency || !locale) {\r\n throw new InvalidCurrencyCodeError('Invalid currency code for formatting.');\r\n }\r\n\r\n let valueToFormat = amount;\r\n const fractionDigits = options.displayAsInteger ? 0 : PriceModel.getDecimalPlaces(currency);\r\n\r\n let formattingOptions: Intl.NumberFormatOptions = {\r\n style: options.style ?? 'currency',\r\n currency: currency,\r\n signDisplay: 'never',\r\n currencyDisplay: options.currencyDisplay,\r\n minimumFractionDigits: fractionDigits,\r\n maximumFractionDigits: fractionDigits,\r\n };\r\n\r\n if (options.displayAsInteger) {\r\n valueToFormat = Math.ceil(valueToFormat);\r\n }\r\n\r\n try {\r\n return new Intl.NumberFormat(locale, formattingOptions).format(valueToFormat);\r\n } catch (error) {\r\n console.error(`Error formatting price for currency \"${currency}\" and locale \"${locale}\":`, error);\r\n // Basic fallback without symbol if Intl fails completely\r\n return `${CurrencySymbolMap[currency] ?? currency} ${PriceModel.addThousandSeparators(valueToFormat.toFixed(fractionDigits))}`;\r\n }\r\n }\r\n\r\n /**\r\n * Helper method to determine standard decimal places for a currency.\r\n * @param currency - The currency code.\r\n * @returns The number of decimal places (0, 2, or 3 based on common rules).\r\n */\r\n private static getDecimalPlaces(currency: CurrencyCode): number {\r\n switch (currency) {\r\n case OperationalCountryCurrency.INR:\r\n default:\r\n return 2;\r\n }\r\n }\r\n\r\n /**\r\n * Adds basic thousand separators (commas) to a number string.\r\n * Does not handle different locale separators (e.g., periods, spaces).\r\n * @param numStr - The number string (potentially with decimals).\r\n * @returns The number string with commas added.\r\n */\r\n private static addThousandSeparators(numStr: string): string {\r\n const parts = numStr.split('.');\r\n const integerPart = parts[0];\r\n const decimalPart = parts.length > 1 ? '.' + parts[1] : '';\r\n\r\n const formattedInteger = integerPart.replace(/\\B(?=(\\d{3})+(?!\\d))/g, ',');\r\n return formattedInteger + decimalPart;\r\n }\r\n\r\n /**\r\n * Rounds a price value according to the standard decimal places\r\n * for the currency associated with the given country.\r\n *\r\n * @param price - The price value to round. Must be a non-negative number.\r\n * @param currency - The currency code to determine the rounding rules.\r\n * @returns The rounded price as a number.\r\n * @throws {Error} If the price is negative or currency is invalid.\r\n */\r\n static getRoundedAmount(amount: number, currency: CurrencyCode): number {\r\n if (amount < 0) {\r\n throw new InvalidPriceAmountError(\"Amount cannot be negative for rounding.\");\r\n }\r\n\r\n if (currency === undefined) {\r\n throw new InvalidCurrencyCodeError('Invalid currency code for rounding.');\r\n }\r\n\r\n const decimalPlaces = PriceModel.getDecimalPlaces(currency);\r\n const multiplier = Math.pow(10, decimalPlaces);\r\n const roundedValue = Math.round(amount * multiplier) / multiplier;\r\n\r\n return roundedValue;\r\n }\r\n}","import { TaxCategory } from \"./Enum\";\r\nimport PriceModel, { PriceData } from \"./Price\";\r\nimport {\r\n InvalidTaxCategoryError,\r\n InvalidMinQuantityError,\r\n InvalidTieredPriceError,\r\n InvalidQuantityError,\r\n NoApplicableTierError\r\n} from \"./Error\";\r\n\r\n/**\r\n * Represents a pricing tier based on a minimum purchase quantity.\r\n */\r\nexport type PriceTier = {\r\n minQuantity: number;\r\n unitPrice: PriceModel;\r\n};\r\n\r\n/**\r\n * Represents the attributes required for tiered pricing.\r\n */\r\nexport type TieredPriceAttributes = {\r\n baseUnitPrice: PriceData;\r\n taxCategory: TaxCategory;\r\n\r\n /** Quantity-based pricing tiers */\r\n tiers: {\r\n minQuantity: number;\r\n unitPrice: PriceData;\r\n }[];\r\n};\r\n\r\nexport type TieredPriceData = TieredPriceAttributes;\r\n\r\nexport class TieredPriceModel {\r\n protected baseUnitPrice: PriceModel;\r\n protected taxCategory: TaxCategory;\r\n protected tiers: PriceTier[];\r\n\r\n /** Constructor\r\n * Initializes the tiered pricing model with the provided attributes.\r\n * @param data - The tiered pricing attributes.\r\n *\r\n * @throws {Error}\r\n * - If the tax category is not valid\r\n * - If any tier has an invalid minimum quantity or unit price\r\n * - If the base unit price is not valid\r\n */\r\n constructor(data: TieredPriceAttributes) {\r\n const baseUnitPrice = new PriceModel(data.baseUnitPrice);\r\n\r\n if (!data.taxCategory) {\r\n throw new InvalidTaxCategoryError();\r\n }\r\n\r\n const tiers = (data.tiers ?? [])\r\n .map(tier => ({\r\n minQuantity: tier.minQuantity,\r\n unitPrice: new PriceModel(tier.unitPrice),\r\n }))\r\n .sort((a, b) => a.minQuantity - b.minQuantity);\r\n\r\n const hasInvalidMinQuantity = tiers.some(t => t.minQuantity <= 0);\r\n if (hasInvalidMinQuantity) {\r\n throw new InvalidMinQuantityError();\r\n }\r\n\r\n const hasDifferentCurrency = tiers.some(\r\n t => t.unitPrice.getCurrency() !== baseUnitPrice.getCurrency()\r\n );\r\n const hasIrregularPricing = tiers.some(\r\n (tier, index) =>\r\n index > 0 &&\r\n tier.unitPrice.compareTo(tiers[index - 1].unitPrice) > 0\r\n );\r\n const basePriceExceedsFirstTier = tiers[0]?.unitPrice.compareTo(baseUnitPrice) > 0;\r\n\r\n if (hasDifferentCurrency || hasIrregularPricing || basePriceExceedsFirstTier) {\r\n throw new InvalidTieredPriceError(\r\n \"Tiers must share the same currency and must not increase in unit price.\"\r\n );\r\n }\r\n\r\n this.baseUnitPrice = baseUnitPrice;\r\n this.taxCategory = data.taxCategory;\r\n this.tiers = tiers;\r\n }\r\n\r\n /** \r\n * Returns the base unit price \r\n * @returns The base unit price as a PriceModel instance.\r\n */\r\n getBaseUnitPrice(): PriceModel {\r\n return this.baseUnitPrice;\r\n }\r\n\r\n /** \r\n * Returns the tax category \r\n * @returns The tax category as a TaxCategory enum value.\r\n */\r\n getTaxCategory(): TaxCategory {\r\n return this.taxCategory;\r\n }\r\n\r\n /** \r\n * Returns all pricing tiers sorted by minimum quantity \r\n * @returns An array of PriceTier objects.\r\n */\r\n getTiers(): readonly PriceTier[] {\r\n return this.tiers;\r\n }\r\n\r\n getDetails(): TieredPriceData {\r\n return {\r\n baseUnitPrice: this.baseUnitPrice.getDetails(),\r\n taxCategory: this.taxCategory,\r\n tiers: this.tiers.map(tier => ({\r\n minQuantity: tier.minQuantity,\r\n unitPrice: tier.unitPrice.getDetails()\r\n }))\r\n };\r\n }\r\n\r\n /**\r\n * Returns the applicable unit price for a given quantity.\r\n *\r\n * @param quantity - Purchase quantity\r\n * @returns The unit price for the highest applicable tier\r\n *\r\n * @throws {Error}\r\n * - If quantity is less than or equal to zero\r\n * - If quantity does not meet the minimum requirement of any tier\r\n */\r\n getApplicableTier(quantity: number): PriceTier {\r\n if (quantity <= 0) {\r\n throw new InvalidQuantityError();\r\n }\r\n\r\n for (let i = this.tiers.length - 1; i >= 0; i--) {\r\n if (quantity >= this.tiers[i].minQuantity) {\r\n return this.tiers[i];\r\n }\r\n }\r\n\r\n throw new NoApplicableTierError(quantity);\r\n }\r\n\r\n /**\r\n * Returns the minimum quantity required to purchase this product.\r\n */\r\n getMinQuantity(): number {\r\n return this.tiers[0]?.minQuantity ?? 1;\r\n }\r\n\r\n /**\r\n * Returns the maximum discount percentage achievable compared to the base unit price.\r\n */\r\n getMaxDiscountPercent(): number {\r\n if (!this.tiers.length) return 0;\r\n\r\n const lowestTierPrice = this.tiers[this.tiers.length - 1].unitPrice.getAmount();\r\n const basePrice = this.baseUnitPrice.getAmount();\r\n\r\n return ((basePrice - lowestTierPrice) / basePrice) * 100;\r\n }\r\n}\r\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"TieredPrice.mjs"}
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import { OperationalCountry, OperationalCountryCurrency, OperationalLocale, OperationalLanguage } from './Classes/Enum.js';
|
|
2
|
+
|
|
3
|
+
type PriceAttributes = {
|
|
4
|
+
amount: number;
|
|
5
|
+
currency: CurrencyCode;
|
|
6
|
+
};
|
|
7
|
+
type PriceData = PriceAttributes;
|
|
8
|
+
declare class PriceModel {
|
|
9
|
+
protected amount: number;
|
|
10
|
+
protected currency: CurrencyCode;
|
|
11
|
+
/**
|
|
12
|
+
* Creates an instance of PriceModel, storing the currency-correct rounded price.
|
|
13
|
+
* @param amount - The initial price value.
|
|
14
|
+
* @param currency - The currency code used for rounding and determining the currency symbol.
|
|
15
|
+
* @throws {Error} If price is negative or country/currency mapping is missing.
|
|
16
|
+
*/
|
|
17
|
+
constructor(data: PriceAttributes);
|
|
18
|
+
/**
|
|
19
|
+
* Gets the currency associated with this price instance.
|
|
20
|
+
* @returns The CurrencyCode enum value.
|
|
21
|
+
*/
|
|
22
|
+
getCurrency(): CurrencyCode;
|
|
23
|
+
/**
|
|
24
|
+
* Returns the raw numeric price value.
|
|
25
|
+
*/
|
|
26
|
+
getAmount(): number;
|
|
27
|
+
/**
|
|
28
|
+
*
|
|
29
|
+
* @returns PriceData
|
|
30
|
+
*/
|
|
31
|
+
getDetails(): PriceData;
|
|
32
|
+
/**
|
|
33
|
+
* Compares this price with another {@link PriceModel} instance.
|
|
34
|
+
*
|
|
35
|
+
* The comparison is performed using the numeric price value and is only valid
|
|
36
|
+
* when both prices are expressed in the same currency.
|
|
37
|
+
*
|
|
38
|
+
* ### Comparison result:
|
|
39
|
+
* - Returns a **negative number** if this price is **less than** `priceModel`
|
|
40
|
+
* - Returns **zero** if both prices are **equal**
|
|
41
|
+
* - Returns a **positive number** if this price is **greater than** `priceModel`
|
|
42
|
+
*
|
|
43
|
+
* @param priceModel - The {@link PriceModel} instance to compare against.
|
|
44
|
+
*
|
|
45
|
+
* @returns
|
|
46
|
+
* A signed number representing the comparison result:
|
|
47
|
+
* - `< 0` → this price is lower
|
|
48
|
+
* - `0` → prices are equal
|
|
49
|
+
* - `> 0` → this price is higher
|
|
50
|
+
*
|
|
51
|
+
* @throws {Error}
|
|
52
|
+
* Throws an error if:
|
|
53
|
+
* - `priceModel` is not an instance of {@link PriceModel}
|
|
54
|
+
* - The currencies of the two prices do not match
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```ts
|
|
58
|
+
* const a = new PriceModel("USD", 100);
|
|
59
|
+
* const b = new PriceModel("USD", 150);
|
|
60
|
+
*
|
|
61
|
+
* a.compareTo(b); // -50
|
|
62
|
+
* b.compareTo(a); // 50
|
|
63
|
+
* a.compareTo(a); // 0
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
compareTo(priceModel: PriceModel): number;
|
|
67
|
+
add(priceModel: PriceModel): PriceModel;
|
|
68
|
+
subtract(priceModel: PriceModel): PriceModel;
|
|
69
|
+
multiply(factor: number | PriceModel): PriceModel;
|
|
70
|
+
divide(divisor: number | PriceModel): PriceModel;
|
|
71
|
+
min(...priceModels: PriceModel[]): PriceModel;
|
|
72
|
+
max(...priceModels: PriceModel[]): PriceModel;
|
|
73
|
+
/**
|
|
74
|
+
* Gets a zero value PriceModel for the same currency.
|
|
75
|
+
* @returns A PriceModel instance representing zero in the same currency.
|
|
76
|
+
*/
|
|
77
|
+
zero(): PriceModel;
|
|
78
|
+
/**
|
|
79
|
+
* Checks if the price is zero.
|
|
80
|
+
* @returns True if the price is zero, false otherwise.
|
|
81
|
+
*/
|
|
82
|
+
isZero(): boolean;
|
|
83
|
+
round(): PriceModel;
|
|
84
|
+
/**
|
|
85
|
+
* Gets the rounded price value based on standard currency rules.
|
|
86
|
+
* @returns The numeric price, rounded according to its currency's typical decimal places.
|
|
87
|
+
*/
|
|
88
|
+
getRoundedAmount(): number;
|
|
89
|
+
/**
|
|
90
|
+
* Gets a locale-aware formatted display string for the price stored in this instance.
|
|
91
|
+
* Uses the static `PriceModel.getFormattedString` method for the actual formatting.
|
|
92
|
+
* @returns The formatted price string according to locale rules.
|
|
93
|
+
*/
|
|
94
|
+
getFormattedString(): string;
|
|
95
|
+
/**
|
|
96
|
+
* Gets a locale-aware formatted display string for the amount.
|
|
97
|
+
* Uses Intl.NumberFormat for accurate formatting based on locale and currency.
|
|
98
|
+
* @param amount - The initial amount value.
|
|
99
|
+
* @param currency - The currency code for formatting.
|
|
100
|
+
* @param options - Configuration options for formatting.
|
|
101
|
+
* @param options.displayAsInteger - If true, the formatted string will show the amount rounded to the next nearest integer (no decimals). Defaults to false.
|
|
102
|
+
* @param options.style - The style of formatting, either 'currency' or 'decimal'. Defaults to 'currency'.
|
|
103
|
+
* @param options.currencyDisplay - The display format for the currency symbol. Options are 'symbol', 'narrowSymbol', 'code', or 'name'. Defaults to 'symbol'.
|
|
104
|
+
* @returns The formatted price string according to locale rules.
|
|
105
|
+
* @throws {Error} If currency code is invalid.
|
|
106
|
+
*/
|
|
107
|
+
static getFormattedString(amount: number, currency: CurrencyCode, options?: {
|
|
108
|
+
displayAsInteger?: boolean;
|
|
109
|
+
style?: 'currency' | 'decimal';
|
|
110
|
+
currencyDisplay?: 'symbol' | 'narrowSymbol' | 'code' | 'name';
|
|
111
|
+
}): string;
|
|
112
|
+
/**
|
|
113
|
+
* Helper method to determine standard decimal places for a currency.
|
|
114
|
+
* @param currency - The currency code.
|
|
115
|
+
* @returns The number of decimal places (0, 2, or 3 based on common rules).
|
|
116
|
+
*/
|
|
117
|
+
private static getDecimalPlaces;
|
|
118
|
+
/**
|
|
119
|
+
* Adds basic thousand separators (commas) to a number string.
|
|
120
|
+
* Does not handle different locale separators (e.g., periods, spaces).
|
|
121
|
+
* @param numStr - The number string (potentially with decimals).
|
|
122
|
+
* @returns The number string with commas added.
|
|
123
|
+
*/
|
|
124
|
+
private static addThousandSeparators;
|
|
125
|
+
/**
|
|
126
|
+
* Rounds a price value according to the standard decimal places
|
|
127
|
+
* for the currency associated with the given country.
|
|
128
|
+
*
|
|
129
|
+
* @param price - The price value to round. Must be a non-negative number.
|
|
130
|
+
* @param currency - The currency code to determine the rounding rules.
|
|
131
|
+
* @returns The rounded price as a number.
|
|
132
|
+
* @throws {Error} If the price is negative or currency is invalid.
|
|
133
|
+
*/
|
|
134
|
+
static getRoundedAmount(amount: number, currency: CurrencyCode): number;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
type Prettify<T> = {
|
|
138
|
+
[K in keyof T]: T[K];
|
|
139
|
+
} & {};
|
|
140
|
+
/**
|
|
141
|
+
* Represents a ISO 3166-1 alpha-2 country code (e.g., 'US', 'IN').
|
|
142
|
+
*/
|
|
143
|
+
type CountryCode = keyof typeof OperationalCountry;
|
|
144
|
+
/**
|
|
145
|
+
* Represents a ISO 4217 currency code (e.g., 'INR', 'USD').
|
|
146
|
+
*/
|
|
147
|
+
type CurrencyCode = keyof typeof OperationalCountryCurrency;
|
|
148
|
+
/**
|
|
149
|
+
* /**
|
|
150
|
+
* Represents a value that can be localized into multiple languages.
|
|
151
|
+
* The 'en' property is mandatory and serves as the default English translation.
|
|
152
|
+
* Additional properties can be added for other locales using their respective locale codes.
|
|
153
|
+
*/
|
|
154
|
+
type LocalizedValue<T> = Prettify<{
|
|
155
|
+
en: T;
|
|
156
|
+
} & {
|
|
157
|
+
[locale in Exclude<LocaleCode | LanguageCode, 'en'>]?: T;
|
|
158
|
+
}>;
|
|
159
|
+
/**
|
|
160
|
+
* /**
|
|
161
|
+
* Represents a string that can be localized into multiple languages.
|
|
162
|
+
* The 'en' property is mandatory and serves as the default English translation.
|
|
163
|
+
* Additional properties can be added for other locales using their respective locale codes.
|
|
164
|
+
*/
|
|
165
|
+
type LocalizedString = LocalizedValue<string>;
|
|
166
|
+
/**
|
|
167
|
+
* Represents a BCP 47 language tag (e.g., 'en-US', 'fr-FR').
|
|
168
|
+
* Used to identify languages and regional variations.
|
|
169
|
+
*/
|
|
170
|
+
type LocaleCode = keyof typeof OperationalLocale;
|
|
171
|
+
type LanguageCode = keyof typeof OperationalLanguage;
|
|
172
|
+
type Color = {
|
|
173
|
+
name: string;
|
|
174
|
+
hex?: string;
|
|
175
|
+
};
|
|
176
|
+
/**
|
|
177
|
+
* Represents a date and time string formatted according to the ISO 8601 standard.
|
|
178
|
+
* Example: "2023-10-27T10:30:00.000Z"
|
|
179
|
+
*/
|
|
180
|
+
type ISODateTimeUTC = string;
|
|
181
|
+
type RegionalPrice = {
|
|
182
|
+
[country in CountryCode]?: PriceData;
|
|
183
|
+
};
|
|
184
|
+
interface ShippingDetails {
|
|
185
|
+
courierName: string;
|
|
186
|
+
courierId?: string;
|
|
187
|
+
serviceType?: string;
|
|
188
|
+
rating?: number;
|
|
189
|
+
estimatedDeliveryDays?: number;
|
|
190
|
+
cost: number;
|
|
191
|
+
currency?: string;
|
|
192
|
+
isFallback: boolean;
|
|
193
|
+
trackingUrl?: string;
|
|
194
|
+
deliveryType?: string;
|
|
195
|
+
insuranceAmount?: number;
|
|
196
|
+
weight?: number;
|
|
197
|
+
dimensions?: {
|
|
198
|
+
length: number;
|
|
199
|
+
width: number;
|
|
200
|
+
height: number;
|
|
201
|
+
unit?: string;
|
|
202
|
+
};
|
|
203
|
+
pickupDate?: string;
|
|
204
|
+
deliveryDate?: string;
|
|
205
|
+
status?: string;
|
|
206
|
+
rawApiData?: any;
|
|
207
|
+
[key: string]: any;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
export { type CountryCode as C, type ISODateTimeUTC as I, type LocaleCode as L, type PriceData as P, type RegionalPrice as R, type ShippingDetails as S, type CurrencyCode as a, PriceModel as b, type LocalizedString as c, type LocalizedValue as d, type Prettify as e, type Color as f, type PriceAttributes as g, type LanguageCode as h };
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import { OperationalCountry, OperationalCountryCurrency, OperationalLocale, OperationalLanguage } from './Classes/Enum.mjs';
|
|
2
|
+
|
|
3
|
+
type PriceAttributes = {
|
|
4
|
+
amount: number;
|
|
5
|
+
currency: CurrencyCode;
|
|
6
|
+
};
|
|
7
|
+
type PriceData = PriceAttributes;
|
|
8
|
+
declare class PriceModel {
|
|
9
|
+
protected amount: number;
|
|
10
|
+
protected currency: CurrencyCode;
|
|
11
|
+
/**
|
|
12
|
+
* Creates an instance of PriceModel, storing the currency-correct rounded price.
|
|
13
|
+
* @param amount - The initial price value.
|
|
14
|
+
* @param currency - The currency code used for rounding and determining the currency symbol.
|
|
15
|
+
* @throws {Error} If price is negative or country/currency mapping is missing.
|
|
16
|
+
*/
|
|
17
|
+
constructor(data: PriceAttributes);
|
|
18
|
+
/**
|
|
19
|
+
* Gets the currency associated with this price instance.
|
|
20
|
+
* @returns The CurrencyCode enum value.
|
|
21
|
+
*/
|
|
22
|
+
getCurrency(): CurrencyCode;
|
|
23
|
+
/**
|
|
24
|
+
* Returns the raw numeric price value.
|
|
25
|
+
*/
|
|
26
|
+
getAmount(): number;
|
|
27
|
+
/**
|
|
28
|
+
*
|
|
29
|
+
* @returns PriceData
|
|
30
|
+
*/
|
|
31
|
+
getDetails(): PriceData;
|
|
32
|
+
/**
|
|
33
|
+
* Compares this price with another {@link PriceModel} instance.
|
|
34
|
+
*
|
|
35
|
+
* The comparison is performed using the numeric price value and is only valid
|
|
36
|
+
* when both prices are expressed in the same currency.
|
|
37
|
+
*
|
|
38
|
+
* ### Comparison result:
|
|
39
|
+
* - Returns a **negative number** if this price is **less than** `priceModel`
|
|
40
|
+
* - Returns **zero** if both prices are **equal**
|
|
41
|
+
* - Returns a **positive number** if this price is **greater than** `priceModel`
|
|
42
|
+
*
|
|
43
|
+
* @param priceModel - The {@link PriceModel} instance to compare against.
|
|
44
|
+
*
|
|
45
|
+
* @returns
|
|
46
|
+
* A signed number representing the comparison result:
|
|
47
|
+
* - `< 0` → this price is lower
|
|
48
|
+
* - `0` → prices are equal
|
|
49
|
+
* - `> 0` → this price is higher
|
|
50
|
+
*
|
|
51
|
+
* @throws {Error}
|
|
52
|
+
* Throws an error if:
|
|
53
|
+
* - `priceModel` is not an instance of {@link PriceModel}
|
|
54
|
+
* - The currencies of the two prices do not match
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```ts
|
|
58
|
+
* const a = new PriceModel("USD", 100);
|
|
59
|
+
* const b = new PriceModel("USD", 150);
|
|
60
|
+
*
|
|
61
|
+
* a.compareTo(b); // -50
|
|
62
|
+
* b.compareTo(a); // 50
|
|
63
|
+
* a.compareTo(a); // 0
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
compareTo(priceModel: PriceModel): number;
|
|
67
|
+
add(priceModel: PriceModel): PriceModel;
|
|
68
|
+
subtract(priceModel: PriceModel): PriceModel;
|
|
69
|
+
multiply(factor: number | PriceModel): PriceModel;
|
|
70
|
+
divide(divisor: number | PriceModel): PriceModel;
|
|
71
|
+
min(...priceModels: PriceModel[]): PriceModel;
|
|
72
|
+
max(...priceModels: PriceModel[]): PriceModel;
|
|
73
|
+
/**
|
|
74
|
+
* Gets a zero value PriceModel for the same currency.
|
|
75
|
+
* @returns A PriceModel instance representing zero in the same currency.
|
|
76
|
+
*/
|
|
77
|
+
zero(): PriceModel;
|
|
78
|
+
/**
|
|
79
|
+
* Checks if the price is zero.
|
|
80
|
+
* @returns True if the price is zero, false otherwise.
|
|
81
|
+
*/
|
|
82
|
+
isZero(): boolean;
|
|
83
|
+
round(): PriceModel;
|
|
84
|
+
/**
|
|
85
|
+
* Gets the rounded price value based on standard currency rules.
|
|
86
|
+
* @returns The numeric price, rounded according to its currency's typical decimal places.
|
|
87
|
+
*/
|
|
88
|
+
getRoundedAmount(): number;
|
|
89
|
+
/**
|
|
90
|
+
* Gets a locale-aware formatted display string for the price stored in this instance.
|
|
91
|
+
* Uses the static `PriceModel.getFormattedString` method for the actual formatting.
|
|
92
|
+
* @returns The formatted price string according to locale rules.
|
|
93
|
+
*/
|
|
94
|
+
getFormattedString(): string;
|
|
95
|
+
/**
|
|
96
|
+
* Gets a locale-aware formatted display string for the amount.
|
|
97
|
+
* Uses Intl.NumberFormat for accurate formatting based on locale and currency.
|
|
98
|
+
* @param amount - The initial amount value.
|
|
99
|
+
* @param currency - The currency code for formatting.
|
|
100
|
+
* @param options - Configuration options for formatting.
|
|
101
|
+
* @param options.displayAsInteger - If true, the formatted string will show the amount rounded to the next nearest integer (no decimals). Defaults to false.
|
|
102
|
+
* @param options.style - The style of formatting, either 'currency' or 'decimal'. Defaults to 'currency'.
|
|
103
|
+
* @param options.currencyDisplay - The display format for the currency symbol. Options are 'symbol', 'narrowSymbol', 'code', or 'name'. Defaults to 'symbol'.
|
|
104
|
+
* @returns The formatted price string according to locale rules.
|
|
105
|
+
* @throws {Error} If currency code is invalid.
|
|
106
|
+
*/
|
|
107
|
+
static getFormattedString(amount: number, currency: CurrencyCode, options?: {
|
|
108
|
+
displayAsInteger?: boolean;
|
|
109
|
+
style?: 'currency' | 'decimal';
|
|
110
|
+
currencyDisplay?: 'symbol' | 'narrowSymbol' | 'code' | 'name';
|
|
111
|
+
}): string;
|
|
112
|
+
/**
|
|
113
|
+
* Helper method to determine standard decimal places for a currency.
|
|
114
|
+
* @param currency - The currency code.
|
|
115
|
+
* @returns The number of decimal places (0, 2, or 3 based on common rules).
|
|
116
|
+
*/
|
|
117
|
+
private static getDecimalPlaces;
|
|
118
|
+
/**
|
|
119
|
+
* Adds basic thousand separators (commas) to a number string.
|
|
120
|
+
* Does not handle different locale separators (e.g., periods, spaces).
|
|
121
|
+
* @param numStr - The number string (potentially with decimals).
|
|
122
|
+
* @returns The number string with commas added.
|
|
123
|
+
*/
|
|
124
|
+
private static addThousandSeparators;
|
|
125
|
+
/**
|
|
126
|
+
* Rounds a price value according to the standard decimal places
|
|
127
|
+
* for the currency associated with the given country.
|
|
128
|
+
*
|
|
129
|
+
* @param price - The price value to round. Must be a non-negative number.
|
|
130
|
+
* @param currency - The currency code to determine the rounding rules.
|
|
131
|
+
* @returns The rounded price as a number.
|
|
132
|
+
* @throws {Error} If the price is negative or currency is invalid.
|
|
133
|
+
*/
|
|
134
|
+
static getRoundedAmount(amount: number, currency: CurrencyCode): number;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
type Prettify<T> = {
|
|
138
|
+
[K in keyof T]: T[K];
|
|
139
|
+
} & {};
|
|
140
|
+
/**
|
|
141
|
+
* Represents a ISO 3166-1 alpha-2 country code (e.g., 'US', 'IN').
|
|
142
|
+
*/
|
|
143
|
+
type CountryCode = keyof typeof OperationalCountry;
|
|
144
|
+
/**
|
|
145
|
+
* Represents a ISO 4217 currency code (e.g., 'INR', 'USD').
|
|
146
|
+
*/
|
|
147
|
+
type CurrencyCode = keyof typeof OperationalCountryCurrency;
|
|
148
|
+
/**
|
|
149
|
+
* /**
|
|
150
|
+
* Represents a value that can be localized into multiple languages.
|
|
151
|
+
* The 'en' property is mandatory and serves as the default English translation.
|
|
152
|
+
* Additional properties can be added for other locales using their respective locale codes.
|
|
153
|
+
*/
|
|
154
|
+
type LocalizedValue<T> = Prettify<{
|
|
155
|
+
en: T;
|
|
156
|
+
} & {
|
|
157
|
+
[locale in Exclude<LocaleCode | LanguageCode, 'en'>]?: T;
|
|
158
|
+
}>;
|
|
159
|
+
/**
|
|
160
|
+
* /**
|
|
161
|
+
* Represents a string that can be localized into multiple languages.
|
|
162
|
+
* The 'en' property is mandatory and serves as the default English translation.
|
|
163
|
+
* Additional properties can be added for other locales using their respective locale codes.
|
|
164
|
+
*/
|
|
165
|
+
type LocalizedString = LocalizedValue<string>;
|
|
166
|
+
/**
|
|
167
|
+
* Represents a BCP 47 language tag (e.g., 'en-US', 'fr-FR').
|
|
168
|
+
* Used to identify languages and regional variations.
|
|
169
|
+
*/
|
|
170
|
+
type LocaleCode = keyof typeof OperationalLocale;
|
|
171
|
+
type LanguageCode = keyof typeof OperationalLanguage;
|
|
172
|
+
type Color = {
|
|
173
|
+
name: string;
|
|
174
|
+
hex?: string;
|
|
175
|
+
};
|
|
176
|
+
/**
|
|
177
|
+
* Represents a date and time string formatted according to the ISO 8601 standard.
|
|
178
|
+
* Example: "2023-10-27T10:30:00.000Z"
|
|
179
|
+
*/
|
|
180
|
+
type ISODateTimeUTC = string;
|
|
181
|
+
type RegionalPrice = {
|
|
182
|
+
[country in CountryCode]?: PriceData;
|
|
183
|
+
};
|
|
184
|
+
interface ShippingDetails {
|
|
185
|
+
courierName: string;
|
|
186
|
+
courierId?: string;
|
|
187
|
+
serviceType?: string;
|
|
188
|
+
rating?: number;
|
|
189
|
+
estimatedDeliveryDays?: number;
|
|
190
|
+
cost: number;
|
|
191
|
+
currency?: string;
|
|
192
|
+
isFallback: boolean;
|
|
193
|
+
trackingUrl?: string;
|
|
194
|
+
deliveryType?: string;
|
|
195
|
+
insuranceAmount?: number;
|
|
196
|
+
weight?: number;
|
|
197
|
+
dimensions?: {
|
|
198
|
+
length: number;
|
|
199
|
+
width: number;
|
|
200
|
+
height: number;
|
|
201
|
+
unit?: string;
|
|
202
|
+
};
|
|
203
|
+
pickupDate?: string;
|
|
204
|
+
deliveryDate?: string;
|
|
205
|
+
status?: string;
|
|
206
|
+
rawApiData?: any;
|
|
207
|
+
[key: string]: any;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
export { type CountryCode as C, type ISODateTimeUTC as I, type LocaleCode as L, type PriceData as P, type RegionalPrice as R, type ShippingDetails as S, type CurrencyCode as a, PriceModel as b, type LocalizedString as c, type LocalizedValue as d, type Prettify as e, type Color as f, type PriceAttributes as g, type LanguageCode as h };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import {a as a$1}from'./chunk-LNIZAPER.mjs';import {a as a$2}from'./chunk-54RUAXYE.mjs';import {e}from'./chunk-72DR3HF2.mjs';import {r}from'./chunk-NJKSUUOB.mjs';import {a}from'./chunk-55SOBG62.mjs';var y=(t=>(t.COUPON="coupon",t.AUTOMATIC="automatic",t))(y||{}),M=(t=>(t.FLAT="flat",t.PERCENTAGE="percentage",t))(M||{}),b=(t=>(t.SHIPPING="SHIPPING",t.CUSTOMER="CUSTOMER",t))(b||{}),P=(t=>(t.ALL="all",t.FTB="ftb",t))(P||{}),p=class extends a{couponCode;name;description;type;customerId;validFrom;validTo;minCartValue;maxCartDiscount;discountMethod;percentageValue;applicableTo;category;constructor(e,t=new Date){if(super(e,t),this.couponCode=e.couponCode,this.name=a$1.deepClone(e.name),this.description=a$1.deepClone(e.description),this.type=e.type,this.customerId=e.customerId,this.validFrom=e.validFrom&&Date.parse(e.validFrom)?new Date(e.validFrom).toISOString():t.toISOString(),this.validTo=e.validTo&&Date.parse(e.validTo)?new Date(e.validTo).toISOString():t.toISOString(),this.minCartValue=Object.keys(e.minCartValue).reduce((o,i)=>{let r=e.minCartValue[i];return r&&(o[i]=new a$2(r)),o},{}),this.maxCartDiscount=Object.keys(e.maxCartDiscount).reduce((o,i)=>{let r=e.maxCartDiscount[i];return r&&(o[i]=new a$2(r)),o},{}),this.discountMethod=e.discountMethod,this.percentageValue=e.percentageValue??0,this.percentageValue>100)throw new r("Percentage value cannot be greater than 100");this.applicableTo=e.applicableTo,this.category=e.category;}getCode(){return this.couponCode}getName(e$1){return e$1?this.name[e$1]??this.name[e[e$1]]??this.name.en:{...this.name}}getDescription(e$1){return e$1?this.description[e$1]??this.description[e[e$1]]??this.description.en:{...this.description}}getType(){return this.type}getCustomerId(){return this.customerId??""}getValidFrom(){return this.validFrom}getValidTo(){return this.validTo}getMinCartValue(e){return e?this.minCartValue[e]:this.minCartValue}getMaxCartDiscount(e){return e?this.maxCartDiscount[e]:this.maxCartDiscount}getDiscountMethod(){return this.discountMethod}getPercentageValue(){return this.percentageValue}getApplicableTo(){return this.applicableTo}getCategory(){return this.category}getDetails(){return {...super.getDetails(),couponCode:this.getCode(),name:this.getName(),description:this.getDescription(),type:this.getType(),customerId:this.getCustomerId(),validFrom:this.getValidFrom(),validTo:this.getValidTo(),minCartValue:Object.keys(this.getMinCartValue()).reduce((e,t)=>{let o=this.getMinCartValue(t);return o&&(e[t]=o.getDetails()),e},{}),maxCartDiscount:Object.keys(this.getMaxCartDiscount()).reduce((e,t)=>{let o=this.getMaxCartDiscount(t);return o&&(e[t]=o.getDetails()),e},{}),discountMethod:this.getDiscountMethod(),percentageValue:this.getPercentageValue(),applicableTo:this.getApplicableTo(),category:this.getCategory()}}isActive(){return new Date(this.validFrom)<=new Date&&new Date(this.validTo)>=new Date}isApplicableTo(e){return this.applicableTo==="all"||this.applicableTo==="ftb"&&e}calculateApplicableCouponDiscount(e,t,o,i,r=!0){let n=new a$2({amount:0,currency:i}),s;if(r&&!this.isActive())return n;let C=this.getMinCartValue(o),c=this.getMaxCartDiscount(o);if(!C||C.compareTo(e)>0||!c)return n;let h=this.getCategory(),D=this.getDiscountMethod(),u=h==="SHIPPING"?t:e;if(u.getAmount()<=0)return n;switch(D){case"flat":let T=c;s=u.min(T);break;case"percentage":s=u.multiply(this.getPercentageValue()/100).round();break;default:return n}return s.min(c)}};export{y as a,M as b,b as c,P as d,p as e};//# sourceMappingURL=chunk-2SGUPNWZ.mjs.map
|
|
2
|
+
//# sourceMappingURL=chunk-2SGUPNWZ.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/Classes/Coupon.ts"],"names":["CouponType","CouponDiscountMethod","CouponCategory","ApplicableTo","CouponModel","BaseModel","data","date","Utils_default","acc","country","priceData","PriceModel","InvalidArgumentError","locale","LocaleLanguageMap","priceModel","ftbCustomer","cartValue","shippingCost","currency","checkExpiry","zeroDiscount","potentialDiscount","minCartValueReq","maxCartDiscountCap","couponCategory","discountMethod","targetValue","flatAmount"],"mappings":"uMAOO,IAAKA,CACVA,CAAAA,CAAAA,CAAAA,GAAAA,CAAAA,CAAA,MAAS,CAAA,QAAA,CACTA,EAAA,SAAY,CAAA,WAAA,CAFFA,CAAA,CAAA,EAAA,CAAA,EAAA,EAAA,CAAA,CAKAC,CACVA,CAAAA,CAAAA,CAAAA,GAAAA,CAAAA,CAAA,IAAO,CAAA,MAAA,CACPA,EAAA,UAAa,CAAA,YAAA,CAFHA,CAAA,CAAA,EAAA,CAAA,EAAA,EAAA,CAAA,CAKAC,CACVA,CAAAA,CAAAA,CAAAA,GAAAA,CAAAA,CAAA,QAAW,CAAA,UAAA,CACXA,EAAA,QAAW,CAAA,UAAA,CAFDA,CAAA,CAAA,EAAA,CAAA,EAAA,EAAA,CAAA,CAKAC,OACVA,CAAA,CAAA,GAAA,CAAM,KACNA,CAAAA,CAAAA,CAAA,IAAM,KAFIA,CAAAA,CAAAA,CAAAA,EAAAA,CAAAA,EAAA,EA0BSC,CAAAA,CAAAA,CAAAA,CAArB,cAAyCC,CAAU,CACvC,UAAA,CACA,KACA,WACA,CAAA,IAAA,CACA,UACA,CAAA,SAAA,CACA,QACA,YAGA,CAAA,eAAA,CAGA,cACA,CAAA,eAAA,CACA,aACA,QAOV,CAAA,WAAA,CAAYC,CAAuBC,CAAAA,CAAAA,CAAa,IAAI,IAAA,CAAQ,CA0B1D,GAzBA,MAAMD,CAAMC,CAAAA,CAAI,CAEhB,CAAA,IAAA,CAAK,WAAaD,CAAK,CAAA,UAAA,CACvB,IAAK,CAAA,IAAA,CAAOE,IAAM,SAAUF,CAAAA,CAAAA,CAAK,IAAI,CAAA,CACrC,IAAK,CAAA,WAAA,CAAcE,GAAM,CAAA,SAAA,CAAU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AAG,CAAE,CAAA,KAAA,GAC1E,MACF,QAEE,OAAON,CACX,CAKA,OAFsBC,CAAAA,CAAkB,GAAIE,CAAAA,CAAkB,CAGhE,CACF","file":"chunk-2SGUPNWZ.mjs","sourcesContent":["import Utils from \"../Utils\";\r\nimport BaseModel, { BaseAttributes } from \"./Base\";\r\nimport { CountryCode, CurrencyCode, ISODateTimeUTC, LocaleCode, LocalizedString, RegionalPrice } from \"./Common\";\r\nimport { LocaleLanguageMap } from \"./Enum\";\r\nimport { InvalidArgumentError } from \"./Error\";\r\nimport PriceModel, { PriceData } from \"./Price\";\r\n\r\nexport enum CouponType {\r\n COUPON = \"coupon\",\r\n AUTOMATIC = \"automatic\",\r\n}\r\n\r\nexport enum CouponDiscountMethod {\r\n FLAT = \"flat\",\r\n PERCENTAGE = \"percentage\",\r\n}\r\n\r\nexport enum CouponCategory {\r\n SHIPPING = \"SHIPPING\",\r\n CUSTOMER = \"CUSTOMER\",\r\n}\r\n\r\nexport enum ApplicableTo {\r\n ALL = \"all\",\r\n FTB = \"ftb\",\r\n}\r\n\r\nexport type CouponAttribute = BaseAttributes & {\r\n couponCode: string;\r\n name: LocalizedString;\r\n description: LocalizedString;\r\n type: CouponType;\r\n customerId?: string;\r\n validFrom: ISODateTimeUTC;\r\n validTo: ISODateTimeUTC;\r\n minCartValue: RegionalPrice;\r\n maxCartDiscount: RegionalPrice;\r\n discountMethod: CouponDiscountMethod;\r\n percentageValue?: number;\r\n applicableTo: ApplicableTo;\r\n category: CouponCategory;\r\n};\r\n\r\nexport type CouponData = Required<CouponAttribute>\r\n\r\n/**\r\n * Represents a discount coupon, extending BaseModel.\r\n */\r\nexport default class CouponModel extends BaseModel {\r\n protected couponCode: string;\r\n protected name: LocalizedString;\r\n protected description: LocalizedString;\r\n protected type: CouponType;\r\n protected customerId?: string;\r\n protected validFrom: ISODateTimeUTC;\r\n protected validTo: ISODateTimeUTC;\r\n protected minCartValue: {\r\n [country in CountryCode]?: PriceModel;\r\n };\r\n protected maxCartDiscount: {\r\n [country in CountryCode]?: PriceModel;\r\n };\r\n protected discountMethod: CouponDiscountMethod;\r\n protected percentageValue: number;\r\n protected applicableTo: ApplicableTo;\r\n protected category: CouponCategory;\r\n\r\n /**\r\n * Creates an instance of CouponModel.\r\n * @param data - The initial coupon attributes.\r\n * @param date - Optional date for setting creation/modification times (defaults to now).\r\n */\r\n constructor(data: CouponAttribute, date: Date = new Date()) {\r\n super(data, date);\r\n\r\n this.couponCode = data.couponCode;\r\n this.name = Utils.deepClone(data.name);\r\n this.description = Utils.deepClone(data.description);\r\n this.type = data.type;\r\n this.customerId = data.customerId;\r\n this.validFrom = data.validFrom && Date.parse(data.validFrom) ? new Date(data.validFrom).toISOString() : date.toISOString();\r\n this.validTo = data.validTo && Date.parse(data.validTo) ? new Date(data.validTo).toISOString() : date.toISOString();\r\n this.minCartValue = (Object.keys(data.minCartValue) as CountryCode[]).reduce((acc, country) => {\r\n const priceData = data.minCartValue[country] as PriceData;\r\n if (priceData) {\r\n acc[country] = new PriceModel(priceData);\r\n }\r\n return acc;\r\n }, {} as { [country in CountryCode]?: PriceModel });\r\n this.maxCartDiscount = (Object.keys(data.maxCartDiscount) as CountryCode[]).reduce((acc, country) => {\r\n const priceData = data.maxCartDiscount[country] as PriceData;\r\n if (priceData) {\r\n acc[country] = new PriceModel(priceData);\r\n }\r\n return acc;\r\n }, {} as { [country in CountryCode]?: PriceModel });\r\n this.discountMethod = data.discountMethod;\r\n this.percentageValue = data.percentageValue ?? 0;\r\n if (this.percentageValue > 100) {\r\n throw new InvalidArgumentError('Percentage value cannot be greater than 100');\r\n }\r\n\r\n this.applicableTo = data.applicableTo;\r\n this.category = data.category;\r\n }\r\n\r\n /** Gets the unique coupon code. */\r\n getCode(): string {\r\n return this.couponCode;\r\n }\r\n\r\n /**\r\n * Gets the full localized coupon name object.\r\n * @returns A copy of the LocalizedString object for the name.\r\n */\r\n getName(): LocalizedString\r\n /**\r\n * Gets the coupon name for a specific locale, falling back to English ('en').\r\n * @param locale - The desired locale code.\r\n * @returns The name string for the specified locale.\r\n */\r\n getName(locale: LocaleCode): string\r\n getName(locale?: LocaleCode): LocalizedString | string {\r\n if (locale) {\r\n return this.name[locale] ?? this.name[LocaleLanguageMap[locale]] ?? this.name.en;\r\n } else {\r\n return { ...this.name };\r\n }\r\n }\r\n\r\n /**\r\n * Gets the full localized coupon description object.\r\n * @returns A copy of the LocalizedString object for the description, or undefined.\r\n */\r\n getDescription(): LocalizedString\r\n /**\r\n * Gets the coupon description for a specific locale, falling back to English ('en').\r\n * @param locale - The desired locale code.\r\n * @returns The description string for the specified locale.\r\n */\r\n getDescription(locale: LocaleCode): string\r\n getDescription(locale?: LocaleCode): LocalizedString | string {\r\n if (locale) {\r\n return this.description[locale] ?? this.description[LocaleLanguageMap[locale]] ?? this.description.en;\r\n } else {\r\n return { ...this.description };\r\n }\r\n }\r\n\r\n /** Gets the type of coupon (COUPON or AUTOMATIC). */\r\n getType(): CouponType {\r\n return this.type;\r\n }\r\n\r\n /** Gets the specific customer ID this coupon is limited to, if any. */\r\n getCustomerId(): string {\r\n return this.customerId ?? '';\r\n }\r\n\r\n /** Gets the ISO date string from when the coupon is valid. */\r\n getValidFrom(): ISODateTimeUTC {\r\n return this.validFrom;\r\n }\r\n\r\n /** Gets the ISO date string until when the coupon is valid. */\r\n getValidTo(): ISODateTimeUTC {\r\n return this.validTo;\r\n }\r\n\r\n /**\r\n * Gets the list of minimum cart values required for the coupon across different regions.\r\n * Returns copies of the price objects.\r\n * @returns The full list of regional minimum cart values.\r\n */\r\n getMinCartValue(): { [country in CountryCode]?: PriceModel }\r\n\r\n /**\r\n * Gets the minimum cart value required for the coupon for a specific country.\r\n * @param country - The country code to filter the minimum value for.\r\n * @returns The regional minimum cart value for the specified country, or undefined if not set for that country.\r\n */\r\n getMinCartValue(country: CountryCode): PriceModel | undefined\r\n getMinCartValue(country?: CountryCode) {\r\n if (country) {\r\n return this.minCartValue[country];\r\n }\r\n return this.minCartValue;\r\n }\r\n\r\n /**\r\n * Gets the list of maximum discount amounts allowed for the coupon across different regions.\r\n * Returns copies of the price objects.\r\n * @returns The full list of regional maximum discount caps.\r\n */\r\n getMaxCartDiscount(): { [country in CountryCode]?: PriceModel }\r\n /**\r\n * Gets the maximum discount amount allowed for the coupon for a specific country.\r\n * @param country - The country code to filter the maximum discount for.\r\n * @returns The regional maximum discount cap for the specified country, or undefined if not set for that country.\r\n */\r\n getMaxCartDiscount(country: CountryCode): PriceModel | undefined\r\n getMaxCartDiscount(country?: CountryCode) {\r\n if (country) {\r\n return this.maxCartDiscount[country];\r\n }\r\n return this.maxCartDiscount;\r\n }\r\n\r\n /** Gets the discount method (FLAT or PERCENTAGE). */\r\n getDiscountMethod(): CouponDiscountMethod {\r\n return this.discountMethod;\r\n }\r\n\r\n /** Gets the percentage discount value (0-100). */\r\n getPercentageValue(): number {\r\n return this.percentageValue;\r\n }\r\n\r\n /** Gets the customer applicability rule (ALL or FTB). */\r\n getApplicableTo(): ApplicableTo {\r\n return this.applicableTo;\r\n }\r\n\r\n /** Gets the category of the coupon (SHIPPING or CUSTOMER). */\r\n getCategory(): CouponCategory {\r\n return this.category;\r\n }\r\n\r\n /**\r\n * Gets a plain data object representing the coupon's details.\r\n * @returns A CouponData object.\r\n */\r\n getDetails(): CouponData {\r\n return {\r\n ...super.getDetails(),\r\n couponCode: this.getCode(),\r\n name: this.getName(),\r\n description: this.getDescription(),\r\n type: this.getType(),\r\n customerId: this.getCustomerId(),\r\n validFrom: this.getValidFrom(),\r\n validTo: this.getValidTo(),\r\n minCartValue: (Object.keys(this.getMinCartValue()) as CountryCode[]).reduce((acc, country) => {\r\n const priceModel = this.getMinCartValue(country);\r\n if (priceModel) {\r\n acc[country] = priceModel.getDetails();\r\n }\r\n return acc;\r\n }, {} as RegionalPrice),\r\n maxCartDiscount: (Object.keys(this.getMaxCartDiscount()) as CountryCode[]).reduce((acc, country) => {\r\n const priceModel = this.getMaxCartDiscount(country);\r\n if (priceModel) {\r\n acc[country] = priceModel.getDetails();\r\n }\r\n return acc;\r\n }, {} as RegionalPrice),\r\n discountMethod: this.getDiscountMethod(),\r\n percentageValue: this.getPercentageValue(),\r\n applicableTo: this.getApplicableTo(),\r\n category: this.getCategory(),\r\n };\r\n }\r\n\r\n /**\r\n * Checks if the coupon is currently active based on its validity dates.\r\n * @returns True if the coupon is currently within its validity period, false otherwise.\r\n */\r\n isActive(): boolean {\r\n return new Date(this.validFrom) <= new Date() && new Date(this.validTo) >= new Date();\r\n }\r\n\r\n\r\n /**\r\n * Checks if the coupon is applicable to a customer based on their status (e.g., first-time buyer).\r\n * @param ftbCustomer - A boolean indicating whether the customer is a first-time buyer.\r\n * @returns True if the coupon's applicability rule matches the customer's status, false otherwise.\r\n */\r\n isApplicableTo(ftbCustomer: boolean): boolean {\r\n return this.applicableTo === ApplicableTo.ALL || (this.applicableTo === ApplicableTo.FTB && ftbCustomer);\r\n }\r\n\r\n /**\r\n * Calculates the discount value for a given coupon based on the current container state.\r\n * Returns 0 if the coupon is invalid, expired, or not applicable based on cart value or target category.\r\n * @param cartValue - The cart subtotal as a PriceModel.\r\n * @param shippingCost - The cart shipping cost.\r\n * @param country - The country code.\r\n * @param currency - The currency code.\r\n * @returns The calculated discount amount (rounded according to country rules).\r\n */\r\n public calculateApplicableCouponDiscount(cartValue: PriceModel, shippingCost: PriceModel, country: CountryCode, currency: CurrencyCode, checkExpiry: boolean = true): PriceModel {\r\n let zeroDiscount: PriceModel = new PriceModel({ amount: 0, currency });\r\n let potentialDiscount: PriceModel;\r\n\r\n // 1. Basic validation (active)\r\n if (checkExpiry && !this.isActive()) {\r\n return zeroDiscount;\r\n }\r\n\r\n // 2. Check regional requirements (min cart value, max discount)\r\n const minCartValueReq = this.getMinCartValue(country);\r\n const maxCartDiscountCap = this.getMaxCartDiscount(country);\r\n\r\n // Ensure minCartValueReq exists and subtotal meets the requirement\r\n if (!minCartValueReq || minCartValueReq.compareTo(cartValue) > 0) {\r\n return zeroDiscount;\r\n }\r\n\r\n // Ensure maxCartDiscountCap exists and is non-negative (price-model throws error when amount < 0)\r\n if (!maxCartDiscountCap) {\r\n return zeroDiscount;\r\n }\r\n\r\n // 3. Calculate potential discount based on method and category\r\n const couponCategory = this.getCategory();\r\n const discountMethod = this.getDiscountMethod();\r\n // Determine the value the coupon applies to (shipping cost or subtotal)\r\n const targetValue = couponCategory === CouponCategory.SHIPPING ? shippingCost : cartValue;\r\n\r\n // No discount if the target value is zero or less\r\n if (targetValue.getAmount() <= 0) return zeroDiscount;\r\n\r\n switch (discountMethod) {\r\n case CouponDiscountMethod.FLAT:\r\n // Flat discount is capped by the target value itself and the max discount cap\r\n const flatAmount = maxCartDiscountCap; // Use cap as the flat amount source? Or coupon.value? Needs clarification. Assuming cap IS the flat amount here.\r\n potentialDiscount = targetValue.min(flatAmount);\r\n break;\r\n case CouponDiscountMethod.PERCENTAGE:\r\n // Calculate percentage discount based on the target value\r\n potentialDiscount = targetValue.multiply(this.getPercentageValue() / 100).round();\r\n break;\r\n default:\r\n // Unknown discount method\r\n return zeroDiscount;\r\n }\r\n\r\n // 4. Apply maximum discount cap to the calculated potential discount\r\n const finalDiscount = potentialDiscount.min(maxCartDiscountCap);\r\n\r\n return finalDiscount;\r\n }\r\n}"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import {i,h}from'./chunk-72DR3HF2.mjs';import {o,p,q,r}from'./chunk-NJKSUUOB.mjs';var m=class t{amount;currency;constructor(e){if(e.amount<0)throw new o("Amount cannot be negative.");if(!e.currency)throw new p("Currency code is required.");this.amount=e.amount,this.currency=e.currency;}getCurrency(){return this.currency}getAmount(){return this.amount}getDetails(){return {amount:this.amount,currency:this.currency}}compareTo(e){if(e instanceof t){if(this.currency!==e.getCurrency())throw new q("Cannot compare prices in different currencies.")}else throw new r("Must be a PriceModel instance.");return this.amount-e.getAmount()}add(e){if(e instanceof t){if(this.currency!==e.getCurrency())throw new q("Cannot add prices in different currencies.")}else throw new r("Must be a PriceModel instance.");return new t({amount:this.amount+e.getAmount(),currency:this.currency})}subtract(e){if(e instanceof t){if(this.currency!==e.getCurrency())throw new q("Cannot subtract prices in different currencies.")}else throw new r("Must be a PriceModel instance.");return new t({amount:this.amount-e.getAmount(),currency:this.currency})}multiply(e){if(e instanceof t){if(this.currency!==e.getCurrency())throw new q("Cannot multiply prices in different currencies.");return new t({amount:this.amount*e.getAmount(),currency:this.currency})}else if(typeof e=="number"&&e>=0)return new t({amount:this.amount*e,currency:this.currency});throw new r("Must be a non-negative number.")}divide(e){if(e instanceof t){if(this.currency!==e.getCurrency())throw new q("Cannot divide prices in different currencies.");return new t({amount:this.amount/e.getAmount(),currency:this.currency})}else if(typeof e=="number"&&e>0)return new t({amount:this.amount/e,currency:this.currency});throw new r("Must be a positive number.")}min(...e){if(e.length===0)throw new r("Must provide at least one PriceModel.");return e.reduce((r$1,n)=>{if(n instanceof t){if(r$1.getCurrency()!==n.getCurrency())throw new q("Cannot compare prices in different currencies.")}else throw new r("Must be a PriceModel instance.");return r$1.compareTo(n)<0?r$1:n})}max(...e){if(e.length===0)throw new r("Must provide at least one PriceModel.");return e.reduce((r$1,n)=>{if(n instanceof t){if(r$1.getCurrency()!==n.getCurrency())throw new q("Cannot compare prices in different currencies.")}else throw new r("Must be a PriceModel instance.");return r$1.compareTo(n)>0?r$1:n})}zero(){return new t({currency:this.currency,amount:0})}isZero(){return this.amount===0}round(){return new t({currency:this.currency,amount:this.getRoundedAmount()})}getRoundedAmount(){return t.getRoundedAmount(this.amount,this.currency)}getFormattedString(){return t.getFormattedString(this.amount,this.currency)}static getFormattedString(e,r,n={displayAsInteger:!1,style:"currency",currencyDisplay:"symbol"}){let u=i[r];if(!r||!u)throw new p("Invalid currency code for formatting.");let o=e,s=n.displayAsInteger?0:t.getDecimalPlaces(r),h$1={style:n.style??"currency",currency:r,signDisplay:"never",currencyDisplay:n.currencyDisplay,minimumFractionDigits:s,maximumFractionDigits:s};n.displayAsInteger&&(o=Math.ceil(o));try{return new Intl.NumberFormat(u,h$1).format(o)}catch(f){return console.error(`Error formatting price for currency "${r}" and locale "${u}":`,f),`${h[r]??r} ${t.addThousandSeparators(o.toFixed(s))}`}}static getDecimalPlaces(e){switch(e){case"INR":default:return 2}}static addThousandSeparators(e){let r=e.split("."),n=r[0],u=r.length>1?"."+r[1]:"";return n.replace(/\B(?=(\d{3})+(?!\d))/g,",")+u}static getRoundedAmount(e,r){if(e<0)throw new o("Amount cannot be negative for rounding.");if(r===void 0)throw new p("Invalid currency code for rounding.");let n=t.getDecimalPlaces(r),u=Math.pow(10,n);return Math.round(e*u)/u}};export{m as a};//# sourceMappingURL=chunk-54RUAXYE.mjs.map
|
|
2
|
+
//# sourceMappingURL=chunk-54RUAXYE.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/Classes/Price.ts"],"names":["PriceModel","_PriceModel","data","InvalidPriceAmountError","InvalidCurrencyCodeError","priceModel","CurrencyMismatchError","InvalidArgumentError","factor","divisor","priceModels","minPrice","currentPrice","maxPrice","amount","currency","options","locale","CurrencyLocaleMap","valueToFormat","fractionDigits","formattingOptions","error","CurrencySymbolMap","numStr","parts","integerPart","decimalPart","decimalPlaces","multiplier"],"mappings":"kFAgBA,IAAqBA,CAArB,CAAA,MAAqBC,CAAW,CACpB,OACA,QAQV,CAAA,WAAA,CAAYC,CAAuB,CAAA,CACjC,GAAIA,CAAK,CAAA,MAAA,CAAS,CAChB,CAAA,MAAM,IAAIC,CAAwB,CAAA,4BAA4B,CAGhE,CAAA,GAAI,CAACD,CAAK,CAAA,QAAA,CACR,MAAM,IAAIE,EAAyB,4BAA4B,CAAA,CAGjE,IAAK,CAAA,MAAA,CAASF,EAAK,MACnB,CAAA,IAAA,CAAK,QAAWA,CAAAA,CAAAA,CAAK,SACvB,CAMO,WAAA,EAA4B,CACjC,OAAO,KAAK,QACd,CAKO,SAAoB,EAAA,CACzB,OAAO,IAAK,CAAA,MACd,CAMO,UAAA,EAAwB,CAC7B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CAAAA,CAAwB,CAC3D,IAAMC,EAAQD,CAAO,CAAA,KAAA,CAAM,GAAG,CAAA,CACxBE,EAAcD,CAAM,CAAA,CAAC,CACrBE,CAAAA,CAAAA,CAAcF,EAAM,MAAS,CAAA,CAAA,CAAI,GAAMA,CAAAA,CAAAA,CAAM,CAAC,CAAI,CAAA,EAAA,CAGxD,OADyBC,CAAAA,CAAY,QAAQ,uBAAyB,CAAA,GAAG,CAC/CC,CAAAA,CAC5B,CAWA,OAAO,gBAAA,CAAiBb,CAAgBC,CAAAA,CAAAA,CAAgC,CACtE,GAAID,CAAAA,CAAS,CACX,CAAA,MAAM,IAAIX,CAAwB,CAAA,yCAAyC,CAG7E,CAAA,GAAIY,IAAa,KACf,CAAA,CAAA,MAAM,IAAIX,CAAAA,CAAyB,qCAAqC,CAG1E,CAAA,IAAMwB,CAAgB3B,CAAAA,CAAAA,CAAW,iBAAiBc,CAAQ,CAAA,CACpDc,CAAa,CAAA,IAAA,CAAK,IAAI,EAAID,CAAAA,CAAa,CAG7C,CAAA,OAFqB,KAAK,KAAMd,CAAAA,CAAAA,CAASe,CAAU,CAAA,CAAIA,CAGzD,CACF","file":"chunk-54RUAXYE.mjs","sourcesContent":["import { CurrencyCode } from \"./Common\";\r\nimport { CurrencyLocaleMap, CurrencySymbolMap, OperationalCountryCurrency } from \"./Enum\";\r\nimport {\r\n InvalidPriceAmountError,\r\n InvalidCurrencyCodeError,\r\n CurrencyMismatchError,\r\n InvalidArgumentError\r\n} from \"./Error\";\r\n\r\nexport type PriceAttributes = {\r\n amount: number;\r\n currency: CurrencyCode;\r\n}\r\n\r\nexport type PriceData = PriceAttributes;\r\n\r\nexport default class PriceModel {\r\n protected amount: number;\r\n protected currency: CurrencyCode;\r\n\r\n /**\r\n * Creates an instance of PriceModel, storing the currency-correct rounded price.\r\n * @param amount - The initial price value.\r\n * @param currency - The currency code used for rounding and determining the currency symbol.\r\n * @throws {Error} If price is negative or country/currency mapping is missing.\r\n */\r\n constructor(data: PriceAttributes) {\r\n if (data.amount < 0) {\r\n throw new InvalidPriceAmountError(\"Amount cannot be negative.\");\r\n }\r\n\r\n if (!data.currency) {\r\n throw new InvalidCurrencyCodeError(\"Currency code is required.\");\r\n }\r\n\r\n this.amount = data.amount;\r\n this.currency = data.currency;\r\n }\r\n\r\n /**\r\n * Gets the currency associated with this price instance.\r\n * @returns The CurrencyCode enum value.\r\n */\r\n public getCurrency(): CurrencyCode {\r\n return this.currency;\r\n }\r\n\r\n /**\r\n * Returns the raw numeric price value.\r\n */\r\n public getAmount(): number {\r\n return this.amount;\r\n }\r\n\r\n /**\r\n *\r\n * @returns PriceData\r\n */\r\n public getDetails(): PriceData {\r\n return {\r\n amount: this.amount,\r\n currency: this.currency\r\n }\r\n }\r\n\r\n /**\r\n * Compares this price with another {@link PriceModel} instance.\r\n *\r\n * The comparison is performed using the numeric price value and is only valid\r\n * when both prices are expressed in the same currency.\r\n *\r\n * ### Comparison result:\r\n * - Returns a **negative number** if this price is **less than** `priceModel`\r\n * - Returns **zero** if both prices are **equal**\r\n * - Returns a **positive number** if this price is **greater than** `priceModel`\r\n *\r\n * @param priceModel - The {@link PriceModel} instance to compare against.\r\n *\r\n * @returns\r\n * A signed number representing the comparison result:\r\n * - `< 0` → this price is lower\r\n * - `0` → prices are equal\r\n * - `> 0` → this price is higher\r\n *\r\n * @throws {Error}\r\n * Throws an error if:\r\n * - `priceModel` is not an instance of {@link PriceModel}\r\n * - The currencies of the two prices do not match\r\n *\r\n * @example\r\n * ```ts\r\n * const a = new PriceModel(\"USD\", 100);\r\n * const b = new PriceModel(\"USD\", 150);\r\n *\r\n * a.compareTo(b); // -50\r\n * b.compareTo(a); // 50\r\n * a.compareTo(a); // 0\r\n * ```\r\n */\r\n public compareTo(priceModel: PriceModel): number {\r\n if (!(priceModel instanceof PriceModel)) {\r\n throw new InvalidArgumentError(\"Must be a PriceModel instance.\");\r\n } else if (this.currency !== priceModel.getCurrency()) {\r\n throw new CurrencyMismatchError(\"Cannot compare prices in different currencies.\");\r\n }\r\n\r\n return this.amount - priceModel.getAmount();\r\n }\r\n\r\n public add(priceModel: PriceModel): PriceModel {\r\n if (!(priceModel instanceof PriceModel)) {\r\n throw new InvalidArgumentError(\"Must be a PriceModel instance.\");\r\n } else if (this.currency !== priceModel.getCurrency()) {\r\n throw new CurrencyMismatchError(\"Cannot add prices in different currencies.\");\r\n }\r\n\r\n return new PriceModel({\r\n amount: this.amount + priceModel.getAmount(),\r\n currency: this.currency\r\n });\r\n }\r\n\r\n public subtract(priceModel: PriceModel): PriceModel {\r\n if (!(priceModel instanceof PriceModel)) {\r\n throw new InvalidArgumentError(\"Must be a PriceModel instance.\");\r\n } else if (this.currency !== priceModel.getCurrency()) {\r\n throw new CurrencyMismatchError(\"Cannot subtract prices in different currencies.\");\r\n }\r\n\r\n return new PriceModel({\r\n amount: this.amount - priceModel.getAmount(),\r\n currency: this.currency\r\n });\r\n }\r\n\r\n public multiply(factor: number | PriceModel): PriceModel {\r\n if (factor instanceof PriceModel) {\r\n if (this.currency !== factor.getCurrency()) {\r\n throw new CurrencyMismatchError(\"Cannot multiply prices in different currencies.\");\r\n }\r\n return new PriceModel({\r\n amount: this.amount * factor.getAmount(),\r\n currency: this.currency\r\n });\r\n } else if (typeof factor === \"number\" && factor >= 0) {\r\n return new PriceModel({\r\n amount: this.amount * factor,\r\n currency: this.currency\r\n });\r\n }\r\n\r\n throw new InvalidArgumentError(\"Must be a non-negative number.\");\r\n }\r\n\r\n public divide(divisor: number | PriceModel): PriceModel {\r\n if (divisor instanceof PriceModel) {\r\n if (this.currency !== divisor.getCurrency()) {\r\n throw new CurrencyMismatchError(\"Cannot divide prices in different currencies.\");\r\n }\r\n return new PriceModel({\r\n amount: this.amount / divisor.getAmount(),\r\n currency: this.currency\r\n });\r\n } else if (typeof divisor === \"number\" && divisor > 0) {\r\n return new PriceModel({\r\n amount: this.amount / divisor,\r\n currency: this.currency\r\n });\r\n }\r\n\r\n throw new InvalidArgumentError(\"Must be a positive number.\");\r\n }\r\n\r\n public min(...priceModels: PriceModel[]): PriceModel {\r\n if (priceModels.length === 0) {\r\n throw new InvalidArgumentError(\"Must provide at least one PriceModel.\");\r\n }\r\n\r\n return priceModels.reduce((minPrice, currentPrice) => {\r\n if (!(currentPrice instanceof PriceModel)) {\r\n throw new InvalidArgumentError(\"Must be a PriceModel instance.\");\r\n } else if (minPrice.getCurrency() !== currentPrice.getCurrency()) {\r\n throw new CurrencyMismatchError(\"Cannot compare prices in different currencies.\");\r\n }\r\n\r\n return minPrice.compareTo(currentPrice) < 0 ? minPrice : currentPrice;\r\n });\r\n }\r\n\r\n public max(...priceModels: PriceModel[]): PriceModel {\r\n if (priceModels.length === 0) {\r\n throw new InvalidArgumentError(\"Must provide at least one PriceModel.\");\r\n }\r\n\r\n return priceModels.reduce((maxPrice, currentPrice) => {\r\n if (!(currentPrice instanceof PriceModel)) {\r\n throw new InvalidArgumentError(\"Must be a PriceModel instance.\");\r\n } else if (maxPrice.getCurrency() !== currentPrice.getCurrency()) {\r\n throw new CurrencyMismatchError(\"Cannot compare prices in different currencies.\");\r\n }\r\n\r\n return maxPrice.compareTo(currentPrice) > 0 ? maxPrice : currentPrice;\r\n });\r\n }\r\n\r\n /**\r\n * Gets a zero value PriceModel for the same currency.\r\n * @returns A PriceModel instance representing zero in the same currency.\r\n */\r\n public zero(): PriceModel {\r\n return new PriceModel({\r\n currency: this.currency,\r\n amount: 0\r\n });\r\n }\r\n\r\n /**\r\n * Checks if the price is zero.\r\n * @returns True if the price is zero, false otherwise.\r\n */\r\n public isZero(): boolean {\r\n return this.amount === 0;\r\n }\r\n\r\n\r\n public round(): PriceModel {\r\n return new PriceModel({\r\n currency: this.currency,\r\n amount: this.getRoundedAmount()\r\n });\r\n }\r\n /**\r\n * Gets the rounded price value based on standard currency rules.\r\n * @returns The numeric price, rounded according to its currency's typical decimal places.\r\n */\r\n public getRoundedAmount(): number {\r\n return PriceModel.getRoundedAmount(this.amount, this.currency);\r\n }\r\n\r\n /**\r\n * Gets a locale-aware formatted display string for the price stored in this instance.\r\n * Uses the static `PriceModel.getFormattedString` method for the actual formatting.\r\n * @returns The formatted price string according to locale rules.\r\n */\r\n public getFormattedString() {\r\n return PriceModel.getFormattedString(this.amount, this.currency);\r\n }\r\n\r\n\r\n /**\r\n * Gets a locale-aware formatted display string for the amount.\r\n * Uses Intl.NumberFormat for accurate formatting based on locale and currency.\r\n * @param amount - The initial amount value.\r\n * @param currency - The currency code for formatting.\r\n * @param options - Configuration options for formatting.\r\n * @param options.displayAsInteger - If true, the formatted string will show the amount rounded to the next nearest integer (no decimals). Defaults to false.\r\n * @param options.style - The style of formatting, either 'currency' or 'decimal'. Defaults to 'currency'.\r\n * @param options.currencyDisplay - The display format for the currency symbol. Options are 'symbol', 'narrowSymbol', 'code', or 'name'. Defaults to 'symbol'.\r\n * @returns The formatted price string according to locale rules.\r\n * @throws {Error} If currency code is invalid.\r\n */\r\n static getFormattedString(amount: number, currency: CurrencyCode, options: {\r\n displayAsInteger?: boolean,\r\n style?: 'currency' | 'decimal',\r\n currencyDisplay?: 'symbol' | 'narrowSymbol' | 'code' | 'name'\r\n } = {\r\n displayAsInteger: false,\r\n style: 'currency',\r\n currencyDisplay: 'symbol'\r\n }): string {\r\n\r\n const locale = CurrencyLocaleMap[currency];\r\n if (!currency || !locale) {\r\n throw new InvalidCurrencyCodeError('Invalid currency code for formatting.');\r\n }\r\n\r\n let valueToFormat = amount;\r\n const fractionDigits = options.displayAsInteger ? 0 : PriceModel.getDecimalPlaces(currency);\r\n\r\n let formattingOptions: Intl.NumberFormatOptions = {\r\n style: options.style ?? 'currency',\r\n currency: currency,\r\n signDisplay: 'never',\r\n currencyDisplay: options.currencyDisplay,\r\n minimumFractionDigits: fractionDigits,\r\n maximumFractionDigits: fractionDigits,\r\n };\r\n\r\n if (options.displayAsInteger) {\r\n valueToFormat = Math.ceil(valueToFormat);\r\n }\r\n\r\n try {\r\n return new Intl.NumberFormat(locale, formattingOptions).format(valueToFormat);\r\n } catch (error) {\r\n console.error(`Error formatting price for currency \"${currency}\" and locale \"${locale}\":`, error);\r\n // Basic fallback without symbol if Intl fails completely\r\n return `${CurrencySymbolMap[currency] ?? currency} ${PriceModel.addThousandSeparators(valueToFormat.toFixed(fractionDigits))}`;\r\n }\r\n }\r\n\r\n /**\r\n * Helper method to determine standard decimal places for a currency.\r\n * @param currency - The currency code.\r\n * @returns The number of decimal places (0, 2, or 3 based on common rules).\r\n */\r\n private static getDecimalPlaces(currency: CurrencyCode): number {\r\n switch (currency) {\r\n case OperationalCountryCurrency.INR:\r\n default:\r\n return 2;\r\n }\r\n }\r\n\r\n /**\r\n * Adds basic thousand separators (commas) to a number string.\r\n * Does not handle different locale separators (e.g., periods, spaces).\r\n * @param numStr - The number string (potentially with decimals).\r\n * @returns The number string with commas added.\r\n */\r\n private static addThousandSeparators(numStr: string): string {\r\n const parts = numStr.split('.');\r\n const integerPart = parts[0];\r\n const decimalPart = parts.length > 1 ? '.' + parts[1] : '';\r\n\r\n const formattedInteger = integerPart.replace(/\\B(?=(\\d{3})+(?!\\d))/g, ',');\r\n return formattedInteger + decimalPart;\r\n }\r\n\r\n /**\r\n * Rounds a price value according to the standard decimal places\r\n * for the currency associated with the given country.\r\n *\r\n * @param price - The price value to round. Must be a non-negative number.\r\n * @param currency - The currency code to determine the rounding rules.\r\n * @returns The rounded price as a number.\r\n * @throws {Error} If the price is negative or currency is invalid.\r\n */\r\n static getRoundedAmount(amount: number, currency: CurrencyCode): number {\r\n if (amount < 0) {\r\n throw new InvalidPriceAmountError(\"Amount cannot be negative for rounding.\");\r\n }\r\n\r\n if (currency === undefined) {\r\n throw new InvalidCurrencyCodeError('Invalid currency code for rounding.');\r\n }\r\n\r\n const decimalPlaces = PriceModel.getDecimalPlaces(currency);\r\n const multiplier = Math.pow(10, decimalPlaces);\r\n const roundedValue = Math.round(amount * multiplier) / multiplier;\r\n\r\n return roundedValue;\r\n }\r\n}"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var i=class{customFields;version;createdAt;modifiedAt;modifiedBy;constructor(e,t=new Date){this.customFields={...e.customFields},this.version=e.version??1,this.createdAt=e.createdAt&&!isNaN(Date.parse(e.createdAt))?new Date(e.createdAt).toISOString():t.toISOString(),this.modifiedAt=e.modifiedAt&&!isNaN(Date.parse(e.modifiedAt))?new Date(e.modifiedAt).toISOString():t.toISOString(),this.modifiedBy={...e.modifiedBy};}getDetails(){return {customFields:this.getAllCustomFields(),version:this.getVersion(),createdAt:this.getCreatedAt(),modifiedAt:this.getModifiedAt(),modifiedBy:this.getModifiedBy()}}getVersion(){return this.version}getCreatedAt(){return this.createdAt}getCreatedAtTime(){return new Date(this.createdAt).getTime()}getModifiedAt(){return this.modifiedAt}getModifiedAtTime(){return new Date(this.modifiedAt).getTime()}getModifiedBy(){return {...this.modifiedBy}}setModifiedBy(e,t,s,r){this.modifiedBy={id:e,authType:t,requestId:s,lambdaName:r};}getCustomField(e){return this.customFields[e]??null}setCustomField(e,t){this.customFields[e]=t;}getAllCustomFields(){return {...this.customFields}}};export{i as a};//# sourceMappingURL=chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
var i=class{customFields;version;createdAt;modifiedAt;modifiedBy;constructor(e,t=new Date){this.customFields={...e.customFields},this.version=e.version??1,this.createdAt=e.createdAt&&!isNaN(Date.parse(e.createdAt))?new Date(e.createdAt).toISOString():t.toISOString(),this.modifiedAt=e.modifiedAt&&!isNaN(Date.parse(e.modifiedAt))?new Date(e.modifiedAt).toISOString():t.toISOString(),this.modifiedBy={...e.modifiedBy};}getDetails(){return {customFields:this.getAllCustomFields(),version:this.getVersion(),createdAt:this.getCreatedAt(),modifiedAt:this.getModifiedAt(),modifiedBy:this.getModifiedBy()}}getVersion(){return this.version}getCreatedAt(){return this.createdAt}getCreatedAtTime(){return new Date(this.createdAt).getTime()}getModifiedAt(){return this.modifiedAt}getModifiedAtTime(){return new Date(this.modifiedAt).getTime()}getModifiedBy(){return {...this.modifiedBy}}setModifiedBy(e,t,s,r){this.modifiedBy={id:e,authType:t,requestId:s,lambdaName:r};}getCustomField(e){return this.customFields[e]??null}setCustomField(e,t){this.customFields[e]=t;}getAllCustomFields(){return {...this.customFields}}};export{i as a};//# sourceMappingURL=chunk-55SOBG62.mjs.map
|
|
2
|
+
//# sourceMappingURL=chunk-55SOBG62.mjs.map
|