rerobe-js-orm 2.7.21 → 2.7.23

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.
@@ -1,6 +1,7 @@
1
1
  export default class ReRobeProductHelpers {
2
2
  static calculateProductionFee(commission: number): number;
3
3
  static calculateFulfillmentFee(commission: number): number;
4
+ static commissionFixer(commisssion: any): string;
4
5
  static buildReRobeEarnings(arrayLike: CompleteProduct | CompleteProduct[]): number[];
5
6
  static materialCompJoinedString(materialComposition?: MaterialComposition): string;
6
7
  static measurementsJoinedString(measurementsObj?: Measurements): string;
@@ -20,10 +20,23 @@ class ReRobeProductHelpers {
20
20
  }
21
21
  return 0;
22
22
  }
23
+ static commissionFixer(commisssion) {
24
+ let fix = String(commisssion);
25
+ if (fix.includes(',')) {
26
+ fix = fix.replace(',', '.');
27
+ }
28
+ if (Number.isNaN(Number(fix)) || !fix) {
29
+ return '0.5';
30
+ }
31
+ while (!(Math.abs(Number(fix)) * 100 >= 0 && Math.abs(Number(fix)) * 100 <= 100)) {
32
+ fix = String(Math.abs(Number(fix)) / 10);
33
+ }
34
+ return String(Math.abs(Number(fix)));
35
+ }
23
36
  static buildReRobeEarnings(arrayLike) {
24
37
  const products = Array.isArray(arrayLike) ? arrayLike : [arrayLike];
25
38
  return products.reduce((acc, cur) => {
26
- const commission = cur.reRobeCommission ? Number(cur.reRobeCommission) : 0.5;
39
+ const commission = cur.reRobeCommission ? Number(this.commissionFixer(cur.reRobeCommission)) : 0.5;
27
40
  const priceToUse = cur.isOnSale === 'yes' && cur.salePrice ? cur.salePrice : cur.price;
28
41
  const listingPrice = Number(Number(priceToUse) <= 1 ? cur.suggestedResalePrice : priceToUse);
29
42
  const inventoryValue = acc[0] + listingPrice;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rerobe-js-orm",
3
- "version": "2.7.21",
3
+ "version": "2.7.23",
4
4
  "description": "ReRobe's Javascript ORM Framework",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",