washday-sdk 0.0.71 → 0.0.73
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/api/axiosInstance.d.ts +2 -0
- package/dist/api/axiosInstance.js +4 -8
- package/dist/api/cashierbox/delete.d.ts +2 -0
- package/dist/api/cashierbox/delete.js +3 -10
- package/dist/api/cashierbox/get.d.ts +7 -0
- package/dist/api/cashierbox/get.js +7 -16
- package/dist/api/cashierbox/post.d.ts +11 -0
- package/dist/api/cashierbox/post.js +5 -13
- package/dist/api/cashierbox/put.d.ts +4 -0
- package/dist/api/cashierbox/put.js +3 -10
- package/dist/api/companies/get.d.ts +2 -0
- package/dist/api/companies/get.js +3 -10
- package/dist/api/companies/post.d.ts +3 -0
- package/dist/api/companies/post.js +5 -13
- package/dist/api/companies/put.d.ts +4 -0
- package/dist/api/companies/put.js +7 -16
- package/dist/api/countries/get.d.ts +2 -0
- package/dist/api/countries/get.js +3 -10
- package/dist/api/countries/post.d.ts +0 -0
- package/dist/api/countries/put.d.ts +0 -0
- package/dist/api/csv/get.d.ts +11 -0
- package/dist/api/csv/get.js +5 -12
- package/dist/api/csv/index.d.ts +1 -0
- package/dist/api/csv/index.js +1 -27
- package/dist/api/customers/delete.d.ts +2 -0
- package/dist/api/customers/delete.js +3 -10
- package/dist/api/customers/get.d.ts +28 -0
- package/dist/api/customers/get.js +12 -22
- package/dist/api/customers/index.d.ts +4 -0
- package/dist/api/customers/index.js +4 -30
- package/dist/api/customers/post.d.ts +18 -0
- package/dist/api/customers/post.js +3 -10
- package/dist/api/customers/put.d.ts +18 -0
- package/dist/api/customers/put.js +3 -10
- package/dist/api/discounts/get.d.ts +6 -0
- package/dist/api/discounts/get.js +11 -22
- package/dist/api/discounts/post.d.ts +3 -0
- package/dist/api/discounts/post.js +5 -13
- package/dist/api/discounts/put.d.ts +3 -0
- package/dist/api/discounts/put.js +5 -13
- package/dist/api/index.d.ts +7 -0
- package/dist/api/index.js +88 -103
- package/dist/api/inventory/delete.d.ts +2 -0
- package/dist/api/inventory/delete.js +3 -10
- package/dist/api/inventory/get.d.ts +7 -0
- package/dist/api/inventory/get.js +7 -16
- package/dist/api/inventory/index.d.ts +4 -0
- package/dist/api/inventory/index.js +4 -30
- package/dist/api/inventory/post.d.ts +7 -0
- package/dist/api/inventory/post.js +3 -10
- package/dist/api/inventory/put.d.ts +8 -0
- package/dist/api/inventory/put.js +5 -13
- package/dist/api/order/delete.js +25 -0
- package/dist/api/order/get.js +58 -0
- package/dist/api/order/index.js +4 -0
- package/dist/api/order/post.js +26 -0
- package/dist/api/order/put.js +40 -0
- package/dist/api/products/delete.d.ts +3 -0
- package/dist/api/products/delete.js +5 -13
- package/dist/api/products/get.d.ts +2 -0
- package/dist/api/products/get.js +3 -10
- package/dist/api/products/index.d.ts +4 -0
- package/dist/api/products/index.js +4 -30
- package/dist/api/products/post.d.ts +27 -0
- package/dist/api/products/post.js +5 -13
- package/dist/api/products/put.d.ts +21 -0
- package/dist/api/products/put.js +5 -13
- package/dist/api/sections/delete.d.ts +2 -0
- package/dist/api/sections/delete.js +3 -10
- package/dist/api/sections/get.d.ts +7 -0
- package/dist/api/sections/get.js +5 -13
- package/dist/api/sections/index.d.ts +4 -0
- package/dist/api/sections/index.js +4 -30
- package/dist/api/sections/post.d.ts +7 -0
- package/dist/api/sections/post.js +3 -10
- package/dist/api/sections/put.d.ts +8 -0
- package/dist/api/sections/put.js +3 -10
- package/dist/api/staff/delete.d.ts +2 -0
- package/dist/api/staff/delete.js +3 -10
- package/dist/api/staff/get.d.ts +3 -0
- package/dist/api/staff/get.js +5 -13
- package/dist/api/staff/post.d.ts +2 -0
- package/dist/api/staff/post.js +3 -10
- package/dist/api/staff/put.d.ts +2 -0
- package/dist/api/staff/put.js +3 -10
- package/dist/api/stores/get.d.ts +12 -0
- package/dist/api/stores/get.js +9 -19
- package/dist/api/stores/post.d.ts +4 -0
- package/dist/api/stores/post.js +7 -16
- package/dist/api/stores/put.d.ts +6 -0
- package/dist/api/stores/put.js +5 -13
- package/dist/api/stripe/get.d.ts +0 -0
- package/dist/api/stripe/post.d.ts +6 -0
- package/dist/api/stripe/post.js +7 -16
- package/dist/api/stripe/put.d.ts +0 -0
- package/dist/api/supplies/delete.d.ts +2 -0
- package/dist/api/supplies/delete.js +3 -10
- package/dist/api/supplies/get.d.ts +7 -0
- package/dist/api/supplies/get.js +7 -16
- package/dist/api/supplies/post.d.ts +11 -0
- package/dist/api/supplies/post.js +3 -10
- package/dist/api/supplies/put.d.ts +6 -0
- package/dist/api/supplies/put.js +5 -13
- package/dist/api/users/put.d.ts +10 -0
- package/dist/api/users/put.js +3 -10
- package/dist/enum/index.d.ts +10 -0
- package/dist/enum/index.js +4 -7
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -33
- package/dist/interfaces/Api.d.ts +3 -0
- package/dist/interfaces/Api.js +1 -2
- package/dist/interfaces/Company.d.ts +0 -0
- package/dist/interfaces/Customer.d.ts +47 -0
- package/dist/interfaces/Customer.js +1 -2
- package/dist/interfaces/Order.d.ts +91 -0
- package/dist/interfaces/Order.js +1 -2
- package/dist/interfaces/Permission.d.ts +22 -0
- package/dist/interfaces/Permission.js +1 -2
- package/dist/interfaces/Product.d.ts +51 -0
- package/dist/interfaces/Product.js +1 -2
- package/dist/interfaces/Section.d.ts +13 -0
- package/dist/interfaces/Section.js +1 -2
- package/dist/interfaces/Store.d.ts +323 -0
- package/dist/interfaces/Store.js +1 -2
- package/dist/interfaces/StoreImage.d.ts +8 -0
- package/dist/interfaces/StoreImage.js +1 -2
- package/dist/interfaces/User.d.ts +38 -0
- package/dist/interfaces/User.js +1 -2
- package/dist/utils/apiUtils.d.ts +3 -0
- package/dist/utils/apiUtils.js +2 -6
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +1 -17
- package/dist/utils/orders/calculateOrderTotal.d.ts +5 -0
- package/dist/utils/orders/calculateOrderTotal.js +10 -14
- package/dist/utils/orders/calculateTotalTaxesIncluded.d.ts +9 -0
- package/dist/utils/orders/calculateTotalTaxesIncluded.js +3 -7
- package/dist/utils/orders/calculateTotalTaxesOverPrice.d.ts +8 -0
- package/dist/utils/orders/calculateTotalTaxesOverPrice.js +7 -11
- package/dist/utils/orders/helpers.d.ts +15 -0
- package/dist/utils/orders/helpers.js +6 -13
- package/dist/utils/orders/index.d.ts +2 -0
- package/dist/utils/orders/index.js +2 -5
- package/dist/utils/receipt/generateReceiptHTML.d.ts +0 -0
- package/dist/utils/util.d.ts +0 -0
- package/package.json +2 -1
- package/src/api/axiosInstance.ts +1 -0
- package/src/api/customers/get.ts +1 -1
- package/src/api/index.ts +11 -10
- package/src/api/order/delete.ts +15 -0
- package/src/api/order/get.ts +64 -0
- package/src/api/order/index.ts +4 -0
- package/src/api/order/post.ts +21 -0
- package/src/api/order/put.ts +53 -0
- package/src/utils/apiUtils.ts +1 -1
- package/tsconfig.json +10 -9
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
import { IProduct } from "./Product";
|
|
2
|
+
import { ISection } from "./Section";
|
|
3
|
+
import { IStoreImage } from "./StoreImage";
|
|
4
|
+
import { IUser, IStaff } from "./User";
|
|
5
|
+
import { IOrder, IOrderPaymentLines } from "./Order";
|
|
6
|
+
export interface IStore {
|
|
7
|
+
name: string;
|
|
8
|
+
streetAddress?: string;
|
|
9
|
+
zipCode?: string;
|
|
10
|
+
administrator: IUser | string;
|
|
11
|
+
owner: IUser | string;
|
|
12
|
+
createdBy: IUser | string;
|
|
13
|
+
city: string;
|
|
14
|
+
state: string;
|
|
15
|
+
country: string;
|
|
16
|
+
phone: string;
|
|
17
|
+
taxesType: string;
|
|
18
|
+
taxOne?: ITax;
|
|
19
|
+
isActive: boolean;
|
|
20
|
+
allowPrePaid: boolean;
|
|
21
|
+
taxTwo?: ITax;
|
|
22
|
+
taxThree?: ITax;
|
|
23
|
+
paymentConfig: IPaymentConfig;
|
|
24
|
+
orderPageConfig: IOrderPageConfig;
|
|
25
|
+
printingConfig: IPrintingConfig;
|
|
26
|
+
notificationConfig: INotificationConfig;
|
|
27
|
+
schedule?: ISchedule;
|
|
28
|
+
pickupDeliverySchedule?: IPickupDeliverySchedule;
|
|
29
|
+
sections?: Array<ISection | string>;
|
|
30
|
+
storeImages: Array<IStoreImage | string>;
|
|
31
|
+
staffs?: Array<IStaff | string>;
|
|
32
|
+
currencySymbol: string;
|
|
33
|
+
inventory?: IInventory;
|
|
34
|
+
supplies?: ISupplies;
|
|
35
|
+
cashUpReports?: ICashUpReport;
|
|
36
|
+
cashierBoxes?: ICashierBox;
|
|
37
|
+
ticketStructure?: ITicketStructure | null;
|
|
38
|
+
ticketForLaundryStructure?: ITicketForLaundryStructure | null;
|
|
39
|
+
storeDiscounts: IStoreDiscount | null;
|
|
40
|
+
discountCodes: IDiscountCode | null;
|
|
41
|
+
marketingConfig: IMarketingConfig;
|
|
42
|
+
emailReportSuscribed: boolean;
|
|
43
|
+
emailReportFrequency: string;
|
|
44
|
+
emailReportDateRange: string;
|
|
45
|
+
}
|
|
46
|
+
export interface ITaxConfig {
|
|
47
|
+
name: string;
|
|
48
|
+
value: number;
|
|
49
|
+
}
|
|
50
|
+
export interface IProductStockActivity {
|
|
51
|
+
type: string;
|
|
52
|
+
date: Date;
|
|
53
|
+
amount: number;
|
|
54
|
+
order?: IOrder | string;
|
|
55
|
+
addedBy?: IUser | string;
|
|
56
|
+
notes?: string;
|
|
57
|
+
}
|
|
58
|
+
export interface ISupplyStockActivity {
|
|
59
|
+
type: string;
|
|
60
|
+
date: Date;
|
|
61
|
+
amount: number;
|
|
62
|
+
order?: IOrder | string;
|
|
63
|
+
product?: IProduct | string;
|
|
64
|
+
addedBy?: IUser | string;
|
|
65
|
+
notes?: string;
|
|
66
|
+
}
|
|
67
|
+
export interface IInventory {
|
|
68
|
+
store: IStore | string;
|
|
69
|
+
product: IProduct | string;
|
|
70
|
+
stock: number;
|
|
71
|
+
alertOnStock: number;
|
|
72
|
+
stockActivityHistory: Array<IProductStockActivity | string>;
|
|
73
|
+
isActive: boolean;
|
|
74
|
+
}
|
|
75
|
+
export interface IInventory {
|
|
76
|
+
store: IStore | string;
|
|
77
|
+
product: IProduct | string;
|
|
78
|
+
stock: number;
|
|
79
|
+
alertOnStock: number;
|
|
80
|
+
stockActivityHistory: Array<IProductStockActivity | string>;
|
|
81
|
+
isActive: boolean;
|
|
82
|
+
}
|
|
83
|
+
export interface ISupplies {
|
|
84
|
+
name: String;
|
|
85
|
+
code: String;
|
|
86
|
+
purchaseUnit: String;
|
|
87
|
+
usageUnit: String;
|
|
88
|
+
usageFactor: number;
|
|
89
|
+
stock: number;
|
|
90
|
+
alertOnStock: number;
|
|
91
|
+
supplyActivityHistory: Array<ISupplyStockActivity | string>;
|
|
92
|
+
isActive: boolean;
|
|
93
|
+
}
|
|
94
|
+
export interface ISupplies {
|
|
95
|
+
name: String;
|
|
96
|
+
code: String;
|
|
97
|
+
purchaseUnit: String;
|
|
98
|
+
usageUnit: String;
|
|
99
|
+
usageFactor: number;
|
|
100
|
+
stock: number;
|
|
101
|
+
alertOnStock: number;
|
|
102
|
+
supplyActivityHistory: Array<ISupplyStockActivity | string>;
|
|
103
|
+
isActive: boolean;
|
|
104
|
+
}
|
|
105
|
+
export interface ICashUpReportLine {
|
|
106
|
+
type: string;
|
|
107
|
+
orderPaymentLineId: string | null | IOrderPaymentLines;
|
|
108
|
+
order: string | null | IOrder;
|
|
109
|
+
movement: string | null | IInOutMovement;
|
|
110
|
+
amount: number;
|
|
111
|
+
paymentMethod: string;
|
|
112
|
+
}
|
|
113
|
+
export interface ICashUpReport {
|
|
114
|
+
createdBy: IUser | string;
|
|
115
|
+
createdDate: Date;
|
|
116
|
+
startingCashDate: Date;
|
|
117
|
+
startingCash: number;
|
|
118
|
+
cardFromOrders: number;
|
|
119
|
+
totalCashCalculated: number;
|
|
120
|
+
totalCardCalculated: number;
|
|
121
|
+
totalTransferCalculated?: number;
|
|
122
|
+
cashFromOrders: number;
|
|
123
|
+
cashPayIns: number;
|
|
124
|
+
cardPayIns: number;
|
|
125
|
+
cardPayOuts: number;
|
|
126
|
+
cashPayOuts: number;
|
|
127
|
+
transferPayIns?: number;
|
|
128
|
+
transferPayOuts?: number;
|
|
129
|
+
transferFromOrders?: number;
|
|
130
|
+
declaredCash: number;
|
|
131
|
+
declaredCard: number;
|
|
132
|
+
declaredTransfer?: number;
|
|
133
|
+
leftInDrawer: number;
|
|
134
|
+
cashToBank: number;
|
|
135
|
+
expectedCash: number;
|
|
136
|
+
variance: number;
|
|
137
|
+
notes: string;
|
|
138
|
+
cashierBox: ICashierBox | string;
|
|
139
|
+
orders: Array<IOrder> | Array<string>;
|
|
140
|
+
movements: Array<IInOutMovement> | Array<string>;
|
|
141
|
+
lines: Array<ICashUpReportLine>;
|
|
142
|
+
}
|
|
143
|
+
export interface ICashUpReport {
|
|
144
|
+
createdBy: IUser | string;
|
|
145
|
+
createdDate: Date;
|
|
146
|
+
startingCashDate: Date;
|
|
147
|
+
startingCash: number;
|
|
148
|
+
cardFromOrders: number;
|
|
149
|
+
totalCashCalculated: number;
|
|
150
|
+
totalCardCalculated: number;
|
|
151
|
+
totalTransferCalculated?: number;
|
|
152
|
+
cashFromOrders: number;
|
|
153
|
+
transferPayIns?: number;
|
|
154
|
+
transferPayOuts?: number;
|
|
155
|
+
transferFromOrders?: number;
|
|
156
|
+
cashPayIns: number;
|
|
157
|
+
cashPayOuts: number;
|
|
158
|
+
declaredCash: number;
|
|
159
|
+
declaredCard: number;
|
|
160
|
+
declaredTransfer?: number;
|
|
161
|
+
leftInDrawer: number;
|
|
162
|
+
cashToBank: number;
|
|
163
|
+
expectedCash: number;
|
|
164
|
+
variance: number;
|
|
165
|
+
notes: string;
|
|
166
|
+
cashierBox: ICashierBox | string;
|
|
167
|
+
orders: Array<IOrder> | Array<string>;
|
|
168
|
+
movements: Array<IInOutMovement> | Array<string>;
|
|
169
|
+
}
|
|
170
|
+
export interface IInOutMovement {
|
|
171
|
+
type: string;
|
|
172
|
+
date: Date;
|
|
173
|
+
amount: number;
|
|
174
|
+
notes: string;
|
|
175
|
+
paymentMethod: string | null;
|
|
176
|
+
isOnACashUpReport: Boolean;
|
|
177
|
+
createdBy: IUser | string;
|
|
178
|
+
}
|
|
179
|
+
export interface ICashierBox {
|
|
180
|
+
createdBy: IUser | string;
|
|
181
|
+
name: string;
|
|
182
|
+
inOutMovements?: IInOutMovement;
|
|
183
|
+
isActive: boolean;
|
|
184
|
+
}
|
|
185
|
+
export interface ITax {
|
|
186
|
+
name: string;
|
|
187
|
+
value: number;
|
|
188
|
+
}
|
|
189
|
+
export interface INotificationConfig {
|
|
190
|
+
notifyOrderCreated: boolean;
|
|
191
|
+
notifyPickedUp: boolean;
|
|
192
|
+
notifyCleaned: boolean;
|
|
193
|
+
notifyCollected: boolean;
|
|
194
|
+
notifyDelivered: boolean;
|
|
195
|
+
notifyOwnerOnOrderCreated: boolean;
|
|
196
|
+
notifyEmail: string;
|
|
197
|
+
}
|
|
198
|
+
export interface IPaymentConfig {
|
|
199
|
+
defaultPaymentMethod: string;
|
|
200
|
+
}
|
|
201
|
+
export interface IPrintingConfig {
|
|
202
|
+
printLogoOnTicket: Boolean;
|
|
203
|
+
printTicketForLaundry: Boolean;
|
|
204
|
+
}
|
|
205
|
+
export interface IMarketingConfig {
|
|
206
|
+
googlePlaceID: string;
|
|
207
|
+
facebookUrl: string;
|
|
208
|
+
ordersForFirstReview: number;
|
|
209
|
+
ordersForSecondReview: number;
|
|
210
|
+
sendReviewByEmail: Boolean;
|
|
211
|
+
sendReviewBySMS: Boolean;
|
|
212
|
+
}
|
|
213
|
+
export interface IOrderPageConfig {
|
|
214
|
+
showProductSearchBarWeb: Boolean;
|
|
215
|
+
defaultDeliveryDate: string;
|
|
216
|
+
defaultDeliveryTime: string;
|
|
217
|
+
defaultNotifyMethod: string;
|
|
218
|
+
printTicketAfterOrder: Boolean;
|
|
219
|
+
shippingServiceCost: number;
|
|
220
|
+
}
|
|
221
|
+
export interface ITicketStructure {
|
|
222
|
+
showTotalPieces: Boolean;
|
|
223
|
+
showEmisionDate: Boolean;
|
|
224
|
+
showEmisionTime: Boolean;
|
|
225
|
+
showLegend: Boolean;
|
|
226
|
+
showPaymentMethod: Boolean;
|
|
227
|
+
showStorePhone: Boolean;
|
|
228
|
+
showDeliveryDate: Boolean;
|
|
229
|
+
showDeliveryTime: Boolean;
|
|
230
|
+
ticketLegendText: String;
|
|
231
|
+
showStoreName: Boolean;
|
|
232
|
+
showCustomerName: Boolean;
|
|
233
|
+
showCreatedByName: Boolean;
|
|
234
|
+
showOrderNotes: Boolean;
|
|
235
|
+
showTaxes: Boolean;
|
|
236
|
+
showDiscounts: Boolean;
|
|
237
|
+
showCredit: Boolean;
|
|
238
|
+
}
|
|
239
|
+
export interface ITicketForLaundryStructure {
|
|
240
|
+
showTotalPieces: Boolean;
|
|
241
|
+
showEmisionDate: Boolean;
|
|
242
|
+
showEmisionTime: Boolean;
|
|
243
|
+
showLegend: Boolean;
|
|
244
|
+
showPaymentMethod: Boolean;
|
|
245
|
+
showStorePhone: Boolean;
|
|
246
|
+
showDeliveryDate: Boolean;
|
|
247
|
+
showDeliveryTime: Boolean;
|
|
248
|
+
ticketLegendText: String;
|
|
249
|
+
printLogoOnTicket: Boolean;
|
|
250
|
+
showStoreName: Boolean;
|
|
251
|
+
showCustomerName: Boolean;
|
|
252
|
+
showCreatedByName: Boolean;
|
|
253
|
+
showOrderNotes: Boolean;
|
|
254
|
+
showTaxes: Boolean;
|
|
255
|
+
showDiscounts: Boolean;
|
|
256
|
+
showCredit: Boolean;
|
|
257
|
+
}
|
|
258
|
+
export interface ITiming {
|
|
259
|
+
openingTime: Date;
|
|
260
|
+
closingTime: Date;
|
|
261
|
+
}
|
|
262
|
+
export interface IPickupDeliveryTiming {
|
|
263
|
+
fromTime: String;
|
|
264
|
+
toTime: String;
|
|
265
|
+
}
|
|
266
|
+
export interface IPickupDeliverySchedule {
|
|
267
|
+
1: [IPickupDeliveryTiming];
|
|
268
|
+
2: [IPickupDeliveryTiming];
|
|
269
|
+
3: [IPickupDeliveryTiming];
|
|
270
|
+
4: [IPickupDeliveryTiming];
|
|
271
|
+
5: [IPickupDeliveryTiming];
|
|
272
|
+
6: [IPickupDeliveryTiming];
|
|
273
|
+
7: [IPickupDeliveryTiming];
|
|
274
|
+
}
|
|
275
|
+
export interface ISchedule {
|
|
276
|
+
sunday: ITiming;
|
|
277
|
+
monday: ITiming;
|
|
278
|
+
tuesday: ITiming;
|
|
279
|
+
wednesday: ITiming;
|
|
280
|
+
thursday: ITiming;
|
|
281
|
+
friday: ITiming;
|
|
282
|
+
saturday: ITiming;
|
|
283
|
+
}
|
|
284
|
+
export interface IStoreDiscount {
|
|
285
|
+
name: String;
|
|
286
|
+
type: String;
|
|
287
|
+
value: number;
|
|
288
|
+
fromDate: Date;
|
|
289
|
+
toDate: Date;
|
|
290
|
+
fromTime: string;
|
|
291
|
+
toTime: string;
|
|
292
|
+
weekDays: Array<Number>;
|
|
293
|
+
products: Array<IProduct | string>;
|
|
294
|
+
createdBy: IUser | string;
|
|
295
|
+
isActive: boolean;
|
|
296
|
+
}
|
|
297
|
+
export interface IBuyAndGetCondition {
|
|
298
|
+
buyConditions: Array<any>;
|
|
299
|
+
getConditions: Array<any>;
|
|
300
|
+
getDiscountType: string;
|
|
301
|
+
discountValue: number;
|
|
302
|
+
}
|
|
303
|
+
export interface IDiscountCode {
|
|
304
|
+
name: String;
|
|
305
|
+
code: String;
|
|
306
|
+
type: String;
|
|
307
|
+
value: number;
|
|
308
|
+
fromDate: Date;
|
|
309
|
+
toDate: Date;
|
|
310
|
+
fromTime: string;
|
|
311
|
+
toTime: string;
|
|
312
|
+
weekDays: Array<Number>;
|
|
313
|
+
products: Array<IProduct | string>;
|
|
314
|
+
createdBy: IUser | string;
|
|
315
|
+
isActive: boolean;
|
|
316
|
+
applyOnceOnOrder: boolean;
|
|
317
|
+
applyToAllProducts: boolean;
|
|
318
|
+
hasUseLimit: boolean;
|
|
319
|
+
useLimitQty: number;
|
|
320
|
+
usedCounter: number;
|
|
321
|
+
onePerCustomer: boolean;
|
|
322
|
+
buyAndGetConditions: Array<IBuyAndGetCondition | string>;
|
|
323
|
+
}
|
package/dist/interfaces/Store.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { IPermission } from "./Permission";
|
|
2
|
+
import { ICashierBox, IStore } from "./Store";
|
|
3
|
+
interface IPrinterConfig {
|
|
4
|
+
name: String;
|
|
5
|
+
paperSize: String;
|
|
6
|
+
}
|
|
7
|
+
export interface IUser {
|
|
8
|
+
email: string;
|
|
9
|
+
name: string;
|
|
10
|
+
password: string;
|
|
11
|
+
roleNum: number;
|
|
12
|
+
languagePreference?: string;
|
|
13
|
+
phoneNumber: string;
|
|
14
|
+
roleChanged: boolean;
|
|
15
|
+
lastLogonDate: Date;
|
|
16
|
+
freshChatRestoreID: String;
|
|
17
|
+
permission: IPermission;
|
|
18
|
+
isActive: boolean;
|
|
19
|
+
verified: boolean;
|
|
20
|
+
cashierBox?: ICashierBox | string | null;
|
|
21
|
+
printer?: IPrinterConfig;
|
|
22
|
+
}
|
|
23
|
+
export interface ISecretCode {
|
|
24
|
+
email: string;
|
|
25
|
+
code: string;
|
|
26
|
+
dateCreated: Date;
|
|
27
|
+
}
|
|
28
|
+
export interface IStoreAdmin extends IUser {
|
|
29
|
+
}
|
|
30
|
+
export interface ISuperAdmin extends IUser {
|
|
31
|
+
hasMultiStore: boolean;
|
|
32
|
+
stripeCustomerId: string;
|
|
33
|
+
}
|
|
34
|
+
export interface IStaff extends IUser {
|
|
35
|
+
store: IStore | string;
|
|
36
|
+
cashierBox: ICashierBox | string;
|
|
37
|
+
}
|
|
38
|
+
export {};
|
package/dist/interfaces/User.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
package/dist/utils/apiUtils.js
CHANGED
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.generateQueryParamsStr = void 0;
|
|
4
|
-
const generateQueryParamsStr = (availableQueryParamsList = [], receivedParamsObj = {}) => {
|
|
1
|
+
export const generateQueryParamsStr = (availableQueryParamsList = [], receivedParamsObj = {}) => {
|
|
5
2
|
let queryParams = [];
|
|
6
|
-
for (let availableParam
|
|
3
|
+
for (let availableParam of availableQueryParamsList) {
|
|
7
4
|
if (receivedParamsObj.hasOwnProperty(availableParam)) {
|
|
8
5
|
queryParams.push(`${availableParam}=${receivedParamsObj[availableParam]}`);
|
|
9
6
|
}
|
|
10
7
|
}
|
|
11
8
|
return queryParams.join('&');
|
|
12
9
|
};
|
|
13
|
-
exports.generateQueryParamsStr = generateQueryParamsStr;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './orders';
|
package/dist/utils/index.js
CHANGED
|
@@ -1,17 +1 @@
|
|
|
1
|
-
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./orders"), exports);
|
|
1
|
+
export * from './orders';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ICustomer } from "../../interfaces/Customer";
|
|
2
|
+
import { IStore } from "../../interfaces/Store";
|
|
3
|
+
export declare const calculateOrderTotal: (order: any, selectedCustomer: {
|
|
4
|
+
customer: ICustomer;
|
|
5
|
+
} | undefined, storeSettings: IStore, hasShippingCost: boolean, storeDiscounts: any[] | undefined, discountCodeObj: any) => any;
|
|
@@ -1,28 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
const calculateTotalTaxesOverPrice_1 = require("./calculateTotalTaxesOverPrice");
|
|
7
|
-
const helpers_1 = require("./helpers");
|
|
8
|
-
const calculateOrderTotal = (order, selectedCustomer, storeSettings, hasShippingCost, storeDiscounts = [], discountCodeObj) => {
|
|
1
|
+
import { DiscountCodeTypes } from "../../enum";
|
|
2
|
+
import { calculateTotalTaxesIncluded } from "./calculateTotalTaxesIncluded";
|
|
3
|
+
import { calculateTotalTaxesOverPrice } from "./calculateTotalTaxesOverPrice";
|
|
4
|
+
import { getCreditApplied, getProductLineTotals, getShippingCost } from "./helpers";
|
|
5
|
+
export const calculateOrderTotal = (order, selectedCustomer, storeSettings, hasShippingCost, storeDiscounts = [], discountCodeObj) => {
|
|
9
6
|
var _a;
|
|
10
7
|
try {
|
|
11
8
|
const appliedOrderDiscounts = {};
|
|
12
|
-
const productTableCalculator = (storeSettings === null || storeSettings === void 0 ? void 0 : storeSettings.taxesType) === 'over_price' ?
|
|
9
|
+
const productTableCalculator = (storeSettings === null || storeSettings === void 0 ? void 0 : storeSettings.taxesType) === 'over_price' ? calculateTotalTaxesOverPrice : calculateTotalTaxesIncluded;
|
|
13
10
|
const productTableImports = productTableCalculator(order, selectedCustomer, storeSettings, storeDiscounts, appliedOrderDiscounts, discountCodeObj);
|
|
14
11
|
// PRODUCT LINE TOTALS
|
|
15
|
-
const { totalQuantity, totalImportWithDiscount, totalImportWithoutDiscount, totalImporTaxes, totalDiscountAmount } =
|
|
12
|
+
const { totalQuantity, totalImportWithDiscount, totalImportWithoutDiscount, totalImporTaxes, totalDiscountAmount } = getProductLineTotals(productTableImports);
|
|
16
13
|
// DISCOUNT TOTAL AND SHIPPING SERVICE COST
|
|
17
14
|
let discountCodeAmount = 0;
|
|
18
|
-
let shippingCost =
|
|
19
|
-
if (discountCodeObj && discountCodeObj.type ===
|
|
15
|
+
let shippingCost = getShippingCost(discountCodeObj, hasShippingCost, storeSettings);
|
|
16
|
+
if (discountCodeObj && discountCodeObj.type === DiscountCodeTypes.NUMBER && discountCodeObj.applyOnceOnOrder) {
|
|
20
17
|
const includesProducts = discountCodeObj.applyToAllProducts || order.products.some((curr) => discountCodeObj.products.includes(curr._id));
|
|
21
18
|
discountCodeAmount = includesProducts ? discountCodeObj.value : 0;
|
|
22
19
|
}
|
|
23
20
|
// ORDER TOTAL CALCULATION AND CREDIT APPLIED
|
|
24
21
|
let orderTotalWithOutCredit = +(totalImportWithDiscount + totalImporTaxes + shippingCost - discountCodeAmount).toFixed(2);
|
|
25
|
-
let creditApplied =
|
|
22
|
+
let creditApplied = getCreditApplied(selectedCustomer, orderTotalWithOutCredit);
|
|
26
23
|
let orderTotal = +(orderTotalWithOutCredit - creditApplied).toFixed(2);
|
|
27
24
|
return Object.assign(Object.assign({}, order), { totalQuantity, customerDiscount: order.discountCode ? 0 : (_a = selectedCustomer === null || selectedCustomer === void 0 ? void 0 : selectedCustomer.customer) === null || _a === void 0 ? void 0 : _a.discount, productTotal: totalImportWithDiscount, taxesTotal: totalImporTaxes, total: orderTotal, creditApplied, productTotalWithoutDiscount: totalImportWithoutDiscount, totalDiscountAmount: totalDiscountAmount + discountCodeAmount, shippingServiceTotal: shippingCost, appliedOrderDiscounts });
|
|
28
25
|
}
|
|
@@ -30,4 +27,3 @@ const calculateOrderTotal = (order, selectedCustomer, storeSettings, hasShipping
|
|
|
30
27
|
throw error;
|
|
31
28
|
}
|
|
32
29
|
};
|
|
33
|
-
exports.calculateOrderTotal = calculateOrderTotal;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { IOrderProduct } from "../../interfaces/Product";
|
|
2
|
+
export declare const calculateTotalTaxesIncluded: (order: any, selectedCustomer: any, storeSettings: any, storeDiscounts: any[], appliedOrderDiscounts: any, discountCodeObj: any | null) => {
|
|
3
|
+
product: IOrderProduct;
|
|
4
|
+
qty: number;
|
|
5
|
+
productLineImportTotal: number;
|
|
6
|
+
productLineTotalWithDiscount: number;
|
|
7
|
+
productLineTaxesTotal: number;
|
|
8
|
+
lineDiscountAmount: number;
|
|
9
|
+
}[];
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.calculateTotalTaxesIncluded = void 0;
|
|
4
|
-
const helpers_1 = require("./helpers");
|
|
5
|
-
const calculateTotalTaxesIncluded = (order, selectedCustomer, storeSettings, storeDiscounts, appliedOrderDiscounts, discountCodeObj) => {
|
|
1
|
+
import { getProductTaxesPercentage } from "./helpers";
|
|
2
|
+
export const calculateTotalTaxesIncluded = (order, selectedCustomer, storeSettings, storeDiscounts, appliedOrderDiscounts, discountCodeObj) => {
|
|
6
3
|
const productTableImports = [...order.products, ...order.buyAndGetProducts].map((current) => {
|
|
7
4
|
var _a, _b;
|
|
8
5
|
let discPercentageInteger = 0;
|
|
@@ -40,7 +37,7 @@ const calculateTotalTaxesIncluded = (order, selectedCustomer, storeSettings, sto
|
|
|
40
37
|
}
|
|
41
38
|
}
|
|
42
39
|
}
|
|
43
|
-
const taxPercentage =
|
|
40
|
+
const taxPercentage = getProductTaxesPercentage(current, storeSettings);
|
|
44
41
|
const taxPercentageInteger = taxPercentage / 100;
|
|
45
42
|
const unitPrice = prodPrice / (1 + taxPercentageInteger);
|
|
46
43
|
const discountAmountPerUnit = discPercentageInteger
|
|
@@ -62,4 +59,3 @@ const calculateTotalTaxesIncluded = (order, selectedCustomer, storeSettings, sto
|
|
|
62
59
|
});
|
|
63
60
|
return productTableImports;
|
|
64
61
|
};
|
|
65
|
-
exports.calculateTotalTaxesIncluded = calculateTotalTaxesIncluded;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const calculateTotalTaxesOverPrice: (order: any, selectedCustomer: any, storeSettings: any, storeDiscounts: any[], appliedOrderDiscounts: any, discountCodeObj: any | null) => {
|
|
2
|
+
product: any;
|
|
3
|
+
qty: any;
|
|
4
|
+
productLineImportTotal: number;
|
|
5
|
+
productLineTotalWithDiscount: number;
|
|
6
|
+
productLineTaxesTotal: number;
|
|
7
|
+
lineDiscountAmount: number;
|
|
8
|
+
}[];
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const enum_1 = require("../../enum");
|
|
5
|
-
const helpers_1 = require("./helpers");
|
|
6
|
-
const calculateTotalTaxesOverPrice = (order, selectedCustomer, storeSettings, storeDiscounts, appliedOrderDiscounts, discountCodeObj) => {
|
|
1
|
+
import { BuyAndGetConditionsTypes, DiscountCodeTypes } from "../../enum";
|
|
2
|
+
import { getProductTaxesPercentage } from "./helpers";
|
|
3
|
+
export const calculateTotalTaxesOverPrice = (order, selectedCustomer, storeSettings, storeDiscounts, appliedOrderDiscounts, discountCodeObj) => {
|
|
7
4
|
const productTableImports = [...order.products, ...order.buyAndGetProducts].map((current) => {
|
|
8
5
|
var _a;
|
|
9
6
|
let discPercentageInteger = 0;
|
|
@@ -30,7 +27,7 @@ const calculateTotalTaxesOverPrice = (order, selectedCustomer, storeSettings, st
|
|
|
30
27
|
discountsToApply.forEach((discount) => (appliedOrderDiscounts[discount._id] = discount)); // it will do this for every product, if two products has the same discount it will just overwrite
|
|
31
28
|
}
|
|
32
29
|
else {
|
|
33
|
-
if (discountCodeObj.type ===
|
|
30
|
+
if (discountCodeObj.type === DiscountCodeTypes.PERCENTAGE) {
|
|
34
31
|
discPercentageInteger = +(discountCodeObj.value / 100).toFixed(2);
|
|
35
32
|
if (!discountCodeObj.applyToAllProducts) {
|
|
36
33
|
discPercentageInteger = discountCodeObj.products.includes(current._id)
|
|
@@ -38,10 +35,10 @@ const calculateTotalTaxesOverPrice = (order, selectedCustomer, storeSettings, st
|
|
|
38
35
|
: 0;
|
|
39
36
|
}
|
|
40
37
|
}
|
|
41
|
-
if (discountCodeObj.type ===
|
|
38
|
+
if (discountCodeObj.type === DiscountCodeTypes.BUY_X_GET_Y) {
|
|
42
39
|
const discountType = discountCodeObj.buyAndGetConditions[0].getDiscountType;
|
|
43
40
|
const discountValue = discountCodeObj.buyAndGetConditions[0].discountValue;
|
|
44
|
-
if (discountType ===
|
|
41
|
+
if (discountType === BuyAndGetConditionsTypes.PERCENTAGE && current.isBuyAndGetProduct) {
|
|
45
42
|
discPercentageInteger = +(discountValue / 100).toFixed(2);
|
|
46
43
|
}
|
|
47
44
|
}
|
|
@@ -53,7 +50,7 @@ const calculateTotalTaxesOverPrice = (order, selectedCustomer, storeSettings, st
|
|
|
53
50
|
//GET PRODUCT PRICE WITH DISCOUNT
|
|
54
51
|
const prodPriceWithDiscountPerUnit = prodPrice - discountAmountPerUnit;
|
|
55
52
|
//GET PRODUCT TAXES APPLIED TO FINAL PRICE PER UNIT
|
|
56
|
-
const taxPercentage =
|
|
53
|
+
const taxPercentage = getProductTaxesPercentage(current, storeSettings);
|
|
57
54
|
const taxPercentageInteger = taxPercentage / 100;
|
|
58
55
|
const prodPriceWithoutTaxesPerUnit = prodPriceWithDiscountPerUnit;
|
|
59
56
|
const taxesAmountPerUnit = prodPriceWithoutTaxesPerUnit * taxPercentageInteger;
|
|
@@ -71,4 +68,3 @@ const calculateTotalTaxesOverPrice = (order, selectedCustomer, storeSettings, st
|
|
|
71
68
|
});
|
|
72
69
|
return productTableImports;
|
|
73
70
|
};
|
|
74
|
-
exports.calculateTotalTaxesOverPrice = calculateTotalTaxesOverPrice;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ICustomer } from "../../interfaces/Customer";
|
|
2
|
+
import { IOrderProduct, ProductLineTotals } from "../../interfaces/Product";
|
|
3
|
+
import { IStore } from "../../interfaces/Store";
|
|
4
|
+
export declare const getProductTaxesPercentage: (productObj: IOrderProduct, store: IStore) => number;
|
|
5
|
+
export declare const getProductLineTotals: (productLinesTotals: ProductLineTotals[]) => {
|
|
6
|
+
totalQuantity: number;
|
|
7
|
+
totalImportWithDiscount: number;
|
|
8
|
+
totalImportWithoutDiscount: number;
|
|
9
|
+
totalImporTaxes: number;
|
|
10
|
+
totalDiscountAmount: number;
|
|
11
|
+
};
|
|
12
|
+
export declare const getShippingCost: (discountObject: any, requireShippingService: boolean, store: IStore) => number;
|
|
13
|
+
export declare const getCreditApplied: (selectedCustomer: {
|
|
14
|
+
customer: ICustomer;
|
|
15
|
+
} | undefined, orderTotal: number) => number;
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.getCreditApplied = exports.getShippingCost = exports.getProductLineTotals = exports.getProductTaxesPercentage = void 0;
|
|
4
|
-
const enum_1 = require("../../enum");
|
|
5
|
-
const getProductTaxesPercentage = (productObj, store) => {
|
|
1
|
+
import { DiscountCodeTypes } from "../../enum";
|
|
2
|
+
export const getProductTaxesPercentage = (productObj, store) => {
|
|
6
3
|
const getTaxValue = (tax, isTaxExempt) => {
|
|
7
4
|
if (!tax) {
|
|
8
5
|
// If no store tax configured, always return 0
|
|
@@ -20,8 +17,7 @@ const getProductTaxesPercentage = (productObj, store) => {
|
|
|
20
17
|
const tax3 = getTaxValue(store.taxThree, productObj.taxExemptThree);
|
|
21
18
|
return tax1 + tax2 + tax3;
|
|
22
19
|
};
|
|
23
|
-
|
|
24
|
-
const getProductLineTotals = (productLinesTotals) => {
|
|
20
|
+
export const getProductLineTotals = (productLinesTotals) => {
|
|
25
21
|
const totalQuantity = +productLinesTotals.reduce((acum, line) => acum + line.qty, 0).toFixed(2);
|
|
26
22
|
const totalImportWithDiscount = +productLinesTotals
|
|
27
23
|
.reduce((acum, line) => acum + line.productLineTotalWithDiscount, 0)
|
|
@@ -43,17 +39,15 @@ const getProductLineTotals = (productLinesTotals) => {
|
|
|
43
39
|
totalDiscountAmount
|
|
44
40
|
};
|
|
45
41
|
};
|
|
46
|
-
|
|
47
|
-
const getShippingCost = (discountObject, requireShippingService, store) => {
|
|
42
|
+
export const getShippingCost = (discountObject, requireShippingService, store) => {
|
|
48
43
|
var _a, _b;
|
|
49
44
|
const shippingCost = requireShippingService ? (_b = (_a = store === null || store === void 0 ? void 0 : store.orderPageConfig) === null || _a === void 0 ? void 0 : _a.shippingServiceCost) !== null && _b !== void 0 ? _b : 0 : 0;
|
|
50
|
-
if ((discountObject === null || discountObject === void 0 ? void 0 : discountObject.type) ===
|
|
45
|
+
if ((discountObject === null || discountObject === void 0 ? void 0 : discountObject.type) === DiscountCodeTypes.FREE_DELIVERY) {
|
|
51
46
|
return 0;
|
|
52
47
|
}
|
|
53
48
|
return shippingCost;
|
|
54
49
|
};
|
|
55
|
-
|
|
56
|
-
const getCreditApplied = (selectedCustomer, orderTotal) => {
|
|
50
|
+
export const getCreditApplied = (selectedCustomer, orderTotal) => {
|
|
57
51
|
var _a, _b;
|
|
58
52
|
const customerCredit = (_b = (_a = selectedCustomer === null || selectedCustomer === void 0 ? void 0 : selectedCustomer.customer) === null || _a === void 0 ? void 0 : _a.credit) !== null && _b !== void 0 ? _b : 0;
|
|
59
53
|
if (customerCredit === 0 || !selectedCustomer) {
|
|
@@ -61,4 +55,3 @@ const getCreditApplied = (selectedCustomer, orderTotal) => {
|
|
|
61
55
|
}
|
|
62
56
|
return Math.min(customerCredit, orderTotal);
|
|
63
57
|
};
|
|
64
|
-
exports.getCreditApplied = getCreditApplied;
|
|
@@ -1,5 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.calculateOrderTotal = void 0;
|
|
4
|
-
const calculateOrderTotal_1 = require("./calculateOrderTotal");
|
|
5
|
-
Object.defineProperty(exports, "calculateOrderTotal", { enumerable: true, get: function () { return calculateOrderTotal_1.calculateOrderTotal; } });
|
|
1
|
+
import { calculateOrderTotal } from './calculateOrderTotal';
|
|
2
|
+
export { calculateOrderTotal };
|
|
File without changes
|
|
File without changes
|