b23-lib 3.5.2 → 3.6.0

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 (55) hide show
  1. package/dist/Auth/index.js +1 -1
  2. package/dist/Auth/index.js.map +1 -1
  3. package/dist/Auth/index.mjs +1 -1
  4. package/dist/Classes/Cart.js +1 -1
  5. package/dist/Classes/Cart.js.map +1 -1
  6. package/dist/Classes/Cart.mjs +1 -1
  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.js +1 -1
  11. package/dist/Classes/Coupon.js.map +1 -1
  12. package/dist/Classes/Coupon.mjs +1 -1
  13. package/dist/Classes/Inventory.js +1 -1
  14. package/dist/Classes/Inventory.js.map +1 -1
  15. package/dist/Classes/Inventory.mjs +1 -1
  16. package/dist/Classes/Invoice.d.mts +82 -3
  17. package/dist/Classes/Invoice.d.ts +82 -3
  18. package/dist/Classes/Invoice.js +1 -1
  19. package/dist/Classes/Invoice.js.map +1 -1
  20. package/dist/Classes/Invoice.mjs +1 -1
  21. package/dist/Classes/Invoice.mjs.map +1 -1
  22. package/dist/Classes/LineItem.d.mts +7 -0
  23. package/dist/Classes/LineItem.d.ts +7 -0
  24. package/dist/Classes/LineItem.js +1 -1
  25. package/dist/Classes/LineItem.js.map +1 -1
  26. package/dist/Classes/LineItem.mjs +1 -1
  27. package/dist/Classes/Order.js +1 -1
  28. package/dist/Classes/Order.js.map +1 -1
  29. package/dist/Classes/Order.mjs +1 -1
  30. package/dist/Classes/Product.d.mts +6 -0
  31. package/dist/Classes/Product.d.ts +6 -0
  32. package/dist/Classes/Product.js +1 -1
  33. package/dist/Classes/Product.js.map +1 -1
  34. package/dist/Classes/Product.mjs +1 -1
  35. package/dist/Classes/ShoppingContainer.js +1 -1
  36. package/dist/Classes/ShoppingContainer.js.map +1 -1
  37. package/dist/Classes/ShoppingContainer.mjs +1 -1
  38. package/dist/{chunk-R7EJN5XT.mjs → chunk-JNOBURNX.mjs} +2 -2
  39. package/dist/{chunk-R7EJN5XT.mjs.map → chunk-JNOBURNX.mjs.map} +1 -1
  40. package/dist/chunk-JTEJUMUM.mjs +2 -0
  41. package/dist/chunk-JTEJUMUM.mjs.map +1 -0
  42. package/dist/{chunk-XTF6ND33.mjs → chunk-L6H7Q6QR.mjs} +2 -2
  43. package/dist/{chunk-XTF6ND33.mjs.map → chunk-L6H7Q6QR.mjs.map} +1 -1
  44. package/dist/chunk-NLUZDAYM.mjs +2 -0
  45. package/dist/chunk-NLUZDAYM.mjs.map +1 -0
  46. package/dist/{chunk-G4AM63RT.mjs → chunk-V3JILCU7.mjs} +2 -2
  47. package/dist/{chunk-G4AM63RT.mjs.map → chunk-V3JILCU7.mjs.map} +1 -1
  48. package/dist/index.js +1 -1
  49. package/dist/index.js.map +1 -1
  50. package/dist/index.mjs +1 -1
  51. package/package.json +1 -1
  52. package/dist/chunk-4G7JC2EH.mjs +0 -2
  53. package/dist/chunk-4G7JC2EH.mjs.map +0 -1
  54. package/dist/chunk-VEOX3TRL.mjs +0 -2
  55. package/dist/chunk-VEOX3TRL.mjs.map +0 -1
@@ -1,2 +1,2 @@
1
- import {a,b as b$1}from'../chunk-4G7JC2EH.mjs';import'../chunk-S6LR7AUZ.mjs';import'../chunk-2B2XI6FG.mjs';import'../chunk-6ZKMKSAG.mjs';import'../chunk-TPIIACE7.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-JTEJUMUM.mjs';import'../chunk-S6LR7AUZ.mjs';import'../chunk-2B2XI6FG.mjs';import'../chunk-6ZKMKSAG.mjs';import'../chunk-TPIIACE7.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
@@ -29,6 +29,7 @@ type InvoiceTaxBreakdownModel = {
29
29
  type InvoiceLineItemData = {
30
30
  id: string;
31
31
  productKey: string;
32
+ sku: string;
32
33
  name: string;
33
34
  variantLabel: string;
34
35
  quantity: number;
@@ -43,6 +44,7 @@ type InvoiceLineItemData = {
43
44
  type InvoiceLineItemModel = {
44
45
  id: string;
45
46
  productKey: string;
47
+ sku: string;
46
48
  name: string;
47
49
  variantLabel: string;
48
50
  quantity: number;
@@ -141,28 +143,105 @@ declare class InvoiceModel extends BaseModel {
141
143
  constructor(data: InvoiceAttributes, date?: Date);
142
144
  private mapTaxBreakdown;
143
145
  private serializeTaxBreakdown;
146
+ /**
147
+ * Gets the invoice number.
148
+ * @returns The invoice number string.
149
+ */
144
150
  getInvoiceNumber(): string;
151
+ /**
152
+ * Gets the order number associated with this invoice.
153
+ * @returns The order number string.
154
+ */
145
155
  getOrderNumber(): string;
156
+ /**
157
+ * Gets the issue date of this invoice.
158
+ * @returns The issue date string in ISO format.
159
+ */
146
160
  getIssueDate(): string;
161
+ /**
162
+ * Gets the country code where the invoice is issued.
163
+ * @returns The CountryCode enum value.
164
+ */
147
165
  getCountry(): CountryCode;
166
+ /**
167
+ * Gets the currency code used in this invoice.
168
+ * @returns The CurrencyCode enum value.
169
+ */
148
170
  getCurrency(): CurrencyCode;
171
+ /**
172
+ * Gets the locale code for the invoice display language/formatting.
173
+ * @returns The LocaleCode enum value.
174
+ */
149
175
  getLocale(): LocaleCode;
176
+ /**
177
+ * Gets the ID of the customer associated with the invoice.
178
+ * @returns The customer ID string.
179
+ */
150
180
  getCustomerId(): string;
181
+ /**
182
+ * Gets the email address of the customer.
183
+ * @returns The customer email string.
184
+ */
151
185
  getCustomerEmail(): string;
186
+ /**
187
+ * Gets the tax context details for recipient and region.
188
+ * @returns A copy of the InvoiceTaxContextData object.
189
+ */
152
190
  getTaxContext(): InvoiceTaxContextData;
153
- getTaxRegistrationNumber(): string;
191
+ /**
192
+ * Gets the tax identifier of the recipient.
193
+ * @returns The recipient tax identifier string.
194
+ */
154
195
  getRecipientTaxIdentifier(): string;
196
+ /**
197
+ * Gets the type of tax identifier used by the recipient.
198
+ * @returns The recipient tax identifier type string.
199
+ */
155
200
  getRecipientTaxIdentifierType(): string;
201
+ /**
202
+ * Gets the billing address model for this invoice.
203
+ * @returns The AddressModel instance for billing.
204
+ */
156
205
  getBillingAddress(): AddressModel;
206
+ /**
207
+ * Gets the shipping address model for this invoice.
208
+ * @returns The AddressModel instance for shipping.
209
+ */
157
210
  getShippingAddress(): AddressModel;
158
- getPlaceOfSupplyState(): string;
159
- getPlaceOfSupplyCode(): string;
211
+ /**
212
+ * Gets the supply region name.
213
+ * @returns The supply region string.
214
+ */
160
215
  getSupplyRegion(): string;
216
+ /**
217
+ * Gets the supply region code.
218
+ * @returns The supply region code string.
219
+ */
161
220
  getSupplyRegionCode(): string;
221
+ /**
222
+ * Gets the merchant details for this invoice.
223
+ * @returns The MerchantModel details.
224
+ */
162
225
  getMerchant(): MerchantModel;
226
+ /**
227
+ * Gets the line items of the invoice.
228
+ * @returns An array of InvoiceLineItemModel objects.
229
+ */
163
230
  getLineItems(): InvoiceLineItemModel[];
231
+ /**
232
+ * Gets the additional charges applied to the invoice.
233
+ * @returns An array of InvoiceChargeModel objects.
234
+ */
164
235
  getCharges(): InvoiceChargeModel[];
236
+ /**
237
+ * Gets the calculated totals of the invoice.
238
+ * @returns The InvoiceTotalModel object.
239
+ */
165
240
  getTotal(): InvoiceTotalModel;
241
+ /**
242
+ * Gets the current state of the invoice.
243
+ * @returns The InvoiceState enum value.
244
+ */
166
245
  getState(): InvoiceState;
167
246
  getDetails(): InvoiceData;
168
247
  }
@@ -29,6 +29,7 @@ type InvoiceTaxBreakdownModel = {
29
29
  type InvoiceLineItemData = {
30
30
  id: string;
31
31
  productKey: string;
32
+ sku: string;
32
33
  name: string;
33
34
  variantLabel: string;
34
35
  quantity: number;
@@ -43,6 +44,7 @@ type InvoiceLineItemData = {
43
44
  type InvoiceLineItemModel = {
44
45
  id: string;
45
46
  productKey: string;
47
+ sku: string;
46
48
  name: string;
47
49
  variantLabel: string;
48
50
  quantity: number;
@@ -141,28 +143,105 @@ declare class InvoiceModel extends BaseModel {
141
143
  constructor(data: InvoiceAttributes, date?: Date);
142
144
  private mapTaxBreakdown;
143
145
  private serializeTaxBreakdown;
146
+ /**
147
+ * Gets the invoice number.
148
+ * @returns The invoice number string.
149
+ */
144
150
  getInvoiceNumber(): string;
151
+ /**
152
+ * Gets the order number associated with this invoice.
153
+ * @returns The order number string.
154
+ */
145
155
  getOrderNumber(): string;
156
+ /**
157
+ * Gets the issue date of this invoice.
158
+ * @returns The issue date string in ISO format.
159
+ */
146
160
  getIssueDate(): string;
161
+ /**
162
+ * Gets the country code where the invoice is issued.
163
+ * @returns The CountryCode enum value.
164
+ */
147
165
  getCountry(): CountryCode;
166
+ /**
167
+ * Gets the currency code used in this invoice.
168
+ * @returns The CurrencyCode enum value.
169
+ */
148
170
  getCurrency(): CurrencyCode;
171
+ /**
172
+ * Gets the locale code for the invoice display language/formatting.
173
+ * @returns The LocaleCode enum value.
174
+ */
149
175
  getLocale(): LocaleCode;
176
+ /**
177
+ * Gets the ID of the customer associated with the invoice.
178
+ * @returns The customer ID string.
179
+ */
150
180
  getCustomerId(): string;
181
+ /**
182
+ * Gets the email address of the customer.
183
+ * @returns The customer email string.
184
+ */
151
185
  getCustomerEmail(): string;
186
+ /**
187
+ * Gets the tax context details for recipient and region.
188
+ * @returns A copy of the InvoiceTaxContextData object.
189
+ */
152
190
  getTaxContext(): InvoiceTaxContextData;
153
- getTaxRegistrationNumber(): string;
191
+ /**
192
+ * Gets the tax identifier of the recipient.
193
+ * @returns The recipient tax identifier string.
194
+ */
154
195
  getRecipientTaxIdentifier(): string;
196
+ /**
197
+ * Gets the type of tax identifier used by the recipient.
198
+ * @returns The recipient tax identifier type string.
199
+ */
155
200
  getRecipientTaxIdentifierType(): string;
201
+ /**
202
+ * Gets the billing address model for this invoice.
203
+ * @returns The AddressModel instance for billing.
204
+ */
156
205
  getBillingAddress(): AddressModel;
206
+ /**
207
+ * Gets the shipping address model for this invoice.
208
+ * @returns The AddressModel instance for shipping.
209
+ */
157
210
  getShippingAddress(): AddressModel;
158
- getPlaceOfSupplyState(): string;
159
- getPlaceOfSupplyCode(): string;
211
+ /**
212
+ * Gets the supply region name.
213
+ * @returns The supply region string.
214
+ */
160
215
  getSupplyRegion(): string;
216
+ /**
217
+ * Gets the supply region code.
218
+ * @returns The supply region code string.
219
+ */
161
220
  getSupplyRegionCode(): string;
221
+ /**
222
+ * Gets the merchant details for this invoice.
223
+ * @returns The MerchantModel details.
224
+ */
162
225
  getMerchant(): MerchantModel;
226
+ /**
227
+ * Gets the line items of the invoice.
228
+ * @returns An array of InvoiceLineItemModel objects.
229
+ */
163
230
  getLineItems(): InvoiceLineItemModel[];
231
+ /**
232
+ * Gets the additional charges applied to the invoice.
233
+ * @returns An array of InvoiceChargeModel objects.
234
+ */
164
235
  getCharges(): InvoiceChargeModel[];
236
+ /**
237
+ * Gets the calculated totals of the invoice.
238
+ * @returns The InvoiceTotalModel object.
239
+ */
165
240
  getTotal(): InvoiceTotalModel;
241
+ /**
242
+ * Gets the current state of the invoice.
243
+ * @returns The InvoiceState enum value.
244
+ */
166
245
  getState(): InvoiceState;
167
246
  getDetails(): InvoiceData;
168
247
  }
@@ -1,2 +1,2 @@
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),C={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,C).format(o)}catch(b){return console.error(`Error formatting price for currency "${t}" and locale "${s}":`,b),`${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;state;constructor(e,t=new Date){super(e,t),this.invoiceNumber=e.invoiceNumber,this.state=e.state,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}getState(){return this.state}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,state:this.state,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
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;state;constructor(e,t=new Date){super(e,t),this.invoiceNumber=e.invoiceNumber,this.state=e.state,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}}getRecipientTaxIdentifier(){return this.taxContext.recipientTaxIdentifier}getRecipientTaxIdentifierType(){return this.taxContext.recipientTaxIdentifierType}getBillingAddress(){return this.billingAddress}getShippingAddress(){return this.shippingAddress}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}getState(){return this.state}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,state:this.state,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