@managesome/eposmatic-toolkit 0.2.376 → 0.2.378
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/constants/WAREHOUSE_ANALYTICS.d.ts +47 -1
- package/lib/helpers/store/cart-actions.js +33 -0
- package/lib/helpers/store/common-sale-order-actions.d.ts +5 -0
- package/lib/helpers/store/common-sale-order-actions.js +65 -0
- package/lib/helpers/store/index.d.ts +1 -0
- package/lib/helpers/store/index.js +1 -0
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SALES_SUMMARY_ENUM } from './ANALYTICS';
|
|
2
|
-
import { PURCHASE_ORDER_STATUS_ENUM, WAREHOUSE_INVOICE_STATUS_ENUM } from './ENUMS';
|
|
2
|
+
import { PURCHASE_ORDER_STATUS_ENUM, SALE_ORDER_INVOICE_TYPE_ENUM, SALES_ORDER_STATUS_ENUM, WAREHOUSE_INVOICE_STATUS_ENUM } from './ENUMS';
|
|
3
3
|
export declare enum WAREHOUSE_DASHBOARD_ANALYTICS_ENUM {
|
|
4
4
|
PURCHASE_ORDERS = "PURCHASE_ORDERS",
|
|
5
5
|
INVOICES = "INVOICES"
|
|
@@ -59,6 +59,22 @@ export interface IClientInvoicesOverview {
|
|
|
59
59
|
totalAmount: number;
|
|
60
60
|
totalQuantity: number;
|
|
61
61
|
}
|
|
62
|
+
export interface ISaleOrderInvoiceEntry {
|
|
63
|
+
invoiceType: SALE_ORDER_INVOICE_TYPE_ENUM;
|
|
64
|
+
paymentType: string;
|
|
65
|
+
amount: number;
|
|
66
|
+
}
|
|
67
|
+
export interface ISaleOrdersOverview {
|
|
68
|
+
_id: string;
|
|
69
|
+
warehouse_id: string;
|
|
70
|
+
client_id: string;
|
|
71
|
+
order_status: SALES_ORDER_STATUS_ENUM;
|
|
72
|
+
client_name: string;
|
|
73
|
+
saleOrderId: string;
|
|
74
|
+
totalAmount: number;
|
|
75
|
+
totalQuantity: number;
|
|
76
|
+
invoices: ISaleOrderInvoiceEntry[];
|
|
77
|
+
}
|
|
62
78
|
export interface IWarehousePurchaseOrdersSummary {
|
|
63
79
|
[SALES_SUMMARY_ENUM.TOTAL_SALES]: {
|
|
64
80
|
_id: string;
|
|
@@ -89,6 +105,36 @@ export interface IWarehousePurchaseOrdersSummary {
|
|
|
89
105
|
totalQuantity: number;
|
|
90
106
|
}[];
|
|
91
107
|
}
|
|
108
|
+
export interface IWarehouseSaleOrdersSummary {
|
|
109
|
+
[SALES_SUMMARY_ENUM.TOTAL_SALES]: {
|
|
110
|
+
_id: string;
|
|
111
|
+
warehouse_id: string;
|
|
112
|
+
client_id: string;
|
|
113
|
+
staff_id: string;
|
|
114
|
+
staff_name: string;
|
|
115
|
+
client_name: string;
|
|
116
|
+
totalAmount: number;
|
|
117
|
+
totalQuantity: number;
|
|
118
|
+
amount_collected: number;
|
|
119
|
+
unpaidAmount: number;
|
|
120
|
+
unpaidQuantity: number;
|
|
121
|
+
cancelledAmount: number;
|
|
122
|
+
cancelledQuantity: number;
|
|
123
|
+
gstAmount: number;
|
|
124
|
+
gstQuantity: number;
|
|
125
|
+
}[];
|
|
126
|
+
[SALES_SUMMARY_ENUM.TOTAL_PAYMENT_SALES]: {
|
|
127
|
+
_id: string;
|
|
128
|
+
warehouse_id: string;
|
|
129
|
+
client_id: string;
|
|
130
|
+
staff_id: string;
|
|
131
|
+
payment_type: string;
|
|
132
|
+
client_name: string;
|
|
133
|
+
staff_name: string;
|
|
134
|
+
totalAmount: number;
|
|
135
|
+
totalQuantity: number;
|
|
136
|
+
}[];
|
|
137
|
+
}
|
|
92
138
|
export interface IWarehouseInvoicesSummary {
|
|
93
139
|
[SALES_SUMMARY_ENUM.TOTAL_SALES]: {
|
|
94
140
|
_id: string;
|
|
@@ -2052,6 +2052,21 @@ function applyCustomDiscountCapsPostSync(synced, appliedCustomDiscounts, platfor
|
|
|
2052
2052
|
};
|
|
2053
2053
|
needsResync = true;
|
|
2054
2054
|
}
|
|
2055
|
+
// Re-cap: percentage still exceeds cap, but the current flat amount
|
|
2056
|
+
// is below cap (e.g. scaled down by a quantity change). Push it
|
|
2057
|
+
// back to maxCap.
|
|
2058
|
+
else if (computedDiscount > maxCap && orderDetails.special_discount < maxCap) {
|
|
2059
|
+
result = {
|
|
2060
|
+
...result,
|
|
2061
|
+
order_discount_details: {
|
|
2062
|
+
...orderDetails,
|
|
2063
|
+
special_discount: maxCap,
|
|
2064
|
+
is_special_discount_percentage: false,
|
|
2065
|
+
total_discount: 0,
|
|
2066
|
+
},
|
|
2067
|
+
};
|
|
2068
|
+
needsResync = true;
|
|
2069
|
+
}
|
|
2055
2070
|
}
|
|
2056
2071
|
}
|
|
2057
2072
|
}
|
|
@@ -2115,6 +2130,24 @@ function applyCustomDiscountCapsPostSync(synced, appliedCustomDiscounts, platfor
|
|
|
2115
2130
|
categoryChanged = true;
|
|
2116
2131
|
continue;
|
|
2117
2132
|
}
|
|
2133
|
+
// Re-cap: percentage still exceeds cap, but the current flat amount
|
|
2134
|
+
// is below cap (e.g. scaled down proportionally by a quantity
|
|
2135
|
+
// decrease). Push it back to maxCap so the discount stays at the
|
|
2136
|
+
// configured limit instead of an incorrect scaled-down value.
|
|
2137
|
+
if (computedDiscount > maxCap && itemDetails.special_discount < maxCap) {
|
|
2138
|
+
newItems.push({
|
|
2139
|
+
...item,
|
|
2140
|
+
item_discount_details: {
|
|
2141
|
+
...itemDetails,
|
|
2142
|
+
special_discount: maxCap,
|
|
2143
|
+
is_special_discount_percentage: false,
|
|
2144
|
+
total_discount: 0,
|
|
2145
|
+
},
|
|
2146
|
+
});
|
|
2147
|
+
needsResync = true;
|
|
2148
|
+
categoryChanged = true;
|
|
2149
|
+
continue;
|
|
2150
|
+
}
|
|
2118
2151
|
}
|
|
2119
2152
|
}
|
|
2120
2153
|
newItems.push(item);
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ISaleOrder, ISaleOrderCategory, ISaleOrderItem, ISaleOrderIteration } from '../../schemas';
|
|
2
|
+
export declare function getSaleOrderIterationsWithPrice(iterations?: ISaleOrderIteration[] | undefined, writeable?: boolean): ISaleOrderIteration[];
|
|
3
|
+
export declare function getSaleOrderItemsWithPrice(items: ISaleOrderItem[] | undefined, convertToPrice: (price: number) => number): ISaleOrderItem[];
|
|
4
|
+
export declare function getSaleOrderCategoriesWithPrice(categories: ISaleOrderCategory[] | undefined, convertToPrice: (price: number) => number): ISaleOrderCategory[];
|
|
5
|
+
export declare function getSaleOrderWithPrice<T extends Partial<ISaleOrder> | ISaleOrder | ISaleOrderIteration>(order: T, writeable?: boolean): T;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getSaleOrderIterationsWithPrice = getSaleOrderIterationsWithPrice;
|
|
4
|
+
exports.getSaleOrderItemsWithPrice = getSaleOrderItemsWithPrice;
|
|
5
|
+
exports.getSaleOrderCategoriesWithPrice = getSaleOrderCategoriesWithPrice;
|
|
6
|
+
exports.getSaleOrderWithPrice = getSaleOrderWithPrice;
|
|
7
|
+
const utils_1 = require("../utils");
|
|
8
|
+
// ── Iterations ──────────────────────────────────────────────────
|
|
9
|
+
function getSaleOrderIterationsWithPrice(iterations, writeable) {
|
|
10
|
+
if (!iterations)
|
|
11
|
+
return [];
|
|
12
|
+
return iterations.map((iteration) => getSaleOrderWithPrice(iteration, writeable));
|
|
13
|
+
}
|
|
14
|
+
// ── Items ───────────────────────────────────────────────────────
|
|
15
|
+
function getSaleOrderItemsWithPrice(items, convertToPrice) {
|
|
16
|
+
if (!items)
|
|
17
|
+
return [];
|
|
18
|
+
return items.map((item) => ({
|
|
19
|
+
...item,
|
|
20
|
+
quantity: (0, utils_1.parseNum)(item.quantity || 1, true),
|
|
21
|
+
price: convertToPrice(item.price ?? 0),
|
|
22
|
+
subtotal: convertToPrice(item.subtotal ?? 0),
|
|
23
|
+
_gst_amount: convertToPrice(item._gst_amount ?? 0),
|
|
24
|
+
_net_amount: convertToPrice(item._net_amount ?? 0),
|
|
25
|
+
_gross_amount: convertToPrice(item._gross_amount ?? 0),
|
|
26
|
+
_discount_amount: convertToPrice(item._discount_amount ?? 0),
|
|
27
|
+
}));
|
|
28
|
+
}
|
|
29
|
+
// ── Categories ──────────────────────────────────────────────────
|
|
30
|
+
function getSaleOrderCategoriesWithPrice(categories, convertToPrice) {
|
|
31
|
+
if (!categories)
|
|
32
|
+
return [];
|
|
33
|
+
return categories.map((category) => ({
|
|
34
|
+
...category,
|
|
35
|
+
items: getSaleOrderItemsWithPrice(category.items, convertToPrice),
|
|
36
|
+
}));
|
|
37
|
+
}
|
|
38
|
+
// ── Main helper ─────────────────────────────────────────────────
|
|
39
|
+
function getSaleOrderWithPrice(order, writeable) {
|
|
40
|
+
const convertToPrice = writeable ? utils_1.convertDecimalToInt : utils_1.convertIntToDecimal;
|
|
41
|
+
const payload = {
|
|
42
|
+
...order,
|
|
43
|
+
...(order.iterations != null
|
|
44
|
+
? {
|
|
45
|
+
iterations: getSaleOrderIterationsWithPrice(order.iterations, writeable),
|
|
46
|
+
}
|
|
47
|
+
: {}),
|
|
48
|
+
...(order.categories != null
|
|
49
|
+
? {
|
|
50
|
+
categories: getSaleOrderCategoriesWithPrice(order.categories, convertToPrice),
|
|
51
|
+
}
|
|
52
|
+
: {}),
|
|
53
|
+
...(order.gst != null ? { gst: convertToPrice(order.gst) } : {}),
|
|
54
|
+
...(order.gst_amount != null ? { gst_amount: convertToPrice(order.gst_amount) } : {}),
|
|
55
|
+
...(order.amount_collected != null
|
|
56
|
+
? {
|
|
57
|
+
amount_collected: convertToPrice(order.amount_collected),
|
|
58
|
+
}
|
|
59
|
+
: {}),
|
|
60
|
+
...(order.amount_earned != null ? { amount_earned: convertToPrice(order.amount_earned) } : {}),
|
|
61
|
+
...(order.grand_total != null ? { grand_total: convertToPrice(order.grand_total) } : {}),
|
|
62
|
+
...(order.price != null ? { price: convertToPrice(order.price) } : {}),
|
|
63
|
+
};
|
|
64
|
+
return payload;
|
|
65
|
+
}
|
|
@@ -5,6 +5,7 @@ export * from './cart-actions';
|
|
|
5
5
|
export * from './catalog-actions';
|
|
6
6
|
export * from './common-order-actions';
|
|
7
7
|
export * from './common-purchase-order-actions';
|
|
8
|
+
export * from './common-sale-order-actions';
|
|
8
9
|
export * from './common-warehouse-invoice-actions';
|
|
9
10
|
export * from './offline-ordering';
|
|
10
11
|
export * from './purchase-orders-cart-actions';
|
|
@@ -21,6 +21,7 @@ __exportStar(require("./cart-actions"), exports);
|
|
|
21
21
|
__exportStar(require("./catalog-actions"), exports);
|
|
22
22
|
__exportStar(require("./common-order-actions"), exports);
|
|
23
23
|
__exportStar(require("./common-purchase-order-actions"), exports);
|
|
24
|
+
__exportStar(require("./common-sale-order-actions"), exports);
|
|
24
25
|
__exportStar(require("./common-warehouse-invoice-actions"), exports);
|
|
25
26
|
__exportStar(require("./offline-ordering"), exports);
|
|
26
27
|
__exportStar(require("./purchase-orders-cart-actions"), exports);
|