rerobe-js-orm 2.7.25 → 2.7.26

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,6 +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
8
  static materialCompJoinedString(materialComposition?: MaterialComposition): string;
8
9
  static measurementsJoinedString(measurementsObj?: Measurements): string;
9
10
  static sizeCommentPretty(sizeComment: string): string;
@@ -55,6 +55,19 @@ class ReRobeProductHelpers {
55
55
  return [inventoryValue, listingFeeEarnings, productionFeeEarnings, fulfillmentFeeEarnings];
56
56
  }, [0, 0, 0, 0]);
57
57
  }
58
+ static buildReRobeEarningsV2(arrayLike) {
59
+ const products = Array.isArray(arrayLike) ? arrayLike : [arrayLike];
60
+ return products.reduce((acc, cur) => {
61
+ const commission = cur.reRobeCommission ? Number(this.commissionFixer(cur.reRobeCommission)) : 0.5;
62
+ const priceToUse = cur.isOnSale === 'yes' && cur.salePrice ? cur.salePrice : cur.price;
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)));
69
+ }, [0, 0, 0, 0]);
70
+ }
58
71
  static materialCompJoinedString(materialComposition = {}) {
59
72
  if (materialComposition) {
60
73
  return Object.keys(materialComposition)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rerobe-js-orm",
3
- "version": "2.7.25",
3
+ "version": "2.7.26",
4
4
  "description": "ReRobe's Javascript ORM Framework",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",