rerobe-js-orm 2.9.8 → 2.9.9

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.
@@ -9,7 +9,7 @@ class OrderFromFormState extends OrderFactory_1.default {
9
9
  const currencyCode = fs.fields.currencyCode.inputValue || 'SEK';
10
10
  const customer = fs.fields.customer.selectedValue || {};
11
11
  const customerAttr = {
12
- userId: (customer === null || customer === void 0 ? void 0 : customer.uid) || '',
12
+ userId: (customer === null || customer === void 0 ? void 0 : customer.uid) || (customer === null || customer === void 0 ? void 0 : customer.documentId) || '',
13
13
  customerName: ((_a = fs.props) === null || _a === void 0 ? void 0 : _a.customerName) || `${fs.fields.firstName.inputValue} ${fs.fields.lastName.inputValue}`.trim(),
14
14
  email: fs.fields.email.inputValue || '',
15
15
  phone: fs.fields.phone.inputValue || '',
@@ -71,6 +71,9 @@ class OrderFromFormState extends OrderFactory_1.default {
71
71
  },
72
72
  };
73
73
  const presentmentTotalPricesAttr = {
74
+ creditDiscountPresentment: fs.fields.presentmentData.selectedValue.creditDiscountPresentment,
75
+ saleDiscountPresentment: fs.fields.presentmentData.selectedValue.saleDiscountPresentment,
76
+ additionalDiscountPresentment: fs.fields.presentmentData.selectedValue.additionalDiscountPresentment,
74
77
  subtotalPricePresentment: fs.fields.presentmentData.selectedValue.subtotalPricePresentment,
75
78
  totalDiscountPresentment: fs.fields.presentmentData.selectedValue.totalDiscountPresentment,
76
79
  totalPricePresentment: fs.fields.presentmentData.selectedValue.totalPricePresentment,
@@ -105,7 +105,7 @@ class OrderFormState extends FormState_1.default {
105
105
  this.fields.lastName.inputValue = !(customer === null || customer === void 0 ? void 0 : customer.displayName) && (customer === null || customer === void 0 ? void 0 : customer.lastName) ? customer === null || customer === void 0 ? void 0 : customer.lastName : '';
106
106
  }
107
107
  fieldFactory(fieldType, fieldKey, fieldOptions) {
108
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
108
+ 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;
109
109
  let options = fieldOptions || [];
110
110
  const hidden = false;
111
111
  if (fieldType === 'textInput') {
@@ -116,6 +116,9 @@ class OrderFormState extends FormState_1.default {
116
116
  if (fieldKey === 'lastName') {
117
117
  inputValue = this.props.name && this.props.name.split(' ').length > 1 ? this.props.name.split(' ')[1] : '';
118
118
  }
119
+ if (fieldKey === 'discountTitle') {
120
+ inputValue = ((_b = (_a = this.props) === null || _a === void 0 ? void 0 : _a.appliedDiscount) === null || _b === void 0 ? void 0 : _b.title) || '';
121
+ }
119
122
  if (fieldKey === 'subtotalPrice' ||
120
123
  fieldKey === 'totalPrice' ||
121
124
  fieldKey === 'totalDiscount' ||
@@ -148,36 +151,39 @@ class OrderFormState extends FormState_1.default {
148
151
  if (fieldType === 'singleSelect') {
149
152
  let selectedValue = this.props[fieldKey] || '';
150
153
  if (fieldKey === 'pickupLocation') {
151
- if (((_a = this.props) === null || _a === void 0 ? void 0 : _a.shippingType) === order_constants_1.SHIPPING_TYPES.localPickUp) {
152
- selectedValue =
153
- ((_b = this.props) === null || _b === void 0 ? void 0 : _b.fulfillmentLocations) && ((_c = this.props.fulfillmentLocations[0]) === null || _c === void 0 ? void 0 : _c.location)
154
- ? this.props.fulfillmentLocations[0].location.locationId ||
155
- this.props.fulfillmentLocations[0].location.documentId ||
156
- ''
157
- : '';
154
+ if (((_c = this.props) === null || _c === void 0 ? void 0 : _c.shippingType) === order_constants_1.SHIPPING_TYPES.localPickUp &&
155
+ ((_d = this.props) === null || _d === void 0 ? void 0 : _d.fulfillmentLocations) &&
156
+ ((_e = this.props.fulfillmentLocations[0]) === null || _e === void 0 ? void 0 : _e.location)) {
157
+ const location = this.props.fulfillmentLocations[0].location;
158
+ const locationId = location.locationId || location.documentId || '';
159
+ selectedValue = locationId;
160
+ options = [{ label: location.address1 ? this.utilities.getAddressLabel(location) : '', value: locationId }];
158
161
  }
159
- if ((_e = (_d = this.opts) === null || _d === void 0 ? void 0 : _d.pickupLocationOptions) === null || _e === void 0 ? void 0 : _e.length) {
160
- options = this.utilities.uniqObjArray(this.opts.pickupLocationOptions, 'value');
162
+ if ((_g = (_f = this.opts) === null || _f === void 0 ? void 0 : _f.pickupLocationOptions) === null || _g === void 0 ? void 0 : _g.length) {
163
+ options = this.utilities.uniqObjArray([...options, ...this.opts.pickupLocationOptions], 'value');
161
164
  }
162
165
  }
163
166
  if (fieldKey === 'shippingInfo') {
164
167
  selectedValue = {
165
- productsLocationsMapping: ((_f = this.props) === null || _f === void 0 ? void 0 : _f.fulfillmentLocations) || [],
168
+ productsLocationsMapping: ((_h = this.props) === null || _h === void 0 ? void 0 : _h.fulfillmentLocations) || [],
166
169
  description: '',
167
- price: ((_h = (_g = this.props) === null || _g === void 0 ? void 0 : _g.totalShippingPrice) === null || _h === void 0 ? void 0 : _h.amount) || 0,
170
+ price: ((_k = (_j = this.props) === null || _j === void 0 ? void 0 : _j.totalShippingPrice) === null || _k === void 0 ? void 0 : _k.amount) || 0,
168
171
  disabled: false,
169
172
  };
170
173
  }
171
174
  if (fieldKey === 'presentmentData') {
172
175
  selectedValue = {
173
- presentmentCurrencyCode: ((_k = (_j = this.props) === null || _j === void 0 ? void 0 : _j.totalPricePresentment) === null || _k === void 0 ? void 0 : _k.currencyCode) || '',
174
- discountTitlePresentment: ((_m = (_l = this.props) === null || _l === void 0 ? void 0 : _l.appliedDiscount) === null || _m === void 0 ? void 0 : _m.title) || '',
175
- subtotalPricePresentment: ((_o = this.props) === null || _o === void 0 ? void 0 : _o.subtotalPricePresentment) || { amount: 0 },
176
- totalDiscountPresentment: ((_p = this.props) === null || _p === void 0 ? void 0 : _p.totalDiscountPresentment) || { amount: 0 },
177
- totalShippingPricePresentment: ((_q = this.props) === null || _q === void 0 ? void 0 : _q.totalShippingPricePresentment) || { amount: 0 },
178
- totalPricePresentment: ((_r = this.props) === null || _r === void 0 ? void 0 : _r.totalPricePresentment) || { amount: 0 },
179
- totalRefundedPresentment: ((_s = this.props) === null || _s === void 0 ? void 0 : _s.totalRefundedPresentment) || { amount: 0 },
180
- totalTaxPresentment: ((_t = this.props) === null || _t === void 0 ? void 0 : _t.totalTaxPresentment) || { amount: 0 },
176
+ presentmentCurrencyCode: ((_m = (_l = this.props) === null || _l === void 0 ? void 0 : _l.totalPricePresentment) === null || _m === void 0 ? void 0 : _m.currencyCode) || '',
177
+ discountTitlePresentment: ((_p = (_o = this.props) === null || _o === void 0 ? void 0 : _o.appliedDiscount) === null || _p === void 0 ? void 0 : _p.title) || '',
178
+ subtotalPricePresentment: ((_q = this.props) === null || _q === void 0 ? void 0 : _q.subtotalPricePresentment) || { amount: 0 },
179
+ totalDiscountPresentment: ((_r = this.props) === null || _r === void 0 ? void 0 : _r.totalDiscountPresentment) || { amount: 0 },
180
+ totalShippingPricePresentment: ((_s = this.props) === null || _s === void 0 ? void 0 : _s.totalShippingPricePresentment) || { amount: 0 },
181
+ totalPricePresentment: ((_t = this.props) === null || _t === void 0 ? void 0 : _t.totalPricePresentment) || { amount: 0 },
182
+ totalRefundedPresentment: ((_u = this.props) === null || _u === void 0 ? void 0 : _u.totalRefundedPresentment) || { amount: 0 },
183
+ totalTaxPresentment: ((_v = this.props) === null || _v === void 0 ? void 0 : _v.totalTaxPresentment) || { amount: 0 },
184
+ creditDiscountPresentment: ((_w = this.props) === null || _w === void 0 ? void 0 : _w.creditDiscountPresentment) || { amount: 0 },
185
+ saleDiscountPresentment: ((_x = this.props) === null || _x === void 0 ? void 0 : _x.saleDiscountPresentment) || { amount: 0 },
186
+ additionalDiscountPresentment: ((_y = this.props) === null || _y === void 0 ? void 0 : _y.additionalDiscountPresentment) || { amount: 0 },
181
187
  };
182
188
  }
183
189
  const valid = !!this.props[fieldKey];
@@ -191,7 +197,7 @@ class OrderFormState extends FormState_1.default {
191
197
  onChangeHandler = (val) => this.customerChangeHandler(val);
192
198
  }
193
199
  if (fieldKey === 'shippingType') {
194
- if ((_v = (_u = this.opts) === null || _u === void 0 ? void 0 : _u.shippingTypeOptions) === null || _v === void 0 ? void 0 : _v.length) {
200
+ if ((_0 = (_z = this.opts) === null || _z === void 0 ? void 0 : _z.shippingTypeOptions) === null || _0 === void 0 ? void 0 : _0.length) {
195
201
  options = this.utilities.uniqObjArray(this.opts.shippingTypeOptions, 'value');
196
202
  }
197
203
  }
@@ -16,4 +16,5 @@ export default class Utilities {
16
16
  sanitizeMillisTimeStamp(t: any): number;
17
17
  isProperString(name: any): boolean;
18
18
  toProperString(name: any): string;
19
+ getAddressLabel(address: AddressInput): string;
19
20
  }
@@ -128,5 +128,14 @@ class Utilities {
128
128
  // Capitalize each word and join the words together
129
129
  return words.map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join(' ');
130
130
  }
131
+ getAddressLabel(address) {
132
+ const { address1 = '', address2 = '', zip = '', city = '', province = '', country = '' } = address;
133
+ return [address1, address2, zip, city, province, country].reduce((res, item) => {
134
+ if (item) {
135
+ return (res === null || res === void 0 ? void 0 : res.length) ? `${res}, ${item}` : item;
136
+ }
137
+ return res;
138
+ }, '');
139
+ }
131
140
  }
132
141
  exports.default = Utilities;
@@ -94,6 +94,9 @@ export default class Order extends Base {
94
94
  totalRefundedPresentment: Money;
95
95
  totalShippingPricePresentment: Money;
96
96
  totalTaxPresentment: Money;
97
+ creditDiscountPresentment: Money;
98
+ saleDiscountPresentment: Money;
99
+ additionalDiscountPresentment: Money;
97
100
  createdAtTimestamp: number;
98
101
  updatedAtTimestamp: number;
99
102
  constructor(props?: any);
@@ -115,6 +115,15 @@ class Order extends Base_1.default {
115
115
  this.totalTaxPresentment = (props === null || props === void 0 ? void 0 : props.totalTaxPresentment) || {
116
116
  amount: 0,
117
117
  };
118
+ this.creditDiscountPresentment = (props === null || props === void 0 ? void 0 : props.creditDiscountPresentment) || {
119
+ amount: 0,
120
+ };
121
+ this.saleDiscountPresentment = (props === null || props === void 0 ? void 0 : props.saleDiscountPresentment) || {
122
+ amount: 0,
123
+ };
124
+ this.additionalDiscountPresentment = (props === null || props === void 0 ? void 0 : props.additionalDiscountPresentment) || {
125
+ amount: 0,
126
+ };
118
127
  this.createdAtTimestamp = (props === null || props === void 0 ? void 0 : props.createdAtTimestamp) || 0;
119
128
  this.updatedAtTimestamp = (props === null || props === void 0 ? void 0 : props.updatedAtTimestamp) || 0;
120
129
  }
@@ -173,6 +182,9 @@ class Order extends Base_1.default {
173
182
  totalRefundedPresentment: this.totalRefundedPresentment,
174
183
  totalShippingPricePresentment: this.totalShippingPricePresentment,
175
184
  totalTaxPresentment: this.totalTaxPresentment,
185
+ creditDiscountPresentment: this.creditDiscountPresentment,
186
+ saleDiscountPresentment: this.saleDiscountPresentment,
187
+ additionalDiscountPresentment: this.additionalDiscountPresentment,
176
188
  createdAtTimestamp: this.createdAtTimestamp,
177
189
  updatedAtTimestamp: this.updatedAtTimestamp,
178
190
  };
@@ -74,6 +74,9 @@ declare type ReRobeOrderObj = {
74
74
  totalRefundedPresentment?: Money;
75
75
  totalShippingPricePresentment?: Money;
76
76
  totalTaxPresentment?: Money;
77
+ creditDiscountPresentment?: Money;
78
+ saleDiscountPresentment?: Money;
79
+ additionalDiscountPresentment?: Money;
77
80
  createdAtTimestamp: number;
78
81
  updatedAtTimestamp: number;
79
82
  };
@@ -676,6 +679,9 @@ declare type OrderPresentmentData = {
676
679
  totalPricePresentment: Money;
677
680
  totalRefundedPresentment?: Money;
678
681
  totalTaxPresentment?: Money;
682
+ creditDiscountPresentment?: Money;
683
+ saleDiscountPresentment?: Money;
684
+ additionalDiscountPresentment?: Money;
679
685
  };
680
686
  declare type CompleteOrder = ReRobeOrderObj & {
681
687
  [key: string]: any;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rerobe-js-orm",
3
- "version": "2.9.8",
3
+ "version": "2.9.9",
4
4
  "description": "ReRobe's Javascript ORM Framework",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",