rerobe-js-orm 2.7.26 → 2.7.28

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.
@@ -4,7 +4,7 @@ export default class ReRobeProductHelpers {
4
4
  static isValidCommission(commission: any): boolean;
5
5
  static commissionFixer(commisssion: any): string;
6
6
  static buildReRobeEarnings(arrayLike: CompleteProduct | CompleteProduct[]): number[];
7
- static buildReRobeEarningsV2(arrayLike: CompleteProduct | CompleteProduct[]): number[];
7
+ static buildReRobeEarningsV2(arrayLike: CompleteProduct | CompleteProduct[], isCanonicalMerchant?: boolean): number[];
8
8
  static materialCompJoinedString(materialComposition?: MaterialComposition): string;
9
9
  static measurementsJoinedString(measurementsObj?: Measurements): string;
10
10
  static sizeCommentPretty(sizeComment: string): string;
@@ -55,17 +55,17 @@ class ReRobeProductHelpers {
55
55
  return [inventoryValue, listingFeeEarnings, productionFeeEarnings, fulfillmentFeeEarnings];
56
56
  }, [0, 0, 0, 0]);
57
57
  }
58
- static buildReRobeEarningsV2(arrayLike) {
58
+ static buildReRobeEarningsV2(arrayLike, isCanonicalMerchant) {
59
59
  const products = Array.isArray(arrayLike) ? arrayLike : [arrayLike];
60
60
  return products.reduce((acc, cur) => {
61
61
  const commission = cur.reRobeCommission ? Number(this.commissionFixer(cur.reRobeCommission)) : 0.5;
62
62
  const priceToUse = cur.isOnSale === 'yes' && cur.salePrice ? cur.salePrice : cur.price;
63
63
  const listingPrice = Number.isNaN(priceToUse) ? 0 : Number(priceToUse);
64
- const inventoryValue = acc[0] + listingPrice;
65
- const listingFeeEarnings = acc[1] + listingPrice * commission;
66
- const productionFeeEarnings = acc[2] + this.calculateProductionFee(commission);
67
- const fulfillmentFeeEarnings = acc[3] + this.calculateFulfillmentFee(commission);
68
- return [inventoryValue, listingFeeEarnings, productionFeeEarnings, fulfillmentFeeEarnings].map((v) => Number(Number(v).toFixed(2)));
64
+ const priceSold = acc[0] + listingPrice;
65
+ const commissionFee = acc[1] + priceSold * commission;
66
+ const productionFee = acc[2] + (Boolean(isCanonicalMerchant) ? this.calculateProductionFee(commission) : 0);
67
+ const fulfillmentFee = acc[3] + (Boolean(isCanonicalMerchant) ? this.calculateFulfillmentFee(commission) : 0);
68
+ return [priceSold, commissionFee, productionFee, fulfillmentFee].map((v) => Number(Number(v).toFixed(2)));
69
69
  }, [0, 0, 0, 0]);
70
70
  }
71
71
  static materialCompJoinedString(materialComposition = {}) {
@@ -18,6 +18,9 @@ export default class SellerLedgerTransaction extends Base {
18
18
  productTitle: string;
19
19
  productImgUrl: string;
20
20
  productCommission: string | number;
21
+ commissionFee: string | number;
22
+ productionFee: string | number;
23
+ fulfillmentFee: string | number;
21
24
  constructor(props?: any);
22
25
  toObj(): SellerLedgerTransactionType;
23
26
  generateSchemaForTypesense(name?: string): {
@@ -22,6 +22,9 @@ class SellerLedgerTransaction extends Base_1.default {
22
22
  this.productTitle = (props === null || props === void 0 ? void 0 : props.productTitle) || '';
23
23
  this.productImgUrl = (props === null || props === void 0 ? void 0 : props.productImgUrl) || '';
24
24
  this.productCommission = Number((props === null || props === void 0 ? void 0 : props.productCommission) || 0);
25
+ this.commissionFee = Number(props === null || props === void 0 ? void 0 : props.commissionFee) || 0;
26
+ this.productionFee = Number(props === null || props === void 0 ? void 0 : props.productionFee) || 0;
27
+ this.fulfillmentFee = Number(props === null || props === void 0 ? void 0 : props.fulfillmentFee) || 0;
25
28
  }
26
29
  toObj() {
27
30
  const transactionObj = {
@@ -43,6 +46,9 @@ class SellerLedgerTransaction extends Base_1.default {
43
46
  productTitle: this.productTitle,
44
47
  productImgUrl: this.productImgUrl,
45
48
  productCommission: this.productCommission,
49
+ commissionFee: this.commissionFee,
50
+ productionFee: this.productionFee,
51
+ fulfillmentFee: this.fulfillmentFee,
46
52
  };
47
53
  return transactionObj;
48
54
  }
@@ -145,6 +151,21 @@ class SellerLedgerTransaction extends Base_1.default {
145
151
  name: 'productCommission',
146
152
  type: 'float',
147
153
  },
154
+ {
155
+ facet: true,
156
+ name: 'commissionFee',
157
+ type: 'float',
158
+ },
159
+ {
160
+ facet: true,
161
+ name: 'productionFee',
162
+ type: 'float',
163
+ },
164
+ {
165
+ facet: true,
166
+ name: 'fulfillmentFee',
167
+ type: 'float',
168
+ },
148
169
  ],
149
170
  name: 'dev_sellerLedgerTransactions_20221026',
150
171
  };
@@ -170,6 +191,9 @@ class SellerLedgerTransaction extends Base_1.default {
170
191
  productTitle: this.utilities.sanitizeString(this.productTitle),
171
192
  productImgUrl: this.utilities.sanitizeString(this.productImgUrl),
172
193
  productCommission: this.utilities.sanitizeNumber(this.productCommission),
194
+ commissionFee: this.utilities.sanitizeNumber(this.commissionFee),
195
+ productionFee: this.utilities.sanitizeNumber(this.productionFee),
196
+ fulfillmentFee: this.utilities.sanitizeNumber(this.fulfillmentFee),
173
197
  };
174
198
  return stagedObj;
175
199
  }
@@ -20,6 +20,9 @@ declare type SellerLedgerTransactionType = {
20
20
  productTitle?: string;
21
21
  productImgUrl?: string;
22
22
  productCommission?: string | number;
23
+ commissionFee?: string | number;
24
+ productionFee?: string | number;
25
+ fulfillmentFee?: string | number;
23
26
  };
24
27
  declare type TypesenseSellerLedgerTransactionObj = {
25
28
  id: string;
@@ -41,4 +44,7 @@ declare type TypesenseSellerLedgerTransactionObj = {
41
44
  productTitle: string;
42
45
  productImgUrl: string;
43
46
  productCommission: number;
47
+ commissionFee: number;
48
+ productionFee: number;
49
+ fulfillmentFee: number;
44
50
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rerobe-js-orm",
3
- "version": "2.7.26",
3
+ "version": "2.7.28",
4
4
  "description": "ReRobe's Javascript ORM Framework",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",