washday-sdk 1.0.1 → 1.1.0
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/README.md +126 -0
- package/babel.config.js +8 -0
- package/dist/api/attendance/delete.js +2 -0
- package/dist/api/attendance/get.js +83 -0
- package/dist/api/attendance/index.js +4 -0
- package/dist/api/attendance/post.js +39 -0
- package/dist/api/attendance/put.js +25 -0
- package/dist/api/auth/index.js +3 -0
- package/dist/api/auth/post.js +170 -0
- package/dist/api/axiosInstance.js +46 -0
- package/dist/api/cashierbox/delete.js +40 -0
- package/dist/api/cashierbox/get.js +63 -0
- package/dist/api/cashierbox/post.js +42 -0
- package/dist/api/cashierbox/put.js +42 -0
- package/dist/api/cashups/delete.js +25 -0
- package/dist/api/cashups/get.js +60 -0
- package/dist/api/cashups/index.js +4 -0
- package/dist/api/cashups/post.js +25 -0
- package/dist/api/cashups/put.js +52 -0
- package/dist/api/cfdi/delete.js +25 -0
- package/dist/api/cfdi/get.js +126 -0
- package/dist/api/cfdi/index.js +4 -0
- package/dist/api/cfdi/post.js +41 -0
- package/dist/api/cfdi/put.js +52 -0
- package/dist/api/companies/get.js +29 -0
- package/dist/api/companies/post.js +41 -0
- package/dist/api/companies/put.js +57 -0
- package/dist/api/countries/get.js +29 -0
- package/dist/api/countries/post.js +1 -0
- package/dist/api/countries/put.js +1 -0
- package/dist/api/csv/get.js +325 -0
- package/dist/api/csv/index.js +1 -0
- package/dist/api/customers/delete.js +40 -0
- package/dist/api/customers/get.js +106 -0
- package/dist/api/customers/index.js +4 -0
- package/dist/api/customers/post.js +41 -0
- package/dist/api/customers/put.js +52 -0
- package/dist/api/discounts/get.js +120 -0
- package/dist/api/discounts/post.js +40 -0
- package/dist/api/discounts/put.js +68 -0
- package/dist/api/index.js +319 -0
- package/dist/api/inventory/delete.js +26 -0
- package/dist/api/inventory/get.js +62 -0
- package/dist/api/inventory/index.js +4 -0
- package/dist/api/inventory/post.js +26 -0
- package/dist/api/inventory/put.js +41 -0
- package/dist/api/order/delete.js +40 -0
- package/dist/api/order/get.js +181 -0
- package/dist/api/order/index.js +4 -0
- package/dist/api/order/post.js +115 -0
- package/dist/api/order/put.js +202 -0
- package/dist/api/outsourcedOrders/delete.js +25 -0
- package/dist/api/outsourcedOrders/get.js +62 -0
- package/dist/api/outsourcedOrders/index.js +4 -0
- package/dist/api/outsourcedOrders/post.js +25 -0
- package/dist/api/outsourcedOrders/put.js +25 -0
- package/dist/api/partners/delete.js +25 -0
- package/dist/api/partners/get.js +40 -0
- package/dist/api/partners/index.js +4 -0
- package/dist/api/partners/post.js +25 -0
- package/dist/api/partners/put.js +25 -0
- package/dist/api/pdf/get.js +43 -0
- package/dist/api/pdf/index.js +1 -0
- package/dist/api/products/delete.js +40 -0
- package/dist/api/products/get.js +25 -0
- package/dist/api/products/index.js +4 -0
- package/dist/api/products/post.js +60 -0
- package/dist/api/products/put.js +40 -0
- package/dist/api/publics/get.js +26 -0
- package/dist/api/publics/index.js +1 -0
- package/dist/api/reports/get.js +303 -0
- package/dist/api/reports/index.js +1 -0
- package/dist/api/reviews/delete.js +15 -0
- package/dist/api/reviews/get.js +41 -0
- package/dist/api/reviews/index.js +4 -0
- package/dist/api/reviews/post.js +20 -0
- package/dist/api/reviews/put.js +52 -0
- package/dist/api/routes/delete.js +25 -0
- package/dist/api/routes/get.js +95 -0
- package/dist/api/routes/index.js +4 -0
- package/dist/api/routes/post.js +67 -0
- package/dist/api/routes/put.js +54 -0
- package/dist/api/sections/delete.js +25 -0
- package/dist/api/sections/get.js +71 -0
- package/dist/api/sections/index.js +4 -0
- package/dist/api/sections/post.js +26 -0
- package/dist/api/sections/put.js +25 -0
- package/dist/api/staff/delete.js +26 -0
- package/dist/api/staff/get.js +40 -0
- package/dist/api/staff/post.js +26 -0
- package/dist/api/staff/put.js +26 -0
- package/dist/api/stores/get.js +110 -0
- package/dist/api/stores/post.js +61 -0
- package/dist/api/stores/put.js +44 -0
- package/dist/api/stripe/get.js +1 -0
- package/dist/api/stripe/post.js +71 -0
- package/dist/api/stripe/put.js +1 -0
- package/dist/api/supplies/delete.js +26 -0
- package/dist/api/supplies/get.js +62 -0
- package/dist/api/supplies/post.js +26 -0
- package/dist/api/supplies/put.js +41 -0
- package/dist/api/users/delete.js +26 -0
- package/dist/api/users/post.js +25 -0
- package/dist/api/users/put.js +29 -0
- package/dist/enum/index.js +12 -7
- package/dist/index.js +3 -28
- package/dist/interfaces/Api.js +1 -0
- package/dist/interfaces/Apple.js +16 -0
- package/dist/interfaces/Attendance.js +1 -0
- package/dist/interfaces/Customer.js +1 -2
- package/dist/interfaces/Order.js +1 -2
- package/dist/interfaces/Permission.js +1 -2
- package/dist/interfaces/Product.js +1 -2
- package/dist/interfaces/Section.js +1 -2
- package/dist/interfaces/Store.js +1 -2
- package/dist/interfaces/StoreImage.js +1 -2
- package/dist/interfaces/User.js +1 -2
- package/dist/utils/apiUtils.js +9 -0
- package/dist/utils/index.js +2 -17
- package/dist/utils/orders/calculateOrderTotal.js +30 -21
- package/dist/utils/orders/calculateTotalTaxesIncluded.js +55 -29
- package/dist/utils/orders/calculateTotalTaxesOverPrice.js +56 -45
- package/dist/utils/orders/helpers.js +126 -17
- package/dist/utils/orders/index.js +3 -5
- package/dist/utils/receipt/generateReceiptHTML.js +157 -0
- package/dist/utils/util.js +63 -0
- package/docs/README.md +66 -0
- package/docs/examples/common-use-cases.md +487 -0
- package/docs/getting-started.md +237 -0
- package/docs/modules/attendance.md +404 -0
- package/jest.config.js +0 -0
- package/package.json +12 -4
- package/src/api/attendance/delete.ts +1 -0
- package/src/api/attendance/get.ts +81 -0
- package/src/api/attendance/index.ts +4 -0
- package/src/api/attendance/post.ts +37 -0
- package/src/api/attendance/put.ts +20 -0
- package/src/api/auth/index.ts +3 -0
- package/src/api/auth/post.ts +198 -0
- package/src/api/axiosInstance.ts +13 -3
- package/src/api/cashierbox/delete.ts +28 -0
- package/src/api/cashierbox/get.ts +53 -0
- package/src/api/cashierbox/post.ts +39 -0
- package/src/api/cashierbox/put.ts +32 -0
- package/src/api/cashups/delete.ts +15 -0
- package/src/api/cashups/get.ts +52 -0
- package/src/api/cashups/index.ts +4 -0
- package/src/api/cashups/post.ts +23 -0
- package/src/api/cashups/put.ts +53 -0
- package/src/api/cfdi/delete.ts +21 -0
- package/src/api/cfdi/get.ts +119 -0
- package/src/api/cfdi/index.ts +4 -0
- package/src/api/cfdi/post.ts +60 -0
- package/src/api/cfdi/put.ts +53 -0
- package/src/api/companies/get.ts +23 -0
- package/src/api/companies/post.ts +29 -0
- package/src/api/companies/put.ts +43 -0
- package/src/api/countries/get.ts +23 -0
- package/src/api/countries/post.ts +0 -0
- package/src/api/countries/put.ts +0 -0
- package/src/api/csv/get.ts +354 -0
- package/src/api/csv/index.ts +1 -0
- package/src/api/customers/delete.ts +29 -0
- package/src/api/customers/get.ts +83 -12
- package/src/api/customers/index.ts +4 -0
- package/src/api/customers/post.ts +48 -0
- package/src/api/customers/put.ts +68 -0
- package/src/api/discounts/get.ts +100 -0
- package/src/api/discounts/post.ts +35 -0
- package/src/api/discounts/put.ts +66 -0
- package/src/api/index.ts +320 -12
- package/src/api/inventory/delete.ts +16 -0
- package/src/api/inventory/get.ts +53 -0
- package/src/api/inventory/index.ts +4 -0
- package/src/api/inventory/post.ts +22 -0
- package/src/api/inventory/put.ts +35 -0
- package/src/api/order/delete.ts +29 -0
- package/src/api/order/get.ts +207 -0
- package/src/api/order/index.ts +4 -0
- package/src/api/order/post.ts +118 -0
- package/src/api/order/put.ts +224 -0
- package/src/api/outsourcedOrders/delete.ts +15 -0
- package/src/api/outsourcedOrders/get.ts +54 -0
- package/src/api/outsourcedOrders/index.ts +4 -0
- package/src/api/outsourcedOrders/post.ts +24 -0
- package/src/api/outsourcedOrders/put.ts +21 -0
- package/src/api/partners/delete.ts +15 -0
- package/src/api/partners/get.ts +28 -0
- package/src/api/partners/index.ts +4 -0
- package/src/api/partners/post.ts +21 -0
- package/src/api/partners/put.ts +21 -0
- package/src/api/pdf/get.ts +43 -0
- package/src/api/pdf/index.ts +1 -0
- package/src/api/products/delete.ts +28 -0
- package/src/api/products/get.ts +16 -0
- package/src/api/products/index.ts +4 -0
- package/src/api/products/post.ts +73 -0
- package/src/api/products/put.ts +49 -0
- package/src/api/publics/get.ts +16 -0
- package/src/api/publics/index.ts +1 -0
- package/src/api/reports/get.ts +329 -0
- package/src/api/reports/index.ts +1 -0
- package/src/api/reviews/delete.ts +15 -0
- package/src/api/reviews/get.ts +31 -0
- package/src/api/reviews/index.ts +4 -0
- package/src/api/reviews/post.ts +20 -0
- package/src/api/reviews/put.ts +53 -0
- package/src/api/routes/delete.ts +15 -0
- package/src/api/routes/get.ts +86 -0
- package/src/api/routes/index.ts +4 -0
- package/src/api/routes/post.ts +60 -0
- package/src/api/routes/put.ts +44 -0
- package/src/api/sections/delete.ts +15 -0
- package/src/api/sections/get.ts +67 -0
- package/src/api/sections/index.ts +4 -0
- package/src/api/sections/post.ts +22 -0
- package/src/api/sections/put.ts +23 -0
- package/src/api/staff/delete.ts +16 -0
- package/src/api/staff/get.ts +29 -0
- package/src/api/staff/post.ts +17 -0
- package/src/api/staff/put.ts +17 -0
- package/src/api/stores/get.ts +93 -0
- package/src/api/stores/post.ts +49 -0
- package/src/api/stores/put.ts +35 -0
- package/src/api/stripe/get.ts +0 -0
- package/src/api/stripe/post.ts +59 -0
- package/src/api/stripe/put.ts +0 -0
- package/src/api/supplies/delete.ts +16 -0
- package/src/api/supplies/get.ts +53 -0
- package/src/api/supplies/post.ts +26 -0
- package/src/api/supplies/put.ts +33 -0
- package/src/api/users/delete.ts +16 -0
- package/src/api/users/post.ts +18 -0
- package/src/api/users/put.ts +36 -0
- package/src/enum/index.ts +9 -1
- package/src/index.ts +1 -4
- package/src/interfaces/Api.ts +308 -0
- package/src/interfaces/Apple.ts +74 -0
- package/src/interfaces/Attendance.ts +45 -0
- package/src/interfaces/Customer.ts +15 -11
- package/src/interfaces/Order.ts +38 -1
- package/src/interfaces/Product.ts +1 -0
- package/src/interfaces/Store.ts +41 -0
- package/src/utils/apiUtils.ts +11 -0
- package/src/utils/index.ts +6 -1
- package/src/utils/orders/calculateOrderTotal.test.js +930 -0
- package/src/utils/orders/calculateOrderTotal.ts +60 -15
- package/src/utils/orders/calculateTotalTaxesIncluded.ts +57 -25
- package/src/utils/orders/calculateTotalTaxesOverPrice.ts +57 -41
- package/src/utils/orders/helpers.ts +195 -47
- package/src/utils/orders/index.ts +3 -1
- package/src/utils/receipt/generateReceiptHTML.ts +163 -0
- package/src/utils/util.ts +65 -0
- package/tsconfig.json +13 -9
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
// import moment from "moment";
|
|
2
|
+
// import { formatMoneyString, truncateOrFill } from "../util";
|
|
3
|
+
|
|
4
|
+
// export const generateReceiptThermalPrinter = (order, storeSettings, ticketStructure, charsPerLine = 32) => {
|
|
5
|
+
// //THIS STRING IS FORMED WITH THE EXPECTED USE OF react-native-thermal-receipt-printer PACKAGE
|
|
6
|
+
|
|
7
|
+
// const PAPER_LINE_LENGTH = charsPerLine;
|
|
8
|
+
// const orderProducts = order?.products || [];
|
|
9
|
+
// const orderBuyAndGerProducts = order?.buyAndGetProducts || [];
|
|
10
|
+
// const orderAllProducts = [...orderProducts, ...orderBuyAndGerProducts];
|
|
11
|
+
|
|
12
|
+
// console.log('PAPER_LINE_LENGTH', PAPER_LINE_LENGTH);
|
|
13
|
+
// const paymentLinesTotal =
|
|
14
|
+
// order.paymentLines?.reduce((prev, next) => {
|
|
15
|
+
// return prev + (next?.amountPaid || 0);
|
|
16
|
+
// }, 0) || 0;
|
|
17
|
+
|
|
18
|
+
// let headers = `
|
|
19
|
+
// ${ticketStructure.showStoreName ? `<CM>${storeSettings.name}</CM>` : ''}
|
|
20
|
+
// ${ticketStructure.showStorePhone ? `Tel: ${storeSettings.phone}` : ''}
|
|
21
|
+
// ${'-'.repeat(PAPER_LINE_LENGTH)}
|
|
22
|
+
// ${ticketStructure.showEmisionDate
|
|
23
|
+
// ? `Fecha emision: ${moment(order?.createdDate).format('DD/MM/YYYY')}`
|
|
24
|
+
// : ''
|
|
25
|
+
// }
|
|
26
|
+
// ${ticketStructure.showEmisionTime
|
|
27
|
+
// ? `Hora emision: ${moment(order?.createdDate).format('hh:mm a')}`
|
|
28
|
+
// : ''
|
|
29
|
+
// }
|
|
30
|
+
// ${ticketStructure.showCreatedByName ? `Atendio: ${order.createdBy.name}` : ''}
|
|
31
|
+
// Pedido: WD-${order.sequence}
|
|
32
|
+
// ${ticketStructure.showCustomerName ? `Cliente: ${order.customer.name}` : ''}
|
|
33
|
+
// ${ticketStructure.showDeliveryDate
|
|
34
|
+
// ? `Entrega: ${moment(order?.deliveryInfo?.date).format('DD/MM/YYYY')} ${ticketStructure.showDeliveryTime
|
|
35
|
+
// ? moment(order?.deliveryInfo?.fromTime).format('HH:mm')
|
|
36
|
+
// : ''
|
|
37
|
+
// }`
|
|
38
|
+
// : ''
|
|
39
|
+
// }
|
|
40
|
+
// ${ticketStructure.showTotalPieces ? `Piezas: ${orderAllProducts?.reduce((prev, curr) => {
|
|
41
|
+
// return prev + +curr.pieces * curr.quantity;
|
|
42
|
+
// }, 0)}` : ''}
|
|
43
|
+
// ${ticketStructure.showOrderNotes && order.notes ? `${order.notes}` : ''}
|
|
44
|
+
// `;
|
|
45
|
+
// let middle = '';
|
|
46
|
+
// //Add order products
|
|
47
|
+
// orderAllProducts.forEach(prod => {
|
|
48
|
+
// //CHARS PER LINE: 32 in 58MM PAPER
|
|
49
|
+
// const quantityFixed = truncateOrFill(
|
|
50
|
+
// `x${prod.quantity.toString()}`,
|
|
51
|
+
// 3,
|
|
52
|
+
// 'right',
|
|
53
|
+
// );
|
|
54
|
+
// const prodNameFixed = truncateOrFill(
|
|
55
|
+
// prod.name,
|
|
56
|
+
// PAPER_LINE_LENGTH - 3 - 7 - 7 - 3,
|
|
57
|
+
// 'right',
|
|
58
|
+
// );
|
|
59
|
+
// const unitPriceFixed = truncateOrFill(
|
|
60
|
+
// formatMoneyString(
|
|
61
|
+
// (order?.express ? +prod.expressPrice : +prod.price) +
|
|
62
|
+
// (+prod.extraAmount / +prod.quantity || 0),
|
|
63
|
+
// ),
|
|
64
|
+
// 7,
|
|
65
|
+
// 'left',
|
|
66
|
+
// );
|
|
67
|
+
// const totalPriceFixed = truncateOrFill(
|
|
68
|
+
// formatMoneyString(
|
|
69
|
+
// (order?.express ? +prod.expressPrice : +prod.price) * +prod.quantity +
|
|
70
|
+
// (+prod.extraAmount || 0),
|
|
71
|
+
// ),
|
|
72
|
+
// 7,
|
|
73
|
+
// 'left',
|
|
74
|
+
// );
|
|
75
|
+
// middle =
|
|
76
|
+
// middle +
|
|
77
|
+
// `${quantityFixed} ${prodNameFixed} ${unitPriceFixed} ${totalPriceFixed}\n`;
|
|
78
|
+
// });
|
|
79
|
+
|
|
80
|
+
// let footer = '';
|
|
81
|
+
// footer =
|
|
82
|
+
// footer +
|
|
83
|
+
// `\n${truncateOrFill(
|
|
84
|
+
// 'Subtotal: ' +
|
|
85
|
+
// formatMoneyString(order.productTotalWithoutDiscount || 0),
|
|
86
|
+
// PAPER_LINE_LENGTH,
|
|
87
|
+
// 'left',
|
|
88
|
+
// )}`;
|
|
89
|
+
// if (ticketStructure.showDiscounts) {
|
|
90
|
+
// footer =
|
|
91
|
+
// footer +
|
|
92
|
+
// `\n${truncateOrFill(
|
|
93
|
+
// 'Descuento: ' + formatMoneyString(order.totalDiscountAmount || 0),
|
|
94
|
+
// PAPER_LINE_LENGTH,
|
|
95
|
+
// 'left',
|
|
96
|
+
// )}`;
|
|
97
|
+
// }
|
|
98
|
+
// if (ticketStructure.showCredit) {
|
|
99
|
+
// footer =
|
|
100
|
+
// footer +
|
|
101
|
+
// `\n${truncateOrFill(
|
|
102
|
+
// 'Credito: ' + formatMoneyString(order.creditApplied || 0),
|
|
103
|
+
// PAPER_LINE_LENGTH,
|
|
104
|
+
// 'left',
|
|
105
|
+
// )}`;
|
|
106
|
+
// }
|
|
107
|
+
// if (ticketStructure.showTaxes) {
|
|
108
|
+
// footer =
|
|
109
|
+
// footer +
|
|
110
|
+
// `\n${truncateOrFill(
|
|
111
|
+
// 'Impuestos: ' + formatMoneyString(order.taxesTotal || 0),
|
|
112
|
+
// PAPER_LINE_LENGTH,
|
|
113
|
+
// 'left',
|
|
114
|
+
// )}`;
|
|
115
|
+
// }
|
|
116
|
+
// footer =
|
|
117
|
+
// footer +
|
|
118
|
+
// `${order.delivery || order.pickup
|
|
119
|
+
// ? `\n${truncateOrFill(
|
|
120
|
+
// 'Servicio a domicilio: ' +
|
|
121
|
+
// formatMoneyString(order.shippingServiceTotal || 0),
|
|
122
|
+
// PAPER_LINE_LENGTH,
|
|
123
|
+
// 'left',
|
|
124
|
+
// )}`
|
|
125
|
+
// : ''
|
|
126
|
+
// }`;
|
|
127
|
+
// footer =
|
|
128
|
+
// footer +
|
|
129
|
+
// '\n' +
|
|
130
|
+
// `${truncateOrFill(
|
|
131
|
+
// 'Total: ' + formatMoneyString(order.total || 0),
|
|
132
|
+
// PAPER_LINE_LENGTH,
|
|
133
|
+
// 'left',
|
|
134
|
+
// )}`;
|
|
135
|
+
// footer =
|
|
136
|
+
// footer +
|
|
137
|
+
// '\n' +
|
|
138
|
+
// `${truncateOrFill(
|
|
139
|
+
// 'Pago: ' + formatMoneyString(paymentLinesTotal),
|
|
140
|
+
// PAPER_LINE_LENGTH,
|
|
141
|
+
// 'left',
|
|
142
|
+
// )}`;
|
|
143
|
+
// footer =
|
|
144
|
+
// footer +
|
|
145
|
+
// '\n' +
|
|
146
|
+
// `${truncateOrFill(
|
|
147
|
+
// 'Debe: ' + ((order.total || 0) - paymentLinesTotal).toFixed(2),
|
|
148
|
+
// PAPER_LINE_LENGTH,
|
|
149
|
+
// 'left',
|
|
150
|
+
// )}`;
|
|
151
|
+
// footer = footer + `\n${'-'.repeat(PAPER_LINE_LENGTH)}\n`;
|
|
152
|
+
// // footer = footer + `${ticketStructure.showPaymentMethod ? `<C>${translatePaymentType(order.paymentMethod)}</C>\n` : ''}`
|
|
153
|
+
// footer =
|
|
154
|
+
// footer +
|
|
155
|
+
// `${ticketStructure.showLegend
|
|
156
|
+
// ? `<C>${ticketStructure.ticketLegendText}</C>`
|
|
157
|
+
// : ''
|
|
158
|
+
// }`;
|
|
159
|
+
|
|
160
|
+
// const ticket = headers + '\n' + middle + '\n' + footer;
|
|
161
|
+
|
|
162
|
+
// return ticket;
|
|
163
|
+
// }
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
|
|
2
|
+
// export function truncateOrFill(str: string, n: number, side: string = 'right') {
|
|
3
|
+
// let needSpacesQty = n - str.length;
|
|
4
|
+
// let whiteSpace = '';
|
|
5
|
+
// if (needSpacesQty > 0) {
|
|
6
|
+
// for (let i = 0; i < needSpacesQty; i++) {
|
|
7
|
+
// whiteSpace += ' ';
|
|
8
|
+
// }
|
|
9
|
+
// }
|
|
10
|
+
// return str.length > n
|
|
11
|
+
// ? str.substr(0, n - 3) + '...'
|
|
12
|
+
// : side === 'right'
|
|
13
|
+
// ? str + whiteSpace
|
|
14
|
+
// : whiteSpace + str;
|
|
15
|
+
// }
|
|
16
|
+
|
|
17
|
+
import { IAddress } from "../interfaces/Customer";
|
|
18
|
+
|
|
19
|
+
// export const formatMoneyString = (
|
|
20
|
+
// amount: string | number = 0,
|
|
21
|
+
// decimalCount: number = 2,
|
|
22
|
+
// decimal = '.',
|
|
23
|
+
// thousands = ',',
|
|
24
|
+
// currencySymbol = '$',
|
|
25
|
+
// ) => {
|
|
26
|
+
// try {
|
|
27
|
+
// decimalCount = Math.abs(decimalCount);
|
|
28
|
+
// decimalCount = isNaN(decimalCount) ? 2 : decimalCount;
|
|
29
|
+
// const negativeSign = amount < 0 ? '-' : '';
|
|
30
|
+
// let i = parseInt(
|
|
31
|
+
// (amount = Math.abs(Number(amount) || 0).toFixed(decimalCount)),
|
|
32
|
+
// ).toString();
|
|
33
|
+
// let j = i.length > 3 ? i.length % 3 : 0;
|
|
34
|
+
// return (
|
|
35
|
+
// currencySymbol +
|
|
36
|
+
// negativeSign +
|
|
37
|
+
// (j ? i.substr(0, j) + thousands : '') +
|
|
38
|
+
// i.substr(j).replace(/(\d{3})(?=\d)/g, '$1' + thousands) +
|
|
39
|
+
// (decimalCount
|
|
40
|
+
// ? decimal +
|
|
41
|
+
// Math.abs(amount - i)
|
|
42
|
+
// .toFixed(decimalCount)
|
|
43
|
+
// .slice(2)
|
|
44
|
+
// : '')
|
|
45
|
+
// );
|
|
46
|
+
// } catch (e) {
|
|
47
|
+
// console.log(e);
|
|
48
|
+
// }
|
|
49
|
+
// };
|
|
50
|
+
|
|
51
|
+
// Function to get a formatted address
|
|
52
|
+
export function getFormattedAddress(address: IAddress): string {
|
|
53
|
+
const { street, neighborhood, postalCode, city, state, country } = address;
|
|
54
|
+
|
|
55
|
+
let formatted = '';
|
|
56
|
+
|
|
57
|
+
if (street) formatted += street;
|
|
58
|
+
if (neighborhood) formatted += `, ${neighborhood}`;
|
|
59
|
+
if (city) formatted += `, ${city}`;
|
|
60
|
+
if (state) formatted += `, ${state}`;
|
|
61
|
+
if (postalCode) formatted += `, ${postalCode}`;
|
|
62
|
+
if (country) formatted += `, ${country}`;
|
|
63
|
+
|
|
64
|
+
return formatted.trim();
|
|
65
|
+
}
|
package/tsconfig.json
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
"
|
|
10
|
-
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES6",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"strict": true,
|
|
6
|
+
"esModuleInterop": true,
|
|
7
|
+
"moduleResolution": "node",
|
|
8
|
+
"outDir": "dist",
|
|
9
|
+
"skipLibCheck": true,
|
|
10
|
+
"lib": ["esnext"]
|
|
11
|
+
},
|
|
12
|
+
"include": ["src/**/*.ts"],
|
|
13
|
+
"exclude": ["node_modules"]
|
|
14
|
+
}
|