@merkaly/api 0.39.3 → 0.39.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/dist/abstract.validator.js +3 -7
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/integration/supplier/order.d.ts +1 -0
- package/dist/integration/supplier/quote.d.ts +5 -0
- package/dist/json.d.ts +1 -0
- package/dist/json.js +8 -0
- package/dist/order/purchase/purchase.entity.d.ts +2 -0
- package/dist/order/sale/checkout.d.ts +2 -0
- package/dist/order/sale/fulfillment.d.ts +16 -0
- package/dist/order/sale/index.js +1 -0
- package/dist/order/sale/procurement.d.ts +3 -0
- package/dist/order/sale/receipt.js +17 -0
- package/dist/order/sale/sale.entity.d.ts +2 -0
- package/dist/transaction.entity.d.ts +1 -0
- package/package.json +1 -1
|
@@ -10,6 +10,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
10
10
|
};
|
|
11
11
|
import * as class_transformer_1 from "class-transformer";
|
|
12
12
|
import * as class_validator_1 from "class-validator";
|
|
13
|
+
import * as json_1 from './json.js';
|
|
13
14
|
class PaginationValidator {
|
|
14
15
|
limit = 10;
|
|
15
16
|
page = 1;
|
|
@@ -235,13 +236,8 @@ function transformStructuredValue(key, value) {
|
|
|
235
236
|
function transformJoinsIntoPopulate(value) {
|
|
236
237
|
function transform(value) {
|
|
237
238
|
if ((0, class_validator_1.isString)(value)) {
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
return transform(parsed);
|
|
241
|
-
}
|
|
242
|
-
catch {
|
|
243
|
-
return [{ path: value }];
|
|
244
|
-
}
|
|
239
|
+
const parsed = (0, json_1.parseJson)(value);
|
|
240
|
+
return parsed === undefined ? [{ path: value }] : transform(parsed);
|
|
245
241
|
}
|
|
246
242
|
if ((0, class_validator_1.isArray)(value)) {
|
|
247
243
|
return value.flatMap(transform);
|
package/dist/index.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ export * from './contact.entity';
|
|
|
11
11
|
export * from './transitionable.types';
|
|
12
12
|
export * from './query.types';
|
|
13
13
|
export * from './postal-code.types';
|
|
14
|
+
export * from './json';
|
|
14
15
|
export * from './abstract.entity';
|
|
15
16
|
export * from './abstract.transition';
|
|
16
17
|
export * from './abstract.validator';
|
package/dist/index.js
CHANGED
|
@@ -2,6 +2,7 @@ export * from './not-equal-to.decorator.js';
|
|
|
2
2
|
export * from './address.validator.js';
|
|
3
3
|
export * from './person.validator.js';
|
|
4
4
|
export * from './transform.validator.js';
|
|
5
|
+
export * from './json.js';
|
|
5
6
|
export * from './abstract.transition.js';
|
|
6
7
|
export * from './abstract.validator.js';
|
|
7
8
|
export * from './relation.status.enum.js';
|
|
@@ -3,6 +3,10 @@ export interface SupplierQuoteRequest {
|
|
|
3
3
|
externalVariantId: string;
|
|
4
4
|
quantity: number;
|
|
5
5
|
}
|
|
6
|
+
export interface SupplierImportTaxBracket {
|
|
7
|
+
rate: number;
|
|
8
|
+
upTo: number | null;
|
|
9
|
+
}
|
|
6
10
|
export interface SupplierQuote extends SupplierQuoteRequest {
|
|
7
11
|
available: boolean;
|
|
8
12
|
currency: string;
|
|
@@ -12,6 +16,7 @@ export interface SupplierQuote extends SupplierQuoteRequest {
|
|
|
12
16
|
freight?: number;
|
|
13
17
|
freightCode?: string;
|
|
14
18
|
freightService?: string;
|
|
19
|
+
taxBrackets?: SupplierImportTaxBracket[];
|
|
15
20
|
deliveryDays?: {
|
|
16
21
|
max?: number;
|
|
17
22
|
min?: number;
|
package/dist/json.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function parseJson<T = unknown>(text: string): T | undefined;
|
package/dist/json.js
ADDED
|
@@ -18,6 +18,7 @@ export interface CheckoutQuoteItem {
|
|
|
18
18
|
unitPrice: number;
|
|
19
19
|
total: number;
|
|
20
20
|
shipping: CheckoutQuoteShipping;
|
|
21
|
+
taxes: number;
|
|
21
22
|
}
|
|
22
23
|
export interface CheckoutQuote {
|
|
23
24
|
currency: string;
|
|
@@ -26,5 +27,6 @@ export interface CheckoutQuote {
|
|
|
26
27
|
items: CheckoutQuoteItem[];
|
|
27
28
|
subtotal: number;
|
|
28
29
|
shipping: number;
|
|
30
|
+
taxes: number;
|
|
29
31
|
total: number;
|
|
30
32
|
}
|
|
@@ -9,6 +9,7 @@ import type { OrderSaleReceipt } from './receipt.js';
|
|
|
9
9
|
export interface OrderSaleCosts {
|
|
10
10
|
products: number;
|
|
11
11
|
shippingCost: number;
|
|
12
|
+
taxCost: number;
|
|
12
13
|
total: number;
|
|
13
14
|
}
|
|
14
15
|
export interface OrderSaleEstimate extends OrderSaleCosts {
|
|
@@ -39,11 +40,24 @@ export interface OrderSaleRefundSummary {
|
|
|
39
40
|
purchase: string | null;
|
|
40
41
|
status: FinanceRefundStatusEnum;
|
|
41
42
|
}
|
|
43
|
+
export interface OrderSaleSupplierCharges {
|
|
44
|
+
shipping: {
|
|
45
|
+
paid: number;
|
|
46
|
+
charged: number;
|
|
47
|
+
};
|
|
48
|
+
taxes: {
|
|
49
|
+
paid: number;
|
|
50
|
+
charged: number;
|
|
51
|
+
};
|
|
52
|
+
balance: number;
|
|
53
|
+
real: boolean;
|
|
54
|
+
}
|
|
42
55
|
export interface OrderSaleSummary {
|
|
43
56
|
currency: string;
|
|
44
57
|
revenue: {
|
|
45
58
|
subtotal: number;
|
|
46
59
|
shipping: number;
|
|
60
|
+
taxes: number;
|
|
47
61
|
total: number;
|
|
48
62
|
};
|
|
49
63
|
costs: OrderSaleCosts & {
|
|
@@ -56,6 +70,7 @@ export interface OrderSaleSummary {
|
|
|
56
70
|
margin: number | null;
|
|
57
71
|
estimate: OrderSaleEstimate;
|
|
58
72
|
variance: number | null;
|
|
73
|
+
supplierCharges: OrderSaleSupplierCharges | null;
|
|
59
74
|
items: OrderSaleItemSummary[];
|
|
60
75
|
history: OrderSaleHistoryEntry[];
|
|
61
76
|
warnings: string[];
|
|
@@ -83,6 +98,7 @@ export interface OrderBuyerPackage {
|
|
|
83
98
|
export interface OrderBuyerPricing {
|
|
84
99
|
shipping: number;
|
|
85
100
|
subtotal: number;
|
|
101
|
+
taxes: number;
|
|
86
102
|
total: number;
|
|
87
103
|
units: number;
|
|
88
104
|
fee: number | null;
|
package/dist/order/sale/index.js
CHANGED
|
@@ -12,6 +12,7 @@ export interface ProcurementLine {
|
|
|
12
12
|
storedUnitCost: number;
|
|
13
13
|
quotedUnitCost?: number;
|
|
14
14
|
shippingCost?: number;
|
|
15
|
+
taxCost?: number;
|
|
15
16
|
quote?: SupplierQuote;
|
|
16
17
|
}
|
|
17
18
|
export interface ProcurementGroup {
|
|
@@ -27,8 +28,10 @@ export interface ProcurementGroup {
|
|
|
27
28
|
totals: {
|
|
28
29
|
retail: number;
|
|
29
30
|
shippingPrice: number;
|
|
31
|
+
taxPrice: number;
|
|
30
32
|
cost: number;
|
|
31
33
|
shippingCost: number;
|
|
34
|
+
taxCost: number;
|
|
32
35
|
margin: number;
|
|
33
36
|
};
|
|
34
37
|
available: boolean;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import * as shipment_enum_1 from '../../logistics/shipment/index.js';
|
|
2
|
+
import * as sale_enum_1 from './sale.enum.js';
|
|
3
|
+
export const deliveredAtOf = (shipments) => {
|
|
4
|
+
const at = Math.max(0, ...shipments.map((it) => (it.deliveredAt ? new Date(it.deliveredAt).getTime() : 0)));
|
|
5
|
+
return at ? new Date(at) : null;
|
|
6
|
+
};
|
|
7
|
+
export const confirmedByBuyer = (shipments) => shipments.some((it) => it.receivedBy === shipment_enum_1.LogisticsShipmentSourceEnum.BUYER);
|
|
8
|
+
export function saleReceipt(status, shipments, now = Date.now()) {
|
|
9
|
+
if (status === sale_enum_1.OrderSaleStatusEnum.SHIPPED)
|
|
10
|
+
return { confirmable: true, until: null };
|
|
11
|
+
const deliveredAt = (0, deliveredAtOf)(shipments);
|
|
12
|
+
if (status !== sale_enum_1.OrderSaleStatusEnum.DELIVERED || !deliveredAt || (0, confirmedByBuyer)(shipments)) {
|
|
13
|
+
return { confirmable: false, until: null };
|
|
14
|
+
}
|
|
15
|
+
const until = new Date(deliveredAt.getTime() + sale_enum_1.WITHDRAWAL_HOLD_MS);
|
|
16
|
+
return { confirmable: until.getTime() > now, until };
|
|
17
|
+
}
|
|
@@ -55,6 +55,7 @@ export declare const OrderSaleDeliveryDaysSchema: MongoSchema<OrderSaleDeliveryD
|
|
|
55
55
|
export declare class OrderSaleDeliveryLineEntity {
|
|
56
56
|
variant: string;
|
|
57
57
|
amount: number;
|
|
58
|
+
taxes?: number;
|
|
58
59
|
method?: string;
|
|
59
60
|
deliveryDays?: OrderSaleDeliveryDaysEntity;
|
|
60
61
|
}
|
|
@@ -71,6 +72,7 @@ export declare class OrderSaleDeliveryEntity {
|
|
|
71
72
|
recipient: OrderSaleDeliveryRecipientEntity;
|
|
72
73
|
address: OrderSaleDeliveryAddressEntity;
|
|
73
74
|
shippingPrice?: number;
|
|
75
|
+
taxes?: number;
|
|
74
76
|
quotedAt?: Date;
|
|
75
77
|
lines?: OrderSaleDeliveryLineEntity[];
|
|
76
78
|
}
|