@managesome/eposmatic-toolkit 0.2.377 → 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.
@@ -105,6 +105,36 @@ export interface IWarehousePurchaseOrdersSummary {
105
105
  totalQuantity: number;
106
106
  }[];
107
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
+ }
108
138
  export interface IWarehouseInvoicesSummary {
109
139
  [SALES_SUMMARY_ENUM.TOTAL_SALES]: {
110
140
  _id: string;
@@ -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);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@managesome/eposmatic-toolkit",
3
- "version": "0.2.377",
3
+ "version": "0.2.378",
4
4
  "description": "A Toolkit Library for Eposmatic",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",