ordering-ui-react-native 0.22.12 → 0.22.13
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/package.json
CHANGED
|
@@ -61,22 +61,22 @@ export const usePrinterCommands = () => {
|
|
|
61
61
|
return formattedDate
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
const generateProductsText = (order: any) => {
|
|
64
|
+
const generateProductsText = (order: any, { endLine }: any) => {
|
|
65
65
|
const list: any = []
|
|
66
66
|
|
|
67
67
|
if (order?.products.length) {
|
|
68
68
|
order?.products.map((product: any) => {
|
|
69
|
-
list.push(`${product?.quantity} ${product?.name} \t ${parsePrice(product.total ?? getProductPrice(product))}
|
|
69
|
+
list.push(`${product?.quantity} ${product?.name} \t ${parsePrice(product.total ?? getProductPrice(product))}${endLine}`)
|
|
70
70
|
|
|
71
71
|
if (product?.ingredients?.length) {
|
|
72
|
-
list.push({ text: `\t ${t('INGREDIENTS', 'Ingredients')}
|
|
72
|
+
list.push({ text: `\t ${t('INGREDIENTS', 'Ingredients')}:${endLine}`, props: { fontSize: 10 } })
|
|
73
73
|
product?.ingredients?.map((ingredient: any) => {
|
|
74
|
-
list.push({ text: `\t ${t('NO', 'No')} ${ingredient.name}
|
|
74
|
+
list.push({ text: `\t ${t('NO', 'No')} ${ingredient.name}${endLine}` , fontSize: 10 })
|
|
75
75
|
})
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
product.options?.map((option: any) => {
|
|
79
|
-
list.push({ text: `\t ${option.name}
|
|
79
|
+
list.push({ text: `\t ${option.name}${endLine}`, props: { fontSize: 10 } })
|
|
80
80
|
|
|
81
81
|
option.suboptions?.map((suboption: any) => {
|
|
82
82
|
const { quantity, name, position, price } = suboption
|
|
@@ -87,23 +87,23 @@ export const usePrinterCommands = () => {
|
|
|
87
87
|
: `${quantity} x ${name} +${parsePrice(price)}`
|
|
88
88
|
: 'No'
|
|
89
89
|
|
|
90
|
-
list.push({ text: `\t\t ${string}
|
|
90
|
+
list.push({ text: `\t\t ${string}${endLine}`, props: { fontSize: 10 } })
|
|
91
91
|
})
|
|
92
92
|
})
|
|
93
93
|
|
|
94
94
|
if (product.comment) {
|
|
95
|
-
list.push({ text: `\t ${t('COMMENT', 'Comment')}
|
|
96
|
-
list.push({ text: `\t\t ${product.comment}
|
|
95
|
+
list.push({ text: `\t ${t('COMMENT', 'Comment')}${endLine}`, props: { fontSize: 10 } })
|
|
96
|
+
list.push({ text: `\t\t ${product.comment}${endLine}`, props: { fontSize: 10 } })
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
-
list.push('_separator_
|
|
99
|
+
list.push('_separator_')
|
|
100
100
|
})
|
|
101
101
|
}
|
|
102
102
|
|
|
103
103
|
return list
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
-
const paymethodsList = (order: any) => {
|
|
106
|
+
const paymethodsList = (order: any, { endLine }: any) => {
|
|
107
107
|
const list: any = []
|
|
108
108
|
|
|
109
109
|
if (order?.payment_events?.length > 0) {
|
|
@@ -116,7 +116,7 @@ export const usePrinterCommands = () => {
|
|
|
116
116
|
? parsePrice(order?.cash, { currency: order?.currency })
|
|
117
117
|
: `-${parsePrice(event?.amount, { currency: order?.currency })}`
|
|
118
118
|
|
|
119
|
-
list.push(`${payment} \t ${amount}
|
|
119
|
+
list.push(`${payment} \t ${amount}${endLine}`)
|
|
120
120
|
})
|
|
121
121
|
}
|
|
122
122
|
|
|
@@ -126,60 +126,61 @@ export const usePrinterCommands = () => {
|
|
|
126
126
|
const generateCommands = (order: any, printMode: string = 'append') => {
|
|
127
127
|
let commands: any = [];
|
|
128
128
|
|
|
129
|
+
const isAppendMode = printMode === 'append'
|
|
130
|
+
const jumpLine = isAppendMode ? '\n' : ' '
|
|
131
|
+
const endLine = isAppendMode ? '\n' : ''
|
|
132
|
+
|
|
129
133
|
const textProps = { fontSize: 12 }
|
|
130
134
|
|
|
131
135
|
const appends: any = [
|
|
132
|
-
{ text: `${t('ORDER_NO', 'Order No.')} ${order.id}
|
|
133
|
-
|
|
134
|
-
`${order.orderStatus}
|
|
135
|
-
{ text: `${t('ORDER_TYPE', 'Order Type')}: ${deliveryStatus[order?.delivery_type]}
|
|
136
|
-
{ text: `${t(`PAYMENT_METHOD${paymethodsLength(order) > 1 ? 'S' : ''}`, `Payment method${paymethodsLength(order) > 1 ? 's' : ''}`)}: ${handlePaymethodsListString(order)}
|
|
137
|
-
`${!!order?.delivery_option ? `${t('DELIVERY_PREFERENCE', 'Delivery Preference')}: ${t(order?.delivery_option?.name?.toUpperCase()?.replace(/ /g, '_'), order?.delivery_option?.name)}
|
|
138
|
-
`${t('DELIVERY_DATE', 'Delivery Date')}: ${deliveryDate(order)}
|
|
139
|
-
'_separator_
|
|
140
|
-
{ text: `${t('CUSTOMER_DETAILS', 'Customer details')}
|
|
141
|
-
`${t('FULL_NAME', 'Full Name')}: ${customerName(order)}
|
|
142
|
-
`${t('EMAIL', 'Email')}: ${order?.customer?.email}
|
|
143
|
-
`${!!order?.customer?.cellphone ? `${t('MOBILE_PHONE', 'Mobile Phone')}: ${order?.customer?.cellphone}
|
|
144
|
-
`${!!order?.customer?.phone ? `${t('MOBILE_PHONE', 'Mobile Phone')}: ${order?.customer?.phone}
|
|
145
|
-
`${t('FULL_ADDRESS', 'Full Addres')}: ${order?.customer?.address}
|
|
146
|
-
`${!!order?.customer?.internal_number ? `${t('INTERNAL_NUMBER', 'Internal Number')}: ${order?.customer?.internal_number}
|
|
147
|
-
`${!!order?.customer?.zipcode ? `${t('ZIPCODE', 'Zipcode')}: ${order?.customer?.zipcode}
|
|
148
|
-
'_separator_
|
|
149
|
-
{ text: `${t('BUSINESS_DETAILS', 'Business details')}
|
|
150
|
-
`${order?.business?.name}
|
|
151
|
-
`${order?.business?.email}
|
|
152
|
-
`${!!order?.business?.cellphone ? `${t('BUSINESS_PHONE', 'Business Phone')}: ${order?.business?.cellphone}
|
|
153
|
-
`${!!order?.business?.phone ? `${t('BUSINESS_PHONE', 'Business Phone')}: ${order?.business?.phone}
|
|
154
|
-
`${t('ADDRESS', 'Address')}: ${order?.business?.address}
|
|
155
|
-
`${!!order?.business?.address_notes ? `${t('SPECIAL_ADDRESS', 'Special Address')}: ${order?.business?.address_notes}
|
|
156
|
-
'_separator_
|
|
157
|
-
{ text: `${t('ORDER_DETAILS', 'Order Details')}
|
|
158
|
-
`${!!order?.comment ? `${t('ORDER_COMMENT', 'Order Comment')}: ${order?.comment}
|
|
159
|
-
...generateProductsText(order),
|
|
160
|
-
' '
|
|
161
|
-
`${t('
|
|
162
|
-
`${order?.
|
|
163
|
-
`${order?.
|
|
164
|
-
`${order?.summary?.
|
|
165
|
-
`${
|
|
166
|
-
|
|
167
|
-
'
|
|
168
|
-
|
|
169
|
-
' '
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
'\n',
|
|
174
|
-
' ',
|
|
175
|
-
'\n',
|
|
136
|
+
{ text: `${t('ORDER_NO', 'Order No.')} ${order.id}${endLine}`, props: { fontSize: 16 } },
|
|
137
|
+
jumpLine,
|
|
138
|
+
`${order.orderStatus}${endLine}`,
|
|
139
|
+
{ text: `${t('ORDER_TYPE', 'Order Type')}: ${deliveryStatus[order?.delivery_type]}${endLine}`, props: { fontSize: 14 } },
|
|
140
|
+
{ text: `${t(`PAYMENT_METHOD${paymethodsLength(order) > 1 ? 'S' : ''}`, `Payment method${paymethodsLength(order) > 1 ? 's' : ''}`)}: ${handlePaymethodsListString(order)}${endLine}`, props: { fontSize: 14 } },
|
|
141
|
+
`${!!order?.delivery_option ? `${t('DELIVERY_PREFERENCE', 'Delivery Preference')}: ${t(order?.delivery_option?.name?.toUpperCase()?.replace(/ /g, '_'), order?.delivery_option?.name)}${endLine}` : ''}`,
|
|
142
|
+
`${t('DELIVERY_DATE', 'Delivery Date')}: ${deliveryDate(order)}${endLine}`,
|
|
143
|
+
'_separator_',
|
|
144
|
+
{ text: `${t('CUSTOMER_DETAILS', 'Customer details')}${endLine}`, props: { fontSize: 14 } },
|
|
145
|
+
`${t('FULL_NAME', 'Full Name')}: ${customerName(order)}${endLine}`,
|
|
146
|
+
`${t('EMAIL', 'Email')}: ${order?.customer?.email}${endLine}`,
|
|
147
|
+
`${!!order?.customer?.cellphone ? `${t('MOBILE_PHONE', 'Mobile Phone')}: ${order?.customer?.cellphone}${endLine}` : ''}`,
|
|
148
|
+
`${!!order?.customer?.phone ? `${t('MOBILE_PHONE', 'Mobile Phone')}: ${order?.customer?.phone}${endLine}` : ''}`,
|
|
149
|
+
`${t('FULL_ADDRESS', 'Full Addres')}: ${order?.customer?.address}${endLine}`,
|
|
150
|
+
`${!!order?.customer?.internal_number ? `${t('INTERNAL_NUMBER', 'Internal Number')}: ${order?.customer?.internal_number}${endLine}` : ''}`,
|
|
151
|
+
`${!!order?.customer?.zipcode ? `${t('ZIPCODE', 'Zipcode')}: ${order?.customer?.zipcode}${endLine}` : ''}`,
|
|
152
|
+
'_separator_',
|
|
153
|
+
{ text: `${t('BUSINESS_DETAILS', 'Business details')}${endLine}`, props: { fontSize: 14 } },
|
|
154
|
+
`${order?.business?.name}${endLine}`,
|
|
155
|
+
`${order?.business?.email}${endLine}`,
|
|
156
|
+
`${!!order?.business?.cellphone ? `${t('BUSINESS_PHONE', 'Business Phone')}: ${order?.business?.cellphone}${endLine}` : ''}`,
|
|
157
|
+
`${!!order?.business?.phone ? `${t('BUSINESS_PHONE', 'Business Phone')}: ${order?.business?.phone}${endLine}` : ''}`,
|
|
158
|
+
`${t('ADDRESS', 'Address')}: ${order?.business?.address}${endLine}`,
|
|
159
|
+
`${!!order?.business?.address_notes ? `${t('SPECIAL_ADDRESS', 'Special Address')}: ${order?.business?.address_notes}${endLine}` : ''}`,
|
|
160
|
+
'_separator_',
|
|
161
|
+
{ text: `${t('ORDER_DETAILS', 'Order Details')}${endLine}`, props: { fontSize: 14 } },
|
|
162
|
+
`${!!order?.comment ? `${t('ORDER_COMMENT', 'Order Comment')}: ${order?.comment}${endLine}` : ''}`,
|
|
163
|
+
...generateProductsText(order, { endLine }),
|
|
164
|
+
`${t('SUBTOTAL', 'Subtotal')} \t\t ${parsePrice(order.tax_type === 1 ? (order?.summary?.subtotal + order?.summary?.tax) ?? 0 : order?.summary?.subtotal ?? 0)}${endLine}`,
|
|
165
|
+
`${order?.summary?.discount > 0 ? `${order?.offer_type === 1 ? `${t('DISCOUNT', 'Discount')} (${verifyDecimals(order?.offer_rate, parsePrice)}%)${endLine}` : t('DISCOUNT', 'Discount')} \t\t ${parsePrice(order?.summary?.discount)}${endLine}` : ''}`,
|
|
166
|
+
`${order?.tax_type !== 1 ? `${t('TAX', 'Tax')} (${verifyDecimals(order?.summary?.tax_rate, parseNumber)}%) \t\t ${parsePrice(order?.summary?.tax ?? 0)}${endLine}` : ''}`,
|
|
167
|
+
`${order?.summary?.delivery_price > 0 && order.delivery_type !== 2 ? `${t('DELIVERY_FEE', 'Delivery Fee')} \t\t ${parsePrice(order?.summary?.delivery_price ?? 0)}${endLine}` : ''}`,
|
|
168
|
+
`${(order?.summary?.driver_tip > 0 || order?.driver_tip > 0) && order.delivery_type !== 2 ? `${t('DRIVER_TIP', 'Driver tip')} ${percentTip(order) ? `(${percentTip(order)}%)` : ''} \t\t ${parsePrice(order?.summary?.driver_tip ?? 0)}${endLine}` : ''}`,
|
|
169
|
+
`${order?.summary?.service_fee > 0 ? `${t('SERVICE_FEE', 'Service Fee')} (${verifyDecimals(order?.summary?.service_fee, parseNumber)}%) \t\t ${parsePrice(order?.summary?.service_fee ?? 0)}${endLine}` : ''}`,
|
|
170
|
+
'_separator_',
|
|
171
|
+
`${t('TOTAL', 'Total')} \t\t ${parsePrice(order?.summary?.total ?? 0)}${endLine}`,
|
|
172
|
+
jumpLine,
|
|
173
|
+
`${order?.payment_events?.length > 0 ? `${t('PAYMENTS', 'Payments')}${endLine}` : ''}`,
|
|
174
|
+
...paymethodsList(order, { endLine }),
|
|
175
|
+
jumpLine,
|
|
176
|
+
jumpLine,
|
|
176
177
|
]
|
|
177
178
|
|
|
178
179
|
commands = [
|
|
179
180
|
...commands,
|
|
180
181
|
...appends.map((append: any) => {
|
|
181
182
|
return append === '_separator_'
|
|
182
|
-
? { [printMode]:
|
|
183
|
+
? { [printMode]: `---------------------------------------${endLine}` }
|
|
183
184
|
: {
|
|
184
185
|
[printMode]: append?.text ?? append,
|
|
185
186
|
...textProps,
|