rerobe-js-orm 2.7.33 → 2.7.35

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,5 +1,5 @@
1
1
  import Base from '../../Base';
2
2
  import SellerLedgerTransaction from '../../models/SellerLedgerTransaction';
3
3
  export default abstract class SellerLedgerTransactionFactory extends Base {
4
- abstract createSellerLedgerTransaction(timestamp: number, type: SellerLedgerTransactionTypeOptions | string, amount: string | number, balance: string | number, accountId: string, merchantId: string, merchantCurrency: string): SellerLedgerTransaction;
4
+ abstract createSellerLedgerTransaction(timestamp: number, type: LedgerTransactionTypeOptions | string, amount: string | number, balance: string | number, accountId: string, merchantId: string, merchantCurrency: string): SellerLedgerTransaction;
5
5
  }
@@ -91,7 +91,7 @@ class ReRobeProductHelpers {
91
91
  const products = Array.isArray(arrayLike) ? arrayLike : [arrayLike];
92
92
  return products.reduce((acc, cur) => {
93
93
  const commission = cur.reRobeCommission ? Number(this.commissionFixer(cur.reRobeCommission)) : 0.5;
94
- const priceToUse = cur.isOnSale === 'yes' && cur.salePrice ? cur.salePrice : cur.price;
94
+ const priceToUse = cur.isOnSale === 'yes' && Boolean(cur.clearanceTimestamp) && cur.salePrice ? cur.salePrice : cur.price;
95
95
  const listingPrice = Number.isNaN(priceToUse) ? 0 : Number(priceToUse);
96
96
  const priceSold = acc[0] + listingPrice;
97
97
  const commissionFee = acc[1] + priceSold * commission;
@@ -0,0 +1,29 @@
1
+ import Base from '../Base';
2
+ export default class CustomerLedgerTransaction extends Base {
3
+ documentId: string;
4
+ createdAtTimestamp: number;
5
+ timestamp: number;
6
+ type: LedgerTransactionTypeOptions | string;
7
+ amount: string | number;
8
+ balance: string | number;
9
+ accountId: string;
10
+ accountName: string;
11
+ accountEmail: string;
12
+ customerId: string;
13
+ merchantId: string;
14
+ merchantCurrency: string;
15
+ orderId: string;
16
+ description: string;
17
+ constructor(props?: any);
18
+ toObj(): CustomerLedgerTransactionType;
19
+ generateSchemaForTypesense(name?: string): {
20
+ default_sorting_field: string;
21
+ fields: {
22
+ facet: boolean;
23
+ name: string;
24
+ type: string;
25
+ }[];
26
+ name: string;
27
+ };
28
+ toObjForTypesense(): TypesenseCustomerLedgerTransactionObj;
29
+ }
@@ -0,0 +1,145 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const Base_1 = require("../Base");
4
+ class CustomerLedgerTransaction extends Base_1.default {
5
+ constructor(props) {
6
+ super();
7
+ this.documentId = (props === null || props === void 0 ? void 0 : props.documentId) || this.utilities.makeRandId(28);
8
+ this.createdAtTimestamp = (props === null || props === void 0 ? void 0 : props.createdAtTimestamp) || 0;
9
+ this.timestamp = (props === null || props === void 0 ? void 0 : props.timestamp) || 0;
10
+ this.type = (props === null || props === void 0 ? void 0 : props.type) || '';
11
+ this.amount = Number((props === null || props === void 0 ? void 0 : props.amount) || 0);
12
+ this.balance = Number((props === null || props === void 0 ? void 0 : props.balance) || 0);
13
+ this.accountId = (props === null || props === void 0 ? void 0 : props.accountId) || '';
14
+ this.accountName = (props === null || props === void 0 ? void 0 : props.accountName) || '';
15
+ this.accountEmail = (props === null || props === void 0 ? void 0 : props.accountEmail) || '';
16
+ this.customerId = (props === null || props === void 0 ? void 0 : props.customerId) || '';
17
+ this.merchantId = (props === null || props === void 0 ? void 0 : props.merchantId) || '';
18
+ this.merchantCurrency = (props === null || props === void 0 ? void 0 : props.merchantCurrency) || '';
19
+ this.orderId = (props === null || props === void 0 ? void 0 : props.orderId) || '';
20
+ this.description = (props === null || props === void 0 ? void 0 : props.description) || '';
21
+ }
22
+ toObj() {
23
+ const transactionObj = {
24
+ documentId: this.documentId,
25
+ createdAtTimestamp: this.createdAtTimestamp,
26
+ timestamp: this.timestamp,
27
+ type: this.type,
28
+ amount: this.amount,
29
+ balance: this.balance,
30
+ accountId: this.accountId,
31
+ accountName: this.accountName,
32
+ accountEmail: this.accountEmail,
33
+ customerId: this.customerId,
34
+ merchantId: this.merchantId,
35
+ merchantCurrency: this.merchantCurrency,
36
+ orderId: this.orderId,
37
+ description: this.description,
38
+ };
39
+ return transactionObj;
40
+ }
41
+ generateSchemaForTypesense(name = 'prod_customerLedgerTransactions_20230103') {
42
+ return {
43
+ default_sorting_field: 'createdAtTimestamp',
44
+ fields: [
45
+ {
46
+ facet: false,
47
+ name: 'id',
48
+ type: 'string',
49
+ },
50
+ {
51
+ facet: false,
52
+ name: 'documentId',
53
+ type: 'string',
54
+ },
55
+ {
56
+ facet: true,
57
+ name: 'createdAtTimestamp',
58
+ type: 'int64',
59
+ },
60
+ {
61
+ facet: true,
62
+ name: 'timestamp',
63
+ type: 'int64',
64
+ },
65
+ {
66
+ facet: true,
67
+ name: 'type',
68
+ type: 'string',
69
+ },
70
+ {
71
+ facet: true,
72
+ name: 'amount',
73
+ type: 'float',
74
+ },
75
+ {
76
+ facet: true,
77
+ name: 'balance',
78
+ type: 'float',
79
+ },
80
+ {
81
+ facet: true,
82
+ name: 'accountId',
83
+ type: 'string',
84
+ },
85
+ {
86
+ facet: true,
87
+ name: 'accountName',
88
+ type: 'string',
89
+ },
90
+ {
91
+ facet: true,
92
+ name: 'accountEmail',
93
+ type: 'string',
94
+ },
95
+ {
96
+ facet: true,
97
+ name: 'customerId',
98
+ type: 'string',
99
+ },
100
+ {
101
+ facet: true,
102
+ name: 'merchantId',
103
+ type: 'string',
104
+ },
105
+ {
106
+ facet: true,
107
+ name: 'merchantCurrency',
108
+ type: 'string',
109
+ },
110
+ {
111
+ facet: true,
112
+ name: 'orderId',
113
+ type: 'string',
114
+ },
115
+ {
116
+ facet: true,
117
+ name: 'description',
118
+ type: 'string',
119
+ },
120
+ ],
121
+ name: 'dev_sellerLedgerTransactions_20221026',
122
+ };
123
+ }
124
+ toObjForTypesense() {
125
+ const stagedObj = {
126
+ id: this.utilities.sanitizeString(this.documentId),
127
+ documentId: this.utilities.sanitizeString(this.documentId),
128
+ createdAtTimestamp: this.utilities.sanitizeMillisTimeStamp(this.createdAtTimestamp),
129
+ timestamp: this.utilities.sanitizeMillisTimeStamp(this.timestamp),
130
+ type: this.utilities.sanitizeString(this.type),
131
+ amount: this.utilities.sanitizeNumber(this.amount),
132
+ balance: this.utilities.sanitizeNumber(this.balance),
133
+ accountId: this.utilities.sanitizeString(this.accountId),
134
+ accountName: this.utilities.sanitizeString(this.accountName),
135
+ accountEmail: this.utilities.sanitizeString(this.accountEmail),
136
+ customerId: this.utilities.sanitizeString(this.customerId),
137
+ merchantId: this.utilities.sanitizeString(this.merchantId),
138
+ merchantCurrency: this.utilities.sanitizeString(this.merchantCurrency),
139
+ orderId: this.utilities.sanitizeString(this.orderId),
140
+ description: this.utilities.sanitizeString(this.description),
141
+ };
142
+ return stagedObj;
143
+ }
144
+ }
145
+ exports.default = CustomerLedgerTransaction;
@@ -3,7 +3,7 @@ export default class SellerLedgerTransaction extends Base {
3
3
  documentId: string;
4
4
  createdAtTimestamp: number;
5
5
  timestamp: number;
6
- type: SellerLedgerTransactionTypeOptions | string;
6
+ type: LedgerTransactionTypeOptions | string;
7
7
  amount: string | number;
8
8
  balance: string | number;
9
9
  accountId: string;
@@ -1,11 +1,11 @@
1
- declare type SellerLedgerTransactionTypeOptions = 'MERCHANT_CREDIT' | 'MERCHANT_DEBIT' | 'SELLER_CREDIT' | 'SELLER_DEBIT' | 'CUSTOMER_CREDIT' | 'CUSTOMER_DEBIT';
1
+ declare type LedgerTransactionTypeOptions = 'MERCHANT_CREDIT' | 'MERCHANT_DEBIT' | 'SELLER_CREDIT' | 'SELLER_DEBIT' | 'CUSTOMER_CREDIT' | 'CUSTOMER_DEBIT';
2
2
  declare type SellerLedgerTransactionType = {
3
3
  documentId: string;
4
4
  createdAtTimestamp: number;
5
5
  createdAt?: string;
6
6
  updatedAt?: string;
7
7
  timestamp?: number;
8
- type: SellerLedgerTransactionTypeOptions | string;
8
+ type: LedgerTransactionTypeOptions | string;
9
9
  amount: string | number;
10
10
  balance: string | number;
11
11
  accountId: string;
@@ -24,6 +24,24 @@ declare type SellerLedgerTransactionType = {
24
24
  productionFee?: string | number;
25
25
  fulfillmentFee?: string | number;
26
26
  };
27
+ declare type CustomerLedgerTransactionType = {
28
+ documentId: string;
29
+ createdAtTimestamp: number;
30
+ createdAt?: string;
31
+ updatedAt?: string;
32
+ timestamp?: number;
33
+ type: LedgerTransactionTypeOptions | string;
34
+ amount: string | number;
35
+ balance: string | number;
36
+ accountId: string;
37
+ accountName?: string;
38
+ accountEmail?: string;
39
+ customerId: string;
40
+ merchantId: string;
41
+ merchantCurrency: string;
42
+ orderId?: string;
43
+ description: string;
44
+ };
27
45
  declare type TypesenseSellerLedgerTransactionObj = {
28
46
  id: string;
29
47
  documentId: string;
@@ -48,3 +66,20 @@ declare type TypesenseSellerLedgerTransactionObj = {
48
66
  productionFee: number;
49
67
  fulfillmentFee: number;
50
68
  };
69
+ declare type TypesenseCustomerLedgerTransactionObj = {
70
+ id: string;
71
+ documentId: string;
72
+ createdAtTimestamp: number;
73
+ timestamp: number;
74
+ type: string;
75
+ amount: number;
76
+ balance: number;
77
+ accountId: string;
78
+ accountName: string;
79
+ accountEmail: string;
80
+ customerId: string;
81
+ merchantId: string;
82
+ merchantCurrency: string;
83
+ orderId: string;
84
+ description: string;
85
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rerobe-js-orm",
3
- "version": "2.7.33",
3
+ "version": "2.7.35",
4
4
  "description": "ReRobe's Javascript ORM Framework",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",