@managesome/eposmatic-toolkit 0.2.461 → 0.2.463
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 +1 -100
- package/lib/constants/WAREHOUSE_ANALYTICS.js +1 -11
- package/lib/constants/WAREHOUSE_ENUMS.d.ts +0 -6
- package/lib/constants/WAREHOUSE_ENUMS.js +1 -9
- package/lib/constants/WORKER_ENDPOINTS.d.ts +0 -4
- package/lib/constants/WORKER_ENDPOINTS.js +0 -4
- package/lib/constants/index.d.ts +0 -1
- package/lib/constants/index.js +0 -1
- package/lib/helpers/order/generate-warehouse-invoice.d.ts +3 -3
- package/lib/helpers/order/generate-warehouse-sale-order.d.ts +11 -0
- package/lib/helpers/order/generate-warehouse-sale-order.js +158 -0
- package/lib/helpers/order/index.d.ts +1 -1
- package/lib/helpers/order/index.js +1 -1
- package/lib/helpers/store/all-warehouse-sale-orders-actions.d.ts +12 -0
- package/lib/helpers/store/all-warehouse-sale-orders-actions.js +78 -0
- package/lib/helpers/store/common-warehouse-sale-order-actions.d.ts +26 -0
- package/lib/helpers/store/common-warehouse-sale-order-actions.js +428 -0
- package/lib/helpers/store/index.d.ts +2 -3
- package/lib/helpers/store/index.js +2 -3
- package/lib/helpers/store/warehouse-invoice-cart-actions.d.ts +2 -34
- package/lib/helpers/store/warehouse-sale-orders-cart-actions.d.ts +55 -0
- package/lib/helpers/store/warehouse-sale-orders-cart-actions.js +472 -0
- package/lib/helpers/types/index.d.ts +5 -5
- package/lib/helpers/types/index.js +5 -5
- package/lib/helpers/types/warehouse-sale-order-cart-actions.d.ts +26 -0
- package/lib/helpers/types/warehouse-sale-order-cart-actions.js +2 -0
- package/lib/helpers/types/workers.d.ts +4 -26
- package/lib/helpers/utils/index.d.ts +4 -4
- package/lib/helpers/utils/index.js +4 -4
- package/lib/helpers/utils/warehouse-sale-order-engine.d.ts +9 -0
- package/lib/helpers/utils/warehouse-sale-order-engine.js +34 -0
- package/lib/helpers/utils/warehouse-sale-order-receipt-engine.d.ts +89 -0
- package/lib/helpers/utils/warehouse-sale-order-receipt-engine.js +216 -0
- package/lib/helpers/utils/warehouse-void-sale-order-items-helpers.d.ts +3 -0
- package/lib/helpers/utils/warehouse-void-sale-order-items-helpers.js +38 -0
- package/lib/helpers/utils/warehouse-void-sale-order-items-report-helpers.d.ts +13 -0
- package/lib/helpers/utils/warehouse-void-sale-order-items-report-helpers.js +22 -0
- package/lib/schemas/models/index.d.ts +1 -2
- package/lib/schemas/models/index.js +1 -2
- package/lib/schemas/models/warehouse_void_sale_order_items.d.ts +176 -0
- package/lib/schemas/models/warehouse_void_sale_order_items.js +177 -0
- package/lib/schemas/types/index.d.ts +1 -2
- package/lib/schemas/types/index.js +1 -2
- package/lib/schemas/types/warehouse_sale_orders.d.ts +6 -0
- package/lib/schemas/types/warehouse_void_sale_order_items.d.ts +37 -0
- package/lib/schemas/types/warehouse_void_sale_order_items.js +2 -0
- package/package.json +1 -1
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { IWarehouseSaleOrderItem, IWarehouseItem } from '../../schemas';
|
|
2
|
+
interface IConvertWarehouseItemToSaleOrderItemParams {
|
|
3
|
+
clientId: string;
|
|
4
|
+
item: IWarehouseItem;
|
|
5
|
+
orderItem?: IWarehouseSaleOrderItem;
|
|
6
|
+
}
|
|
7
|
+
export declare function convertWarehouseItemToSaleOrderItem({ clientId, item, orderItem, }: IConvertWarehouseItemToSaleOrderItemParams): IWarehouseSaleOrderItem;
|
|
8
|
+
export declare function getCurrentWarehouseSaleOrderItemTotalPrice(orderItem: IWarehouseSaleOrderItem): number;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.convertWarehouseItemToSaleOrderItem = convertWarehouseItemToSaleOrderItem;
|
|
7
|
+
exports.getCurrentWarehouseSaleOrderItemTotalPrice = getCurrentWarehouseSaleOrderItemTotalPrice;
|
|
8
|
+
const bson_objectid_1 = __importDefault(require("bson-objectid"));
|
|
9
|
+
function convertWarehouseItemToSaleOrderItem({ clientId, item, orderItem, }) {
|
|
10
|
+
const { _id = (0, bson_objectid_1.default)().toHexString(), price = item.purchase_price?.[clientId] ?? item.purchase_price?.BASE_PRICE ?? 0, quantity = 1, special_instructions = '', is_ready, } = orderItem ?? {};
|
|
11
|
+
const saleOrderItem = {
|
|
12
|
+
_id,
|
|
13
|
+
item_id: item._id,
|
|
14
|
+
name: item.name,
|
|
15
|
+
price,
|
|
16
|
+
subtotal: price * quantity,
|
|
17
|
+
quantity,
|
|
18
|
+
special_instructions,
|
|
19
|
+
is_ready,
|
|
20
|
+
// These values will be auto calculated
|
|
21
|
+
_discount_amount: 0,
|
|
22
|
+
_gross_amount: 0,
|
|
23
|
+
_gst_amount: 0,
|
|
24
|
+
_net_amount: 0,
|
|
25
|
+
};
|
|
26
|
+
return saleOrderItem;
|
|
27
|
+
}
|
|
28
|
+
// ==========================================================><====================================================
|
|
29
|
+
function getCurrentWarehouseSaleOrderItemTotalPrice(orderItem) {
|
|
30
|
+
// For sale orders, total is simply price * quantity
|
|
31
|
+
// No modifiers, discounts, etc.
|
|
32
|
+
const total = orderItem.price * orderItem.quantity;
|
|
33
|
+
return total;
|
|
34
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { CURRENCY_SYMBOL_ENUM } from '../../constants';
|
|
2
|
+
import { IWarehouse, IWarehouseSaleOrder, IWarehouseSaleOrderItem } from '../../schemas';
|
|
3
|
+
export interface IWarehouseSaleReceiptProps {
|
|
4
|
+
order: Partial<IWarehouseSaleOrder>;
|
|
5
|
+
warehouse_settings: {
|
|
6
|
+
image_url: IWarehouse['image_url'] | undefined;
|
|
7
|
+
name: IWarehouse['name'] | undefined;
|
|
8
|
+
warehouse_address: IWarehouse['warehouse_address'] | undefined;
|
|
9
|
+
support_email: IWarehouse['support_email'] | undefined;
|
|
10
|
+
public_phone_numbers: IWarehouse['public_phone_numbers'] | undefined;
|
|
11
|
+
currency_symbol: IWarehouse['currency_symbol'] | undefined;
|
|
12
|
+
tax_business_number: IWarehouse['tax_business_number'] | undefined;
|
|
13
|
+
tax_invoice_provider: IWarehouse['tax_invoice_provider'] | undefined;
|
|
14
|
+
hide_gst_value: IWarehouse['hide_gst_value'] | undefined;
|
|
15
|
+
country_alpha_2: IWarehouse['country_alpha_2'] | undefined;
|
|
16
|
+
};
|
|
17
|
+
printer_settings: {
|
|
18
|
+
display_item_instructions: boolean;
|
|
19
|
+
display_order_instructions: boolean;
|
|
20
|
+
display_unit_item_price: boolean;
|
|
21
|
+
print_staff_name: boolean;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
export interface IWarehouseSaleReceiptItem {
|
|
25
|
+
left: string;
|
|
26
|
+
right?: string;
|
|
27
|
+
prev_right?: string;
|
|
28
|
+
option_name?: string;
|
|
29
|
+
is_bold?: boolean;
|
|
30
|
+
_id?: string;
|
|
31
|
+
item_id?: string;
|
|
32
|
+
image_url?: string;
|
|
33
|
+
}
|
|
34
|
+
export interface IWarehouseSaleReceiptEngine {
|
|
35
|
+
_id: string;
|
|
36
|
+
warehouse_details: {
|
|
37
|
+
image_url: IWarehouse['image_url'] | undefined;
|
|
38
|
+
name: IWarehouse['name'] | undefined;
|
|
39
|
+
warehouse_address: IWarehouse['warehouse_address'] | undefined;
|
|
40
|
+
support_email: IWarehouse['support_email'] | undefined;
|
|
41
|
+
public_phone_numbers: IWarehouse['public_phone_numbers'] | undefined;
|
|
42
|
+
taxNumberTitle: string;
|
|
43
|
+
tax_business_number: IWarehouse['tax_business_number'] | undefined;
|
|
44
|
+
};
|
|
45
|
+
placed_time: string;
|
|
46
|
+
expected_time: string | null;
|
|
47
|
+
order_number: string;
|
|
48
|
+
client_details: {
|
|
49
|
+
client_id?: string;
|
|
50
|
+
client_name?: string;
|
|
51
|
+
};
|
|
52
|
+
order_details: {
|
|
53
|
+
staff_name: string | null;
|
|
54
|
+
};
|
|
55
|
+
items: IWarehouseSaleReceiptItem[];
|
|
56
|
+
footer: IWarehouseSaleReceiptItem[];
|
|
57
|
+
total_items: number;
|
|
58
|
+
payment_details: IWarehouseSaleReceiptItem[];
|
|
59
|
+
payment_status: string | null;
|
|
60
|
+
order_link: string | null;
|
|
61
|
+
cancel_reason: string | null;
|
|
62
|
+
}
|
|
63
|
+
interface IWarehouseSaleSettings {
|
|
64
|
+
currency_symbol: IWarehouse['currency_symbol'] | null | undefined;
|
|
65
|
+
gstName: string;
|
|
66
|
+
hide_gst_value: boolean | undefined;
|
|
67
|
+
}
|
|
68
|
+
export declare function getWarehouseSaleReceiptEngineFooterDetails(order: Partial<IWarehouseSaleOrder>, settings: IWarehouseSaleSettings): IWarehouseSaleReceiptItem[];
|
|
69
|
+
interface IWarehouseSaleReceiptOrderItem extends IWarehouseSaleOrderItem {
|
|
70
|
+
image_url?: string;
|
|
71
|
+
}
|
|
72
|
+
interface IGetWarehouseSaleOrderItemReceiptBody {
|
|
73
|
+
orderItem: IWarehouseSaleReceiptOrderItem;
|
|
74
|
+
currency_symbol?: string;
|
|
75
|
+
displayItemInstructions?: boolean;
|
|
76
|
+
displayUnitItemPrice?: boolean;
|
|
77
|
+
isRemoved?: boolean;
|
|
78
|
+
}
|
|
79
|
+
export declare function getWarehouseSaleOrderItemReceiptBody({ orderItem, currency_symbol, displayItemInstructions, displayUnitItemPrice, isRemoved, }: IGetWarehouseSaleOrderItemReceiptBody): IWarehouseSaleReceiptItem[];
|
|
80
|
+
interface IGetWarehouseSaleReceiptBody {
|
|
81
|
+
orderItems: IWarehouseSaleReceiptOrderItem[];
|
|
82
|
+
currency_symbol: CURRENCY_SYMBOL_ENUM | null | undefined;
|
|
83
|
+
displayItemInstructions: boolean;
|
|
84
|
+
displayUnitItemPrice?: boolean;
|
|
85
|
+
isRemoved?: boolean;
|
|
86
|
+
}
|
|
87
|
+
export declare function getWarehouseSaleReceiptBody({ orderItems, currency_symbol, displayItemInstructions, displayUnitItemPrice, isRemoved, }: IGetWarehouseSaleReceiptBody): IWarehouseSaleReceiptItem[];
|
|
88
|
+
export declare function getWarehouseSaleReceiptEngine(payload: IWarehouseSaleReceiptProps): IWarehouseSaleReceiptEngine;
|
|
89
|
+
export {};
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getWarehouseSaleReceiptEngineFooterDetails = getWarehouseSaleReceiptEngineFooterDetails;
|
|
7
|
+
exports.getWarehouseSaleOrderItemReceiptBody = getWarehouseSaleOrderItemReceiptBody;
|
|
8
|
+
exports.getWarehouseSaleReceiptBody = getWarehouseSaleReceiptBody;
|
|
9
|
+
exports.getWarehouseSaleReceiptEngine = getWarehouseSaleReceiptEngine;
|
|
10
|
+
const emoji_strip_1 = __importDefault(require("emoji-strip"));
|
|
11
|
+
const moment_1 = __importDefault(require("moment"));
|
|
12
|
+
const constants_1 = require("../../constants");
|
|
13
|
+
const common_1 = require("./common");
|
|
14
|
+
const payment_helpers_1 = require("./payment-helpers");
|
|
15
|
+
// =========================><=========================
|
|
16
|
+
function getWarehouseSaleReceiptEngineFooterDetails(order, settings) {
|
|
17
|
+
const currencySymbol = settings.currency_symbol ?? '';
|
|
18
|
+
const price = order.price ?? 0;
|
|
19
|
+
const grandTotal = order.grand_total ?? 0;
|
|
20
|
+
const details = [];
|
|
21
|
+
if (price !== grandTotal) {
|
|
22
|
+
const right = `${(0, common_1.localeAmount)(currencySymbol, price)}`;
|
|
23
|
+
details.push({
|
|
24
|
+
left: 'Price',
|
|
25
|
+
right,
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
if (order.gst && !settings.hide_gst_value) {
|
|
29
|
+
if (order.is_gst_inclusive) {
|
|
30
|
+
const right = (0, common_1.localeAmount)(currencySymbol, Math.max(0, (order.grand_total ?? 0) - (order.gst_amount ?? 0)));
|
|
31
|
+
details.push({
|
|
32
|
+
left: `Total before ${settings.gstName}`,
|
|
33
|
+
right,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
let left = '';
|
|
37
|
+
if (order.is_gst_inclusive) {
|
|
38
|
+
left = `${settings.gstName} (${(0, common_1.parseNum)(order.gst)}% Inclusive)`;
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
left = `${settings.gstName} (${(0, common_1.parseNum)(order.gst)}%)`;
|
|
42
|
+
}
|
|
43
|
+
const right = (0, common_1.localeAmount)(currencySymbol, order.gst_amount ?? 0);
|
|
44
|
+
details.push({
|
|
45
|
+
left,
|
|
46
|
+
right,
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
return details;
|
|
50
|
+
}
|
|
51
|
+
function getWarehouseSaleOrderItemReceiptBody({ orderItem, currency_symbol, displayItemInstructions, displayUnitItemPrice, isRemoved, }) {
|
|
52
|
+
const name = orderItem.name;
|
|
53
|
+
const quantity = orderItem.quantity;
|
|
54
|
+
const subtotal = (0, common_1.parseNum)(orderItem.subtotal);
|
|
55
|
+
let description = `${quantity}x ${name}`;
|
|
56
|
+
const amount = (0, common_1.localeAmount)(currency_symbol, subtotal);
|
|
57
|
+
if (displayUnitItemPrice) {
|
|
58
|
+
description += ` @\u200E${(0, common_1.parseNum)(subtotal / quantity)}`;
|
|
59
|
+
}
|
|
60
|
+
const options = [
|
|
61
|
+
{
|
|
62
|
+
left: description,
|
|
63
|
+
right: amount,
|
|
64
|
+
_id: orderItem._id,
|
|
65
|
+
item_id: orderItem.item_id,
|
|
66
|
+
image_url: orderItem.image_url,
|
|
67
|
+
},
|
|
68
|
+
];
|
|
69
|
+
if (!isRemoved && displayItemInstructions && orderItem.special_instructions.length > 0) {
|
|
70
|
+
options.push({
|
|
71
|
+
left: `** Note: ${(0, emoji_strip_1.default)(orderItem.special_instructions)} **`,
|
|
72
|
+
is_bold: true,
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
if (isRemoved && orderItem.void_reason != null && orderItem.void_reason.length > 0) {
|
|
76
|
+
options.push({
|
|
77
|
+
left: `** Reason: ${(0, emoji_strip_1.default)(orderItem.void_reason)} **`,
|
|
78
|
+
is_bold: true,
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
return options;
|
|
82
|
+
}
|
|
83
|
+
function getWarehouseSaleReceiptBody({ orderItems, currency_symbol, displayItemInstructions, displayUnitItemPrice, isRemoved, }) {
|
|
84
|
+
const currency = currency_symbol ?? '';
|
|
85
|
+
const items = orderItems
|
|
86
|
+
.map((item) => getWarehouseSaleOrderItemReceiptBody({
|
|
87
|
+
orderItem: item,
|
|
88
|
+
currency_symbol: currency,
|
|
89
|
+
displayItemInstructions,
|
|
90
|
+
displayUnitItemPrice,
|
|
91
|
+
isRemoved,
|
|
92
|
+
}))
|
|
93
|
+
.flat();
|
|
94
|
+
return items;
|
|
95
|
+
}
|
|
96
|
+
// =========================><=========================
|
|
97
|
+
function getWarehouseSaleReceiptEngine(payload) {
|
|
98
|
+
const { currency_symbol, image_url, name, public_phone_numbers, warehouse_address, support_email, tax_business_number, tax_invoice_provider, country_alpha_2, hide_gst_value, } = payload.warehouse_settings;
|
|
99
|
+
const { display_item_instructions, display_order_instructions, display_unit_item_price, print_staff_name } = payload.printer_settings;
|
|
100
|
+
const currencySymbol = currency_symbol ?? '';
|
|
101
|
+
const grandTotal = payload.order.grand_total ?? 0;
|
|
102
|
+
const orderPayments = payload.order.payments ?? [];
|
|
103
|
+
const { amountPayedSoFar, existingPayments, change } = (0, payment_helpers_1.getOrderPaymentsDetails)(payload.order.grand_total, orderPayments);
|
|
104
|
+
const payments = (0, payment_helpers_1.getSortedPayments)(existingPayments.filter((payment) => payment.payment_status === constants_1.PAYMENT_STATUS_ENUM.SETTLED ||
|
|
105
|
+
payment.payment_status === constants_1.PAYMENT_STATUS_ENUM.REFUNDED));
|
|
106
|
+
const gstName = (0, common_1.getGSTName)(country_alpha_2, tax_invoice_provider);
|
|
107
|
+
const taxNumberTitle = (0, common_1.getTaxNumberTitle)(country_alpha_2, tax_invoice_provider);
|
|
108
|
+
const isFullyPaid = (0, payment_helpers_1.isOrderFullyPaid)(grandTotal, orderPayments);
|
|
109
|
+
const settings = {
|
|
110
|
+
currency_symbol,
|
|
111
|
+
gstName,
|
|
112
|
+
hide_gst_value,
|
|
113
|
+
};
|
|
114
|
+
const categories = payload.order.categories ?? [];
|
|
115
|
+
const items = categories.reduce((acc, category) => acc.concat(category.items.map((item) => ({
|
|
116
|
+
...item,
|
|
117
|
+
}))), []);
|
|
118
|
+
const receiptItems = getWarehouseSaleReceiptBody({
|
|
119
|
+
orderItems: items,
|
|
120
|
+
currency_symbol,
|
|
121
|
+
displayItemInstructions: display_item_instructions,
|
|
122
|
+
displayUnitItemPrice: display_unit_item_price,
|
|
123
|
+
});
|
|
124
|
+
const total_items = items.length;
|
|
125
|
+
const changeAmount = change > 0 ? (0, common_1.localeAmount)(currencySymbol, change) : null;
|
|
126
|
+
const payment_details = [
|
|
127
|
+
...payments.map((payment) => {
|
|
128
|
+
const isRefund = payment.amount_refunded > 0 && payment.amount_refunded > payment.amount_paid;
|
|
129
|
+
const paymentTitle = (0, payment_helpers_1.getPaymentSmartTitle)(payment.payment_type).title;
|
|
130
|
+
const amount = (payment.payment_type !== constants_1.PAYMENT_TYPE_ENUM.UNPAID
|
|
131
|
+
? isRefund
|
|
132
|
+
? payment.amount_refunded - payment.amount_paid
|
|
133
|
+
: payment.amount_paid
|
|
134
|
+
: payment.amount_due) + (payment.card_details?.card_charges ?? 0);
|
|
135
|
+
return {
|
|
136
|
+
left: `${(0, common_1.sentenceCase)(paymentTitle).replace(/_/g, ' ')}${isRefund ? ' (Refund)' : ''}`,
|
|
137
|
+
right: (0, common_1.localeAmount)(currencySymbol, amount),
|
|
138
|
+
};
|
|
139
|
+
}),
|
|
140
|
+
...(changeAmount
|
|
141
|
+
? [
|
|
142
|
+
{
|
|
143
|
+
left: 'Change',
|
|
144
|
+
right: changeAmount,
|
|
145
|
+
},
|
|
146
|
+
]
|
|
147
|
+
: []),
|
|
148
|
+
];
|
|
149
|
+
const parsedAmountPayedSoFar = (0, common_1.parseNum)(amountPayedSoFar);
|
|
150
|
+
const staff_name = print_staff_name && payload.order.staff_details != null ? (payload.order.staff_details.staff_name ?? null) : null;
|
|
151
|
+
let payment_status = null;
|
|
152
|
+
if (payload.order.is_deleted) {
|
|
153
|
+
payment_status = '* DELETED *';
|
|
154
|
+
}
|
|
155
|
+
else if (payload.order.order_status === constants_1.WAREHOUSE_SALES_ORDER_STATUS_ENUM.CANCELLED) {
|
|
156
|
+
payment_status = '* CANCELLED *';
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
if (parsedAmountPayedSoFar >= (0, common_1.parseNum)(grandTotal)) {
|
|
160
|
+
payment_status = '* PAID *';
|
|
161
|
+
}
|
|
162
|
+
else if (parsedAmountPayedSoFar > 0) {
|
|
163
|
+
payment_status = '* PARTIALLY PAID *';
|
|
164
|
+
payment_details.push({
|
|
165
|
+
left: 'Pending Amount',
|
|
166
|
+
right: (0, common_1.localeAmount)(currencySymbol, grandTotal - parsedAmountPayedSoFar),
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
else {
|
|
170
|
+
payment_status = '* UNPAID *';
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
let cancel_reason = null;
|
|
174
|
+
if (payload.order.order_status === constants_1.WAREHOUSE_SALES_ORDER_STATUS_ENUM.CANCELLED) {
|
|
175
|
+
cancel_reason = payload.order.cancel_reason ?? null;
|
|
176
|
+
}
|
|
177
|
+
let invoice_name = `Invoice #${payload.order.order_number ?? ''}`;
|
|
178
|
+
if (isFullyPaid) {
|
|
179
|
+
if (payload.order.tax_number || (country_alpha_2 !== constants_1.COUNTRY_ALPHA_2_ENUM.PK && tax_business_number)) {
|
|
180
|
+
invoice_name = `Tax ${invoice_name}`;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
const engine = {
|
|
184
|
+
_id: payload.order._id ?? '',
|
|
185
|
+
warehouse_details: {
|
|
186
|
+
image_url,
|
|
187
|
+
name,
|
|
188
|
+
warehouse_address,
|
|
189
|
+
support_email,
|
|
190
|
+
public_phone_numbers,
|
|
191
|
+
tax_business_number,
|
|
192
|
+
taxNumberTitle,
|
|
193
|
+
},
|
|
194
|
+
placed_time: (0, moment_1.default)(payload.order.createdAt).format('ddd, MMMM Do, h:mmA'),
|
|
195
|
+
expected_time: null,
|
|
196
|
+
order_number: invoice_name,
|
|
197
|
+
client_details: {
|
|
198
|
+
client_id: payload.order.client_id,
|
|
199
|
+
client_name: payload.order.client_name,
|
|
200
|
+
},
|
|
201
|
+
order_details: {
|
|
202
|
+
staff_name,
|
|
203
|
+
},
|
|
204
|
+
payment_status,
|
|
205
|
+
order_link: null,
|
|
206
|
+
total_items,
|
|
207
|
+
items: receiptItems,
|
|
208
|
+
payment_details,
|
|
209
|
+
footer: getWarehouseSaleReceiptEngineFooterDetails(payload.order, settings).concat({
|
|
210
|
+
left: `Grand Total${payload.order.gst && hide_gst_value ? ` (Incl. ${gstName})` : ''}`,
|
|
211
|
+
right: (0, common_1.localeAmount)(currencySymbol, payload.order.grand_total ?? 0),
|
|
212
|
+
}),
|
|
213
|
+
cancel_reason,
|
|
214
|
+
};
|
|
215
|
+
return engine;
|
|
216
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { IWarehouseVoidSaleOrderItem } from '../../schemas';
|
|
2
|
+
export declare function getWarehouseVoidSaleOrderItemFromCents<T extends Partial<IWarehouseVoidSaleOrderItem> | IWarehouseVoidSaleOrderItem>(voidSaleOrderItem: T): T;
|
|
3
|
+
export declare function getFetchedWarehouseVoidSaleOrderItems(voidItems: IWarehouseVoidSaleOrderItem[]): IWarehouseVoidSaleOrderItem[];
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getWarehouseVoidSaleOrderItemFromCents = getWarehouseVoidSaleOrderItemFromCents;
|
|
4
|
+
exports.getFetchedWarehouseVoidSaleOrderItems = getFetchedWarehouseVoidSaleOrderItems;
|
|
5
|
+
const common_order_actions_1 = require("../store/common-order-actions");
|
|
6
|
+
const price_conversion_1 = require("./price-conversion");
|
|
7
|
+
function getWarehouseVoidSaleOrderItemFromCents(voidSaleOrderItem) {
|
|
8
|
+
return {
|
|
9
|
+
...voidSaleOrderItem,
|
|
10
|
+
...(typeof voidSaleOrderItem.subtotal === 'number'
|
|
11
|
+
? {
|
|
12
|
+
subtotal: (0, price_conversion_1.convertPriceFromCents)(voidSaleOrderItem.subtotal),
|
|
13
|
+
}
|
|
14
|
+
: {}),
|
|
15
|
+
...(typeof voidSaleOrderItem.total_adjusted_subtotal === 'number'
|
|
16
|
+
? {
|
|
17
|
+
total_adjusted_subtotal: (0, price_conversion_1.convertPriceFromCents)(voidSaleOrderItem.total_adjusted_subtotal),
|
|
18
|
+
}
|
|
19
|
+
: {}),
|
|
20
|
+
...(voidSaleOrderItem.adjustments != null
|
|
21
|
+
? {
|
|
22
|
+
adjustments: voidSaleOrderItem.adjustments.map((adjustment) => ({
|
|
23
|
+
...adjustment,
|
|
24
|
+
...(typeof adjustment.subtotal === 'number'
|
|
25
|
+
? {
|
|
26
|
+
subtotal: (0, price_conversion_1.convertPriceFromCents)(adjustment.subtotal),
|
|
27
|
+
}
|
|
28
|
+
: {}),
|
|
29
|
+
})),
|
|
30
|
+
}
|
|
31
|
+
: {}),
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
function getFetchedWarehouseVoidSaleOrderItems(voidItems) {
|
|
35
|
+
return voidItems
|
|
36
|
+
.map((voidSaleOrderItem) => getWarehouseVoidSaleOrderItemFromCents(voidSaleOrderItem))
|
|
37
|
+
.sort(common_order_actions_1.sortByCreatedAt);
|
|
38
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { CURRENCY_SYMBOL_ENUM } from '../../constants';
|
|
2
|
+
import { IWarehouseVoidSaleOrderItem } from '../../schemas';
|
|
3
|
+
export interface IWarehouseVoidSaleOrderItemsReportProps {
|
|
4
|
+
data: IWarehouseVoidSaleOrderItem[];
|
|
5
|
+
warehouseName: string | undefined;
|
|
6
|
+
from: Date | null;
|
|
7
|
+
to: Date | null;
|
|
8
|
+
width?: number;
|
|
9
|
+
monochrome?: boolean;
|
|
10
|
+
currency_symbol: CURRENCY_SYMBOL_ENUM | undefined;
|
|
11
|
+
}
|
|
12
|
+
export declare function getWarehouseVoidSaleOrderItemsReportHtml(props: IWarehouseVoidSaleOrderItemsReportProps): string;
|
|
13
|
+
export declare function getWarehouseVoidSaleOrderItemsReportReceiptHtml(props: IWarehouseVoidSaleOrderItemsReportProps): string;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getWarehouseVoidSaleOrderItemsReportHtml = getWarehouseVoidSaleOrderItemsReportHtml;
|
|
4
|
+
exports.getWarehouseVoidSaleOrderItemsReportReceiptHtml = getWarehouseVoidSaleOrderItemsReportReceiptHtml;
|
|
5
|
+
const void_items_report_helpers_1 = require("./void-items-report-helpers");
|
|
6
|
+
function toCommonProps(props) {
|
|
7
|
+
return {
|
|
8
|
+
data: props.data,
|
|
9
|
+
tenantName: props.warehouseName,
|
|
10
|
+
from: props.from,
|
|
11
|
+
to: props.to,
|
|
12
|
+
width: props.width,
|
|
13
|
+
monochrome: props.monochrome,
|
|
14
|
+
currency_symbol: props.currency_symbol,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
function getWarehouseVoidSaleOrderItemsReportHtml(props) {
|
|
18
|
+
return (0, void_items_report_helpers_1.getVoidItemsReportHtml)(toCommonProps(props));
|
|
19
|
+
}
|
|
20
|
+
function getWarehouseVoidSaleOrderItemsReportReceiptHtml(props) {
|
|
21
|
+
return (0, void_items_report_helpers_1.getVoidItemsReportReceiptHtml)(toCommonProps(props));
|
|
22
|
+
}
|
|
@@ -70,7 +70,6 @@ export * from './warehouse_communications';
|
|
|
70
70
|
export * from './warehouse_internal_movements';
|
|
71
71
|
export * from './warehouse_inventory_lot_serial_numbers';
|
|
72
72
|
export * from './warehouse_inventory_transactions';
|
|
73
|
-
export * from './warehouse_invoices';
|
|
74
73
|
export * from './warehouse_item_transactions';
|
|
75
74
|
export * from './warehouse_items';
|
|
76
75
|
export * from './warehouse_operational_roles';
|
|
@@ -85,6 +84,6 @@ export * from './warehouse_sale_orders';
|
|
|
85
84
|
export * from './warehouse_staffs';
|
|
86
85
|
export * from './warehouse_track_order_numbers';
|
|
87
86
|
export * from './warehouse_vendors';
|
|
88
|
-
export * from './warehouse_void_invoice_items';
|
|
89
87
|
export * from './warehouse_void_purchase_order_items';
|
|
88
|
+
export * from './warehouse_void_sale_order_items';
|
|
90
89
|
export * from './warehouses';
|
|
@@ -86,7 +86,6 @@ __exportStar(require("./warehouse_communications"), exports);
|
|
|
86
86
|
__exportStar(require("./warehouse_internal_movements"), exports);
|
|
87
87
|
__exportStar(require("./warehouse_inventory_lot_serial_numbers"), exports);
|
|
88
88
|
__exportStar(require("./warehouse_inventory_transactions"), exports);
|
|
89
|
-
__exportStar(require("./warehouse_invoices"), exports);
|
|
90
89
|
__exportStar(require("./warehouse_item_transactions"), exports);
|
|
91
90
|
__exportStar(require("./warehouse_items"), exports);
|
|
92
91
|
__exportStar(require("./warehouse_operational_roles"), exports);
|
|
@@ -101,6 +100,6 @@ __exportStar(require("./warehouse_sale_orders"), exports);
|
|
|
101
100
|
__exportStar(require("./warehouse_staffs"), exports);
|
|
102
101
|
__exportStar(require("./warehouse_track_order_numbers"), exports);
|
|
103
102
|
__exportStar(require("./warehouse_vendors"), exports);
|
|
104
|
-
__exportStar(require("./warehouse_void_invoice_items"), exports);
|
|
105
103
|
__exportStar(require("./warehouse_void_purchase_order_items"), exports);
|
|
104
|
+
__exportStar(require("./warehouse_void_sale_order_items"), exports);
|
|
106
105
|
__exportStar(require("./warehouses"), exports);
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import { Schema } from 'mongoose';
|
|
2
|
+
export declare const VoidSaleOrderItemSchema: Schema<any, import("mongoose").Model<any, any, any, any, any, any>, {}, {}, {}, {}, {
|
|
3
|
+
timestamps: true;
|
|
4
|
+
versionKey: false;
|
|
5
|
+
minimize: false;
|
|
6
|
+
}, {
|
|
7
|
+
createdAt: NativeDate;
|
|
8
|
+
updatedAt: NativeDate;
|
|
9
|
+
} & {
|
|
10
|
+
_id: import("mongoose").Types.ObjectId;
|
|
11
|
+
name: string;
|
|
12
|
+
order_id: import("mongoose").Types.ObjectId;
|
|
13
|
+
staff_id: string;
|
|
14
|
+
staff_name: string;
|
|
15
|
+
createdAt_mins: number;
|
|
16
|
+
createdAt: NativeDate;
|
|
17
|
+
updatedAt: NativeDate;
|
|
18
|
+
description: string;
|
|
19
|
+
order_number: number;
|
|
20
|
+
warehouse_id: string;
|
|
21
|
+
client_name: string;
|
|
22
|
+
client_id: import("mongoose").Types.ObjectId;
|
|
23
|
+
subtotal: number;
|
|
24
|
+
item_id: import("mongoose").Types.ObjectId;
|
|
25
|
+
void_reason: string;
|
|
26
|
+
quantity: number;
|
|
27
|
+
order_item_id: import("mongoose").Types.ObjectId;
|
|
28
|
+
void_type: import("../../constants").VOID_PURCHASE_ORDER_ITEM_TYPE_ENUM;
|
|
29
|
+
iteration: number;
|
|
30
|
+
total_adjusted_quantity: number;
|
|
31
|
+
total_adjusted_subtotal: number;
|
|
32
|
+
order_punched_at: NativeDate;
|
|
33
|
+
adjustments?: import("mongoose").Types.DocumentArray<{
|
|
34
|
+
_id: import("mongoose").Types.ObjectId;
|
|
35
|
+
order_id: import("mongoose").Types.ObjectId;
|
|
36
|
+
staff_id: string;
|
|
37
|
+
staff_name: string;
|
|
38
|
+
order_number: number;
|
|
39
|
+
subtotal: number;
|
|
40
|
+
quantity: number;
|
|
41
|
+
order_item_id: import("mongoose").Types.ObjectId;
|
|
42
|
+
}, import("mongoose").Types.Subdocument<import("mongoose").Types.ObjectId, any, {
|
|
43
|
+
_id: import("mongoose").Types.ObjectId;
|
|
44
|
+
order_id: import("mongoose").Types.ObjectId;
|
|
45
|
+
staff_id: string;
|
|
46
|
+
staff_name: string;
|
|
47
|
+
order_number: number;
|
|
48
|
+
subtotal: number;
|
|
49
|
+
quantity: number;
|
|
50
|
+
order_item_id: import("mongoose").Types.ObjectId;
|
|
51
|
+
}> & {
|
|
52
|
+
_id: import("mongoose").Types.ObjectId;
|
|
53
|
+
order_id: import("mongoose").Types.ObjectId;
|
|
54
|
+
staff_id: string;
|
|
55
|
+
staff_name: string;
|
|
56
|
+
order_number: number;
|
|
57
|
+
subtotal: number;
|
|
58
|
+
quantity: number;
|
|
59
|
+
order_item_id: import("mongoose").Types.ObjectId;
|
|
60
|
+
}> | null | undefined;
|
|
61
|
+
}, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<{
|
|
62
|
+
createdAt: NativeDate;
|
|
63
|
+
updatedAt: NativeDate;
|
|
64
|
+
} & {
|
|
65
|
+
_id: import("mongoose").Types.ObjectId;
|
|
66
|
+
name: string;
|
|
67
|
+
order_id: import("mongoose").Types.ObjectId;
|
|
68
|
+
staff_id: string;
|
|
69
|
+
staff_name: string;
|
|
70
|
+
createdAt_mins: number;
|
|
71
|
+
createdAt: NativeDate;
|
|
72
|
+
updatedAt: NativeDate;
|
|
73
|
+
description: string;
|
|
74
|
+
order_number: number;
|
|
75
|
+
warehouse_id: string;
|
|
76
|
+
client_name: string;
|
|
77
|
+
client_id: import("mongoose").Types.ObjectId;
|
|
78
|
+
subtotal: number;
|
|
79
|
+
item_id: import("mongoose").Types.ObjectId;
|
|
80
|
+
void_reason: string;
|
|
81
|
+
quantity: number;
|
|
82
|
+
order_item_id: import("mongoose").Types.ObjectId;
|
|
83
|
+
void_type: import("../../constants").VOID_PURCHASE_ORDER_ITEM_TYPE_ENUM;
|
|
84
|
+
iteration: number;
|
|
85
|
+
total_adjusted_quantity: number;
|
|
86
|
+
total_adjusted_subtotal: number;
|
|
87
|
+
order_punched_at: NativeDate;
|
|
88
|
+
adjustments?: import("mongoose").Types.DocumentArray<{
|
|
89
|
+
_id: import("mongoose").Types.ObjectId;
|
|
90
|
+
order_id: import("mongoose").Types.ObjectId;
|
|
91
|
+
staff_id: string;
|
|
92
|
+
staff_name: string;
|
|
93
|
+
order_number: number;
|
|
94
|
+
subtotal: number;
|
|
95
|
+
quantity: number;
|
|
96
|
+
order_item_id: import("mongoose").Types.ObjectId;
|
|
97
|
+
}, import("mongoose").Types.Subdocument<import("mongoose").Types.ObjectId, any, {
|
|
98
|
+
_id: import("mongoose").Types.ObjectId;
|
|
99
|
+
order_id: import("mongoose").Types.ObjectId;
|
|
100
|
+
staff_id: string;
|
|
101
|
+
staff_name: string;
|
|
102
|
+
order_number: number;
|
|
103
|
+
subtotal: number;
|
|
104
|
+
quantity: number;
|
|
105
|
+
order_item_id: import("mongoose").Types.ObjectId;
|
|
106
|
+
}> & {
|
|
107
|
+
_id: import("mongoose").Types.ObjectId;
|
|
108
|
+
order_id: import("mongoose").Types.ObjectId;
|
|
109
|
+
staff_id: string;
|
|
110
|
+
staff_name: string;
|
|
111
|
+
order_number: number;
|
|
112
|
+
subtotal: number;
|
|
113
|
+
quantity: number;
|
|
114
|
+
order_item_id: import("mongoose").Types.ObjectId;
|
|
115
|
+
}> | null | undefined;
|
|
116
|
+
}>> & import("mongoose").FlatRecord<{
|
|
117
|
+
createdAt: NativeDate;
|
|
118
|
+
updatedAt: NativeDate;
|
|
119
|
+
} & {
|
|
120
|
+
_id: import("mongoose").Types.ObjectId;
|
|
121
|
+
name: string;
|
|
122
|
+
order_id: import("mongoose").Types.ObjectId;
|
|
123
|
+
staff_id: string;
|
|
124
|
+
staff_name: string;
|
|
125
|
+
createdAt_mins: number;
|
|
126
|
+
createdAt: NativeDate;
|
|
127
|
+
updatedAt: NativeDate;
|
|
128
|
+
description: string;
|
|
129
|
+
order_number: number;
|
|
130
|
+
warehouse_id: string;
|
|
131
|
+
client_name: string;
|
|
132
|
+
client_id: import("mongoose").Types.ObjectId;
|
|
133
|
+
subtotal: number;
|
|
134
|
+
item_id: import("mongoose").Types.ObjectId;
|
|
135
|
+
void_reason: string;
|
|
136
|
+
quantity: number;
|
|
137
|
+
order_item_id: import("mongoose").Types.ObjectId;
|
|
138
|
+
void_type: import("../../constants").VOID_PURCHASE_ORDER_ITEM_TYPE_ENUM;
|
|
139
|
+
iteration: number;
|
|
140
|
+
total_adjusted_quantity: number;
|
|
141
|
+
total_adjusted_subtotal: number;
|
|
142
|
+
order_punched_at: NativeDate;
|
|
143
|
+
adjustments?: import("mongoose").Types.DocumentArray<{
|
|
144
|
+
_id: import("mongoose").Types.ObjectId;
|
|
145
|
+
order_id: import("mongoose").Types.ObjectId;
|
|
146
|
+
staff_id: string;
|
|
147
|
+
staff_name: string;
|
|
148
|
+
order_number: number;
|
|
149
|
+
subtotal: number;
|
|
150
|
+
quantity: number;
|
|
151
|
+
order_item_id: import("mongoose").Types.ObjectId;
|
|
152
|
+
}, import("mongoose").Types.Subdocument<import("mongoose").Types.ObjectId, any, {
|
|
153
|
+
_id: import("mongoose").Types.ObjectId;
|
|
154
|
+
order_id: import("mongoose").Types.ObjectId;
|
|
155
|
+
staff_id: string;
|
|
156
|
+
staff_name: string;
|
|
157
|
+
order_number: number;
|
|
158
|
+
subtotal: number;
|
|
159
|
+
quantity: number;
|
|
160
|
+
order_item_id: import("mongoose").Types.ObjectId;
|
|
161
|
+
}> & {
|
|
162
|
+
_id: import("mongoose").Types.ObjectId;
|
|
163
|
+
order_id: import("mongoose").Types.ObjectId;
|
|
164
|
+
staff_id: string;
|
|
165
|
+
staff_name: string;
|
|
166
|
+
order_number: number;
|
|
167
|
+
subtotal: number;
|
|
168
|
+
quantity: number;
|
|
169
|
+
order_item_id: import("mongoose").Types.ObjectId;
|
|
170
|
+
}> | null | undefined;
|
|
171
|
+
}> & Required<{
|
|
172
|
+
_id: import("mongoose").Types.ObjectId;
|
|
173
|
+
}> & {
|
|
174
|
+
__v: number;
|
|
175
|
+
}>;
|
|
176
|
+
export declare const WAREHOUSE_VOID_SALE_ORDER_ITEMS_COLLECTION_NAME = "warehouse_void_sale_order_items";
|