b23-lib 3.0.0 → 3.0.2

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.
@@ -1,2 +1,2 @@
1
- 'use strict';var y=class{customFields;constructor(e,t=new Date){this.customFields={...e.customFields};}getCustomField(e){return this.customFields[e]??null}setCustomField(e,t){this.customFields[e]=t;}getAllCustomFields(){return {...this.customFields}}},m=class extends y{version;createdAt;modifiedAt;modifiedBy;constructor(e,t=new Date){super(e),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,n,i){this.modifiedBy={id:e,authType:t,requestId:n,lambdaName:i};}};var g={INR:"\u20B9"},h={INR:"en-IN"};var d=class extends Error{constructor(e="Amount cannot be negative."){super(`InvalidAmount: ${e}`),this.name="InvalidPriceAmountError";}},u=class extends Error{constructor(e="Currency code is required."){super(`InvalidCurrency: ${e}`),this.name="InvalidCurrencyCodeError";}},s=class extends Error{constructor(e="Cannot perform operation on prices with different currencies."){super(`CurrencyMismatch: ${e}`),this.name="CurrencyMismatchError";}},o=class extends Error{constructor(e){super(`InvalidArgument: ${e}`),this.name="InvalidArgumentError";}};var c=class r{#e;amount;currency;constructor(e){if(this.#e="PriceModel",e.amount<0)throw new d("Amount cannot be negative.");if(!e.currency)throw new u("Currency code is required.");this.amount=e.amount,this.currency=e.currency;}get kind(){return this.#e}static isPriceModel(e){return typeof e=="object"&&e!==null&&e.kind==="PriceModel"}getCurrency(){return this.currency}getAmount(){return this.amount}getDetails(){return {amount:this.amount,currency:this.currency}}compareTo(e){if(r.isPriceModel(e)){if(this.currency!==e.getCurrency())throw new s("Cannot compare prices in different currencies.")}else throw new o("Must be a PriceModel instance.");return this.amount-e.getAmount()}add(e){if(r.isPriceModel(e)){if(this.currency!==e.getCurrency())throw new s("Cannot add prices in different currencies.")}else throw new o("Must be a PriceModel instance.");return new r({amount:this.amount+e.getAmount(),currency:this.currency})}subtract(e){if(r.isPriceModel(e)){if(this.currency!==e.getCurrency())throw new s("Cannot subtract prices in different currencies.")}else throw new o("Must be a PriceModel instance.");return new r({amount:this.amount-e.getAmount(),currency:this.currency})}multiply(e){if(r.isPriceModel(e)){if(this.currency!==e.getCurrency())throw new s("Cannot multiply prices in different currencies.");return new r({amount:this.amount*e.getAmount(),currency:this.currency})}else if(typeof e=="number"&&e>=0)return new r({amount:this.amount*e,currency:this.currency});throw new o("Must be a non-negative number.")}divide(e){if(r.isPriceModel(e)){if(this.currency!==e.getCurrency())throw new s("Cannot divide prices in different currencies.");return new r({amount:this.amount/e.getAmount(),currency:this.currency})}else if(typeof e=="number"&&e>0)return new r({amount:this.amount/e,currency:this.currency});throw new o("Must be a positive number.")}min(...e){if(e.length===0)throw new o("Must provide at least one PriceModel.");return e.reduce((t,n)=>{if(r.isPriceModel(n)){if(t.getCurrency()!==n.getCurrency())throw new s("Cannot compare prices in different currencies.")}else throw new o("Must be a PriceModel instance.");return t.compareTo(n)<0?t:n},this)}max(...e){if(e.length===0)throw new o("Must provide at least one PriceModel.");return e.reduce((t,n)=>{if(r.isPriceModel(n)){if(t.getCurrency()!==n.getCurrency())throw new s("Cannot compare prices in different currencies.")}else throw new o("Must be a PriceModel instance.");return t.compareTo(n)>0?t:n},this)}zero(){return new r({currency:this.currency,amount:0})}isZero(){return this.amount===0}round(){return new r({currency:this.currency,amount:this.getRoundedAmount()})}getRoundedAmount(){return r.getRoundedAmount(this.amount,this.currency)}getFormattedString(){return r.getFormattedString(this.amount,this.currency)}toString(){return this.getFormattedString()}static getFormattedString(e,t,n={displayAsInteger:!1,style:"currency",currencyDisplay:"symbol"}){let i=h[t];if(!t||!i)throw new u("Invalid currency code for formatting.");let a=e,p=n.displayAsInteger?0:r.getDecimalPlaces(t),f={style:n.style??"currency",currency:t,signDisplay:"never",currencyDisplay:n.currencyDisplay,minimumFractionDigits:p,maximumFractionDigits:p};n.displayAsInteger&&(a=Math.ceil(a));try{return new Intl.NumberFormat(i,f).format(a)}catch(C){return console.error(`Error formatting price for currency "${t}" and locale "${i}":`,C),`${g[t]??t} ${r.addThousandSeparators(a.toFixed(p))}`}}static getDecimalPlaces(e){switch(e){case"INR":default:return 2}}static addThousandSeparators(e){let t=e.split("."),n=t[0],i=t.length>1?"."+t[1]:"";return n.replace(/\B(?=(\d{3})+(?!\d))/g,",")+i}static getRoundedAmount(e,t){if(e<0)throw new d("Amount cannot be negative for rounding.");if(t===void 0)throw new u("Invalid currency code for rounding.");let n=r.getDecimalPlaces(t),i=Math.pow(10,n);return Math.round(e*i)/i}};var x=class extends m{taxCategory;taxSystem;taxCountry;taxComponents;constructor(e,t=new Date){super(e,t),this.taxCategory=e.taxCategory,this.taxSystem=e.taxSystem,this.taxCountry=e.taxCountry,this.taxComponents=e.taxComponents.map(n=>({taxSubSystem:n.taxSubSystem,slabs:n.slabs.map(i=>({rate:i.rate,minUnitPrice:new c(i.minUnitPrice),maxUnitPrice:i.maxUnitPrice?new c(i.maxUnitPrice):void 0})),effectiveFrom:n.effectiveFrom,effectiveTo:n.effectiveTo}));}getTaxCategory(){return this.taxCategory}getTaxSystem(){return this.taxSystem}getTaxCountry(){return this.taxCountry}getTaxComponents(){return this.taxComponents}getDetails(){return {taxCategory:this.getTaxCategory(),taxSystem:this.getTaxSystem(),taxCountry:this.getTaxCountry(),taxComponents:this.getTaxComponents().map(e=>({taxSubSystem:e.taxSubSystem,slabs:e.slabs.map(t=>({rate:t.rate,minUnitPrice:t.minUnitPrice.getDetails(),maxUnitPrice:t.maxUnitPrice?t.maxUnitPrice.getDetails():void 0})),effectiveFrom:e.effectiveFrom,effectiveTo:e.effectiveTo})),...super.getDetails()}}};exports.TaxCategoryModel=x;//# sourceMappingURL=TaxCategoryModel.js.map
2
- //# sourceMappingURL=TaxCategoryModel.js.map
1
+ 'use strict';var y=class{customFields;constructor(e,t=new Date){this.customFields={...e.customFields};}getCustomField(e){return this.customFields[e]??null}setCustomField(e,t){this.customFields[e]=t;}getAllCustomFields(){return {...this.customFields}}},m=class extends y{version;createdAt;modifiedAt;modifiedBy;constructor(e,t=new Date){super(e),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,n,i){this.modifiedBy={id:e,authType:t,requestId:n,lambdaName:i};}};var g={INR:"\u20B9"},h={INR:"en-IN"};var d=class extends Error{constructor(e="Amount cannot be negative."){super(`InvalidAmount: ${e}`),this.name="InvalidPriceAmountError";}},u=class extends Error{constructor(e="Currency code is required."){super(`InvalidCurrency: ${e}`),this.name="InvalidCurrencyCodeError";}},s=class extends Error{constructor(e="Cannot perform operation on prices with different currencies."){super(`CurrencyMismatch: ${e}`),this.name="CurrencyMismatchError";}},o=class extends Error{constructor(e){super(`InvalidArgument: ${e}`),this.name="InvalidArgumentError";}};var c=class r{#e;amount;currency;constructor(e){if(this.#e="PriceModel",e.amount<0)throw new d("Amount cannot be negative.");if(!e.currency)throw new u("Currency code is required.");this.amount=e.amount,this.currency=e.currency;}get kind(){return this.#e}static isPriceModel(e){return typeof e=="object"&&e!==null&&e.kind==="PriceModel"}getCurrency(){return this.currency}getAmount(){return this.amount}getDetails(){return {amount:this.amount,currency:this.currency}}compareTo(e){if(r.isPriceModel(e)){if(this.currency!==e.getCurrency())throw new s("Cannot compare prices in different currencies.")}else throw new o("Must be a PriceModel instance.");return this.amount-e.getAmount()}add(e){if(r.isPriceModel(e)){if(this.currency!==e.getCurrency())throw new s("Cannot add prices in different currencies.")}else throw new o("Must be a PriceModel instance.");return new r({amount:this.amount+e.getAmount(),currency:this.currency})}subtract(e){if(r.isPriceModel(e)){if(this.currency!==e.getCurrency())throw new s("Cannot subtract prices in different currencies.")}else throw new o("Must be a PriceModel instance.");return new r({amount:this.amount-e.getAmount(),currency:this.currency})}multiply(e){if(r.isPriceModel(e)){if(this.currency!==e.getCurrency())throw new s("Cannot multiply prices in different currencies.");return new r({amount:this.amount*e.getAmount(),currency:this.currency})}else if(typeof e=="number"&&e>=0)return new r({amount:this.amount*e,currency:this.currency});throw new o("Must be a non-negative number.")}divide(e){if(r.isPriceModel(e)){if(this.currency!==e.getCurrency())throw new s("Cannot divide prices in different currencies.");return new r({amount:this.amount/e.getAmount(),currency:this.currency})}else if(typeof e=="number"&&e>0)return new r({amount:this.amount/e,currency:this.currency});throw new o("Must be a positive number.")}min(...e){if(e.length===0)throw new o("Must provide at least one PriceModel.");return e.reduce((t,n)=>{if(r.isPriceModel(n)){if(t.getCurrency()!==n.getCurrency())throw new s("Cannot compare prices in different currencies.")}else throw new o("Must be a PriceModel instance.");return t.compareTo(n)<0?t:n},this)}max(...e){if(e.length===0)throw new o("Must provide at least one PriceModel.");return e.reduce((t,n)=>{if(r.isPriceModel(n)){if(t.getCurrency()!==n.getCurrency())throw new s("Cannot compare prices in different currencies.")}else throw new o("Must be a PriceModel instance.");return t.compareTo(n)>0?t:n},this)}zero(){return new r({currency:this.currency,amount:0})}isZero(){return this.amount===0}round(){return new r({currency:this.currency,amount:this.getRoundedAmount()})}getRoundedAmount(){return r.getRoundedAmount(this.amount,this.currency)}getFormattedString(){return r.getFormattedString(this.amount,this.currency)}toString(){return this.getFormattedString()}static getFormattedString(e,t,n={displayAsInteger:!1,style:"currency",currencyDisplay:"symbol"}){let i=h[t];if(!t||!i)throw new u("Invalid currency code for formatting.");let a=e,p=n.displayAsInteger?0:r.getDecimalPlaces(t),f={style:n.style??"currency",currency:t,signDisplay:"never",currencyDisplay:n.currencyDisplay,minimumFractionDigits:p,maximumFractionDigits:p};n.displayAsInteger&&(a=Math.ceil(a));try{return new Intl.NumberFormat(i,f).format(a)}catch(C){return console.error(`Error formatting price for currency "${t}" and locale "${i}":`,C),`${g[t]??t} ${r.addThousandSeparators(a.toFixed(p))}`}}static getDecimalPlaces(e){switch(e){case"INR":default:return 2}}static addThousandSeparators(e){let t=e.split("."),n=t[0],i=t.length>1?"."+t[1]:"";return n.replace(/\B(?=(\d{3})+(?!\d))/g,",")+i}static getRoundedAmount(e,t){if(e<0)throw new d("Amount cannot be negative for rounding.");if(t===void 0)throw new u("Invalid currency code for rounding.");let n=r.getDecimalPlaces(t),i=Math.pow(10,n);return Math.round(e*i)/i}};var x=class extends m{taxCategory;taxSystem;taxCountry;taxComponents;constructor(e,t=new Date){super(e,t),this.taxCategory=e.taxCategory,this.taxSystem=e.taxSystem,this.taxCountry=e.taxCountry,this.taxComponents=e.taxComponents.map(n=>({taxSubSystem:n.taxSubSystem,slabs:n.slabs.map(i=>({rate:i.rate,minUnitPrice:new c(i.minUnitPrice),maxUnitPrice:i.maxUnitPrice?new c(i.maxUnitPrice):void 0})),effectiveFrom:n.effectiveFrom,effectiveTo:n.effectiveTo}));}getTaxCategory(){return this.taxCategory}getTaxSystem(){return this.taxSystem}getTaxCountry(){return this.taxCountry}getTaxComponents(){return this.taxComponents}getDetails(){return {taxCategory:this.getTaxCategory(),taxSystem:this.getTaxSystem(),taxCountry:this.getTaxCountry(),taxComponents:this.getTaxComponents().map(e=>({taxSubSystem:e.taxSubSystem,slabs:e.slabs.map(t=>({rate:t.rate,minUnitPrice:t.minUnitPrice.getDetails(),maxUnitPrice:t.maxUnitPrice?t.maxUnitPrice.getDetails():void 0})),effectiveFrom:e.effectiveFrom,effectiveTo:e.effectiveTo})),...super.getDetails()}}};exports.TaxCategoryModel=x;//# sourceMappingURL=TaxCategory.js.map
2
+ //# sourceMappingURL=TaxCategory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/Classes/Base.ts","../../src/Classes/Enum.ts","../../src/Classes/Error.ts","../../src/Classes/Price.ts","../../src/Classes/TaxCategory.ts"],"names":["CustomFieldModel","data","date","fieldName","value","BaseModel","id","authType","requestId","lambdaName","CurrencySymbolMap","CurrencyLocaleMap","InvalidPriceAmountError","message","InvalidCurrencyCodeError","CurrencyMismatchError","InvalidArgumentError","PriceModel","_PriceModel","#kind","obj","priceModel","factor","divisor","priceModels","minPrice","currentPrice","maxPrice","amount","currency","options","locale","valueToFormat","fractionDigits","formattingOptions","error","numStr","parts","integerPart","decimalPart","decimalPlaces","multiplier","TaxCategoryModel","component","slab"],"mappings":"aAWO,IAAMA,CAAN,CAAA,KAAuB,CAClB,YAAA,CACV,WAAYC,CAAAA,CAAAA,CAA6BC,CAAa,CAAA,IAAI,IAAQ,CAAA,CAChE,IAAK,CAAA,YAAA,CAAe,CAAE,GAAGD,CAAAA,CAAK,YAAa,EAC7C,CAOA,cAAA,CAAeE,CAAwB,CAAA,CACrC,OAAO,IAAK,CAAA,YAAA,CAAaA,CAAS,CAAA,EAAK,IACzC,CAQA,cAAeA,CAAAA,CAAAA,CAAmBC,EAAkB,CAClD,IAAA,CAAK,YAAaD,CAAAA,CAAS,CAAIC,CAAAA,EACjC,CAMA,kBAAA,EAAmC,CACjC,O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,CAAK,CAAA,YAAA,CAAe,IAAI3B,CAAAA,CAAW2B,CAAK,CAAA,YAAY,EAAI,KACvE,CAAA,CAAA,CAAE,CACF,CAAA,aAAA,CAAeD,CAAU,CAAA,aAAA,CACzB,WAAaA,CAAAA,CAAAA,CAAU,WACxB,CAAE,CAAA,EACH,CAEO,cAAA,EAAyB,CAC/B,OAAO,IAAK,CAAA,WACb,CAEO,YAA0B,EAAA,CAChC,OAAO,IAAA,CAAK,SACb,CAEO,aAA6B,EAAA,CACnC,OAAO,IAAK,CAAA,UACb,CAEO,gBAAA,EAKH,CACH,OAAO,IAAK,CAAA,aACb,CAEO,UAA8B,EAAA,CACpC,OAAO,CACN,WAAa,CAAA,IAAA,CAAK,cAAe,EAAA,CACjC,UAAW,IAAK,CAAA,YAAA,EAChB,CAAA,UAAA,CAAY,IAAK,CAAA,aAAA,EACjB,CAAA,aAAA,CAAe,KAAK,gBAAiB,EAAA,CAAE,GAAIA,CAAAA,CAAAA,GAAc,CACxD,YAAA,CAAcA,CAAU,CAAA,YAAA,CACxB,MAAOA,CAAU,CAAA,KAAA,CAAM,GAAIC,CAAAA,CAAAA,GAAS,CACnC,IAAA,CAAMA,CAAK,CAAA,IAAA,CACX,aAAcA,CAAK,CAAA,YAAA,CAAa,UAAW,EAAA,CAC3C,YAAcA,CAAAA,CAAAA,CAAK,YAAeA,CAAAA,CAAAA,CAAK,aAAa,UAAW,EAAA,CAAI,KACpE,CAAA,CAAA,CAAE,CACF,CAAA,aAAA,CAAeD,CAAU,CAAA,aAAA,CACzB,YAAaA,CAAU,CAAA,WACxB,CAAE,CAAA,CAAA,CACF,GAAG,KAAA,CAAM,UAAW,EACrB,CACD,CACD","file":"TaxCategory.js","sourcesContent":["import { AuthType } from \"../Auth\";\r\nimport { ISODateTimeUTC, Prettify } from \"./Common\";\r\n\r\nexport interface CustomFields {\r\n [key: string]: any;\r\n}\r\n\r\nexport type CustomFieldAttributes = {\r\n customFields?: CustomFields;\r\n}\r\n\r\nexport class CustomFieldModel {\r\n protected customFields: CustomFields;\r\n constructor(data: CustomFieldAttributes, date: Date = new Date()) {\r\n this.customFields = { ...data.customFields };\r\n }\r\n\r\n /**\r\n * Retrieves the value of a specific custom field.\r\n * @param fieldName - The name (key) of the custom field to retrieve.\r\n * @returns The value of the custom field, or null if the field does not exist.\r\n */\r\n getCustomField(fieldName: string): any {\r\n return this.customFields[fieldName] ?? null;\r\n }\r\n\r\n /**\r\n * Sets the value of a specific custom field.\r\n * Also updates the modification timestamp and increments the version.\r\n * @param fieldName - The name (key) of the custom field to set.\r\n * @param value - The value to assign to the custom field.\r\n */\r\n setCustomField(fieldName: string, value: any): void {\r\n this.customFields[fieldName] = value;\r\n }\r\n\r\n /**\r\n * Retrieves a shallow copy of all custom fields associated with the instance.\r\n * @returns An object containing all custom fields.\r\n */\r\n getAllCustomFields(): CustomFields {\r\n return { ...this.customFields };\r\n }\r\n}\r\n\r\nexport type ModifiedBy = {\r\n id?: string;\r\n authType?: string;\r\n requestId?: string;\r\n lambdaName?: string;\r\n}\r\n\r\nexport type BaseAttributes = Prettify<CustomFieldAttributes & {\r\n version?: number;\r\n createdAt?: ISODateTimeUTC;\r\n modifiedAt?: ISODateTimeUTC;\r\n modifiedBy?: ModifiedBy;\r\n}>;\r\n\r\nexport type BaseData = Required<BaseAttributes>;\r\n\r\n/**\r\n * Provides common foundational properties and methods for other data models.\r\n * Handles tracking of custom fields, versioning, and timestamps.\r\n */\r\nexport default class BaseModel extends CustomFieldModel {\r\n protected version: number;\r\n protected createdAt: ISODateTimeUTC;\r\n protected modifiedAt: ISODateTimeUTC;\r\n protected modifiedBy: ModifiedBy;\r\n\r\n /**\r\n * Creates an instance of BaseModel.\r\n * Initializes common properties like timestamps, version, and custom fields.\r\n * @param data - Optional initial attributes for the base model.\r\n * @param date - Optional date object to use for default timestamps (defaults to current time).\r\n */\r\n constructor(data: BaseAttributes, date: Date = new Date()) {\r\n super(data);\r\n this.version = data.version ?? 1;\r\n this.createdAt = data.createdAt && !isNaN(Date.parse(data.createdAt))\r\n ?\r\n new Date(data.createdAt).toISOString()\r\n :\r\n date.toISOString();\r\n this.modifiedAt = data.modifiedAt && !isNaN(Date.parse(data.modifiedAt))\r\n ? new Date(data.modifiedAt).toISOString()\r\n : date.toISOString();\r\n\r\n this.modifiedBy = { ...data.modifiedBy };\r\n }\r\n\r\n /**\r\n * Gets a plain data object representing the base model's current state.\r\n * @returns BaseData object containing common properties.\r\n */\r\n getDetails(): BaseData {\r\n return {\r\n customFields: this.getAllCustomFields(), // Use getter to return a copy\r\n version: this.getVersion(),\r\n createdAt: this.getCreatedAt(),\r\n modifiedAt: this.getModifiedAt(),\r\n modifiedBy: this.getModifiedBy(),\r\n }\r\n }\r\n\r\n /**\r\n * Gets the current version number of the model instance.\r\n * @returns The version number.\r\n */\r\n getVersion(): number {\r\n return this.version;\r\n }\r\n\r\n /**\r\n * Gets the creation timestamp as an ISO 8601 string.\r\n * @returns The creation timestamp string.\r\n */\r\n getCreatedAt(): string {\r\n return this.createdAt;\r\n }\r\n\r\n /**\r\n * Gets the creation timestamp as a Unix epoch time (milliseconds).\r\n * @returns The creation time in milliseconds since the epoch.\r\n */\r\n getCreatedAtTime(): number {\r\n return new Date(this.createdAt).getTime();\r\n }\r\n\r\n\r\n /**\r\n * Gets the last modification timestamp as an ISO 8601 string.\r\n * @returns The last modification timestamp string.\r\n */\r\n getModifiedAt(): string {\r\n return this.modifiedAt;\r\n }\r\n\r\n /**\r\n * Gets the last modification timestamp as a Unix epoch time (milliseconds).\r\n * @returns The last modification time in milliseconds since the epoch.\r\n */\r\n getModifiedAtTime(): number {\r\n return new Date(this.modifiedAt).getTime();\r\n }\r\n\r\n /**\r\n * Gets the identifier of the user or process that last modified the instance.\r\n * @returns\r\n */\r\n getModifiedBy(): ModifiedBy {\r\n return { ...this.modifiedBy };\r\n }\r\n\r\n /**\r\n * Sets the identifier of the user or process that last modified the instance.\r\n * @param modifiedBy - The identifier string.\r\n */\r\n setModifiedBy(id?: string, authType?: AuthType, requestId?: string, lambdaName?: string): void {\r\n this.modifiedBy = {\r\n id,\r\n authType,\r\n requestId,\r\n lambdaName,\r\n };\r\n }\r\n}\r\n","/**\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 ChargeType {\r\n SHIPPING = 'SHIPPING',\r\n ADJUSTMENT = 'ADJUSTMENT'\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 InvalidLineItemStateError extends Error {\r\n constructor(state: string) {\r\n super(`Invalid line item state: ${state}`);\r\n this.name = 'InvalidLineItemStateError';\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 DuplicateSelectionAttributeError extends Error {\r\n constructor(attribute: string) {\r\n super(`Duplicate selection attribute found: ${attribute}`);\r\n this.name = 'DuplicateSelectionAttributeError';\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}\r\n\r\nexport class InvalidChargeError extends Error {\r\n constructor(message: string = \"Invalid charge data.\") {\r\n super(`InvalidCharge: ${message}`);\r\n this.name = 'InvalidChargeError';\r\n }\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 #kind: string;\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 this.#kind = \"PriceModel\";\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 get kind() {\r\n return this.#kind;\r\n }\r\n\r\n static isPriceModel(obj: unknown): obj is PriceModel {\r\n return typeof obj === \"object\" &&\r\n obj !== null &&\r\n (obj as any).kind === \"PriceModel\";\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.isPriceModel(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.isPriceModel(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.isPriceModel(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 (PriceModel.isPriceModel(factor)) {\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 (PriceModel.isPriceModel(divisor)) {\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 (!PriceModel.isPriceModel(currentPrice)) {\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 }, this);\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 (!PriceModel.isPriceModel(currentPrice)) {\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 }, this);\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 * 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 toString() {\r\n return this.getFormattedString();\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 Utils from \"../Utils\";\r\nimport BaseModel, { BaseAttributes } from \"./Base\";\r\nimport { CountryCode, ISODateTimeUTC } from \"./Common\";\r\nimport { TaxSystem } from \"./Enum\";\r\nimport PriceModel from \"./Price\";\r\nimport { TaxRuleModel, TaxSlabData, TaxSlabModel } from \"./TaxRule\";\r\n\r\nexport type TaxCategoryAttributes = {\r\n\ttaxCategory: string;\r\n\ttaxSystem: TaxSystem;\r\n\ttaxCountry: CountryCode;\r\n\ttaxComponents: {\r\n\t\ttaxSubSystem: string;\r\n\t\tslabs: TaxSlabData[];\r\n\t\teffectiveFrom: ISODateTimeUTC;\r\n\t\teffectiveTo?: ISODateTimeUTC;\r\n\t}[];\r\n} & BaseAttributes;\r\n\r\nexport type TaxCategoryData = Required<TaxCategoryAttributes>;\r\n\r\nexport class TaxCategoryModel extends BaseModel {\r\n\tprotected taxCategory: string;\r\n\tprotected taxSystem: TaxSystem;\r\n\tprotected taxCountry: CountryCode;\r\n\tprotected taxComponents: {\r\n\t\ttaxSubSystem: string;\r\n\t\tslabs: TaxSlabModel[];\r\n\t\teffectiveFrom: ISODateTimeUTC;\r\n\t\teffectiveTo?: ISODateTimeUTC;\r\n\t}[];\r\n\r\n\tconstructor(data: TaxCategoryAttributes, date: Date = new Date()) {\r\n\t\tsuper(data, date);\r\n\t\tthis.taxCategory = data.taxCategory;\r\n\t\tthis.taxSystem = data.taxSystem;\r\n\t\tthis.taxCountry = data.taxCountry;\r\n\t\tthis.taxComponents = data.taxComponents.map(component => ({\r\n\t\t\ttaxSubSystem: component.taxSubSystem,\r\n\t\t\tslabs: component.slabs.map(slab => ({\r\n\t\t\t\trate: slab.rate,\r\n\t\t\t\tminUnitPrice: new PriceModel(slab.minUnitPrice),\r\n\t\t\t\tmaxUnitPrice: slab.maxUnitPrice ? new PriceModel(slab.maxUnitPrice) : undefined,\r\n\t\t\t})),\r\n\t\t\teffectiveFrom: component.effectiveFrom,\r\n\t\t\teffectiveTo: component.effectiveTo\r\n\t\t}));\r\n\t}\r\n\r\n\tpublic getTaxCategory(): string {\r\n\t\treturn this.taxCategory;\r\n\t}\r\n\r\n\tpublic getTaxSystem(): TaxSystem {\r\n\t\treturn this.taxSystem;\r\n\t}\r\n\r\n\tpublic getTaxCountry(): CountryCode {\r\n\t\treturn this.taxCountry;\r\n\t}\r\n\r\n\tpublic getTaxComponents(): {\r\n\t\ttaxSubSystem: string;\r\n\t\tslabs: TaxSlabModel[];\r\n\t\teffectiveFrom: ISODateTimeUTC;\r\n\t\teffectiveTo?: ISODateTimeUTC;\r\n\t}[] {\r\n\t\treturn this.taxComponents;\r\n\t}\r\n\r\n\tpublic getDetails(): TaxCategoryData {\r\n\t\treturn {\r\n\t\t\ttaxCategory: this.getTaxCategory(),\r\n\t\t\ttaxSystem: this.getTaxSystem(),\r\n\t\t\ttaxCountry: this.getTaxCountry(),\r\n\t\t\ttaxComponents: this.getTaxComponents().map(component => ({\r\n\t\t\t\ttaxSubSystem: component.taxSubSystem,\r\n\t\t\t\tslabs: component.slabs.map(slab => ({\r\n\t\t\t\t\trate: slab.rate,\r\n\t\t\t\t\tminUnitPrice: slab.minUnitPrice.getDetails(),\r\n\t\t\t\t\tmaxUnitPrice: slab.maxUnitPrice ? slab.maxUnitPrice.getDetails() : undefined,\r\n\t\t\t\t})),\r\n\t\t\t\teffectiveFrom: component.effectiveFrom,\r\n\t\t\t\teffectiveTo: component.effectiveTo\r\n\t\t\t})),\r\n\t\t\t...super.getDetails(),\r\n\t\t};\r\n\t}\r\n}\r\n"]}
@@ -1,2 +1,2 @@
1
- import {a}from'../chunk-6X5O25W5.mjs';import'../chunk-FC4P26U3.mjs';import'../chunk-XPKK6DFA.mjs';import {b}from'../chunk-6KCJVEZD.mjs';var s=class extends b{taxCategory;taxSystem;taxCountry;taxComponents;constructor(t,e=new Date){super(t,e),this.taxCategory=t.taxCategory,this.taxSystem=t.taxSystem,this.taxCountry=t.taxCountry,this.taxComponents=t.taxComponents.map(a$1=>({taxSubSystem:a$1.taxSubSystem,slabs:a$1.slabs.map(r=>({rate:r.rate,minUnitPrice:new a(r.minUnitPrice),maxUnitPrice:r.maxUnitPrice?new a(r.maxUnitPrice):void 0})),effectiveFrom:a$1.effectiveFrom,effectiveTo:a$1.effectiveTo}));}getTaxCategory(){return this.taxCategory}getTaxSystem(){return this.taxSystem}getTaxCountry(){return this.taxCountry}getTaxComponents(){return this.taxComponents}getDetails(){return {taxCategory:this.getTaxCategory(),taxSystem:this.getTaxSystem(),taxCountry:this.getTaxCountry(),taxComponents:this.getTaxComponents().map(t=>({taxSubSystem:t.taxSubSystem,slabs:t.slabs.map(e=>({rate:e.rate,minUnitPrice:e.minUnitPrice.getDetails(),maxUnitPrice:e.maxUnitPrice?e.maxUnitPrice.getDetails():void 0})),effectiveFrom:t.effectiveFrom,effectiveTo:t.effectiveTo})),...super.getDetails()}}};export{s as TaxCategoryModel};//# sourceMappingURL=TaxCategoryModel.mjs.map
2
- //# sourceMappingURL=TaxCategoryModel.mjs.map
1
+ import {a}from'../chunk-6X5O25W5.mjs';import'../chunk-FC4P26U3.mjs';import'../chunk-XPKK6DFA.mjs';import {b}from'../chunk-6KCJVEZD.mjs';var s=class extends b{taxCategory;taxSystem;taxCountry;taxComponents;constructor(t,e=new Date){super(t,e),this.taxCategory=t.taxCategory,this.taxSystem=t.taxSystem,this.taxCountry=t.taxCountry,this.taxComponents=t.taxComponents.map(a$1=>({taxSubSystem:a$1.taxSubSystem,slabs:a$1.slabs.map(r=>({rate:r.rate,minUnitPrice:new a(r.minUnitPrice),maxUnitPrice:r.maxUnitPrice?new a(r.maxUnitPrice):void 0})),effectiveFrom:a$1.effectiveFrom,effectiveTo:a$1.effectiveTo}));}getTaxCategory(){return this.taxCategory}getTaxSystem(){return this.taxSystem}getTaxCountry(){return this.taxCountry}getTaxComponents(){return this.taxComponents}getDetails(){return {taxCategory:this.getTaxCategory(),taxSystem:this.getTaxSystem(),taxCountry:this.getTaxCountry(),taxComponents:this.getTaxComponents().map(t=>({taxSubSystem:t.taxSubSystem,slabs:t.slabs.map(e=>({rate:e.rate,minUnitPrice:e.minUnitPrice.getDetails(),maxUnitPrice:e.maxUnitPrice?e.maxUnitPrice.getDetails():void 0})),effectiveFrom:t.effectiveFrom,effectiveTo:t.effectiveTo})),...super.getDetails()}}};export{s as TaxCategoryModel};//# sourceMappingURL=TaxCategory.mjs.map
2
+ //# sourceMappingURL=TaxCategory.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/Classes/TaxCategory.ts"],"names":["TaxCategoryModel","BaseModel","data","date","component","slab","PriceModel"],"mappings":"wIAqBO,IAAMA,EAAN,cAA+BC,CAAU,CACrC,WAAA,CACA,UACA,UACA,CAAA,aAAA,CAOV,WAAYC,CAAAA,CAAAA,CAA6BC,EAAa,IAAI,IAAA,CAAQ,CACjE,KAAA,CAAMD,EAAMC,CAAI,CAAA,CAChB,IAAK,CAAA,WAAA,CAAcD,EAAK,WACxB,CAAA,IAAA,CAAK,SAAYA,CAAAA,CAAAA,CAAK,UACtB,IA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ACF,CAAA,GAAG,MAAM,UAAW,EACrB,CACD,CACD","file":"TaxCategory.mjs","sourcesContent":["import Utils from \"../Utils\";\r\nimport BaseModel, { BaseAttributes } from \"./Base\";\r\nimport { CountryCode, ISODateTimeUTC } from \"./Common\";\r\nimport { TaxSystem } from \"./Enum\";\r\nimport PriceModel from \"./Price\";\r\nimport { TaxRuleModel, TaxSlabData, TaxSlabModel } from \"./TaxRule\";\r\n\r\nexport type TaxCategoryAttributes = {\r\n\ttaxCategory: string;\r\n\ttaxSystem: TaxSystem;\r\n\ttaxCountry: CountryCode;\r\n\ttaxComponents: {\r\n\t\ttaxSubSystem: string;\r\n\t\tslabs: TaxSlabData[];\r\n\t\teffectiveFrom: ISODateTimeUTC;\r\n\t\teffectiveTo?: ISODateTimeUTC;\r\n\t}[];\r\n} & BaseAttributes;\r\n\r\nexport type TaxCategoryData = Required<TaxCategoryAttributes>;\r\n\r\nexport class TaxCategoryModel extends BaseModel {\r\n\tprotected taxCategory: string;\r\n\tprotected taxSystem: TaxSystem;\r\n\tprotected taxCountry: CountryCode;\r\n\tprotected taxComponents: {\r\n\t\ttaxSubSystem: string;\r\n\t\tslabs: TaxSlabModel[];\r\n\t\teffectiveFrom: ISODateTimeUTC;\r\n\t\teffectiveTo?: ISODateTimeUTC;\r\n\t}[];\r\n\r\n\tconstructor(data: TaxCategoryAttributes, date: Date = new Date()) {\r\n\t\tsuper(data, date);\r\n\t\tthis.taxCategory = data.taxCategory;\r\n\t\tthis.taxSystem = data.taxSystem;\r\n\t\tthis.taxCountry = data.taxCountry;\r\n\t\tthis.taxComponents = data.taxComponents.map(component => ({\r\n\t\t\ttaxSubSystem: component.taxSubSystem,\r\n\t\t\tslabs: component.slabs.map(slab => ({\r\n\t\t\t\trate: slab.rate,\r\n\t\t\t\tminUnitPrice: new PriceModel(slab.minUnitPrice),\r\n\t\t\t\tmaxUnitPrice: slab.maxUnitPrice ? new PriceModel(slab.maxUnitPrice) : undefined,\r\n\t\t\t})),\r\n\t\t\teffectiveFrom: component.effectiveFrom,\r\n\t\t\teffectiveTo: component.effectiveTo\r\n\t\t}));\r\n\t}\r\n\r\n\tpublic getTaxCategory(): string {\r\n\t\treturn this.taxCategory;\r\n\t}\r\n\r\n\tpublic getTaxSystem(): TaxSystem {\r\n\t\treturn this.taxSystem;\r\n\t}\r\n\r\n\tpublic getTaxCountry(): CountryCode {\r\n\t\treturn this.taxCountry;\r\n\t}\r\n\r\n\tpublic getTaxComponents(): {\r\n\t\ttaxSubSystem: string;\r\n\t\tslabs: TaxSlabModel[];\r\n\t\teffectiveFrom: ISODateTimeUTC;\r\n\t\teffectiveTo?: ISODateTimeUTC;\r\n\t}[] {\r\n\t\treturn this.taxComponents;\r\n\t}\r\n\r\n\tpublic getDetails(): TaxCategoryData {\r\n\t\treturn {\r\n\t\t\ttaxCategory: this.getTaxCategory(),\r\n\t\t\ttaxSystem: this.getTaxSystem(),\r\n\t\t\ttaxCountry: this.getTaxCountry(),\r\n\t\t\ttaxComponents: this.getTaxComponents().map(component => ({\r\n\t\t\t\ttaxSubSystem: component.taxSubSystem,\r\n\t\t\t\tslabs: component.slabs.map(slab => ({\r\n\t\t\t\t\trate: slab.rate,\r\n\t\t\t\t\tminUnitPrice: slab.minUnitPrice.getDetails(),\r\n\t\t\t\t\tmaxUnitPrice: slab.maxUnitPrice ? slab.maxUnitPrice.getDetails() : undefined,\r\n\t\t\t\t})),\r\n\t\t\t\teffectiveFrom: component.effectiveFrom,\r\n\t\t\t\teffectiveTo: component.effectiveTo\r\n\t\t\t})),\r\n\t\t\t...super.getDetails(),\r\n\t\t};\r\n\t}\r\n}\r\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "b23-lib",
3
- "version": "3.0.0",
3
+ "version": "3.0.2",
4
4
  "description": "This repo hold common classes, type and util functiona",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -196,6 +196,16 @@
196
196
  "default": "./dist/Classes/ShoppingContainer.js"
197
197
  }
198
198
  },
199
+ "./tax-category": {
200
+ "import": {
201
+ "types": "./dist/Classes/TaxCategory.d.mts",
202
+ "default": "./dist/Classes/TaxCategory.mjs"
203
+ },
204
+ "require": {
205
+ "types": "./dist/Classes/TaxCategory.d.ts",
206
+ "default": "./dist/Classes/TaxCategory.js"
207
+ }
208
+ },
199
209
  "./tax-rule": {
200
210
  "import": {
201
211
  "types": "./dist/Classes/TaxRule.d.mts",
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/Classes/Base.ts","../../src/Classes/Enum.ts","../../src/Classes/Error.ts","../../src/Classes/Price.ts","../../src/Classes/TaxCategoryModel.ts"],"names":["CustomFieldModel","data","date","fieldName","value","BaseModel","id","authType","requestId","lambdaName","CurrencySymbolMap","CurrencyLocaleMap","InvalidPriceAmountError","message","InvalidCurrencyCodeError","CurrencyMismatchError","InvalidArgumentError","PriceModel","_PriceModel","#kind","obj","priceModel","factor","divisor","priceModels","minPrice","currentPrice","maxPrice","amount","currency","options","locale","valueToFormat","fractionDigits","formattingOptions","error","numStr","parts","integerPart","decimalPart","decimalPlaces","multiplier","TaxCategoryModel","component","slab"],"mappings":"aAWO,IAAMA,CAAN,CAAA,KAAuB,CAClB,YAAA,CACV,WAAYC,CAAAA,CAAAA,CAA6BC,CAAa,CAAA,IAAI,IAAQ,CAAA,CAChE,IAAK,CAAA,YAAA,CAAe,CAAE,GAAGD,CAAAA,CAAK,YAAa,EAC7C,CAOA,cAAA,CAAeE,CAAwB,CAAA,CACrC,OAAO,IAAK,CAAA,YAAA,CAAaA,CAAS,CAAA,EAAK,IACzC,CAQA,cAAeA,CAAAA,CAAAA,CAAmBC,EAAkB,CAClD,IAAA,CAAK,YAAaD,CAAAA,CAAS,CAAIC,CAAAA,EACjC,CAMA,kBAAA,EAAmC,CACjC,OAAO,CAAE,GAAG,IAAA,CAAK,YAAa,CAChC,CACF,CAAA,CAsBqBC,EAArB,cAAuCL,CAAiB,CAC5C,OAAA,CACA,SACA,CA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aAAA,CAAeD,CAAU,CAAA,aAAA,CACzB,WAAaA,CAAAA,CAAAA,CAAU,WACxB,CAAE,CAAA,EACH,CAEO,cAAA,EAAyB,CAC/B,OAAO,IAAK,CAAA,WACb,CAEO,YAA0B,EAAA,CAChC,OAAO,IAAA,CAAK,SACb,CAEO,aAA6B,EAAA,CACnC,OAAO,IAAK,CAAA,UACb,CAEO,gBAAA,EAKH,CACH,OAAO,IAAK,CAAA,aACb,CAEO,UAA8B,EAAA,CACpC,OAAO,CACN,WAAa,CAAA,IAAA,CAAK,cAAe,EAAA,CACjC,UAAW,IAAK,CAAA,YAAA,EAChB,CAAA,UAAA,CAAY,IAAK,CAAA,aAAA,EACjB,CAAA,aAAA,CAAe,KAAK,gBAAiB,EAAA,CAAE,GAAIA,CAAAA,CAAAA,GAAc,CACxD,YAAA,CAAcA,CAAU,CAAA,YAAA,CACxB,MAAOA,CAAU,CAAA,KAAA,CAAM,GAAIC,CAAAA,CAAAA,GAAS,CACnC,IAAA,CAAMA,CAAK,CAAA,IAAA,CACX,aAAcA,CAAK,CAAA,YAAA,CAAa,UAAW,EAAA,CAC3C,YAAcA,CAAAA,CAAAA,CAAK,YAAeA,CAAAA,CAAAA,CAAK,aAAa,UAAW,EAAA,CAAI,KACpE,CAAA,CAAA,CAAE,CACF,CAAA,aAAA,CAAeD,CAAU,CAAA,aAAA,CACzB,YAAaA,CAAU,CAAA,WACxB,CAAE,CAAA,CAAA,CACF,GAAG,KAAA,CAAM,UAAW,EACrB,CACD,CACD","file":"TaxCategoryModel.js","sourcesContent":["import { AuthType } from \"../Auth\";\r\nimport { ISODateTimeUTC, Prettify } from \"./Common\";\r\n\r\nexport interface CustomFields {\r\n [key: string]: any;\r\n}\r\n\r\nexport type CustomFieldAttributes = {\r\n customFields?: CustomFields;\r\n}\r\n\r\nexport class CustomFieldModel {\r\n protected customFields: CustomFields;\r\n constructor(data: CustomFieldAttributes, date: Date = new Date()) {\r\n this.customFields = { ...data.customFields };\r\n }\r\n\r\n /**\r\n * Retrieves the value of a specific custom field.\r\n * @param fieldName - The name (key) of the custom field to retrieve.\r\n * @returns The value of the custom field, or null if the field does not exist.\r\n */\r\n getCustomField(fieldName: string): any {\r\n return this.customFields[fieldName] ?? null;\r\n }\r\n\r\n /**\r\n * Sets the value of a specific custom field.\r\n * Also updates the modification timestamp and increments the version.\r\n * @param fieldName - The name (key) of the custom field to set.\r\n * @param value - The value to assign to the custom field.\r\n */\r\n setCustomField(fieldName: string, value: any): void {\r\n this.customFields[fieldName] = value;\r\n }\r\n\r\n /**\r\n * Retrieves a shallow copy of all custom fields associated with the instance.\r\n * @returns An object containing all custom fields.\r\n */\r\n getAllCustomFields(): CustomFields {\r\n return { ...this.customFields };\r\n }\r\n}\r\n\r\nexport type ModifiedBy = {\r\n id?: string;\r\n authType?: string;\r\n requestId?: string;\r\n lambdaName?: string;\r\n}\r\n\r\nexport type BaseAttributes = Prettify<CustomFieldAttributes & {\r\n version?: number;\r\n createdAt?: ISODateTimeUTC;\r\n modifiedAt?: ISODateTimeUTC;\r\n modifiedBy?: ModifiedBy;\r\n}>;\r\n\r\nexport type BaseData = Required<BaseAttributes>;\r\n\r\n/**\r\n * Provides common foundational properties and methods for other data models.\r\n * Handles tracking of custom fields, versioning, and timestamps.\r\n */\r\nexport default class BaseModel extends CustomFieldModel {\r\n protected version: number;\r\n protected createdAt: ISODateTimeUTC;\r\n protected modifiedAt: ISODateTimeUTC;\r\n protected modifiedBy: ModifiedBy;\r\n\r\n /**\r\n * Creates an instance of BaseModel.\r\n * Initializes common properties like timestamps, version, and custom fields.\r\n * @param data - Optional initial attributes for the base model.\r\n * @param date - Optional date object to use for default timestamps (defaults to current time).\r\n */\r\n constructor(data: BaseAttributes, date: Date = new Date()) {\r\n super(data);\r\n this.version = data.version ?? 1;\r\n this.createdAt = data.createdAt && !isNaN(Date.parse(data.createdAt))\r\n ?\r\n new Date(data.createdAt).toISOString()\r\n :\r\n date.toISOString();\r\n this.modifiedAt = data.modifiedAt && !isNaN(Date.parse(data.modifiedAt))\r\n ? new Date(data.modifiedAt).toISOString()\r\n : date.toISOString();\r\n\r\n this.modifiedBy = { ...data.modifiedBy };\r\n }\r\n\r\n /**\r\n * Gets a plain data object representing the base model's current state.\r\n * @returns BaseData object containing common properties.\r\n */\r\n getDetails(): BaseData {\r\n return {\r\n customFields: this.getAllCustomFields(), // Use getter to return a copy\r\n version: this.getVersion(),\r\n createdAt: this.getCreatedAt(),\r\n modifiedAt: this.getModifiedAt(),\r\n modifiedBy: this.getModifiedBy(),\r\n }\r\n }\r\n\r\n /**\r\n * Gets the current version number of the model instance.\r\n * @returns The version number.\r\n */\r\n getVersion(): number {\r\n return this.version;\r\n }\r\n\r\n /**\r\n * Gets the creation timestamp as an ISO 8601 string.\r\n * @returns The creation timestamp string.\r\n */\r\n getCreatedAt(): string {\r\n return this.createdAt;\r\n }\r\n\r\n /**\r\n * Gets the creation timestamp as a Unix epoch time (milliseconds).\r\n * @returns The creation time in milliseconds since the epoch.\r\n */\r\n getCreatedAtTime(): number {\r\n return new Date(this.createdAt).getTime();\r\n }\r\n\r\n\r\n /**\r\n * Gets the last modification timestamp as an ISO 8601 string.\r\n * @returns The last modification timestamp string.\r\n */\r\n getModifiedAt(): string {\r\n return this.modifiedAt;\r\n }\r\n\r\n /**\r\n * Gets the last modification timestamp as a Unix epoch time (milliseconds).\r\n * @returns The last modification time in milliseconds since the epoch.\r\n */\r\n getModifiedAtTime(): number {\r\n return new Date(this.modifiedAt).getTime();\r\n }\r\n\r\n /**\r\n * Gets the identifier of the user or process that last modified the instance.\r\n * @returns\r\n */\r\n getModifiedBy(): ModifiedBy {\r\n return { ...this.modifiedBy };\r\n }\r\n\r\n /**\r\n * Sets the identifier of the user or process that last modified the instance.\r\n * @param modifiedBy - The identifier string.\r\n */\r\n setModifiedBy(id?: string, authType?: AuthType, requestId?: string, lambdaName?: string): void {\r\n this.modifiedBy = {\r\n id,\r\n authType,\r\n requestId,\r\n lambdaName,\r\n };\r\n }\r\n}\r\n","/**\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 ChargeType {\r\n SHIPPING = 'SHIPPING',\r\n ADJUSTMENT = 'ADJUSTMENT'\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 InvalidLineItemStateError extends Error {\r\n constructor(state: string) {\r\n super(`Invalid line item state: ${state}`);\r\n this.name = 'InvalidLineItemStateError';\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 DuplicateSelectionAttributeError extends Error {\r\n constructor(attribute: string) {\r\n super(`Duplicate selection attribute found: ${attribute}`);\r\n this.name = 'DuplicateSelectionAttributeError';\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}\r\n\r\nexport class InvalidChargeError extends Error {\r\n constructor(message: string = \"Invalid charge data.\") {\r\n super(`InvalidCharge: ${message}`);\r\n this.name = 'InvalidChargeError';\r\n }\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 #kind: string;\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 this.#kind = \"PriceModel\";\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 get kind() {\r\n return this.#kind;\r\n }\r\n\r\n static isPriceModel(obj: unknown): obj is PriceModel {\r\n return typeof obj === \"object\" &&\r\n obj !== null &&\r\n (obj as any).kind === \"PriceModel\";\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.isPriceModel(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.isPriceModel(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.isPriceModel(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 (PriceModel.isPriceModel(factor)) {\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 (PriceModel.isPriceModel(divisor)) {\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 (!PriceModel.isPriceModel(currentPrice)) {\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 }, this);\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 (!PriceModel.isPriceModel(currentPrice)) {\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 }, this);\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 * 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 toString() {\r\n return this.getFormattedString();\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 Utils from \"../Utils\";\r\nimport BaseModel, { BaseAttributes } from \"./Base\";\r\nimport { CountryCode, ISODateTimeUTC } from \"./Common\";\r\nimport { TaxSystem } from \"./Enum\";\r\nimport PriceModel from \"./Price\";\r\nimport { TaxRuleModel, TaxSlabData, TaxSlabModel } from \"./TaxRule\";\r\n\r\nexport type TaxCategoryAttributes = {\r\n\ttaxCategory: string;\r\n\ttaxSystem: TaxSystem;\r\n\ttaxCountry: CountryCode;\r\n\ttaxComponents: {\r\n\t\ttaxSubSystem: string;\r\n\t\tslabs: TaxSlabData[];\r\n\t\teffectiveFrom: ISODateTimeUTC;\r\n\t\teffectiveTo?: ISODateTimeUTC;\r\n\t}[];\r\n} & BaseAttributes;\r\n\r\nexport type TaxCategoryData = Required<TaxCategoryAttributes>;\r\n\r\nexport class TaxCategoryModel extends BaseModel {\r\n\tprotected taxCategory: string;\r\n\tprotected taxSystem: TaxSystem;\r\n\tprotected taxCountry: CountryCode;\r\n\tprotected taxComponents: {\r\n\t\ttaxSubSystem: string;\r\n\t\tslabs: TaxSlabModel[];\r\n\t\teffectiveFrom: ISODateTimeUTC;\r\n\t\teffectiveTo?: ISODateTimeUTC;\r\n\t}[];\r\n\r\n\tconstructor(data: TaxCategoryAttributes, date: Date = new Date()) {\r\n\t\tsuper(data, date);\r\n\t\tthis.taxCategory = data.taxCategory;\r\n\t\tthis.taxSystem = data.taxSystem;\r\n\t\tthis.taxCountry = data.taxCountry;\r\n\t\tthis.taxComponents = data.taxComponents.map(component => ({\r\n\t\t\ttaxSubSystem: component.taxSubSystem,\r\n\t\t\tslabs: component.slabs.map(slab => ({\r\n\t\t\t\trate: slab.rate,\r\n\t\t\t\tminUnitPrice: new PriceModel(slab.minUnitPrice),\r\n\t\t\t\tmaxUnitPrice: slab.maxUnitPrice ? new PriceModel(slab.maxUnitPrice) : undefined,\r\n\t\t\t})),\r\n\t\t\teffectiveFrom: component.effectiveFrom,\r\n\t\t\teffectiveTo: component.effectiveTo\r\n\t\t}));\r\n\t}\r\n\r\n\tpublic getTaxCategory(): string {\r\n\t\treturn this.taxCategory;\r\n\t}\r\n\r\n\tpublic getTaxSystem(): TaxSystem {\r\n\t\treturn this.taxSystem;\r\n\t}\r\n\r\n\tpublic getTaxCountry(): CountryCode {\r\n\t\treturn this.taxCountry;\r\n\t}\r\n\r\n\tpublic getTaxComponents(): {\r\n\t\ttaxSubSystem: string;\r\n\t\tslabs: TaxSlabModel[];\r\n\t\teffectiveFrom: ISODateTimeUTC;\r\n\t\teffectiveTo?: ISODateTimeUTC;\r\n\t}[] {\r\n\t\treturn this.taxComponents;\r\n\t}\r\n\r\n\tpublic getDetails(): TaxCategoryData {\r\n\t\treturn {\r\n\t\t\ttaxCategory: this.getTaxCategory(),\r\n\t\t\ttaxSystem: this.getTaxSystem(),\r\n\t\t\ttaxCountry: this.getTaxCountry(),\r\n\t\t\ttaxComponents: this.getTaxComponents().map(component => ({\r\n\t\t\t\ttaxSubSystem: component.taxSubSystem,\r\n\t\t\t\tslabs: component.slabs.map(slab => ({\r\n\t\t\t\t\trate: slab.rate,\r\n\t\t\t\t\tminUnitPrice: slab.minUnitPrice.getDetails(),\r\n\t\t\t\t\tmaxUnitPrice: slab.maxUnitPrice ? slab.maxUnitPrice.getDetails() : undefined,\r\n\t\t\t\t})),\r\n\t\t\t\teffectiveFrom: component.effectiveFrom,\r\n\t\t\t\teffectiveTo: component.effectiveTo\r\n\t\t\t})),\r\n\t\t\t...super.getDetails(),\r\n\t\t};\r\n\t}\r\n}\r\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/Classes/TaxCategoryModel.ts"],"names":["TaxCategoryModel","BaseModel","data","date","component","slab","PriceModel"],"mappings":"wIAqBO,IAAMA,EAAN,cAA+BC,CAAU,CACrC,WAAA,CACA,UACA,UACA,CAAA,aAAA,CAOV,WAAYC,CAAAA,CAAAA,CAA6BC,EAAa,IAAI,IAAA,CAAQ,CACjE,KAAA,CAAMD,EAAMC,CAAI,CAAA,CAChB,IAAK,CAAA,WAAA,CAAcD,EAAK,WACxB,CAAA,IAAA,CAAK,SAAYA,CAAAA,CAAAA,CAAK,UACtB,IAAK,CAAA,UAAA,CAAaA,CAAK,CAAA,UAAA,CACvB,KAAK,aAAgBA,CAAAA,CAAAA,CAAK,cAAc,GAAIE,CAAAA,GAAAA,GAAc,CACzD,YAAcA,CAAAA,GAAAA,CAAU,YACxB,CAAA,KAAA,CAAOA,IAAU,KAAM,CAAA,GAAA,CAAIC,CAAS,GAAA,CACnC,KAAMA,CAAK,CAAA,IAAA,CACX,YAAc,CAAA,IAAIC,EAAWD,CAAK,CAAA,YAAY,EAC9C,YAAcA,CAAAA,CAAAA,CAAK,aAAe,IAAIC,CAAAA,CAAWD,CAAK,CAAA,YAAY,EAAI,KACvE,CAAA,CAAA,CAAE,CACF,CAAA,aAAA,CAAeD,IAAU,aACzB,CAAA,WAAA,CAAaA,GAAU,CAAA,WACxB,EAAE,EACH,CAEO,gBAAyB,CAC/B,OAAO,KAAK,WACb,CAEO,YAA0B,EAAA,CAChC,OAAO,IAAK,CAAA,SACb,CAEO,aAAA,EAA6B,CACnC,OAAO,IAAA,CAAK,UACb,CAEO,kBAKH,CACH,OAAO,IAAK,CAAA,aACb,CAEO,UAA8B,EAAA,CACpC,OAAO,CACN,YAAa,IAAK,CAAA,cAAA,EAClB,CAAA,SAAA,CAAW,KAAK,YAAa,EAAA,CAC7B,UAAY,CAAA,IAAA,CAAK,eACjB,CAAA,aAAA,CAAe,KAAK,gBAAiB,EAAA,CAAE,IAAIA,CAAc,GAAA,CACxD,YAAcA,CAAAA,CAAAA,CAAU,aACxB,KAAOA,CAAAA,CAAAA,CAAU,KAAM,CAAA,GAAA,CAAIC,IAAS,CACnC,IAAA,CAAMA,CAAK,CAAA,IAAA,CACX,aAAcA,CAAK,CAAA,YAAA,CAAa,YAChC,CAAA,YAAA,CAAcA,EAAK,YAAeA,CAAAA,CAAAA,CAAK,YAAa,CAAA,UAAA,GAAe,KACpE,CAAA,CAAA,CAAE,CACF,CAAA,aAAA,CAAeD,EAAU,aACzB,CAAA,WAAA,CAAaA,CAAU,CAAA,WACxB,EAAE,CACF,CAAA,GAAG,MAAM,UAAW,EACrB,CACD,CACD","file":"TaxCategoryModel.mjs","sourcesContent":["import Utils from \"../Utils\";\r\nimport BaseModel, { BaseAttributes } from \"./Base\";\r\nimport { CountryCode, ISODateTimeUTC } from \"./Common\";\r\nimport { TaxSystem } from \"./Enum\";\r\nimport PriceModel from \"./Price\";\r\nimport { TaxRuleModel, TaxSlabData, TaxSlabModel } from \"./TaxRule\";\r\n\r\nexport type TaxCategoryAttributes = {\r\n\ttaxCategory: string;\r\n\ttaxSystem: TaxSystem;\r\n\ttaxCountry: CountryCode;\r\n\ttaxComponents: {\r\n\t\ttaxSubSystem: string;\r\n\t\tslabs: TaxSlabData[];\r\n\t\teffectiveFrom: ISODateTimeUTC;\r\n\t\teffectiveTo?: ISODateTimeUTC;\r\n\t}[];\r\n} & BaseAttributes;\r\n\r\nexport type TaxCategoryData = Required<TaxCategoryAttributes>;\r\n\r\nexport class TaxCategoryModel extends BaseModel {\r\n\tprotected taxCategory: string;\r\n\tprotected taxSystem: TaxSystem;\r\n\tprotected taxCountry: CountryCode;\r\n\tprotected taxComponents: {\r\n\t\ttaxSubSystem: string;\r\n\t\tslabs: TaxSlabModel[];\r\n\t\teffectiveFrom: ISODateTimeUTC;\r\n\t\teffectiveTo?: ISODateTimeUTC;\r\n\t}[];\r\n\r\n\tconstructor(data: TaxCategoryAttributes, date: Date = new Date()) {\r\n\t\tsuper(data, date);\r\n\t\tthis.taxCategory = data.taxCategory;\r\n\t\tthis.taxSystem = data.taxSystem;\r\n\t\tthis.taxCountry = data.taxCountry;\r\n\t\tthis.taxComponents = data.taxComponents.map(component => ({\r\n\t\t\ttaxSubSystem: component.taxSubSystem,\r\n\t\t\tslabs: component.slabs.map(slab => ({\r\n\t\t\t\trate: slab.rate,\r\n\t\t\t\tminUnitPrice: new PriceModel(slab.minUnitPrice),\r\n\t\t\t\tmaxUnitPrice: slab.maxUnitPrice ? new PriceModel(slab.maxUnitPrice) : undefined,\r\n\t\t\t})),\r\n\t\t\teffectiveFrom: component.effectiveFrom,\r\n\t\t\teffectiveTo: component.effectiveTo\r\n\t\t}));\r\n\t}\r\n\r\n\tpublic getTaxCategory(): string {\r\n\t\treturn this.taxCategory;\r\n\t}\r\n\r\n\tpublic getTaxSystem(): TaxSystem {\r\n\t\treturn this.taxSystem;\r\n\t}\r\n\r\n\tpublic getTaxCountry(): CountryCode {\r\n\t\treturn this.taxCountry;\r\n\t}\r\n\r\n\tpublic getTaxComponents(): {\r\n\t\ttaxSubSystem: string;\r\n\t\tslabs: TaxSlabModel[];\r\n\t\teffectiveFrom: ISODateTimeUTC;\r\n\t\teffectiveTo?: ISODateTimeUTC;\r\n\t}[] {\r\n\t\treturn this.taxComponents;\r\n\t}\r\n\r\n\tpublic getDetails(): TaxCategoryData {\r\n\t\treturn {\r\n\t\t\ttaxCategory: this.getTaxCategory(),\r\n\t\t\ttaxSystem: this.getTaxSystem(),\r\n\t\t\ttaxCountry: this.getTaxCountry(),\r\n\t\t\ttaxComponents: this.getTaxComponents().map(component => ({\r\n\t\t\t\ttaxSubSystem: component.taxSubSystem,\r\n\t\t\t\tslabs: component.slabs.map(slab => ({\r\n\t\t\t\t\trate: slab.rate,\r\n\t\t\t\t\tminUnitPrice: slab.minUnitPrice.getDetails(),\r\n\t\t\t\t\tmaxUnitPrice: slab.maxUnitPrice ? slab.maxUnitPrice.getDetails() : undefined,\r\n\t\t\t\t})),\r\n\t\t\t\teffectiveFrom: component.effectiveFrom,\r\n\t\t\t\teffectiveTo: component.effectiveTo\r\n\t\t\t})),\r\n\t\t\t...super.getDetails(),\r\n\t\t};\r\n\t}\r\n}\r\n"]}