@managesome/eposmatic-toolkit 0.2.453 → 0.2.454
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/helpers/store/common-warehouse-sale-order-invoice-actions.d.ts +16 -0
- package/lib/helpers/store/common-warehouse-sale-order-invoice-actions.js +59 -0
- package/lib/helpers/store/index.d.ts +1 -0
- package/lib/helpers/store/index.js +1 -0
- package/lib/schemas/models/internal_invoices.d.ts +3 -3
- package/lib/schemas/models/warehouse_internal_movements.d.ts +3 -3
- package/lib/schemas/models/warehouse_sale_deliveries.d.ts +3 -3
- package/lib/schemas/models/warehouse_sale_invoices.d.ts +6 -6
- package/package.json +1 -1
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { IWarehouseSaleOrderFinancialLine, IWarehouseSaleOrderInvoice } from '../../schemas';
|
|
2
|
+
/**
|
|
3
|
+
* Convert unit_price on every financial line (invoice items).
|
|
4
|
+
*/
|
|
5
|
+
export declare function getWarehouseSaleOrderInvoiceLinesWithPrice(lines: IWarehouseSaleOrderFinancialLine[] | undefined, convertToPrice: (price: number) => number): IWarehouseSaleOrderFinancialLine[];
|
|
6
|
+
/**
|
|
7
|
+
* Convert payments on a sale-order invoice.
|
|
8
|
+
*/
|
|
9
|
+
export declare function getWarehouseSaleOrderInvoicePaymentsWithPrice(payments: IWarehouseSaleOrderInvoice['payments'] | undefined, convertToPrice: (price: number) => number): IWarehouseSaleOrderInvoice['payments'];
|
|
10
|
+
/**
|
|
11
|
+
* Convert all monetary fields on a sale-order invoice / credit note.
|
|
12
|
+
*
|
|
13
|
+
* - `writeable = true` → decimal → cents (before sending to backend)
|
|
14
|
+
* - `writeable = false` → cents → decimal (after receiving from backend)
|
|
15
|
+
*/
|
|
16
|
+
export declare function getWarehouseSaleOrderInvoiceWithPrice<T extends Partial<IWarehouseSaleOrderInvoice> | IWarehouseSaleOrderInvoice>(order: T, writeable?: boolean): T;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getWarehouseSaleOrderInvoiceLinesWithPrice = getWarehouseSaleOrderInvoiceLinesWithPrice;
|
|
4
|
+
exports.getWarehouseSaleOrderInvoicePaymentsWithPrice = getWarehouseSaleOrderInvoicePaymentsWithPrice;
|
|
5
|
+
exports.getWarehouseSaleOrderInvoiceWithPrice = getWarehouseSaleOrderInvoiceWithPrice;
|
|
6
|
+
const utils_1 = require("../utils");
|
|
7
|
+
const common_order_actions_1 = require("./common-order-actions");
|
|
8
|
+
/**
|
|
9
|
+
* Convert unit_price on every financial line (invoice items).
|
|
10
|
+
*/
|
|
11
|
+
function getWarehouseSaleOrderInvoiceLinesWithPrice(lines, convertToPrice) {
|
|
12
|
+
if (!lines)
|
|
13
|
+
return [];
|
|
14
|
+
return lines.map((line) => ({
|
|
15
|
+
...line,
|
|
16
|
+
unit_price: convertToPrice(line.unit_price),
|
|
17
|
+
}));
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Convert payments on a sale-order invoice.
|
|
21
|
+
*/
|
|
22
|
+
function getWarehouseSaleOrderInvoicePaymentsWithPrice(payments, convertToPrice) {
|
|
23
|
+
if (!payments)
|
|
24
|
+
return [];
|
|
25
|
+
return payments.map((payment) => ({
|
|
26
|
+
...payment,
|
|
27
|
+
card_details: (0, common_order_actions_1.getOrderPaymentsCardDetailsWithPrice)(payment.card_details, convertToPrice),
|
|
28
|
+
amount_paid: convertToPrice(payment.amount_paid),
|
|
29
|
+
amount_due: convertToPrice(payment.amount_due),
|
|
30
|
+
amount_refunded: convertToPrice(payment.amount_refunded),
|
|
31
|
+
}));
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Convert all monetary fields on a sale-order invoice / credit note.
|
|
35
|
+
*
|
|
36
|
+
* - `writeable = true` → decimal → cents (before sending to backend)
|
|
37
|
+
* - `writeable = false` → cents → decimal (after receiving from backend)
|
|
38
|
+
*/
|
|
39
|
+
function getWarehouseSaleOrderInvoiceWithPrice(order, writeable) {
|
|
40
|
+
const convertToPrice = writeable ? utils_1.convertDecimalToInt : utils_1.convertIntToDecimal;
|
|
41
|
+
return {
|
|
42
|
+
...order,
|
|
43
|
+
...(order.items != null
|
|
44
|
+
? {
|
|
45
|
+
items: getWarehouseSaleOrderInvoiceLinesWithPrice(order.items, convertToPrice),
|
|
46
|
+
}
|
|
47
|
+
: {}),
|
|
48
|
+
...(order.payments != null
|
|
49
|
+
? {
|
|
50
|
+
payments: getWarehouseSaleOrderInvoicePaymentsWithPrice(order.payments, convertToPrice),
|
|
51
|
+
}
|
|
52
|
+
: {}),
|
|
53
|
+
...(order.amount != null ? { amount: convertToPrice(order.amount) } : {}),
|
|
54
|
+
...(order.amount_paid != null ? { amount_paid: convertToPrice(order.amount_paid) } : {}),
|
|
55
|
+
...(order.down_payment_value != null ? { down_payment_value: convertToPrice(order.down_payment_value) } : {}),
|
|
56
|
+
...(order.gst != null ? { gst: convertToPrice(order.gst) } : {}),
|
|
57
|
+
...(order.gst_amount != null ? { gst_amount: convertToPrice(order.gst_amount) } : {}),
|
|
58
|
+
};
|
|
59
|
+
}
|
|
@@ -13,6 +13,7 @@ export * from './common-warehouse-purchase-order-actions';
|
|
|
13
13
|
export * from './common-warehouse-purchase-order-rfq-actions';
|
|
14
14
|
export * from './common-warehouse-purchase-order-vendor-return-actions';
|
|
15
15
|
export * from './common-warehouse-sale-order-actions';
|
|
16
|
+
export * from './common-warehouse-sale-order-invoice-actions';
|
|
16
17
|
export * from './common-warehouse-sale-order-rfq-actions';
|
|
17
18
|
export * from './offline-ordering';
|
|
18
19
|
export * from './tenant-purchase-orders-cart-actions';
|
|
@@ -29,6 +29,7 @@ __exportStar(require("./common-warehouse-purchase-order-actions"), exports);
|
|
|
29
29
|
__exportStar(require("./common-warehouse-purchase-order-rfq-actions"), exports);
|
|
30
30
|
__exportStar(require("./common-warehouse-purchase-order-vendor-return-actions"), exports);
|
|
31
31
|
__exportStar(require("./common-warehouse-sale-order-actions"), exports);
|
|
32
|
+
__exportStar(require("./common-warehouse-sale-order-invoice-actions"), exports);
|
|
32
33
|
__exportStar(require("./common-warehouse-sale-order-rfq-actions"), exports);
|
|
33
34
|
__exportStar(require("./offline-ordering"), exports);
|
|
34
35
|
__exportStar(require("./tenant-purchase-orders-cart-actions"), exports);
|
|
@@ -22,9 +22,9 @@ export declare const InternalInvoiceSchema: Schema<any, import("mongoose").Model
|
|
|
22
22
|
subtotal: number;
|
|
23
23
|
payment_terms: string;
|
|
24
24
|
notes: string;
|
|
25
|
+
invoice_type: import("../../constants").INTERNAL_INVOICE_TYPE_ENUM;
|
|
25
26
|
customer_id: import("mongoose").Types.ObjectId;
|
|
26
27
|
invoice_number: string;
|
|
27
|
-
invoice_type: import("../../constants").INTERNAL_INVOICE_TYPE_ENUM;
|
|
28
28
|
hardware: string[];
|
|
29
29
|
currency: import("../../constants").CURRENCY_CODE_ENUM;
|
|
30
30
|
dqrc: string;
|
|
@@ -50,9 +50,9 @@ export declare const InternalInvoiceSchema: Schema<any, import("mongoose").Model
|
|
|
50
50
|
subtotal: number;
|
|
51
51
|
payment_terms: string;
|
|
52
52
|
notes: string;
|
|
53
|
+
invoice_type: import("../../constants").INTERNAL_INVOICE_TYPE_ENUM;
|
|
53
54
|
customer_id: import("mongoose").Types.ObjectId;
|
|
54
55
|
invoice_number: string;
|
|
55
|
-
invoice_type: import("../../constants").INTERNAL_INVOICE_TYPE_ENUM;
|
|
56
56
|
hardware: string[];
|
|
57
57
|
currency: import("../../constants").CURRENCY_CODE_ENUM;
|
|
58
58
|
dqrc: string;
|
|
@@ -78,9 +78,9 @@ export declare const InternalInvoiceSchema: Schema<any, import("mongoose").Model
|
|
|
78
78
|
subtotal: number;
|
|
79
79
|
payment_terms: string;
|
|
80
80
|
notes: string;
|
|
81
|
+
invoice_type: import("../../constants").INTERNAL_INVOICE_TYPE_ENUM;
|
|
81
82
|
customer_id: import("mongoose").Types.ObjectId;
|
|
82
83
|
invoice_number: string;
|
|
83
|
-
invoice_type: import("../../constants").INTERNAL_INVOICE_TYPE_ENUM;
|
|
84
84
|
hardware: string[];
|
|
85
85
|
currency: import("../../constants").CURRENCY_CODE_ENUM;
|
|
86
86
|
dqrc: string;
|
|
@@ -46,8 +46,8 @@ export declare const WarehouseInternalMovementsSchema: Schema<any, import("mongo
|
|
|
46
46
|
name: string;
|
|
47
47
|
uid: string;
|
|
48
48
|
};
|
|
49
|
-
ref_type: import("../../constants").WAREHOUSE_REF_TYPE_ENUM;
|
|
50
49
|
doc_number: string;
|
|
50
|
+
ref_type: import("../../constants").WAREHOUSE_REF_TYPE_ENUM;
|
|
51
51
|
record_type: import("../../constants").WAREHOUSE_INTERNAL_MOVEMENT_RECORD_TYPE_ENUM;
|
|
52
52
|
flow: import("../../constants").WAREHOUSE_INTERNAL_MOVEMENT_FLOW_ENUM;
|
|
53
53
|
source_id: string;
|
|
@@ -164,8 +164,8 @@ export declare const WarehouseInternalMovementsSchema: Schema<any, import("mongo
|
|
|
164
164
|
name: string;
|
|
165
165
|
uid: string;
|
|
166
166
|
};
|
|
167
|
-
ref_type: import("../../constants").WAREHOUSE_REF_TYPE_ENUM;
|
|
168
167
|
doc_number: string;
|
|
168
|
+
ref_type: import("../../constants").WAREHOUSE_REF_TYPE_ENUM;
|
|
169
169
|
record_type: import("../../constants").WAREHOUSE_INTERNAL_MOVEMENT_RECORD_TYPE_ENUM;
|
|
170
170
|
flow: import("../../constants").WAREHOUSE_INTERNAL_MOVEMENT_FLOW_ENUM;
|
|
171
171
|
source_id: string;
|
|
@@ -282,8 +282,8 @@ export declare const WarehouseInternalMovementsSchema: Schema<any, import("mongo
|
|
|
282
282
|
name: string;
|
|
283
283
|
uid: string;
|
|
284
284
|
};
|
|
285
|
-
ref_type: import("../../constants").WAREHOUSE_REF_TYPE_ENUM;
|
|
286
285
|
doc_number: string;
|
|
286
|
+
ref_type: import("../../constants").WAREHOUSE_REF_TYPE_ENUM;
|
|
287
287
|
record_type: import("../../constants").WAREHOUSE_INTERNAL_MOVEMENT_RECORD_TYPE_ENUM;
|
|
288
288
|
flow: import("../../constants").WAREHOUSE_INTERNAL_MOVEMENT_FLOW_ENUM;
|
|
289
289
|
source_id: string;
|
|
@@ -44,12 +44,12 @@ export declare const SaleOrderDeliveriesSchema: Schema<any, import("mongoose").M
|
|
|
44
44
|
name: string;
|
|
45
45
|
} | null | undefined;
|
|
46
46
|
cancelled_at?: NativeDate | null | undefined;
|
|
47
|
+
applied_to_doc_id?: import("mongoose").Types.ObjectId | null | undefined;
|
|
47
48
|
delivered_at?: NativeDate | null | undefined;
|
|
48
49
|
delivered_by?: {
|
|
49
50
|
_id: string;
|
|
50
51
|
name: string;
|
|
51
52
|
} | null | undefined;
|
|
52
|
-
applied_to_doc_id?: import("mongoose").Types.ObjectId | null | undefined;
|
|
53
53
|
inventory_restocked?: boolean | null | undefined;
|
|
54
54
|
returned_by?: {
|
|
55
55
|
_id: string;
|
|
@@ -96,12 +96,12 @@ export declare const SaleOrderDeliveriesSchema: Schema<any, import("mongoose").M
|
|
|
96
96
|
name: string;
|
|
97
97
|
} | null | undefined;
|
|
98
98
|
cancelled_at?: NativeDate | null | undefined;
|
|
99
|
+
applied_to_doc_id?: import("mongoose").Types.ObjectId | null | undefined;
|
|
99
100
|
delivered_at?: NativeDate | null | undefined;
|
|
100
101
|
delivered_by?: {
|
|
101
102
|
_id: string;
|
|
102
103
|
name: string;
|
|
103
104
|
} | null | undefined;
|
|
104
|
-
applied_to_doc_id?: import("mongoose").Types.ObjectId | null | undefined;
|
|
105
105
|
inventory_restocked?: boolean | null | undefined;
|
|
106
106
|
returned_by?: {
|
|
107
107
|
_id: string;
|
|
@@ -148,12 +148,12 @@ export declare const SaleOrderDeliveriesSchema: Schema<any, import("mongoose").M
|
|
|
148
148
|
name: string;
|
|
149
149
|
} | null | undefined;
|
|
150
150
|
cancelled_at?: NativeDate | null | undefined;
|
|
151
|
+
applied_to_doc_id?: import("mongoose").Types.ObjectId | null | undefined;
|
|
151
152
|
delivered_at?: NativeDate | null | undefined;
|
|
152
153
|
delivered_by?: {
|
|
153
154
|
_id: string;
|
|
154
155
|
name: string;
|
|
155
156
|
} | null | undefined;
|
|
156
|
-
applied_to_doc_id?: import("mongoose").Types.ObjectId | null | undefined;
|
|
157
157
|
inventory_restocked?: boolean | null | undefined;
|
|
158
158
|
returned_by?: {
|
|
159
159
|
_id: string;
|
|
@@ -35,10 +35,10 @@ export declare const WarehouseSaleOrderInvoiceSchema: Schema<any, import("mongoo
|
|
|
35
35
|
amount: number;
|
|
36
36
|
payments: any[];
|
|
37
37
|
warehouse_id: string;
|
|
38
|
-
doc_number: number;
|
|
39
|
-
invoice_type: import("../../constants").WAREHOUSE_SALE_ORDER_INVOICE_TYPE_ENUM;
|
|
40
38
|
doc_kind: import("../../constants").WAREHOUSE_SALE_ORDER_FIN_DOC_KIND_ENUM;
|
|
41
39
|
sale_order_id: import("mongoose").Types.ObjectId;
|
|
40
|
+
doc_number: number;
|
|
41
|
+
invoice_type: import("../../constants").WAREHOUSE_SALE_ORDER_INVOICE_TYPE_ENUM;
|
|
42
42
|
amount_paid?: number | null | undefined;
|
|
43
43
|
cancel_reason?: string | null | undefined;
|
|
44
44
|
is_gst_inclusive?: boolean | null | undefined;
|
|
@@ -107,10 +107,10 @@ export declare const WarehouseSaleOrderInvoiceSchema: Schema<any, import("mongoo
|
|
|
107
107
|
amount: number;
|
|
108
108
|
payments: any[];
|
|
109
109
|
warehouse_id: string;
|
|
110
|
-
doc_number: number;
|
|
111
|
-
invoice_type: import("../../constants").WAREHOUSE_SALE_ORDER_INVOICE_TYPE_ENUM;
|
|
112
110
|
doc_kind: import("../../constants").WAREHOUSE_SALE_ORDER_FIN_DOC_KIND_ENUM;
|
|
113
111
|
sale_order_id: import("mongoose").Types.ObjectId;
|
|
112
|
+
doc_number: number;
|
|
113
|
+
invoice_type: import("../../constants").WAREHOUSE_SALE_ORDER_INVOICE_TYPE_ENUM;
|
|
114
114
|
amount_paid?: number | null | undefined;
|
|
115
115
|
cancel_reason?: string | null | undefined;
|
|
116
116
|
is_gst_inclusive?: boolean | null | undefined;
|
|
@@ -179,10 +179,10 @@ export declare const WarehouseSaleOrderInvoiceSchema: Schema<any, import("mongoo
|
|
|
179
179
|
amount: number;
|
|
180
180
|
payments: any[];
|
|
181
181
|
warehouse_id: string;
|
|
182
|
-
doc_number: number;
|
|
183
|
-
invoice_type: import("../../constants").WAREHOUSE_SALE_ORDER_INVOICE_TYPE_ENUM;
|
|
184
182
|
doc_kind: import("../../constants").WAREHOUSE_SALE_ORDER_FIN_DOC_KIND_ENUM;
|
|
185
183
|
sale_order_id: import("mongoose").Types.ObjectId;
|
|
184
|
+
doc_number: number;
|
|
185
|
+
invoice_type: import("../../constants").WAREHOUSE_SALE_ORDER_INVOICE_TYPE_ENUM;
|
|
186
186
|
amount_paid?: number | null | undefined;
|
|
187
187
|
cancel_reason?: string | null | undefined;
|
|
188
188
|
is_gst_inclusive?: boolean | null | undefined;
|