rerobe-js-orm 3.6.0 → 3.6.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.
@@ -98,7 +98,7 @@ class OrderFromFormState extends OrderFactory_1.default {
98
98
  fulfillmentStatus: fs.fields.fulfillmentStatus.selectedValue,
99
99
  statusUrl: ((_j = fs.props) === null || _j === void 0 ? void 0 : _j.statusUrl) || '',
100
100
  };
101
- const orderAttributes = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, totalPricesAttr), presentmentTotalPricesAttr), discountsAttr), shippingAndLocationAttr), customerAttr), statusesAttr), { id: ((_k = fs.props) === null || _k === void 0 ? void 0 : _k.id) || '', documentId: ((_l = fs.props) === null || _l === void 0 ? void 0 : _l.documentId) || '', name: ((_m = fs.props) === null || _m === void 0 ? void 0 : _m.name) || '', orderNumber: (_o = fs.props) === null || _o === void 0 ? void 0 : _o.orderNumber, ribbnOrderNumber: (_p = fs.props) === null || _p === void 0 ? void 0 : _p.ribbnOrderNumber, merchantId: ((_q = fs.props) === null || _q === void 0 ? void 0 : _q.merchantId) || '', currencyCode: fs.fields.currencyCode.inputValue, lineItems: fs.fields.lineItems.selectedValues || [], fulfillments: ((_r = fs.props) === null || _r === void 0 ? void 0 : _r.fulfillments) || [], refunds: ((_s = fs.props) === null || _s === void 0 ? void 0 : _s.refunds) || [], paymentType: fs.fields.paymentType.selectedValue, paymentMethod: fs.fields.paymentMethod.selectedValue || '', paymentDetails: fs.fields.paymentDetails.selectedValue || {}, notes: fs.fields.notes.inputValue || '', tags: fs.fields.tags.selectedValues || [], cancelReason: fs.fields.cancelReason.selectedValue || '', canceledAt: ((_t = fs.props) === null || _t === void 0 ? void 0 : _t.canceledAt) || '', processedAt: ((_u = fs.props) === null || _u === void 0 ? void 0 : _u.processedAt) || new Date().toUTCString(), adjustments: ((_v = fs.props) === null || _v === void 0 ? void 0 : _v.adjustments) || [], createdAtTimestamp: 0, updatedAtTimestamp: 0, createdByUserId: ((_w = fs.props) === null || _w === void 0 ? void 0 : _w.createdByUserId) || '' });
101
+ const orderAttributes = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, totalPricesAttr), presentmentTotalPricesAttr), discountsAttr), shippingAndLocationAttr), customerAttr), statusesAttr), { id: ((_k = fs.props) === null || _k === void 0 ? void 0 : _k.id) || '', documentId: ((_l = fs.props) === null || _l === void 0 ? void 0 : _l.documentId) || '', name: ((_m = fs.props) === null || _m === void 0 ? void 0 : _m.name) || '', orderNumber: (_o = fs.props) === null || _o === void 0 ? void 0 : _o.orderNumber, ribbnOrderNumber: (_p = fs.props) === null || _p === void 0 ? void 0 : _p.ribbnOrderNumber, merchantId: ((_q = fs.props) === null || _q === void 0 ? void 0 : _q.merchantId) || '', currencyCode: fs.fields.currencyCode.inputValue, lineItems: fs.fields.lineItems.selectedValues || [], fulfillments: ((_r = fs.props) === null || _r === void 0 ? void 0 : _r.fulfillments) || [], refunds: ((_s = fs.props) === null || _s === void 0 ? void 0 : _s.refunds) || [], paymentType: fs.fields.paymentType.selectedValue, paymentMethod: fs.fields.paymentMethod.selectedValue || '', paymentDetails: fs.fields.paymentDetails.selectedValue || {}, notes: fs.fields.notes.inputValue || '', tags: fs.fields.tags.selectedValues || [], cancelReason: fs.fields.cancelReason.selectedValue || '', canceledAt: ((_t = fs.props) === null || _t === void 0 ? void 0 : _t.canceledAt) || '', processedAt: ((_u = fs.props) === null || _u === void 0 ? void 0 : _u.processedAt) || new Date().toUTCString(), adjustments: ((_v = fs.props) === null || _v === void 0 ? void 0 : _v.adjustments) || [], createdAtTimestamp: 0, updatedAtTimestamp: 0, createdByUserId: ((_w = fs.props) === null || _w === void 0 ? void 0 : _w.createdByUserId) || '', taxTitle: fs.fields.taxTitle.inputValue || '' });
102
102
  return new Order_1.default(Object.assign({}, orderAttributes));
103
103
  }
104
104
  }
@@ -40,6 +40,7 @@ class OrderFormState extends FormState_1.default {
40
40
  this.fields.subTotalWithSalePriceIncluded = this.fieldFactory('textInput', 'subTotalWithSalePriceIncluded');
41
41
  this.fields.subTotalWithShipping = this.fieldFactory('textInput', 'subTotalWithShipping');
42
42
  this.fields.discountTitle = this.fieldFactory('textInput', 'discountTitle');
43
+ this.fields.taxTitle = this.fieldFactory('textInput', 'taxTitle');
43
44
  this.fields.creditDiscount = this.fieldFactory('textInput', 'creditDiscount');
44
45
  this.fields.saleDiscount = this.fieldFactory('textInput', 'saleDiscount');
45
46
  this.fields.availableCredit = this.fieldFactory('textInput', 'availableCredit');
@@ -108,7 +109,7 @@ class OrderFormState extends FormState_1.default {
108
109
  }
109
110
  }
110
111
  fieldFactory(fieldType, fieldKey, fieldOptions) {
111
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0;
112
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1;
112
113
  let options = fieldOptions || [];
113
114
  const hidden = false;
114
115
  if (fieldType === 'textInput') {
@@ -124,6 +125,9 @@ class OrderFormState extends FormState_1.default {
124
125
  if (fieldKey === 'discountTitle') {
125
126
  inputValue = ((_b = (_a = this.props) === null || _a === void 0 ? void 0 : _a.appliedDiscount) === null || _b === void 0 ? void 0 : _b.title) || '';
126
127
  }
128
+ if (fieldKey === 'taxTitle') {
129
+ inputValue = ((_c = this.props) === null || _c === void 0 ? void 0 : _c.taxTitle) || '';
130
+ }
127
131
  if (fieldKey === 'subtotalPrice' ||
128
132
  fieldKey === 'totalPrice' ||
129
133
  fieldKey === 'totalDiscount' ||
@@ -157,39 +161,39 @@ class OrderFormState extends FormState_1.default {
157
161
  let selectedValue = this.props[fieldKey] || '';
158
162
  let onChangeHandler = (val) => this.singleSelectChangeHandler(fieldKey, val);
159
163
  if (fieldKey === 'pickupLocation') {
160
- if (((_c = this.props) === null || _c === void 0 ? void 0 : _c.shippingType) === order_constants_1.SHIPPING_TYPES.localPickUp &&
161
- ((_d = this.props) === null || _d === void 0 ? void 0 : _d.fulfillmentLocations) &&
162
- ((_e = this.props.fulfillmentLocations[0]) === null || _e === void 0 ? void 0 : _e.location)) {
164
+ if (((_d = this.props) === null || _d === void 0 ? void 0 : _d.shippingType) === order_constants_1.SHIPPING_TYPES.localPickUp &&
165
+ ((_e = this.props) === null || _e === void 0 ? void 0 : _e.fulfillmentLocations) &&
166
+ ((_f = this.props.fulfillmentLocations[0]) === null || _f === void 0 ? void 0 : _f.location)) {
163
167
  const location = this.props.fulfillmentLocations[0].location;
164
168
  const locationId = location.locationId || location.documentId || '';
165
169
  selectedValue = locationId;
166
170
  options = [{ label: location.address1 ? this.utilities.getAddressLabel(location) : '', value: locationId }];
167
171
  }
168
- if ((_g = (_f = this.opts) === null || _f === void 0 ? void 0 : _f.pickupLocationOptions) === null || _g === void 0 ? void 0 : _g.length) {
172
+ if ((_h = (_g = this.opts) === null || _g === void 0 ? void 0 : _g.pickupLocationOptions) === null || _h === void 0 ? void 0 : _h.length) {
169
173
  options = this.utilities.uniqObjArray([...options, ...this.opts.pickupLocationOptions], 'value');
170
174
  }
171
175
  }
172
176
  if (fieldKey === 'shippingInfo') {
173
177
  selectedValue = {
174
- productsLocationsMapping: ((_h = this.props) === null || _h === void 0 ? void 0 : _h.fulfillmentLocations) || [],
178
+ productsLocationsMapping: ((_j = this.props) === null || _j === void 0 ? void 0 : _j.fulfillmentLocations) || [],
175
179
  description: '',
176
- price: ((_k = (_j = this.props) === null || _j === void 0 ? void 0 : _j.totalShippingPrice) === null || _k === void 0 ? void 0 : _k.amount) || 0,
180
+ price: ((_l = (_k = this.props) === null || _k === void 0 ? void 0 : _k.totalShippingPrice) === null || _l === void 0 ? void 0 : _l.amount) || 0,
177
181
  disabled: false,
178
182
  };
179
183
  }
180
184
  if (fieldKey === 'presentmentData') {
181
185
  selectedValue = {
182
- presentmentCurrencyCode: ((_m = (_l = this.props) === null || _l === void 0 ? void 0 : _l.totalPricePresentment) === null || _m === void 0 ? void 0 : _m.currencyCode) || '',
183
- discountTitlePresentment: ((_p = (_o = this.props) === null || _o === void 0 ? void 0 : _o.appliedDiscount) === null || _p === void 0 ? void 0 : _p.title) || '',
184
- subtotalPricePresentment: ((_q = this.props) === null || _q === void 0 ? void 0 : _q.subtotalPricePresentment) || { amount: 0 },
185
- totalDiscountPresentment: ((_r = this.props) === null || _r === void 0 ? void 0 : _r.totalDiscountPresentment) || { amount: 0 },
186
- totalShippingPricePresentment: ((_s = this.props) === null || _s === void 0 ? void 0 : _s.totalShippingPricePresentment) || { amount: 0 },
187
- totalPricePresentment: ((_t = this.props) === null || _t === void 0 ? void 0 : _t.totalPricePresentment) || { amount: 0 },
188
- totalRefundedPresentment: ((_u = this.props) === null || _u === void 0 ? void 0 : _u.totalRefundedPresentment) || { amount: 0 },
189
- totalTaxPresentment: ((_v = this.props) === null || _v === void 0 ? void 0 : _v.totalTaxPresentment) || { amount: 0 },
190
- creditDiscountPresentment: ((_w = this.props) === null || _w === void 0 ? void 0 : _w.creditDiscountPresentment) || { amount: 0 },
191
- saleDiscountPresentment: ((_x = this.props) === null || _x === void 0 ? void 0 : _x.saleDiscountPresentment) || { amount: 0 },
192
- additionalDiscountPresentment: ((_y = this.props) === null || _y === void 0 ? void 0 : _y.additionalDiscountPresentment) || { amount: 0 },
186
+ presentmentCurrencyCode: ((_o = (_m = this.props) === null || _m === void 0 ? void 0 : _m.totalPricePresentment) === null || _o === void 0 ? void 0 : _o.currencyCode) || '',
187
+ discountTitlePresentment: ((_q = (_p = this.props) === null || _p === void 0 ? void 0 : _p.appliedDiscount) === null || _q === void 0 ? void 0 : _q.title) || '',
188
+ subtotalPricePresentment: ((_r = this.props) === null || _r === void 0 ? void 0 : _r.subtotalPricePresentment) || { amount: 0 },
189
+ totalDiscountPresentment: ((_s = this.props) === null || _s === void 0 ? void 0 : _s.totalDiscountPresentment) || { amount: 0 },
190
+ totalShippingPricePresentment: ((_t = this.props) === null || _t === void 0 ? void 0 : _t.totalShippingPricePresentment) || { amount: 0 },
191
+ totalPricePresentment: ((_u = this.props) === null || _u === void 0 ? void 0 : _u.totalPricePresentment) || { amount: 0 },
192
+ totalRefundedPresentment: ((_v = this.props) === null || _v === void 0 ? void 0 : _v.totalRefundedPresentment) || { amount: 0 },
193
+ totalTaxPresentment: ((_w = this.props) === null || _w === void 0 ? void 0 : _w.totalTaxPresentment) || { amount: 0 },
194
+ creditDiscountPresentment: ((_x = this.props) === null || _x === void 0 ? void 0 : _x.creditDiscountPresentment) || { amount: 0 },
195
+ saleDiscountPresentment: ((_y = this.props) === null || _y === void 0 ? void 0 : _y.saleDiscountPresentment) || { amount: 0 },
196
+ additionalDiscountPresentment: ((_z = this.props) === null || _z === void 0 ? void 0 : _z.additionalDiscountPresentment) || { amount: 0 },
193
197
  };
194
198
  }
195
199
  if (fieldKey === 'customer') {
@@ -209,7 +213,7 @@ class OrderFormState extends FormState_1.default {
209
213
  }
210
214
  const valid = !!this.props[fieldKey];
211
215
  if (fieldKey === 'shippingType') {
212
- if ((_0 = (_z = this.opts) === null || _z === void 0 ? void 0 : _z.shippingTypeOptions) === null || _0 === void 0 ? void 0 : _0.length) {
216
+ if ((_1 = (_0 = this.opts) === null || _0 === void 0 ? void 0 : _0.shippingTypeOptions) === null || _1 === void 0 ? void 0 : _1.length) {
213
217
  options = this.utilities.uniqObjArray(this.opts.shippingTypeOptions, 'value');
214
218
  }
215
219
  }
@@ -3,7 +3,7 @@ export default class OrderHelpers {
3
3
  getShippingTypeFromShopifyObj(shippingLines: ShippingLineRest[] | null | undefined): string;
4
4
  getPaymentTypeUsingTags(tags: string | null | undefined): string | null;
5
5
  getSalesChannelUsingTags(tags: string | null | undefined): string | null;
6
- buildLineItemFromProduct(product: CompleteProduct, currencyCode: string, quantity?: number): ReRobeOrderLineItem;
6
+ buildLineItemFromProduct(product: CompleteProduct, currencyCode: string, quantity?: number, taxProps?: RibbnTaxProps): ReRobeOrderLineItem;
7
7
  toFixedPointPrice(price: number | string): string;
8
8
  getAmountSumByField(array: OrderRefund[] | ReRobeOrderLineItem[], fieldKey: string): number;
9
9
  getOrderInfoWithRefundsAndFulfillments(order: CompleteOrder): OrderWithRefundsAndFulfillmentsInfoObj;
@@ -25,33 +25,24 @@ export default class OrderHelpers {
25
25
  additionalDiscount: number;
26
26
  currency: string;
27
27
  }): string;
28
- getSubtotalWithoutSalePrice(productsFullInfoWithQuantity?: {
29
- product: CompleteProduct;
30
- quantity: number;
31
- }[]): number;
32
- getSubtotalWithSalePriceIncluded(productsFullInfoWithQuantity?: {
33
- product: CompleteProduct;
34
- quantity: number;
35
- }[]): number;
36
- getSaleDiscountAmount(productsFullInfoWithQuantity: {
37
- product: CompleteProduct;
38
- quantity: number;
39
- }[]): number;
40
- preparePresentmentData({ merchantName, merchantCurrency, presentmentCurrencyCode, productsFullInfoWithQuantity, currencyConverter, saleDiscountAmount, creditDiscountAmount, additionalDiscount, shippingPrice, subTotalWithSalePriceIncluded, totalIncludingShipping, }: {
28
+ getSubtotalWithoutSalePrice(productsFullInfoWithQuantity?: ProductsFullInfoWithQuantity): number;
29
+ getSubtotalWithSalePriceIncluded(productsFullInfoWithQuantity?: ProductsFullInfoWithQuantity): number;
30
+ getSaleDiscountAmount(productsFullInfoWithQuantity: ProductsFullInfoWithQuantity): number;
31
+ preparePresentmentData({ merchantName, merchantCurrency, presentmentCurrencyCode, productsFullInfoWithQuantity, currencyConverter, saleDiscountAmount, creditDiscountAmount, additionalDiscount, shippingPrice, itemsTax, shippingFeeTax, subTotalWithSalePriceIncluded, totalIncludingShipping, totalIncludingShippingAndTaxes, }: {
41
32
  merchantName: string;
42
33
  merchantCurrency: string;
43
34
  presentmentCurrencyCode?: string;
44
- productsFullInfoWithQuantity: {
45
- product: CompleteProduct;
46
- quantity: number;
47
- }[];
35
+ productsFullInfoWithQuantity: ProductsFullInfoWithQuantity;
48
36
  currencyConverter?(v: number | string, roundUpTo?: number): number;
49
37
  saleDiscountAmount: number;
50
38
  creditDiscountAmount: number;
51
39
  additionalDiscount: number;
52
40
  shippingPrice: number;
41
+ itemsTax: number;
42
+ shippingFeeTax: number;
53
43
  subTotalWithSalePriceIncluded: number;
54
44
  totalIncludingShipping: number;
45
+ totalIncludingShippingAndTaxes: number;
55
46
  }): {
56
47
  discountTitlePresentment: string;
57
48
  saleDiscountPresentment: {
@@ -88,9 +79,85 @@ export default class OrderHelpers {
88
79
  unfulfilledQuantity?: string | number | undefined;
89
80
  status?: string | undefined;
90
81
  isOnSale?: string | undefined;
91
- isTaxable?: string | undefined;
92
82
  salePrice?: string | undefined;
93
83
  presentmentTaxPrice?: Money | undefined;
84
+ isTaxable?: boolean | undefined;
85
+ taxRate?: number | undefined;
86
+ fromCountry?: string | undefined;
87
+ toCountry?: string | undefined;
88
+ taxAmount?: Money | undefined;
89
+ discountedPrice?: Money | undefined;
90
+ taxAmountWithDiscount?: Money | undefined;
91
+ title: string;
92
+ quantity: string | number;
93
+ variant: ProductVariant | null;
94
+ originalTotalPrice?: Money | undefined;
95
+ originalUnitPrice?: Money | undefined;
96
+ discountedTotalPrice?: Money | undefined;
97
+ image?: Image | undefined;
98
+ }[];
99
+ subtotalPricePresentment: {
100
+ amount: string;
101
+ currencyCode: string;
102
+ };
103
+ totalDiscountPresentment: {
104
+ amount: string;
105
+ currencyCode: string;
106
+ };
107
+ totalShippingPricePresentment: {
108
+ amount: string;
109
+ currencyCode: string;
110
+ };
111
+ itemsTaxPresentment: {
112
+ amount: string;
113
+ currencyCode: string;
114
+ };
115
+ shippingFeeTax: {
116
+ amount: string;
117
+ currencyCode: string;
118
+ };
119
+ totalTaxPresentment: {
120
+ amount: string;
121
+ currencyCode: string;
122
+ };
123
+ totalPricePresentment: {
124
+ amount: string;
125
+ currencyCode: string;
126
+ };
127
+ shippingFeeTaxPresentment?: undefined;
128
+ } | {
129
+ discountTitlePresentment: string;
130
+ lineItems: {
131
+ presentmentTotalPrice: {
132
+ amount: string;
133
+ currencyCode: string;
134
+ };
135
+ presentmentUnitPrice: {
136
+ amount: string;
137
+ currencyCode: string;
138
+ };
139
+ presentmentSalePrice: {
140
+ amount: string;
141
+ currencyCode: string;
142
+ };
143
+ brand?: string | null | undefined;
144
+ productId?: string | null | undefined;
145
+ shopifyProductId?: string | number | null | undefined;
146
+ refundedQuantity?: string | number | undefined;
147
+ canceledQuantity?: string | number | undefined;
148
+ fulfilledQuantity?: string | number | undefined;
149
+ unfulfilledQuantity?: string | number | undefined;
150
+ status?: string | undefined;
151
+ isOnSale?: string | undefined;
152
+ salePrice?: string | undefined;
153
+ presentmentTaxPrice?: Money | undefined;
154
+ isTaxable?: boolean | undefined;
155
+ taxRate?: number | undefined;
156
+ fromCountry?: string | undefined;
157
+ toCountry?: string | undefined;
158
+ taxAmount?: Money | undefined;
159
+ discountedPrice?: Money | undefined;
160
+ taxAmountWithDiscount?: Money | undefined;
94
161
  title: string;
95
162
  quantity: string | number;
96
163
  variant: ProductVariant | null;
@@ -99,6 +166,18 @@ export default class OrderHelpers {
99
166
  discountedTotalPrice?: Money | undefined;
100
167
  image?: Image | undefined;
101
168
  }[];
169
+ saleDiscountPresentment: {
170
+ amount: string;
171
+ currencyCode: string;
172
+ };
173
+ creditDiscountPresentment: {
174
+ amount: string;
175
+ currencyCode: string;
176
+ };
177
+ additionalDiscountPresentment: {
178
+ amount: string;
179
+ currencyCode: string;
180
+ };
102
181
  subtotalPricePresentment: {
103
182
  amount: string;
104
183
  currencyCode: string;
@@ -115,5 +194,18 @@ export default class OrderHelpers {
115
194
  amount: string;
116
195
  currencyCode: string;
117
196
  };
197
+ itemsTaxPresentment: {
198
+ amount: string;
199
+ currencyCode: string;
200
+ };
201
+ shippingFeeTaxPresentment: {
202
+ amount: string;
203
+ currencyCode: string;
204
+ };
205
+ totalTaxPresentment: {
206
+ amount: string;
207
+ currencyCode: string;
208
+ };
209
+ shippingFeeTax?: undefined;
118
210
  };
119
211
  }
@@ -62,8 +62,17 @@ class OrderHelpers {
62
62
  }
63
63
  return null;
64
64
  }
65
- buildLineItemFromProduct(product, currencyCode, quantity = 1) {
65
+ buildLineItemFromProduct(product, currencyCode, quantity = 1, taxProps = {}) {
66
66
  const q = quantity || 1;
67
+ const getImgSrc = () => {
68
+ if (product.imageUrls && !!product.imageUrls.length) {
69
+ return product.imageUrls[0];
70
+ }
71
+ if (product.sellRequestImageUrls && !!product.sellRequestImageUrls.length) {
72
+ return product.sellRequestImageUrls[0];
73
+ }
74
+ return '';
75
+ };
67
76
  return {
68
77
  title: product.title,
69
78
  quantity: q,
@@ -80,13 +89,29 @@ class OrderHelpers {
80
89
  currencyCode,
81
90
  },
82
91
  image: {
83
- originalSrc: product.imageUrls && !!product.imageUrls.length ? product.imageUrls[0] : '',
92
+ originalSrc: getImgSrc(),
84
93
  },
85
94
  shopifyProductId: product.shopifyId || null,
86
95
  productId: product.documentId,
87
96
  status: product.status || '',
88
97
  isOnSale: product.isOnSale === 'yes' && product.clearanceTimestamp ? 'yes' : '',
89
98
  salePrice: product.salePrice || '',
99
+ isTaxable: Boolean((taxProps === null || taxProps === void 0 ? void 0 : taxProps.isTaxable) || ''),
100
+ taxAmount: {
101
+ amount: Number(Number((taxProps === null || taxProps === void 0 ? void 0 : taxProps.taxAmount) || 0).toFixed(2)),
102
+ currencyCode,
103
+ },
104
+ taxRate: (taxProps === null || taxProps === void 0 ? void 0 : taxProps.taxRate) || 0,
105
+ fromCountry: (taxProps === null || taxProps === void 0 ? void 0 : taxProps.fromCountry) || '',
106
+ toCountry: (taxProps === null || taxProps === void 0 ? void 0 : taxProps.toCountry) || '',
107
+ discountedPrice: {
108
+ amount: Number(Number((taxProps === null || taxProps === void 0 ? void 0 : taxProps.discountedPrice) || product.price).toFixed(2)),
109
+ currencyCode,
110
+ },
111
+ taxAmountWithDiscount: {
112
+ amount: Number(Number((taxProps === null || taxProps === void 0 ? void 0 : taxProps.taxAmountWithDiscount) || 0).toFixed(2)),
113
+ currencyCode,
114
+ },
90
115
  };
91
116
  }
92
117
  toFixedPointPrice(price) {
@@ -346,16 +371,26 @@ class OrderHelpers {
346
371
  })
347
372
  .reduce((a, b) => a + b, 0);
348
373
  }
349
- preparePresentmentData({ merchantName, merchantCurrency, presentmentCurrencyCode = '', productsFullInfoWithQuantity, currencyConverter = (v) => Number(v), saleDiscountAmount, creditDiscountAmount, additionalDiscount, shippingPrice, subTotalWithSalePriceIncluded, totalIncludingShipping, }) {
374
+ preparePresentmentData({ merchantName, merchantCurrency, presentmentCurrencyCode = '', productsFullInfoWithQuantity, currencyConverter = (v) => Number(v), saleDiscountAmount, creditDiscountAmount, additionalDiscount, shippingPrice, itemsTax, shippingFeeTax, subTotalWithSalePriceIncluded, totalIncludingShipping, totalIncludingShippingAndTaxes, }) {
350
375
  const convertAndFixPrice = (v, roundUpTo = 1) => this.toFixedPointPrice(currencyConverter(Number(this.toFixedPointPrice(v || 0)), roundUpTo));
351
376
  const prepareMoneyObj = (amount) => ({
352
377
  amount: this.toFixedPointPrice(amount),
353
378
  currencyCode: presentmentCurrencyCode || merchantCurrency,
354
379
  });
355
380
  let subtotalOriginalPresentment = 0;
381
+ const totalTax = Number(itemsTax || 0) + Number(shippingFeeTax || 0);
356
382
  const lineItems = productsFullInfoWithQuantity.map((item) => {
357
383
  var _a;
358
- const lineItem = this.buildLineItemFromProduct(item.product, merchantCurrency, item.quantity);
384
+ const lineItem = this.buildLineItemFromProduct(item.product, merchantCurrency, item.quantity, {
385
+ price: item.price,
386
+ isTaxable: item.isTaxable,
387
+ taxAmount: item.taxAmount,
388
+ taxRate: item.taxRate,
389
+ fromCountry: item.fromCountry,
390
+ toCountry: item.toCountry,
391
+ discountedPrice: item.discountedPrice,
392
+ taxAmountWithDiscount: item.taxAmountWithDiscount,
393
+ });
359
394
  const presentmentUnitPrice = convertAndFixPrice((_a = lineItem.originalUnitPrice) === null || _a === void 0 ? void 0 : _a.amount, 5);
360
395
  const presentmentSalePrice = convertAndFixPrice(lineItem.salePrice, 5);
361
396
  const presentmentItemPrice = lineItem.isOnSale === 'yes' ? presentmentSalePrice : presentmentUnitPrice;
@@ -379,7 +414,10 @@ class OrderHelpers {
379
414
  subtotalPricePresentment: prepareMoneyObj(subTotalWithSalePriceIncluded - creditDiscountAmount - additionalDiscount),
380
415
  totalDiscountPresentment: prepareMoneyObj(creditDiscountAmount + additionalDiscount),
381
416
  totalShippingPricePresentment: prepareMoneyObj(shippingPrice),
382
- totalPricePresentment: prepareMoneyObj(totalIncludingShipping),
417
+ itemsTaxPresentment: prepareMoneyObj(itemsTax),
418
+ shippingFeeTax: prepareMoneyObj(shippingFeeTax),
419
+ totalTaxPresentment: prepareMoneyObj(totalTax),
420
+ totalPricePresentment: prepareMoneyObj(totalIncludingShippingAndTaxes || totalIncludingShipping),
383
421
  };
384
422
  }
385
423
  const subtotalPricePresentmentWithSalePrice = lineItems
@@ -389,6 +427,9 @@ class OrderHelpers {
389
427
  const creditDiscountPresentmentAmount = convertAndFixPrice(creditDiscountAmount || 0);
390
428
  const additionalDiscountPresentmentAmount = convertAndFixPrice(additionalDiscount || 0);
391
429
  const totalShippingPricePresentmentAmount = convertAndFixPrice(shippingPrice || 0);
430
+ const itemsTaxPresentmentAmount = convertAndFixPrice(itemsTax || 0);
431
+ const shippingFeeTaxPresentmentAmount = convertAndFixPrice(shippingFeeTax || 0);
432
+ const totalTaxPresentmentAmount = convertAndFixPrice(totalTax || 0);
392
433
  let subtotalPricePresentmentAmount = subtotalPricePresentmentWithSalePrice -
393
434
  Number(creditDiscountPresentmentAmount) -
394
435
  Number(additionalDiscountPresentmentAmount);
@@ -413,7 +454,12 @@ class OrderHelpers {
413
454
  subtotalPricePresentment: prepareMoneyObj(subtotalPricePresentmentAmount),
414
455
  totalDiscountPresentment: prepareMoneyObj(Number(creditDiscountPresentmentAmount) + Number(additionalDiscountPresentmentAmount)),
415
456
  totalShippingPricePresentment: prepareMoneyObj(totalShippingPricePresentmentAmount),
416
- totalPricePresentment: prepareMoneyObj(Number(subtotalPricePresentmentAmount) + Number(totalShippingPricePresentmentAmount)),
457
+ totalPricePresentment: prepareMoneyObj(Number(subtotalPricePresentmentAmount) +
458
+ Number(totalShippingPricePresentmentAmount) +
459
+ Number(totalTaxPresentmentAmount)),
460
+ itemsTaxPresentment: prepareMoneyObj(itemsTaxPresentmentAmount),
461
+ shippingFeeTaxPresentment: prepareMoneyObj(shippingFeeTaxPresentmentAmount),
462
+ totalTaxPresentment: prepareMoneyObj(totalTaxPresentmentAmount),
417
463
  };
418
464
  }
419
465
  }
@@ -66,6 +66,7 @@ export default class Order extends Base {
66
66
  totalPrice: Money;
67
67
  totalRefunded: Money;
68
68
  totalShippingPrice: Money;
69
+ taxTitle: string;
69
70
  totalTax: Money;
70
71
  originalTotalPrice: Money;
71
72
  lineItems: ReRobeOrderLineItem[];
@@ -61,6 +61,7 @@ class Order extends Base_1.default {
61
61
  this.totalRefunded = (props === null || props === void 0 ? void 0 : props.totalRefunded) || { amount: 0 };
62
62
  this.totalShippingPrice = (props === null || props === void 0 ? void 0 : props.totalShippingPrice) || { amount: 0 };
63
63
  this.totalTax = (props === null || props === void 0 ? void 0 : props.totalTax) || { amount: 0 };
64
+ this.taxTitle = (props === null || props === void 0 ? void 0 : props.taxTitle) || '';
64
65
  this.originalTotalPrice = (props === null || props === void 0 ? void 0 : props.originalTotalPrice) || { amount: 0 };
65
66
  this.lineItems = (props === null || props === void 0 ? void 0 : props.lineItems) || [];
66
67
  this.cancelReason = (props === null || props === void 0 ? void 0 : props.cancelReason) ? props === null || props === void 0 ? void 0 : props.cancelReason.toUpperCase() : '';
@@ -53,6 +53,7 @@ type ReRobeOrderObj = {
53
53
  totalRefunded?: Money;
54
54
  totalShippingPrice?: Money;
55
55
  totalTax?: Money;
56
+ taxTitle?: string;
56
57
  originalTotalPrice?: Money;
57
58
  cancelReason?: CancelReasonTypes | string | null;
58
59
  canceledAt?: string;
@@ -228,6 +229,21 @@ type MoneyBag = {
228
229
  shopMoney: Money;
229
230
  presentmentMoney?: Money;
230
231
  };
232
+ type RibbnTaxProps = {
233
+ price?: number;
234
+ isTaxable?: boolean;
235
+ taxAmount?: number;
236
+ taxRate?: number;
237
+ fromCountry?: string;
238
+ toCountry?: string;
239
+ discountedPrice?: number;
240
+ taxAmountWithDiscount?: number;
241
+ };
242
+ type ProductsFullInfoWithQuantity = ({
243
+ product: CompleteProduct;
244
+ quantity: number;
245
+ price?: number;
246
+ } & RibbnTaxProps)[];
231
247
  interface OrderLineItem {
232
248
  title: string;
233
249
  quantity: number | string;
@@ -247,12 +263,18 @@ interface ReRobeOrderLineItem extends OrderLineItem {
247
263
  unfulfilledQuantity?: number | string;
248
264
  status?: ProductSellStatusKeys | string;
249
265
  isOnSale?: string;
250
- isTaxable?: string;
251
266
  salePrice?: string;
252
267
  presentmentTotalPrice?: Money;
253
268
  presentmentUnitPrice?: Money;
254
269
  presentmentSalePrice?: Money;
255
270
  presentmentTaxPrice?: Money;
271
+ isTaxable?: boolean;
272
+ taxRate?: number;
273
+ fromCountry?: string;
274
+ toCountry?: string;
275
+ taxAmount?: Money;
276
+ discountedPrice?: Money;
277
+ taxAmountWithDiscount?: Money;
256
278
  }
257
279
  type OrderLineItemConnection = {
258
280
  edges: OrderLineItemEdge[];
@@ -761,6 +783,7 @@ type OrderAttributesFormFields = {
761
783
  subTotalWithSalePriceIncluded: TextInputFormField<string | number>;
762
784
  subTotalWithShipping: TextInputFormField<string | number>;
763
785
  discountTitle: TextInputFormField<string>;
786
+ taxTitle: TextInputFormField<string>;
764
787
  creditDiscount: TextInputFormField<string | number>;
765
788
  saleDiscount: TextInputFormField<string | number>;
766
789
  availableCredit: TextInputFormField<string | number>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rerobe-js-orm",
3
- "version": "3.6.0",
3
+ "version": "3.6.2",
4
4
  "description": "ReRobe's Javascript ORM Framework",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",