b23-lib 3.2.2 → 3.2.4

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.
Files changed (37) hide show
  1. package/dist/Auth/index.mjs +1 -1
  2. package/dist/Classes/Cart.js +1 -1
  3. package/dist/Classes/Cart.js.map +1 -1
  4. package/dist/Classes/Cart.mjs +1 -1
  5. package/dist/Classes/Charge.d.mts +2 -2
  6. package/dist/Classes/Charge.d.ts +2 -2
  7. package/dist/Classes/Charge.js +1 -1
  8. package/dist/Classes/Charge.js.map +1 -1
  9. package/dist/Classes/Charge.mjs +1 -1
  10. package/dist/Classes/Coupon.mjs +1 -1
  11. package/dist/Classes/Inventory.mjs +1 -1
  12. package/dist/Classes/Invoice.d.mts +32 -5
  13. package/dist/Classes/Invoice.d.ts +32 -5
  14. package/dist/Classes/Invoice.js +1 -1
  15. package/dist/Classes/Invoice.js.map +1 -1
  16. package/dist/Classes/Invoice.mjs +1 -1
  17. package/dist/Classes/Invoice.mjs.map +1 -1
  18. package/dist/Classes/LineItem.mjs +1 -1
  19. package/dist/Classes/Order.js +1 -1
  20. package/dist/Classes/Order.js.map +1 -1
  21. package/dist/Classes/Order.mjs +1 -1
  22. package/dist/Classes/Product.mjs +1 -1
  23. package/dist/Classes/ShoppingContainer.js +1 -1
  24. package/dist/Classes/ShoppingContainer.js.map +1 -1
  25. package/dist/Classes/ShoppingContainer.mjs +1 -1
  26. package/dist/{chunk-5IRYC2KY.mjs → chunk-B2VFJRLS.mjs} +2 -2
  27. package/dist/{chunk-5IRYC2KY.mjs.map → chunk-B2VFJRLS.mjs.map} +1 -1
  28. package/dist/{chunk-XJPFHEW3.mjs → chunk-G6LH7V5B.mjs} +2 -2
  29. package/dist/{chunk-XJPFHEW3.mjs.map → chunk-G6LH7V5B.mjs.map} +1 -1
  30. package/dist/{chunk-QGIQ3MH6.mjs → chunk-MHLRJ4IJ.mjs} +2 -2
  31. package/dist/{chunk-QGIQ3MH6.mjs.map → chunk-MHLRJ4IJ.mjs.map} +1 -1
  32. package/dist/{chunk-PWWKQNF7.mjs → chunk-RQ2FFWUW.mjs} +2 -2
  33. package/dist/{chunk-PWWKQNF7.mjs.map → chunk-RQ2FFWUW.mjs.map} +1 -1
  34. package/dist/{chunk-MJGCYQ53.mjs → chunk-VTBHWXR4.mjs} +2 -2
  35. package/dist/{chunk-MJGCYQ53.mjs.map → chunk-VTBHWXR4.mjs.map} +1 -1
  36. package/dist/index.mjs +1 -1
  37. package/package.json +1 -1
@@ -1,2 +1,2 @@
1
- export{a as default}from'../chunk-XJPFHEW3.mjs';import'../chunk-SOZHGHMY.mjs';import'../chunk-QGIQ3MH6.mjs';import'../chunk-FCRJAAPY.mjs';import'../chunk-LI5JQ6UC.mjs';import'../chunk-QK4XJ3GB.mjs';import'../chunk-2B2XI6FG.mjs';import'../chunk-R5DM7WCD.mjs';import'../chunk-UXZBULDS.mjs';//# sourceMappingURL=Charge.mjs.map
1
+ export{a as default}from'../chunk-G6LH7V5B.mjs';import'../chunk-SOZHGHMY.mjs';import'../chunk-MHLRJ4IJ.mjs';import'../chunk-FCRJAAPY.mjs';import'../chunk-2B2XI6FG.mjs';import'../chunk-LI5JQ6UC.mjs';import'../chunk-QK4XJ3GB.mjs';import'../chunk-R5DM7WCD.mjs';import'../chunk-UXZBULDS.mjs';//# sourceMappingURL=Charge.mjs.map
2
2
  //# sourceMappingURL=Charge.mjs.map
@@ -1,2 +1,2 @@
1
- export{d as ApplicableTo,c as CouponCategory,b as CouponDiscountMethod,a as CouponType,e as default}from'../chunk-PWWKQNF7.mjs';import'../chunk-QGIQ3MH6.mjs';import'../chunk-FCRJAAPY.mjs';import'../chunk-LI5JQ6UC.mjs';import'../chunk-QK4XJ3GB.mjs';import'../chunk-2B2XI6FG.mjs';import'../chunk-R5DM7WCD.mjs';import'../chunk-UXZBULDS.mjs';//# sourceMappingURL=Coupon.mjs.map
1
+ export{d as ApplicableTo,c as CouponCategory,b as CouponDiscountMethod,a as CouponType,e as default}from'../chunk-RQ2FFWUW.mjs';import'../chunk-MHLRJ4IJ.mjs';import'../chunk-FCRJAAPY.mjs';import'../chunk-2B2XI6FG.mjs';import'../chunk-LI5JQ6UC.mjs';import'../chunk-QK4XJ3GB.mjs';import'../chunk-R5DM7WCD.mjs';import'../chunk-UXZBULDS.mjs';//# sourceMappingURL=Coupon.mjs.map
2
2
  //# sourceMappingURL=Coupon.mjs.map
@@ -1,2 +1,2 @@
1
- import {a,b as b$1}from'../chunk-QGIQ3MH6.mjs';import'../chunk-FCRJAAPY.mjs';import'../chunk-LI5JQ6UC.mjs';import'../chunk-QK4XJ3GB.mjs';import'../chunk-2B2XI6FG.mjs';import'../chunk-R5DM7WCD.mjs';import {b}from'../chunk-UXZBULDS.mjs';var u=class extends b{productKey;stocks;constructor(r,o=new Date){super(r,o),this.productKey=r.productKey,this.stocks=r.stocks.map(e=>({selectionAttributes:a.deepClone(e.selectionAttributes),size:e.size,available:e.available,country:e.country}));}getProductKey(){return this.productKey}getStockData(r,o,e){let n=r?b$1.generateSelectionAttributesKey(r):void 0;return this.stocks.filter(t=>!(n&&b$1.generateSelectionAttributesKey(t.selectionAttributes)!==n||o&&t.size!==o||e&&t.country!==e)).map(t=>({selectionAttributes:a.deepClone(t.selectionAttributes),size:t.size,available:t.available,country:t.country}))}getDetails(){return {...super.getDetails(),productKey:this.getProductKey(),stocks:this.getStockData()}}};export{u as InventoryModel};//# sourceMappingURL=Inventory.mjs.map
1
+ import {a,b as b$1}from'../chunk-MHLRJ4IJ.mjs';import'../chunk-FCRJAAPY.mjs';import'../chunk-2B2XI6FG.mjs';import'../chunk-LI5JQ6UC.mjs';import'../chunk-QK4XJ3GB.mjs';import'../chunk-R5DM7WCD.mjs';import {b}from'../chunk-UXZBULDS.mjs';var u=class extends b{productKey;stocks;constructor(r,o=new Date){super(r,o),this.productKey=r.productKey,this.stocks=r.stocks.map(e=>({selectionAttributes:a.deepClone(e.selectionAttributes),size:e.size,available:e.available,country:e.country}));}getProductKey(){return this.productKey}getStockData(r,o,e){let n=r?b$1.generateSelectionAttributesKey(r):void 0;return this.stocks.filter(t=>!(n&&b$1.generateSelectionAttributesKey(t.selectionAttributes)!==n||o&&t.size!==o||e&&t.country!==e)).map(t=>({selectionAttributes:a.deepClone(t.selectionAttributes),size:t.size,available:t.available,country:t.country}))}getDetails(){return {...super.getDetails(),productKey:this.getProductKey(),stocks:this.getStockData()}}};export{u as InventoryModel};//# sourceMappingURL=Inventory.mjs.map
2
2
  //# sourceMappingURL=Inventory.mjs.map
@@ -40,6 +40,20 @@ type InvoiceLineItemData = {
40
40
  taxCode: string;
41
41
  taxCodeType: string;
42
42
  };
43
+ type InvoiceLineItemModel = {
44
+ id: string;
45
+ productKey: string;
46
+ name: string;
47
+ variantLabel: string;
48
+ quantity: number;
49
+ netUnitPrice: PriceModel;
50
+ netSubtotal: PriceModel;
51
+ taxTotal: PriceModel;
52
+ grandTotal: PriceModel;
53
+ taxBreakdown: Record<string, InvoiceTaxBreakdownModel>;
54
+ taxCode: string;
55
+ taxCodeType: string;
56
+ };
43
57
  type InvoiceChargeData = {
44
58
  id: string;
45
59
  type: ChargeType;
@@ -53,6 +67,19 @@ type InvoiceChargeData = {
53
67
  taxCode: string;
54
68
  taxCodeType: string;
55
69
  };
70
+ type InvoiceChargeModel = {
71
+ id: string;
72
+ type: ChargeType;
73
+ category: string;
74
+ impact: ChargeImpact;
75
+ name: string;
76
+ taxableValue: PriceModel;
77
+ taxTotal: PriceModel;
78
+ grandTotal: PriceModel;
79
+ taxBreakdown: Record<string, InvoiceTaxBreakdownModel>;
80
+ taxCode: string;
81
+ taxCodeType: string;
82
+ };
56
83
  type InvoiceTaxContextData = {
57
84
  recipientTaxIdentifier: string;
58
85
  recipientTaxIdentifierType: string;
@@ -106,8 +133,8 @@ declare class InvoiceModel extends BaseModel {
106
133
  protected shippingAddress: AddressModel;
107
134
  protected taxContext: InvoiceTaxContextData;
108
135
  protected merchant: MerchantModel;
109
- protected lineItems: InvoiceLineItemData[];
110
- protected charges: InvoiceChargeData[];
136
+ protected lineItems: InvoiceLineItemModel[];
137
+ protected charges: InvoiceChargeModel[];
111
138
  protected total: InvoiceTotalModel;
112
139
  constructor(data: InvoiceAttributes, date?: Date);
113
140
  private mapTaxBreakdown;
@@ -131,10 +158,10 @@ declare class InvoiceModel extends BaseModel {
131
158
  getSupplyRegion(): string;
132
159
  getSupplyRegionCode(): string;
133
160
  getMerchant(): MerchantModel;
134
- getLineItems(): InvoiceLineItemData[];
135
- getCharges(): InvoiceChargeData[];
161
+ getLineItems(): InvoiceLineItemModel[];
162
+ getCharges(): InvoiceChargeModel[];
136
163
  getTotal(): InvoiceTotalModel;
137
164
  getDetails(): InvoiceData;
138
165
  }
139
166
 
140
- export { type InvoiceAttributes, type InvoiceChargeData, type InvoiceData, type InvoiceLineItemData, type InvoiceTaxBreakdown, type InvoiceTaxBreakdownModel, type InvoiceTaxContextData, type InvoiceTotal, type InvoiceTotalModel, type MerchantData, type MerchantModel, InvoiceModel as default };
167
+ export { type InvoiceAttributes, type InvoiceChargeData, type InvoiceChargeModel, type InvoiceData, type InvoiceLineItemData, type InvoiceLineItemModel, type InvoiceTaxBreakdown, type InvoiceTaxBreakdownModel, type InvoiceTaxContextData, type InvoiceTotal, type InvoiceTotalModel, type MerchantData, type MerchantModel, InvoiceModel as default };
@@ -40,6 +40,20 @@ type InvoiceLineItemData = {
40
40
  taxCode: string;
41
41
  taxCodeType: string;
42
42
  };
43
+ type InvoiceLineItemModel = {
44
+ id: string;
45
+ productKey: string;
46
+ name: string;
47
+ variantLabel: string;
48
+ quantity: number;
49
+ netUnitPrice: PriceModel;
50
+ netSubtotal: PriceModel;
51
+ taxTotal: PriceModel;
52
+ grandTotal: PriceModel;
53
+ taxBreakdown: Record<string, InvoiceTaxBreakdownModel>;
54
+ taxCode: string;
55
+ taxCodeType: string;
56
+ };
43
57
  type InvoiceChargeData = {
44
58
  id: string;
45
59
  type: ChargeType;
@@ -53,6 +67,19 @@ type InvoiceChargeData = {
53
67
  taxCode: string;
54
68
  taxCodeType: string;
55
69
  };
70
+ type InvoiceChargeModel = {
71
+ id: string;
72
+ type: ChargeType;
73
+ category: string;
74
+ impact: ChargeImpact;
75
+ name: string;
76
+ taxableValue: PriceModel;
77
+ taxTotal: PriceModel;
78
+ grandTotal: PriceModel;
79
+ taxBreakdown: Record<string, InvoiceTaxBreakdownModel>;
80
+ taxCode: string;
81
+ taxCodeType: string;
82
+ };
56
83
  type InvoiceTaxContextData = {
57
84
  recipientTaxIdentifier: string;
58
85
  recipientTaxIdentifierType: string;
@@ -106,8 +133,8 @@ declare class InvoiceModel extends BaseModel {
106
133
  protected shippingAddress: AddressModel;
107
134
  protected taxContext: InvoiceTaxContextData;
108
135
  protected merchant: MerchantModel;
109
- protected lineItems: InvoiceLineItemData[];
110
- protected charges: InvoiceChargeData[];
136
+ protected lineItems: InvoiceLineItemModel[];
137
+ protected charges: InvoiceChargeModel[];
111
138
  protected total: InvoiceTotalModel;
112
139
  constructor(data: InvoiceAttributes, date?: Date);
113
140
  private mapTaxBreakdown;
@@ -131,10 +158,10 @@ declare class InvoiceModel extends BaseModel {
131
158
  getSupplyRegion(): string;
132
159
  getSupplyRegionCode(): string;
133
160
  getMerchant(): MerchantModel;
134
- getLineItems(): InvoiceLineItemData[];
135
- getCharges(): InvoiceChargeData[];
161
+ getLineItems(): InvoiceLineItemModel[];
162
+ getCharges(): InvoiceChargeModel[];
136
163
  getTotal(): InvoiceTotalModel;
137
164
  getDetails(): InvoiceData;
138
165
  }
139
166
 
140
- export { type InvoiceAttributes, type InvoiceChargeData, type InvoiceData, type InvoiceLineItemData, type InvoiceTaxBreakdown, type InvoiceTaxBreakdownModel, type InvoiceTaxContextData, type InvoiceTotal, type InvoiceTotalModel, type MerchantData, type MerchantModel, InvoiceModel as default };
167
+ export { type InvoiceAttributes, type InvoiceChargeData, type InvoiceChargeModel, type InvoiceData, type InvoiceLineItemData, type InvoiceLineItemModel, type InvoiceTaxBreakdown, type InvoiceTaxBreakdownModel, type InvoiceTaxContextData, type InvoiceTotal, type InvoiceTotalModel, type MerchantData, type MerchantModel, InvoiceModel as default };
@@ -1,2 +1,2 @@
1
- 'use strict';var J=require('crypto');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var J__default=/*#__PURE__*/_interopDefault(J);var x={"en-IN":"en","kn-IN":"kn"};var Q={INR:"\u20B9"},K={INR:"en-IN"};var D=class extends Error{constructor(e){super(`Duplicate selection attribute found: ${e}`),this.name="DuplicateSelectionAttributeError";}};var p=class extends Error{constructor(e="Failed to parse selection attributes key."){super(`SelectionAttributeParseError: ${e}`),this.name="SelectionAttributeParseError";}};var w=class extends Error{constructor(e="Tax category is not valid."){super(`InvalidTaxCategory: ${e}`),this.name="InvalidTaxCategoryError";}},v=class extends Error{constructor(e="Minimum quantity must be greater than zero."){super(`InvalidMinQuantity: ${e}`),this.name="InvalidMinQuantityError";}},M=class extends Error{constructor(e){super(`InvalidTieredPrice: ${e}`),this.name="InvalidTieredPriceError";}},N=class extends Error{constructor(e="Quantity must be greater than zero."){super(`InvalidQuantity: ${e}`),this.name="InvalidQuantityError";}},L=class extends Error{constructor(e){super(`NoApplicableTier: Quantity ${e} does not meet the minimum purchase requirement.`),this.name="NoApplicableTierError";}};var T=class extends Error{constructor(e="Amount cannot be negative."){super(`InvalidAmount: ${e}`),this.name="InvalidPriceAmountError";}},I=class extends Error{constructor(e="Currency code is required."){super(`InvalidCurrency: ${e}`),this.name="InvalidCurrencyCodeError";}},h=class extends Error{constructor(e="Cannot perform operation on prices with different currencies."){super(`CurrencyMismatch: ${e}`),this.name="CurrencyMismatchError";}},m=class extends Error{constructor(e){super(`InvalidArgument: ${e}`),this.name="InvalidArgumentError";}},S=class extends Error{constructor(e="Invalid image source configuration."){super(`InvalidImageSource: ${e}`),this.name="InvalidImageSourceError";}};var o=class r{#e;amount;currency;constructor(e){if(this.#e="PriceModel",e.amount<0)throw new T("Amount cannot be negative.");if(!e.currency)throw new I("Currency code is required.");this.currency=e.currency,this.amount=parseFloat(e.amount.toFixed(r.getPrecisionPlaces(this.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}}getPreciseAmount(e){return parseFloat(e.toFixed(r.getPrecisionPlaces(this.currency)))}compareTo(e){if(r.isPriceModel(e)){if(this.currency!==e.getCurrency())throw new h("Cannot compare prices in different currencies.")}else throw new m("Must be a PriceModel instance.");return this.getPreciseAmount(this.amount-e.getAmount())}add(e){if(r.isPriceModel(e)){if(this.currency!==e.getCurrency())throw new h("Cannot add prices in different currencies.")}else throw new m("Must be a PriceModel instance.");return new r({amount:this.getPreciseAmount(this.amount+e.getAmount()),currency:this.currency})}subtract(e){if(r.isPriceModel(e)){if(this.currency!==e.getCurrency())throw new h("Cannot subtract prices in different currencies.")}else throw new m("Must be a PriceModel instance.");return new r({amount:this.getPreciseAmount(this.amount-e.getAmount()),currency:this.currency})}multiply(e){if(r.isPriceModel(e)){if(this.currency!==e.getCurrency())throw new h("Cannot multiply prices in different currencies.");return new r({amount:this.getPreciseAmount(this.amount*e.getAmount()),currency:this.currency})}else if(typeof e=="number"&&e>=0)return new r({amount:this.getPreciseAmount(this.amount*e),currency:this.currency});throw new m("Must be a non-negative number.")}divide(e){if(r.isPriceModel(e)){if(this.currency!==e.getCurrency())throw new h("Cannot divide prices in different currencies.");return new r({amount:this.getPreciseAmount(this.amount/e.getAmount()),currency:this.currency})}else if(typeof e=="number"&&e>0)return new r({amount:this.getPreciseAmount(this.amount/e),currency:this.currency});throw new m("Must be a positive number.")}min(...e){if(e.length===0)throw new m("Must provide at least one PriceModel.");return e.reduce((t,i)=>{if(r.isPriceModel(i)){if(t.getCurrency()!==i.getCurrency())throw new h("Cannot compare prices in different currencies.")}else throw new m("Must be a PriceModel instance.");return t.compareTo(i)<0?t:i},this)}max(...e){if(e.length===0)throw new m("Must provide at least one PriceModel.");return e.reduce((t,i)=>{if(r.isPriceModel(i)){if(t.getCurrency()!==i.getCurrency())throw new h("Cannot compare prices in different currencies.")}else throw new m("Must be a PriceModel instance.");return t.compareTo(i)>0?t:i},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,i={displayAsInteger:!1,style:"currency",currencyDisplay:"symbol"}){let n=K[t];if(!t||!n)throw new I("Invalid currency code for formatting.");let s=e,d=i.displayAsInteger?0:r.getDecimalPlaces(t),f={style:i.style??"currency",currency:t,signDisplay:"never",currencyDisplay:i.currencyDisplay,minimumFractionDigits:d,maximumFractionDigits:d};i.displayAsInteger&&(s=Math.ceil(s));try{return new Intl.NumberFormat(n,f).format(s)}catch(l){return console.error(`Error formatting price for currency "${t}" and locale "${n}":`,l),`${Q[t]??t} ${r.addThousandSeparators(s.toFixed(d))}`}}static getDecimalPlaces(e){switch(e){case"INR":default:return 2}}static getPrecisionPlaces(e){switch(e){case"INR":default:return 6}}static addThousandSeparators(e){let t=e.split("."),i=t[0],n=t.length>1?"."+t[1]:"";return i.replace(/\B(?=(\d{3})+(?!\d))/g,",")+n}static getRoundedAmount(e,t){if(e<0)throw new T("Amount cannot be negative for rounding.");if(t===void 0)throw new I("Invalid currency code for rounding.");let i=r.getDecimalPlaces(t),n=Math.pow(10,i);return Math.round(e*n)/n}};var V=r=>structuredClone(r),U=class{customFields;constructor(e,t=new Date){this.customFields={...e.customFields};}getCustomField(e){let t=this.customFields[e];return t==null?t:V(t)}setCustomField(e,t){this.customFields[e]=t;}getAllCustomFields(){return V(this.customFields)}},y=class extends U{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,i,n){this.modifiedBy={id:e,authType:t,requestId:i,lambdaName:n};}};var b=class extends y{id;firstName;lastName;company;phone;email;addressLine1;addressLine2;city;postalCode;state;country;isBillingAddress;isShippingAddress;constructor(e,t=new Date){super(e,t),this.id=e.id,this.firstName=e.firstName,this.lastName=e.lastName||"",this.company=e.company||"",this.phone=e.phone,this.email=e.email,this.addressLine1=e.addressLine1,this.addressLine2=e.addressLine2||"",this.city=e.city,this.postalCode=e.postalCode,this.state=e.state,this.country=e.country,this.isBillingAddress=e.isBillingAddress,this.isShippingAddress=e.isShippingAddress;}getDetails(){return {...super.getDetails(),id:this.getId(),firstName:this.getFirstName(),lastName:this.getLastName(),company:this.getCompany(),phone:this.getPhone(),email:this.getEmail(),addressLine1:this.getAddressLine1(),addressLine2:this.getAddressLine2(),city:this.getCity(),postalCode:this.getPostalCode(),state:this.getState(),country:this.getCountry(),isBillingAddress:this.getIsBillingAddress(),isShippingAddress:this.getIsShippingAddress()}}getId(){return this.id}getFirstName(){return this.firstName}getLastName(){return this.lastName}getCompany(){return this.company}getPhone(){return this.phone}getEmail(){return this.email}getAddressLine1(){return this.addressLine1}getAddressLine2(){return this.addressLine2}getCity(){return this.city}getPostalCode(){return this.postalCode}getState(){return this.state}getCountry(){return this.country}getIsBillingAddress(){return this.isBillingAddress}getIsShippingAddress(){return this.isShippingAddress}getAddressType(){return this.isBillingAddress&&this.isShippingAddress?"billing&shipping":this.isBillingAddress?"billing":this.isShippingAddress?"shipping":"none"}static checkIfShippingAddress(e){return e==="shipping"||e==="billing&shipping"}static checkIfBillingAddress(e){return e==="billing"||e==="billing&shipping"}};var B=new Uint8Array(256),E=B.length;function O(){return E>B.length-16&&(J__default.default.randomFillSync(B),E=0),B.slice(E,E+=16)}var H=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function X(r){return typeof r=="string"&&H.test(r)}var q=X;var u=[];for(let r=0;r<256;++r)u.push((r+256).toString(16).slice(1));function R(r,e=0){return u[r[e+0]]+u[r[e+1]]+u[r[e+2]]+u[r[e+3]]+"-"+u[r[e+4]]+u[r[e+5]]+"-"+u[r[e+6]]+u[r[e+7]]+"-"+u[r[e+8]]+u[r[e+9]]+"-"+u[r[e+10]]+u[r[e+11]]+u[r[e+12]]+u[r[e+13]]+u[r[e+14]]+u[r[e+15]]}function W(r){if(!q(r))throw TypeError("Invalid UUID");let e,t=new Uint8Array(16);return t[0]=(e=parseInt(r.slice(0,8),16))>>>24,t[1]=e>>>16&255,t[2]=e>>>8&255,t[3]=e&255,t[4]=(e=parseInt(r.slice(9,13),16))>>>8,t[5]=e&255,t[6]=(e=parseInt(r.slice(14,18),16))>>>8,t[7]=e&255,t[8]=(e=parseInt(r.slice(19,23),16))>>>8,t[9]=e&255,t[10]=(e=parseInt(r.slice(24,36),16))/1099511627776&255,t[11]=e/4294967296&255,t[12]=e>>>24&255,t[13]=e>>>16&255,t[14]=e>>>8&255,t[15]=e&255,t}var Y=W;function _(r){r=unescape(encodeURIComponent(r));let e=[];for(let t=0;t<r.length;++t)e.push(r.charCodeAt(t));return e}var ee="6ba7b810-9dad-11d1-80b4-00c04fd430c8",te="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function $(r,e,t){function i(n,s,d,f){var l;if(typeof n=="string"&&(n=_(n)),typeof s=="string"&&(s=Y(s)),((l=s)===null||l===void 0?void 0:l.length)!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");let g=new Uint8Array(16+n.length);if(g.set(s),g.set(n,s.length),g=t(g),g[6]=g[6]&15|e,g[8]=g[8]&63|128,d){f=f||0;for(let P=0;P<16;++P)d[f+P]=g[P];return d}return R(g)}try{i.name=r;}catch{}return i.DNS=ee,i.URL=te,i}var F={randomUUID:J__default.default.randomUUID};function ie(r,e,t){if(F.randomUUID&&!e&&!r)return F.randomUUID();r=r||{};let i=r.random||(r.rng||O)();if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,e){t=t||0;for(let n=0;n<16;++n)e[t+n]=i[n];return e}return R(i)}var z=ie;function se(r){return Array.isArray(r)?r=Buffer.from(r):typeof r=="string"&&(r=Buffer.from(r,"utf8")),J__default.default.createHash("sha1").update(r).digest()}var Z=se;var oe=$("v5",80,Z),G=oe;var A=class{sources;alt;order;label;constructor(e){if(this.sources={...e.sources},this.alt=e.alt,this.order=e.order,this.label=e.label,!this.sources.original)throw new S("ImageInfoModel cannot be created without an 'original' source URL.")}getSources(){return {...this.sources}}getSource(e){return this.sources[e]||this.sources.original}getAlt(){return this.alt}getOrder(){return this.order}getLabel(){return this.label}setAlt(e){this.alt=e;}setOrder(e){this.order=e;}setLabel(e){this.label=e;}setSource(e,t){if(t===void 0){if(e==="original")throw new S("Cannot remove the 'original' image source.");delete this.sources[e];}else this.sources[e]=t;}getDetails(){return {sources:this.getSources(),alt:this.getAlt(),order:this.getOrder(),label:this.getLabel()}}};var k=class{baseUnitPrice;taxCategory;tiers;constructor(e){let t=new o(e.baseUnitPrice);if(!e.taxCategory)throw new w;let i=(e.tiers??[]).map(l=>({minQuantity:l.minQuantity,unitPrice:new o(l.unitPrice)})).sort((l,g)=>l.minQuantity-g.minQuantity);if(i.some(l=>l.minQuantity<=0))throw new v;let s=i.some(l=>l.unitPrice.getCurrency()!==t.getCurrency()),d=i.some((l,g)=>g>0&&l.unitPrice.compareTo(i[g-1].unitPrice)>0),f=i[0]?.unitPrice.compareTo(t)>0;if(s||d||f)throw new M("Tiers must share the same currency and must not increase in unit price.");this.baseUnitPrice=t,this.taxCategory=e.taxCategory,this.tiers=i;}getBaseUnitPrice(){return this.baseUnitPrice}getTaxCategory(){return this.taxCategory}getTiers(){return this.tiers.map(e=>({minQuantity:e.minQuantity,unitPrice:e.unitPrice}))}getDetails(){return {baseUnitPrice:this.baseUnitPrice.getDetails(),taxCategory:this.taxCategory,tiers:this.tiers.map(e=>({minQuantity:e.minQuantity,unitPrice:e.unitPrice.getDetails()}))}}getApplicableTier(e){if(e<=0)throw new N;for(let t=this.tiers.length-1;t>=0;t--)if(e>=this.tiers[t].minQuantity){let i=this.tiers[t];return {minQuantity:i.minQuantity,unitPrice:i.unitPrice}}throw new L(e)}getMinQuantity(){return this.tiers[0]?.minQuantity??1}getMaxDiscountPercent(){if(!this.tiers.length)return 0;let e=this.tiers[this.tiers.length-1].unitPrice.getAmount(),t=this.baseUnitPrice.getAmount();return (t-e)/t*100}};var C=class r extends y{id;key;name;description;slug;brand;pricing;variants;targetGender;attributes;specifications;categories;isActive;searchTags;static productKeyRegex=/^(?!\s)(?!.*\s$)[A-Z0-9-]{4,16}$/;static productSKURegex=/^(?!\s)(?!.*\s$)[A-Z0-9-]{4,16}$/;static generateSelectionAttributesKey(e){if(typeof e!="object")throw new p("Selection attributes must be an object");return Object.keys(e).filter(i=>e[i]!==void 0&&i.toLowerCase()!=="size").sort().map(i=>e[i].name?`${i}:c+${e[i].name}`:`${i}:${e[i]}`).join("|").toLowerCase()}static parseSelectionAttributesKey(e){try{let t={},i=e.split("|");for(let n of i){let[s,d]=n.split(":");d.startsWith("c+")?t[s]={name:d.slice(2)}:t[s]=d;}return t}catch(t){throw new p(t?.message)}}constructor(e,t=new Date){super(e,t),this.id=e.id,this.key=e.key,this.name={...e.name},this.description={...e.description},this.slug={...e.slug},this.brand=e.brand,this.pricing=Object.keys(e.pricing).reduce((n,s)=>(e.pricing[s]&&(n[s]=new k(e.pricing[s])),n),{}),this.targetGender=e.targetGender,this.attributes=c.deepClone(e.attributes),this.specifications=c.deepClone(e.specifications),this.categories=c.deepClone(e.categories);let i=new Set;this.variants=(e.variants||[]).map(n=>{if(!n.selectionAttributes||typeof n.selectionAttributes!="object")throw new p("Selection attributes are required");this.checkSelectionAttributes(n.selectionAttributes);let s=r.generateSelectionAttributesKey(n.selectionAttributes);if(i.has(s))throw new D(s);return i.add(s),{sku:n.sku,selectionAttributes:n.selectionAttributes,images:{primary:new A(n.images.primary),gallery:(n.images.gallery||[]).map(d=>new A(d))}}}),this.isActive=e.isActive,this.searchTags=e.searchTags?c.deepClone(e.searchTags):{en:[]};}getId(){return this.id}getKey(){return this.key}getName(e){return e?this.name[e]??this.name[x[e]]??this.name.en:c.deepClone(this.name)}getDescription(e){return e?this.description[e]??this.description[x[e]]??this.description.en:c.deepClone(this.description)}getSlug(e){return e?this.slug[e]??this.slug[x[e]]??this.slug.en:c.deepClone(this.slug)}getBrand(){return this.brand}getPriceDetails(e){return e?this.pricing[e]??null:{...this.pricing}}getAttributes(){return c.deepClone(this.attributes)}getVariants(){return this.variants.map(e=>({sku:e.sku,selectionAttributes:c.deepClone(e.selectionAttributes),images:{primary:e.images.primary,gallery:[...e.images.gallery]}}))}getImagesBySelectionAttributes(e){let t=r.generateSelectionAttributesKey(e),i=this.variants.find(n=>r.generateSelectionAttributesKey(n.selectionAttributes)===t);return i?{primary:i.images.primary,gallery:[...i.images.gallery]}:null}getImages(e,t){switch(t){case"PRIMARY":return this.getImagesBySelectionAttributes(e)?.primary??this.variants[0]?.images?.primary;case"GALLERY":return this.getImagesBySelectionAttributes(e)?.gallery??[];default:return this.getImagesBySelectionAttributes(e)??{primary:this.variants[0]?.images?.primary,gallery:[]}}}getIsActive(){return this.isActive}getTargetGender(){return this.targetGender}getCategories(){return c.deepClone(this.categories)}getSpecifications(e){return e?c.deepClone(this.specifications[e]??this.specifications[x[e]]??this.specifications.en):c.deepClone(this.specifications)}getSearchTags(e){return e?c.deepClone(this.searchTags[e]??this.searchTags[x[e]]??this.searchTags.en):c.deepClone(this.searchTags)}getDetails(){let e=super.getDetails();return {id:this.getId(),key:this.getKey(),name:this.getName(),description:this.getDescription(),slug:this.getSlug(),brand:this.getBrand(),pricing:Object.keys(this.pricing).reduce((t,i)=>(this.pricing[i]&&(t[i]=this.pricing[i]?.getDetails()),t),{}),attributes:this.getAttributes(),variants:this.variants.map(t=>({sku:t.sku,selectionAttributes:c.deepClone(t.selectionAttributes),images:{primary:t.images.primary.getDetails(),gallery:t.images.gallery.map(i=>i.getDetails())}})),isActive:this.getIsActive(),targetGender:this.getTargetGender(),categories:this.getCategories(),specifications:this.getSpecifications(),searchTags:this.getSearchTags(),...e}}checkSelectionAttributes(e){if(!e||typeof e!="object")throw new p("Selection attributes are required");Object.keys(this.attributes).forEach(t=>{if(t.toLowerCase()==="size")return;let i=this.attributes[t],n=e[t];if(n===void 0)throw new p(`Selection attribute '${t}' is missing`);if(typeof i=="string"){if(typeof n!="string"||i!==n)throw new p(`Selection attribute '${t}' is invalid`)}else if(Array.isArray(i)){if(i.length>0&&typeof i[0]=="string"){if(typeof n!="string"||!i.includes(n))throw new p(`Selection attribute '${t}' is invalid`)}else if(typeof n!="object"||!("name"in n)||i.findIndex(s=>s.name===n.name)<0)throw new p(`Selection attribute '${t}' is invalid`)}});}validateSelectionAttribute(e){let t=r.generateSelectionAttributesKey(e);return this.variants.some(i=>r.generateSelectionAttributesKey(i.selectionAttributes)===t)}validateSize(e){return this.attributes.size.includes(e)}};var ae={isUUID:r=>/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(r),isEmail:r=>/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(r),isURL:r=>/^(http|https):\/\/[^ "]+$/.test(r),generateUUID:(r,e)=>e&&r?G(r,e):z(),generateSearchId:(r,e)=>`${r}#${C.generateSelectionAttributesKey(e)}`,getKeyfromSearchId:r=>{let[e,t]=r.split("#");return {key:e,selectionAttributes:C.parseSelectionAttributesKey(t)}},deepClone(r){return structuredClone(r)}},c=ae;var j=class extends y{invoiceNumber;orderNumber;issueDate;country;currency;locale;customerId;customerEmail;billingAddress;shippingAddress;taxContext;merchant;lineItems;charges;total;constructor(e,t=new Date){super(e,t),this.invoiceNumber=e.invoiceNumber,this.orderNumber=e.orderNumber,this.issueDate=e.issueDate,this.country=e.country,this.currency=e.currency,this.locale=e.locale,this.customerId=e.customerId,this.customerEmail=e.customerEmail,this.billingAddress=new b(e.billingAddress),this.shippingAddress=new b(e.shippingAddress),this.taxContext=e.taxContext,this.merchant={merchantName:e.merchant.merchantName,taxIdentifier:e.merchant.taxIdentifier,email:e.merchant.email,phone:e.merchant.phone,address:new b(e.merchant.address)},this.lineItems=c.deepClone(e.lineItems),this.charges=c.deepClone(e.charges),this.total={lineItemSubtotal:new o(e.total.lineItemSubtotal),netLineItemSubtotal:new o(e.total.netLineItemSubtotal),lineItemTaxTotal:new o(e.total.lineItemTaxTotal),lineItemTaxBreakdown:this.mapTaxBreakdown(e.total.lineItemTaxBreakdown),additiveCharges:new o(e.total.additiveCharges),netAdditiveCharges:new o(e.total.netAdditiveCharges),additiveChargesTaxTotal:new o(e.total.additiveChargesTaxTotal),additiveChargesTaxBreakdown:this.mapTaxBreakdown(e.total.additiveChargesTaxBreakdown),adjustmentCharges:new o(e.total.adjustmentCharges),shippingCharges:new o(e.total.shippingCharges),netShippingCharges:new o(e.total.netShippingCharges),discountTotal:new o(e.total.discountTotal),discountBreakdown:Object.fromEntries(Object.entries(e.total.discountBreakdown).map(([i,n])=>[i,new o(n)])),taxTotal:new o(e.total.taxTotal),taxBreakdown:this.mapTaxBreakdown(e.total.taxBreakdown),grandTotal:new o(e.total.grandTotal)};}mapTaxBreakdown(e){return Object.fromEntries(Object.entries(e||{}).map(([t,i])=>[t,{system:i.system,totalAmount:new o(i.totalAmount),subSystems:Object.fromEntries(Object.entries(i.subSystems).map(([n,s])=>[n,new o(s)]))}]))}serializeTaxBreakdown(e){return Object.fromEntries(Object.entries(e||{}).map(([t,i])=>[t,{system:i.system,totalAmount:i.totalAmount.getDetails(),subSystems:Object.fromEntries(Object.entries(i.subSystems).map(([n,s])=>[n,s.getDetails()]))}]))}getInvoiceNumber(){return this.invoiceNumber}getOrderNumber(){return this.orderNumber}getIssueDate(){return this.issueDate}getCountry(){return this.country}getCurrency(){return this.currency}getLocale(){return this.locale}getCustomerId(){return this.customerId}getCustomerEmail(){return this.customerEmail}getTaxContext(){return {...this.taxContext}}getTaxRegistrationNumber(){return this.taxContext.recipientTaxIdentifier}getRecipientTaxIdentifier(){return this.taxContext.recipientTaxIdentifier}getRecipientTaxIdentifierType(){return this.taxContext.recipientTaxIdentifierType}getBillingAddress(){return this.billingAddress}getShippingAddress(){return this.shippingAddress}getPlaceOfSupplyState(){return this.taxContext.supplyRegion}getPlaceOfSupplyCode(){return this.taxContext.supplyRegionCode}getSupplyRegion(){return this.taxContext.supplyRegion}getSupplyRegionCode(){return this.taxContext.supplyRegionCode}getMerchant(){return {merchantName:this.merchant.merchantName,taxIdentifier:this.merchant.taxIdentifier,email:this.merchant.email,phone:this.merchant.phone,address:this.merchant.address}}getLineItems(){return this.lineItems}getCharges(){return this.charges}getTotal(){return this.total}getDetails(){let e=this.getTotal();return {...super.getDetails(),invoiceNumber:this.invoiceNumber,orderNumber:this.orderNumber,issueDate:this.issueDate,country:this.country,currency:this.currency,locale:this.locale,customerId:this.customerId,customerEmail:this.customerEmail,billingAddress:this.billingAddress.getDetails(),shippingAddress:this.shippingAddress.getDetails(),taxContext:this.taxContext,merchant:{merchantName:this.merchant.merchantName,taxIdentifier:this.merchant.taxIdentifier,email:this.merchant.email,phone:this.merchant.phone,address:this.merchant.address.getDetails()},lineItems:this.lineItems,charges:this.charges,total:{lineItemSubtotal:e.lineItemSubtotal.getDetails(),netLineItemSubtotal:e.netLineItemSubtotal.getDetails(),lineItemTaxTotal:e.lineItemTaxTotal.getDetails(),lineItemTaxBreakdown:this.serializeTaxBreakdown(e.lineItemTaxBreakdown),additiveCharges:e.additiveCharges.getDetails(),netAdditiveCharges:e.netAdditiveCharges.getDetails(),additiveChargesTaxTotal:e.additiveChargesTaxTotal.getDetails(),additiveChargesTaxBreakdown:this.serializeTaxBreakdown(e.additiveChargesTaxBreakdown),adjustmentCharges:e.adjustmentCharges.getDetails(),shippingCharges:e.shippingCharges.getDetails(),netShippingCharges:e.netShippingCharges.getDetails(),discountTotal:e.discountTotal.getDetails(),discountBreakdown:Object.fromEntries(Object.entries(e.discountBreakdown).map(([t,i])=>[t,i.getDetails()])),taxTotal:e.taxTotal.getDetails(),taxBreakdown:this.serializeTaxBreakdown(e.taxBreakdown),grandTotal:e.grandTotal.getDetails()}}}};module.exports=j;//# sourceMappingURL=Invoice.js.map
1
+ 'use strict';var y={INR:"\u20B9"},I={INR:"en-IN"};var g=class extends Error{constructor(e="Amount cannot be negative."){super(`InvalidAmount: ${e}`),this.name="InvalidPriceAmountError";}},l=class extends Error{constructor(e="Currency code is required."){super(`InvalidCurrency: ${e}`),this.name="InvalidCurrencyCodeError";}},c=class extends Error{constructor(e="Cannot perform operation on prices with different currencies."){super(`CurrencyMismatch: ${e}`),this.name="CurrencyMismatchError";}},a=class extends Error{constructor(e){super(`InvalidArgument: ${e}`),this.name="InvalidArgumentError";}};var i=class n{#e;amount;currency;constructor(e){if(this.#e="PriceModel",e.amount<0)throw new g("Amount cannot be negative.");if(!e.currency)throw new l("Currency code is required.");this.currency=e.currency,this.amount=parseFloat(e.amount.toFixed(n.getPrecisionPlaces(this.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}}getPreciseAmount(e){return parseFloat(e.toFixed(n.getPrecisionPlaces(this.currency)))}compareTo(e){if(n.isPriceModel(e)){if(this.currency!==e.getCurrency())throw new c("Cannot compare prices in different currencies.")}else throw new a("Must be a PriceModel instance.");return this.getPreciseAmount(this.amount-e.getAmount())}add(e){if(n.isPriceModel(e)){if(this.currency!==e.getCurrency())throw new c("Cannot add prices in different currencies.")}else throw new a("Must be a PriceModel instance.");return new n({amount:this.getPreciseAmount(this.amount+e.getAmount()),currency:this.currency})}subtract(e){if(n.isPriceModel(e)){if(this.currency!==e.getCurrency())throw new c("Cannot subtract prices in different currencies.")}else throw new a("Must be a PriceModel instance.");return new n({amount:this.getPreciseAmount(this.amount-e.getAmount()),currency:this.currency})}multiply(e){if(n.isPriceModel(e)){if(this.currency!==e.getCurrency())throw new c("Cannot multiply prices in different currencies.");return new n({amount:this.getPreciseAmount(this.amount*e.getAmount()),currency:this.currency})}else if(typeof e=="number"&&e>=0)return new n({amount:this.getPreciseAmount(this.amount*e),currency:this.currency});throw new a("Must be a non-negative number.")}divide(e){if(n.isPriceModel(e)){if(this.currency!==e.getCurrency())throw new c("Cannot divide prices in different currencies.");return new n({amount:this.getPreciseAmount(this.amount/e.getAmount()),currency:this.currency})}else if(typeof e=="number"&&e>0)return new n({amount:this.getPreciseAmount(this.amount/e),currency:this.currency});throw new a("Must be a positive number.")}min(...e){if(e.length===0)throw new a("Must provide at least one PriceModel.");return e.reduce((t,r)=>{if(n.isPriceModel(r)){if(t.getCurrency()!==r.getCurrency())throw new c("Cannot compare prices in different currencies.")}else throw new a("Must be a PriceModel instance.");return t.compareTo(r)<0?t:r},this)}max(...e){if(e.length===0)throw new a("Must provide at least one PriceModel.");return e.reduce((t,r)=>{if(n.isPriceModel(r)){if(t.getCurrency()!==r.getCurrency())throw new c("Cannot compare prices in different currencies.")}else throw new a("Must be a PriceModel instance.");return t.compareTo(r)>0?t:r},this)}zero(){return new n({currency:this.currency,amount:0})}isZero(){return this.amount===0}round(){return new n({currency:this.currency,amount:this.getRoundedAmount()})}getRoundedAmount(){return n.getRoundedAmount(this.amount,this.currency)}getFormattedString(){return n.getFormattedString(this.amount,this.currency)}toString(){return this.getFormattedString()}static getFormattedString(e,t,r={displayAsInteger:!1,style:"currency",currencyDisplay:"symbol"}){let s=I[t];if(!t||!s)throw new l("Invalid currency code for formatting.");let o=e,p=r.displayAsInteger?0:n.getDecimalPlaces(t),b={style:r.style??"currency",currency:t,signDisplay:"never",currencyDisplay:r.currencyDisplay,minimumFractionDigits:p,maximumFractionDigits:p};r.displayAsInteger&&(o=Math.ceil(o));try{return new Intl.NumberFormat(s,b).format(o)}catch(C){return console.error(`Error formatting price for currency "${t}" and locale "${s}":`,C),`${y[t]??t} ${n.addThousandSeparators(o.toFixed(p))}`}}static getDecimalPlaces(e){switch(e){case"INR":default:return 2}}static getPrecisionPlaces(e){switch(e){case"INR":default:return 6}}static addThousandSeparators(e){let t=e.split("."),r=t[0],s=t.length>1?"."+t[1]:"";return r.replace(/\B(?=(\d{3})+(?!\d))/g,",")+s}static getRoundedAmount(e,t){if(e<0)throw new g("Amount cannot be negative for rounding.");if(t===void 0)throw new l("Invalid currency code for rounding.");let r=n.getDecimalPlaces(t),s=Math.pow(10,r);return Math.round(e*s)/s}};var A=n=>structuredClone(n),h=class{customFields;constructor(e,t=new Date){this.customFields={...e.customFields};}getCustomField(e){let t=this.customFields[e];return t==null?t:A(t)}setCustomField(e,t){this.customFields[e]=t;}getAllCustomFields(){return A(this.customFields)}},d=class extends h{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,r,s){this.modifiedBy={id:e,authType:t,requestId:r,lambdaName:s};}};var u=class extends d{id;firstName;lastName;company;phone;email;addressLine1;addressLine2;city;postalCode;state;country;isBillingAddress;isShippingAddress;constructor(e,t=new Date){super(e,t),this.id=e.id,this.firstName=e.firstName,this.lastName=e.lastName||"",this.company=e.company||"",this.phone=e.phone,this.email=e.email,this.addressLine1=e.addressLine1,this.addressLine2=e.addressLine2||"",this.city=e.city,this.postalCode=e.postalCode,this.state=e.state,this.country=e.country,this.isBillingAddress=e.isBillingAddress,this.isShippingAddress=e.isShippingAddress;}getDetails(){return {...super.getDetails(),id:this.getId(),firstName:this.getFirstName(),lastName:this.getLastName(),company:this.getCompany(),phone:this.getPhone(),email:this.getEmail(),addressLine1:this.getAddressLine1(),addressLine2:this.getAddressLine2(),city:this.getCity(),postalCode:this.getPostalCode(),state:this.getState(),country:this.getCountry(),isBillingAddress:this.getIsBillingAddress(),isShippingAddress:this.getIsShippingAddress()}}getId(){return this.id}getFirstName(){return this.firstName}getLastName(){return this.lastName}getCompany(){return this.company}getPhone(){return this.phone}getEmail(){return this.email}getAddressLine1(){return this.addressLine1}getAddressLine2(){return this.addressLine2}getCity(){return this.city}getPostalCode(){return this.postalCode}getState(){return this.state}getCountry(){return this.country}getIsBillingAddress(){return this.isBillingAddress}getIsShippingAddress(){return this.isShippingAddress}getAddressType(){return this.isBillingAddress&&this.isShippingAddress?"billing&shipping":this.isBillingAddress?"billing":this.isShippingAddress?"shipping":"none"}static checkIfShippingAddress(e){return e==="shipping"||e==="billing&shipping"}static checkIfBillingAddress(e){return e==="billing"||e==="billing&shipping"}};var x=class extends d{invoiceNumber;orderNumber;issueDate;country;currency;locale;customerId;customerEmail;billingAddress;shippingAddress;taxContext;merchant;lineItems;charges;total;constructor(e,t=new Date){super(e,t),this.invoiceNumber=e.invoiceNumber,this.orderNumber=e.orderNumber,this.issueDate=e.issueDate,this.country=e.country,this.currency=e.currency,this.locale=e.locale,this.customerId=e.customerId,this.customerEmail=e.customerEmail,this.billingAddress=new u(e.billingAddress),this.shippingAddress=new u(e.shippingAddress),this.taxContext=e.taxContext,this.merchant={merchantName:e.merchant.merchantName,taxIdentifier:e.merchant.taxIdentifier,email:e.merchant.email,phone:e.merchant.phone,address:new u(e.merchant.address)},this.lineItems=e.lineItems.map(r=>({...r,netUnitPrice:new i(r.netUnitPrice),netSubtotal:new i(r.netSubtotal),taxTotal:new i(r.taxTotal),grandTotal:new i(r.grandTotal),taxBreakdown:Object.fromEntries(Object.entries(r.taxBreakdown||{}).map(([s,o])=>[s,{...o,taxableAmount:new i(o.taxableAmount),taxAmount:new i(o.taxAmount)}]))})),this.charges=e.charges.map(r=>({...r,taxableValue:new i(r.taxableValue),taxTotal:new i(r.taxTotal),grandTotal:new i(r.grandTotal),taxBreakdown:Object.fromEntries(Object.entries(r.taxBreakdown||{}).map(([s,o])=>[s,{...o,taxableAmount:new i(o.taxableAmount),taxAmount:new i(o.taxAmount)}]))})),this.total={lineItemSubtotal:new i(e.total.lineItemSubtotal),netLineItemSubtotal:new i(e.total.netLineItemSubtotal),lineItemTaxTotal:new i(e.total.lineItemTaxTotal),lineItemTaxBreakdown:this.mapTaxBreakdown(e.total.lineItemTaxBreakdown),additiveCharges:new i(e.total.additiveCharges),netAdditiveCharges:new i(e.total.netAdditiveCharges),additiveChargesTaxTotal:new i(e.total.additiveChargesTaxTotal),additiveChargesTaxBreakdown:this.mapTaxBreakdown(e.total.additiveChargesTaxBreakdown),adjustmentCharges:new i(e.total.adjustmentCharges),shippingCharges:new i(e.total.shippingCharges),netShippingCharges:new i(e.total.netShippingCharges),discountTotal:new i(e.total.discountTotal),discountBreakdown:Object.fromEntries(Object.entries(e.total.discountBreakdown).map(([r,s])=>[r,new i(s)])),taxTotal:new i(e.total.taxTotal),taxBreakdown:this.mapTaxBreakdown(e.total.taxBreakdown),grandTotal:new i(e.total.grandTotal)};}mapTaxBreakdown(e){return Object.fromEntries(Object.entries(e||{}).map(([t,r])=>[t,{system:r.system,totalAmount:new i(r.totalAmount),subSystems:Object.fromEntries(Object.entries(r.subSystems).map(([s,o])=>[s,new i(o)]))}]))}serializeTaxBreakdown(e){return Object.fromEntries(Object.entries(e).map(([t,r])=>[t,{system:r.system,totalAmount:r.totalAmount.getDetails(),subSystems:Object.fromEntries(Object.entries(r.subSystems).map(([s,o])=>[s,o.getDetails()]))}]))}getInvoiceNumber(){return this.invoiceNumber}getOrderNumber(){return this.orderNumber}getIssueDate(){return this.issueDate}getCountry(){return this.country}getCurrency(){return this.currency}getLocale(){return this.locale}getCustomerId(){return this.customerId}getCustomerEmail(){return this.customerEmail}getTaxContext(){return {...this.taxContext}}getTaxRegistrationNumber(){return this.taxContext.recipientTaxIdentifier}getRecipientTaxIdentifier(){return this.taxContext.recipientTaxIdentifier}getRecipientTaxIdentifierType(){return this.taxContext.recipientTaxIdentifierType}getBillingAddress(){return this.billingAddress}getShippingAddress(){return this.shippingAddress}getPlaceOfSupplyState(){return this.taxContext.supplyRegion}getPlaceOfSupplyCode(){return this.taxContext.supplyRegionCode}getSupplyRegion(){return this.taxContext.supplyRegion}getSupplyRegionCode(){return this.taxContext.supplyRegionCode}getMerchant(){return {merchantName:this.merchant.merchantName,taxIdentifier:this.merchant.taxIdentifier,email:this.merchant.email,phone:this.merchant.phone,address:this.merchant.address}}getLineItems(){return [...this.lineItems]}getCharges(){return [...this.charges]}getTotal(){return this.total}getDetails(){let e=this.getTotal();return {...super.getDetails(),invoiceNumber:this.invoiceNumber,orderNumber:this.orderNumber,issueDate:this.issueDate,country:this.country,currency:this.currency,locale:this.locale,customerId:this.customerId,customerEmail:this.customerEmail,billingAddress:this.billingAddress.getDetails(),shippingAddress:this.shippingAddress.getDetails(),taxContext:this.taxContext,merchant:{merchantName:this.merchant.merchantName,taxIdentifier:this.merchant.taxIdentifier,email:this.merchant.email,phone:this.merchant.phone,address:this.merchant.address.getDetails()},lineItems:this.lineItems.map(t=>({...t,netUnitPrice:t.netUnitPrice.getDetails(),netSubtotal:t.netSubtotal.getDetails(),taxTotal:t.taxTotal.getDetails(),grandTotal:t.grandTotal.getDetails(),taxBreakdown:Object.fromEntries(Object.entries(t.taxBreakdown).map(([r,s])=>[r,{...s,taxableAmount:s.taxableAmount.getDetails(),taxAmount:s.taxAmount.getDetails()}]))})),charges:this.charges.map(t=>({...t,taxableValue:t.taxableValue.getDetails(),taxTotal:t.taxTotal.getDetails(),grandTotal:t.grandTotal.getDetails(),taxBreakdown:Object.fromEntries(Object.entries(t.taxBreakdown).map(([r,s])=>[r,{...s,taxableAmount:s.taxableAmount.getDetails(),taxAmount:s.taxAmount.getDetails()}]))})),total:{lineItemSubtotal:e.lineItemSubtotal.getDetails(),netLineItemSubtotal:e.netLineItemSubtotal.getDetails(),lineItemTaxTotal:e.lineItemTaxTotal.getDetails(),lineItemTaxBreakdown:this.serializeTaxBreakdown(e.lineItemTaxBreakdown),additiveCharges:e.additiveCharges.getDetails(),netAdditiveCharges:e.netAdditiveCharges.getDetails(),additiveChargesTaxTotal:e.additiveChargesTaxTotal.getDetails(),additiveChargesTaxBreakdown:this.serializeTaxBreakdown(e.additiveChargesTaxBreakdown),adjustmentCharges:e.adjustmentCharges.getDetails(),shippingCharges:e.shippingCharges.getDetails(),netShippingCharges:e.netShippingCharges.getDetails(),discountTotal:e.discountTotal.getDetails(),discountBreakdown:Object.fromEntries(Object.entries(e.discountBreakdown).map(([t,r])=>[t,r.getDetails()])),taxTotal:e.taxTotal.getDetails(),taxBreakdown:this.serializeTaxBreakdown(e.taxBreakdown),grandTotal:e.grandTotal.getDetails()}}}};module.exports=x;//# sourceMappingURL=Invoice.js.map
2
2
  //# sourceMappingURL=Invoice.js.map