rerobe-js-orm 3.9.3 → 3.9.4
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.
package/lib/models/Product.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export default class Product extends Base {
|
|
|
11
11
|
toProductInputObjForShopify(location?: string): any;
|
|
12
12
|
toProductInputObjForShopifyV2(locationId: string, weightUnit?: string): any[];
|
|
13
13
|
toObjForTextTranslation(): TranslatableAttributes;
|
|
14
|
-
toObjForTypesense(): TypesenseProductObj;
|
|
14
|
+
toObjForTypesense(isCanonicalMerchant?: boolean): TypesenseProductObj;
|
|
15
15
|
buildUpdatedFieldsForSalesChannel(): {
|
|
16
16
|
title: string;
|
|
17
17
|
description: string;
|
package/lib/models/Product.js
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const Base_1 = require("../Base");
|
|
4
4
|
const product_constants_1 = require("../constants/product-constants");
|
|
5
5
|
const options_1 = require("../form-states/Product/options");
|
|
6
|
+
const ReRobeProductHelpers_1 = require("../helpers/ReRobeProductHelpers");
|
|
6
7
|
class Product extends Base_1.default {
|
|
7
8
|
constructor(props) {
|
|
8
9
|
super();
|
|
@@ -276,10 +277,14 @@ class Product extends Base_1.default {
|
|
|
276
277
|
condition: this.filterAttributes.condition || this.FIELD_NOT_TRANSLATABLE_KEY,
|
|
277
278
|
};
|
|
278
279
|
}
|
|
279
|
-
toObjForTypesense() {
|
|
280
|
+
toObjForTypesense(isCanonicalMerchant = false) {
|
|
280
281
|
var _a, _b;
|
|
281
282
|
const createdAtTimestamp = this.utilities.sanitizeMillisTimeStamp(this.timestampAttributes.createdAtTimestamp);
|
|
282
283
|
const { createdAtHour, createdAtDay, createdAtMonth, createdAtYear } = this.utilities.formatTimestamp(createdAtTimestamp);
|
|
284
|
+
const [priceSold, commissionFee, productionFee, fulfillmentFee] = ReRobeProductHelpers_1.default.buildReRobeEarningsV2(this.toObj(), isCanonicalMerchant);
|
|
285
|
+
const merchantValue = commissionFee + productionFee + fulfillmentFee;
|
|
286
|
+
const sellerValue = priceSold - merchantValue;
|
|
287
|
+
const calculatedCommission = merchantValue / priceSold;
|
|
283
288
|
const stagedObj = {
|
|
284
289
|
brand: this.utilities.sanitizeString(this.filterAttributes.brand),
|
|
285
290
|
size: this.utilities.sanitizeString(this.filterAttributes.size),
|
|
@@ -294,6 +299,8 @@ class Product extends Base_1.default {
|
|
|
294
299
|
merchants: this.utilities.sanitzeStringArr(this.attributes.merchants),
|
|
295
300
|
merchantId: this.utilities.sanitizeString(this.attributes.merchantId),
|
|
296
301
|
price: this.utilities.sanitizeNumber(this.attributes.price),
|
|
302
|
+
merchantValue: this.utilities.sanitizeNumber(merchantValue),
|
|
303
|
+
sellerValue: this.utilities.sanitizeNumber(sellerValue),
|
|
297
304
|
suggestedResalePrice: this.utilities.sanitizeNumber(this.consignmentAttributes.suggestedResalePrice),
|
|
298
305
|
salePrice: this.utilities.sanitizeNumber(this.consignmentAttributes.salePrice),
|
|
299
306
|
compareAtPrice: this.utilities.sanitizeNumber(this.attributes.compareAtPrice),
|
|
@@ -303,6 +310,7 @@ class Product extends Base_1.default {
|
|
|
303
310
|
productCategory: this.utilities.sanitizeString(this.filterAttributes.productCategory),
|
|
304
311
|
productType: this.utilities.sanitizeString(this.filterAttributes.productType),
|
|
305
312
|
productStyle: this.utilities.sanitzeStringArr(this.filterAttributes.productStyle),
|
|
313
|
+
calculatedCommission: this.utilities.sanitizeNumber(calculatedCommission),
|
|
306
314
|
reRobeCommission: this.sanitizeCommission(),
|
|
307
315
|
rfidTag: this.utilities.sanitizeString(this.attributes.rfidTag),
|
|
308
316
|
sku: this.utilities.sanitizeString(this.attributes.sku),
|
|
@@ -677,6 +685,21 @@ class Product extends Base_1.default {
|
|
|
677
685
|
name: 'price',
|
|
678
686
|
type: 'float',
|
|
679
687
|
},
|
|
688
|
+
{
|
|
689
|
+
facet: true,
|
|
690
|
+
name: 'merchantValue',
|
|
691
|
+
type: 'float',
|
|
692
|
+
},
|
|
693
|
+
{
|
|
694
|
+
facet: true,
|
|
695
|
+
name: 'sellerValue',
|
|
696
|
+
type: 'float',
|
|
697
|
+
},
|
|
698
|
+
{
|
|
699
|
+
facet: true,
|
|
700
|
+
name: 'calculatedCommission',
|
|
701
|
+
type: 'float',
|
|
702
|
+
},
|
|
680
703
|
{
|
|
681
704
|
facet: true,
|
|
682
705
|
optional: true,
|
|
@@ -267,6 +267,8 @@ type TypesenseProductObj = {
|
|
|
267
267
|
merchants: string[];
|
|
268
268
|
merchantId: string;
|
|
269
269
|
price: number;
|
|
270
|
+
merchantValue: number;
|
|
271
|
+
sellerValue: number;
|
|
270
272
|
suggestedResalePrice: number;
|
|
271
273
|
salePrice: number;
|
|
272
274
|
compareAtPrice: number;
|
|
@@ -277,6 +279,7 @@ type TypesenseProductObj = {
|
|
|
277
279
|
productType: string;
|
|
278
280
|
productStyle: string[];
|
|
279
281
|
reRobeCommission: number;
|
|
282
|
+
calculatedCommission: number;
|
|
280
283
|
rfidTag: string;
|
|
281
284
|
sku: string;
|
|
282
285
|
salesChannel: string[];
|