@aglyn/plugins-commerce 1.0.0-beta.285 → 1.0.0-beta.288

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.
Files changed (430) hide show
  1. package/README.md +1 -1
  2. package/package.json +13 -13
  3. package/src/lib/components/cart.js +25 -12
  4. package/src/lib/components/cart.js.map +1 -1
  5. package/src/lib/components/commerce-console-page.js +70 -13
  6. package/src/lib/components/commerce-console-page.js.map +1 -1
  7. package/src/lib/components/console/order-detail-dialog.component.js +2 -1
  8. package/src/lib/components/console/order-detail-dialog.component.js.map +1 -1
  9. package/src/lib/components/console/order-webhooks-card.component.js +1 -1
  10. package/src/lib/components/console/order-webhooks-card.component.js.map +1 -1
  11. package/src/lib/components/console/payment-methods-card.component.js +1 -1
  12. package/src/lib/components/console/payment-methods-card.component.js.map +1 -1
  13. package/src/lib/components/console/pos/pos-cart-panel.component.d.ts +5 -0
  14. package/src/lib/components/console/pos/pos-cart-panel.component.js +18 -12
  15. package/src/lib/components/console/pos/pos-cart-panel.component.js.map +1 -1
  16. package/src/lib/components/console/pos/pos-hardware-api.d.ts +76 -5
  17. package/src/lib/components/console/pos/pos-hardware-api.js +53 -11
  18. package/src/lib/components/console/pos/pos-hardware-api.js.map +1 -1
  19. package/src/lib/components/console/pos/pos-hardware-buyer.component.d.ts +18 -0
  20. package/src/lib/components/console/pos/pos-hardware-buyer.component.js +629 -0
  21. package/src/lib/components/console/pos/pos-hardware-buyer.component.js.map +1 -0
  22. package/src/lib/components/console/pos/pos-hardware-sale-api.d.ts +162 -0
  23. package/src/lib/components/console/pos/pos-hardware-sale-api.js +122 -0
  24. package/src/lib/components/console/pos/pos-hardware-sale-api.js.map +1 -0
  25. package/src/lib/components/console/pos/pos-hardware-sale-terms.component.d.ts +39 -0
  26. package/src/lib/components/console/pos/pos-hardware-sale-terms.component.js +251 -0
  27. package/src/lib/components/console/pos/pos-hardware-sale-terms.component.js.map +1 -0
  28. package/src/lib/components/console/pos/use-pos-display.js +50 -0
  29. package/src/lib/components/console/pos/use-pos-display.js.map +1 -1
  30. package/src/lib/components/console/pos-cellular-control.component.d.ts +41 -0
  31. package/src/lib/components/console/pos-cellular-control.component.js +211 -0
  32. package/src/lib/components/console/pos-cellular-control.component.js.map +1 -0
  33. package/src/lib/components/console/pos-devices-card.component.d.ts +9 -1
  34. package/src/lib/components/console/pos-devices-card.component.js +47 -15
  35. package/src/lib/components/console/pos-devices-card.component.js.map +1 -1
  36. package/src/lib/components/console/pos-display/pos-display-api.d.ts +6 -0
  37. package/src/lib/components/console/pos-display/pos-display-api.js +8 -1
  38. package/src/lib/components/console/pos-display/pos-display-api.js.map +1 -1
  39. package/src/lib/components/console/pos-display-page.component.d.ts +13 -0
  40. package/src/lib/components/console/pos-display-page.component.js +44 -2
  41. package/src/lib/components/console/pos-display-page.component.js.map +1 -1
  42. package/src/lib/components/console/pos-hardware-card.component.d.ts +12 -4
  43. package/src/lib/components/console/pos-hardware-card.component.js +157 -36
  44. package/src/lib/components/console/pos-hardware-card.component.js.map +1 -1
  45. package/src/lib/components/console/pos-hardware-orders-staff-page.component.js +360 -80
  46. package/src/lib/components/console/pos-hardware-orders-staff-page.component.js.map +1 -1
  47. package/src/lib/components/console/pos-hardware-terms-page.component.d.ts +34 -0
  48. package/src/lib/components/console/pos-hardware-terms-page.component.js +257 -0
  49. package/src/lib/components/console/pos-hardware-terms-page.component.js.map +1 -0
  50. package/src/lib/components/console/pos-hardware-terms-sign-page.component.d.ts +27 -0
  51. package/src/lib/components/console/pos-hardware-terms-sign-page.component.js +104 -0
  52. package/src/lib/components/console/pos-hardware-terms-sign-page.component.js.map +1 -0
  53. package/src/lib/components/console/pos-hardware-waiting-card.component.d.ts +24 -0
  54. package/src/lib/components/console/pos-hardware-waiting-card.component.js +205 -0
  55. package/src/lib/components/console/pos-hardware-waiting-card.component.js.map +1 -0
  56. package/src/lib/components/console/pos-ops/pos-check-in-dialog.component.js +297 -201
  57. package/src/lib/components/console/pos-ops/pos-check-in-dialog.component.js.map +1 -1
  58. package/src/lib/components/console/pos-ops/pos-check-ins-card.component.d.ts +3 -0
  59. package/src/lib/components/console/pos-ops/pos-check-ins-card.component.js +260 -92
  60. package/src/lib/components/console/pos-ops/pos-check-ins-card.component.js.map +1 -1
  61. package/src/lib/components/console/pos-ops/pos-operations-bar.component.d.ts +9 -0
  62. package/src/lib/components/console/pos-ops/pos-operations-bar.component.js +15 -6
  63. package/src/lib/components/console/pos-ops/pos-operations-bar.component.js.map +1 -1
  64. package/src/lib/components/console/pos-ops/pos-rain-check-dialog.component.d.ts +25 -0
  65. package/src/lib/components/console/pos-ops/pos-rain-check-dialog.component.js +136 -0
  66. package/src/lib/components/console/pos-ops/pos-rain-check-dialog.component.js.map +1 -0
  67. package/src/lib/components/console/pos-ops/pos-shift-panel.component.d.ts +6 -0
  68. package/src/lib/components/console/pos-ops/pos-shift-panel.component.js +48 -31
  69. package/src/lib/components/console/pos-ops/pos-shift-panel.component.js.map +1 -1
  70. package/src/lib/components/console/pos-page.component.d.ts +1 -1
  71. package/src/lib/components/console/pos-page.component.js +63 -12
  72. package/src/lib/components/console/pos-page.component.js.map +1 -1
  73. package/src/lib/components/console/pos-reader-splash-setting.component.js +1 -1
  74. package/src/lib/components/console/pos-reader-splash-setting.component.js.map +1 -1
  75. package/src/lib/components/console/product-check-in-fields.component.d.ts +4 -2
  76. package/src/lib/components/console/product-check-in-fields.component.js +60 -14
  77. package/src/lib/components/console/product-check-in-fields.component.js.map +1 -1
  78. package/src/lib/components/console/product-editor-dialog.component.js +44 -1
  79. package/src/lib/components/console/product-editor-dialog.component.js.map +1 -1
  80. package/src/lib/components/console/product-hardware-sku-field.component.d.ts +19 -0
  81. package/src/lib/components/console/product-hardware-sku-field.component.js +92 -0
  82. package/src/lib/components/console/product-hardware-sku-field.component.js.map +1 -0
  83. package/src/lib/components/console/product-kiosk-offer-field.component.d.ts +22 -0
  84. package/src/lib/components/console/product-kiosk-offer-field.component.js +94 -0
  85. package/src/lib/components/console/product-kiosk-offer-field.component.js.map +1 -0
  86. package/src/lib/components/console/product-register-fields.component.d.ts +4 -0
  87. package/src/lib/components/console/product-register-fields.component.js +31 -2
  88. package/src/lib/components/console/product-register-fields.component.js.map +1 -1
  89. package/src/lib/components/console/products-hub-card.component.js +11 -2
  90. package/src/lib/components/console/products-hub-card.component.js.map +1 -1
  91. package/src/lib/components/console/register-hardware-card.component.d.ts +11 -0
  92. package/src/lib/components/console/register-hardware-card.component.js +56 -27
  93. package/src/lib/components/console/register-hardware-card.component.js.map +1 -1
  94. package/src/lib/components/console/reservation-guests-dialog.component.d.ts +28 -0
  95. package/src/lib/components/console/reservation-guests-dialog.component.js +189 -0
  96. package/src/lib/components/console/reservation-guests-dialog.component.js.map +1 -0
  97. package/src/lib/components/console/reservations-card.component.d.ts +9 -0
  98. package/src/lib/components/console/reservations-card.component.js +158 -23
  99. package/src/lib/components/console/reservations-card.component.js.map +1 -1
  100. package/src/lib/components/console/shippingeasy-card.component.js +1 -1
  101. package/src/lib/components/console/shippingeasy-card.component.js.map +1 -1
  102. package/src/lib/components/console/shipstation-card.component.d.ts +1 -1
  103. package/src/lib/components/console/shipstation-card.component.js +3 -3
  104. package/src/lib/components/console/shipstation-card.component.js.map +1 -1
  105. package/src/lib/components/product-detail.d.ts +4 -0
  106. package/src/lib/components/product-detail.js +40 -5
  107. package/src/lib/components/product-detail.js.map +1 -1
  108. package/src/lib/components/product-reviews.js +28 -11
  109. package/src/lib/components/product-reviews.js.map +1 -1
  110. package/src/lib/components/reservation-widget.js +28 -5
  111. package/src/lib/components/reservation-widget.js.map +1 -1
  112. package/src/lib/components/use-day-picker.d.ts +25 -0
  113. package/src/lib/components/use-day-picker.js +57 -0
  114. package/src/lib/components/use-day-picker.js.map +1 -0
  115. package/src/lib/constants/operator-alerts.d.ts +55 -0
  116. package/src/lib/constants/operator-alerts.js +156 -1
  117. package/src/lib/constants/operator-alerts.js.map +1 -1
  118. package/src/lib/declarations.console-server.js +54 -1
  119. package/src/lib/declarations.console-server.js.map +1 -1
  120. package/src/lib/declarations.d.ts +4 -2
  121. package/src/lib/declarations.js +15 -4
  122. package/src/lib/declarations.js.map +1 -1
  123. package/src/lib/declarations.server.js +9 -0
  124. package/src/lib/declarations.server.js.map +1 -1
  125. package/src/lib/model/commerce-cart.d.ts +9 -1
  126. package/src/lib/model/commerce-cart.js +4 -3
  127. package/src/lib/model/commerce-cart.js.map +1 -1
  128. package/src/lib/model/commerce-check-in-product.d.ts +26 -0
  129. package/src/lib/model/commerce-check-in-product.js +64 -2
  130. package/src/lib/model/commerce-check-in-product.js.map +1 -1
  131. package/src/lib/model/commerce-check-in-record.d.ts +127 -0
  132. package/src/lib/model/commerce-check-in-record.js +36 -0
  133. package/src/lib/model/commerce-check-in-record.js.map +1 -0
  134. package/src/lib/model/commerce-check-in.d.ts +91 -87
  135. package/src/lib/model/commerce-check-in.js +186 -62
  136. package/src/lib/model/commerce-check-in.js.map +1 -1
  137. package/src/lib/model/commerce-kiosk-offer.d.ts +31 -0
  138. package/src/lib/model/commerce-kiosk-offer.js +35 -0
  139. package/src/lib/model/commerce-kiosk-offer.js.map +1 -0
  140. package/src/lib/model/commerce-orders.d.ts +76 -0
  141. package/src/lib/model/commerce-orders.js +6 -0
  142. package/src/lib/model/commerce-orders.js.map +1 -1
  143. package/src/lib/model/commerce-pos-day-report.d.ts +54 -1
  144. package/src/lib/model/commerce-pos-day-report.js +39 -2
  145. package/src/lib/model/commerce-pos-day-report.js.map +1 -1
  146. package/src/lib/model/commerce-pos-offline.d.ts +1 -1
  147. package/src/lib/model/commerce-pos-offline.js +6 -1
  148. package/src/lib/model/commerce-pos-offline.js.map +1 -1
  149. package/src/lib/model/commerce-pos-ops.js +3 -2
  150. package/src/lib/model/commerce-pos-ops.js.map +1 -1
  151. package/src/lib/model/commerce-pos.d.ts +36 -3
  152. package/src/lib/model/commerce-pos.js +14 -6
  153. package/src/lib/model/commerce-pos.js.map +1 -1
  154. package/src/lib/model/commerce-receipt.js +3 -2
  155. package/src/lib/model/commerce-receipt.js.map +1 -1
  156. package/src/lib/model/commerce-reservations.d.ts +69 -4
  157. package/src/lib/model/commerce-reservations.js +57 -5
  158. package/src/lib/model/commerce-reservations.js.map +1 -1
  159. package/src/lib/model/commerce.d.ts +66 -0
  160. package/src/lib/model/commerce.js +15 -0
  161. package/src/lib/model/commerce.js.map +1 -1
  162. package/src/lib/model/order-list-fields.d.ts +11 -0
  163. package/src/lib/model/order-list-fields.js +17 -1
  164. package/src/lib/model/order-list-fields.js.map +1 -1
  165. package/src/lib/model/own-store-tax-summary.d.ts +152 -0
  166. package/src/lib/model/own-store-tax-summary.js +288 -0
  167. package/src/lib/model/own-store-tax-summary.js.map +1 -0
  168. package/src/lib/model/plugin-permissions.d.ts +74 -0
  169. package/src/lib/model/plugin-permissions.js +224 -7
  170. package/src/lib/model/plugin-permissions.js.map +1 -1
  171. package/src/lib/model/pos-cellular.d.ts +223 -0
  172. package/src/lib/model/pos-cellular.js +293 -0
  173. package/src/lib/model/pos-cellular.js.map +1 -0
  174. package/src/lib/model/pos-hardware-in-person.d.ts +98 -0
  175. package/src/lib/model/pos-hardware-in-person.js +224 -0
  176. package/src/lib/model/pos-hardware-in-person.js.map +1 -0
  177. package/src/lib/model/pos-hardware-tax-summary.d.ts +166 -0
  178. package/src/lib/model/pos-hardware-tax-summary.js +225 -0
  179. package/src/lib/model/pos-hardware-tax-summary.js.map +1 -0
  180. package/src/lib/model/pos-hardware-terms.d.ts +74 -0
  181. package/src/lib/model/pos-hardware-terms.js +115 -0
  182. package/src/lib/model/pos-hardware-terms.js.map +1 -0
  183. package/src/lib/model/pos-hardware.d.ts +349 -7
  184. package/src/lib/model/pos-hardware.js +291 -20
  185. package/src/lib/model/pos-hardware.js.map +1 -1
  186. package/src/lib/model/product-write.d.ts +10 -0
  187. package/src/lib/model/product-write.js +4 -2
  188. package/src/lib/model/product-write.js.map +1 -1
  189. package/src/lib/model/workspace-site-permissions.d.ts +26 -0
  190. package/src/lib/model/workspace-site-permissions.js +81 -0
  191. package/src/lib/model/workspace-site-permissions.js.map +1 -0
  192. package/src/lib/plugin.js +16 -0
  193. package/src/lib/plugin.js.map +1 -1
  194. package/src/lib/server/billing-webhook.js +25 -1
  195. package/src/lib/server/billing-webhook.js.map +1 -1
  196. package/src/lib/server/cancel-order.js +7 -5
  197. package/src/lib/server/cancel-order.js.map +1 -1
  198. package/src/lib/server/cart-checkout.js +20 -8
  199. package/src/lib/server/cart-checkout.js.map +1 -1
  200. package/src/lib/server/cart.js +29 -0
  201. package/src/lib/server/cart.js.map +1 -1
  202. package/src/lib/server/checkout.js +42 -13
  203. package/src/lib/server/checkout.js.map +1 -1
  204. package/src/lib/server/collection-membership.d.ts +4 -0
  205. package/src/lib/server/collection-membership.js +5 -10
  206. package/src/lib/server/collection-membership.js.map +1 -1
  207. package/src/lib/server/commerce-site-keys.d.ts +48 -0
  208. package/src/lib/server/commerce-site-keys.js +61 -0
  209. package/src/lib/server/commerce-site-keys.js.map +1 -0
  210. package/src/lib/server/draft-order.js +8 -5
  211. package/src/lib/server/draft-order.js.map +1 -1
  212. package/src/lib/server/fulfill-order.js +7 -5
  213. package/src/lib/server/fulfill-order.js.map +1 -1
  214. package/src/lib/server/gift-cards.js +8 -5
  215. package/src/lib/server/gift-cards.js.map +1 -1
  216. package/src/lib/server/local-fulfillment-status.js +9 -6
  217. package/src/lib/server/local-fulfillment-status.js.map +1 -1
  218. package/src/lib/server/member-post.js +6 -5
  219. package/src/lib/server/member-post.js.map +1 -1
  220. package/src/lib/server/membership-admin-password.d.ts +4 -2
  221. package/src/lib/server/membership-admin-password.js +10 -8
  222. package/src/lib/server/membership-admin-password.js.map +1 -1
  223. package/src/lib/server/membership-admin-remove.d.ts +7 -5
  224. package/src/lib/server/membership-admin-remove.js +9 -9
  225. package/src/lib/server/membership-admin-remove.js.map +1 -1
  226. package/src/lib/server/order-notifications.js +5 -2
  227. package/src/lib/server/order-notifications.js.map +1 -1
  228. package/src/lib/server/order-print.js +7 -5
  229. package/src/lib/server/order-print.js.map +1 -1
  230. package/src/lib/server/order-receipt-send.js +8 -5
  231. package/src/lib/server/order-receipt-send.js.map +1 -1
  232. package/src/lib/server/order-webhooks.js +8 -8
  233. package/src/lib/server/order-webhooks.js.map +1 -1
  234. package/src/lib/server/orders-shipping-prepare.js +9 -6
  235. package/src/lib/server/orders-shipping-prepare.js.map +1 -1
  236. package/src/lib/server/own-store-tax-return-source.d.ts +47 -0
  237. package/src/lib/server/own-store-tax-return-source.js +312 -0
  238. package/src/lib/server/own-store-tax-return-source.js.map +1 -0
  239. package/src/lib/server/payment-methods.js +13 -9
  240. package/src/lib/server/payment-methods.js.map +1 -1
  241. package/src/lib/server/pos-auth.d.ts +37 -6
  242. package/src/lib/server/pos-auth.js +40 -15
  243. package/src/lib/server/pos-auth.js.map +1 -1
  244. package/src/lib/server/pos-cellular-billing.d.ts +81 -0
  245. package/src/lib/server/pos-cellular-billing.js +711 -0
  246. package/src/lib/server/pos-cellular-billing.js.map +1 -0
  247. package/src/lib/server/pos-cellular-notify.d.ts +47 -0
  248. package/src/lib/server/pos-cellular-notify.js +150 -0
  249. package/src/lib/server/pos-cellular-notify.js.map +1 -0
  250. package/src/lib/server/pos-cellular.d.ts +88 -0
  251. package/src/lib/server/pos-cellular.js +339 -0
  252. package/src/lib/server/pos-cellular.js.map +1 -0
  253. package/src/lib/server/pos-check-in.d.ts +5 -1
  254. package/src/lib/server/pos-check-in.js +296 -28
  255. package/src/lib/server/pos-check-in.js.map +1 -1
  256. package/src/lib/server/pos-day-report.js +29 -3
  257. package/src/lib/server/pos-day-report.js.map +1 -1
  258. package/src/lib/server/pos-display.d.ts +16 -0
  259. package/src/lib/server/pos-display.js +129 -2
  260. package/src/lib/server/pos-display.js.map +1 -1
  261. package/src/lib/server/pos-hardware-admin.d.ts +10 -1
  262. package/src/lib/server/pos-hardware-admin.js +250 -84
  263. package/src/lib/server/pos-hardware-admin.js.map +1 -1
  264. package/src/lib/server/pos-hardware-attach.d.ts +105 -0
  265. package/src/lib/server/pos-hardware-attach.js +443 -0
  266. package/src/lib/server/pos-hardware-attach.js.map +1 -0
  267. package/src/lib/server/pos-hardware-buyer-lookup.d.ts +58 -0
  268. package/src/lib/server/pos-hardware-buyer-lookup.js +180 -0
  269. package/src/lib/server/pos-hardware-buyer-lookup.js.map +1 -0
  270. package/src/lib/server/pos-hardware-buyer-record.d.ts +29 -0
  271. package/src/lib/server/pos-hardware-buyer-record.js +86 -0
  272. package/src/lib/server/pos-hardware-buyer-record.js.map +1 -0
  273. package/src/lib/server/pos-hardware-cancel.d.ts +58 -0
  274. package/src/lib/server/pos-hardware-cancel.js +147 -0
  275. package/src/lib/server/pos-hardware-cancel.js.map +1 -0
  276. package/src/lib/server/pos-hardware-closure-notices.d.ts +27 -0
  277. package/src/lib/server/pos-hardware-closure-notices.js +85 -0
  278. package/src/lib/server/pos-hardware-closure-notices.js.map +1 -0
  279. package/src/lib/server/pos-hardware-closure.d.ts +60 -0
  280. package/src/lib/server/pos-hardware-closure.js +153 -0
  281. package/src/lib/server/pos-hardware-closure.js.map +1 -0
  282. package/src/lib/server/pos-hardware-in-person.d.ts +61 -0
  283. package/src/lib/server/pos-hardware-in-person.js +236 -0
  284. package/src/lib/server/pos-hardware-in-person.js.map +1 -0
  285. package/src/lib/server/pos-hardware-notify.d.ts +40 -2
  286. package/src/lib/server/pos-hardware-notify.js +195 -14
  287. package/src/lib/server/pos-hardware-notify.js.map +1 -1
  288. package/src/lib/server/pos-hardware-readers.d.ts +115 -0
  289. package/src/lib/server/pos-hardware-readers.js +430 -0
  290. package/src/lib/server/pos-hardware-readers.js.map +1 -0
  291. package/src/lib/server/pos-hardware-returns.d.ts +116 -0
  292. package/src/lib/server/pos-hardware-returns.js +502 -0
  293. package/src/lib/server/pos-hardware-returns.js.map +1 -0
  294. package/src/lib/server/pos-hardware-sale-fields.d.ts +28 -0
  295. package/src/lib/server/pos-hardware-sale-fields.js +44 -0
  296. package/src/lib/server/pos-hardware-sale-fields.js.map +1 -0
  297. package/src/lib/server/pos-hardware-sale.d.ts +54 -0
  298. package/src/lib/server/pos-hardware-sale.js +369 -0
  299. package/src/lib/server/pos-hardware-sale.js.map +1 -0
  300. package/src/lib/server/pos-hardware-tax-return-source.d.ts +99 -0
  301. package/src/lib/server/pos-hardware-tax-return-source.js +462 -0
  302. package/src/lib/server/pos-hardware-tax-return-source.js.map +1 -0
  303. package/src/lib/server/pos-hardware-terms.d.ts +64 -0
  304. package/src/lib/server/pos-hardware-terms.js +154 -0
  305. package/src/lib/server/pos-hardware-terms.js.map +1 -0
  306. package/src/lib/server/pos-hardware-user-eraser.d.ts +3 -0
  307. package/src/lib/server/pos-hardware-user-eraser.js +31 -7
  308. package/src/lib/server/pos-hardware-user-eraser.js.map +1 -1
  309. package/src/lib/server/pos-hardware-webhook.d.ts +5 -0
  310. package/src/lib/server/pos-hardware-webhook.js +51 -6
  311. package/src/lib/server/pos-hardware-webhook.js.map +1 -1
  312. package/src/lib/server/pos-hardware.d.ts +74 -1
  313. package/src/lib/server/pos-hardware.js +175 -10
  314. package/src/lib/server/pos-hardware.js.map +1 -1
  315. package/src/lib/server/pos-kiosk.d.ts +2 -0
  316. package/src/lib/server/pos-kiosk.js +17 -12
  317. package/src/lib/server/pos-kiosk.js.map +1 -1
  318. package/src/lib/server/pos-offline-card-order.d.ts +64 -0
  319. package/src/lib/server/pos-offline-card-order.js +102 -0
  320. package/src/lib/server/pos-offline-card-order.js.map +1 -0
  321. package/src/lib/server/pos-offline-card-reconcile.d.ts +67 -1
  322. package/src/lib/server/pos-offline-card-reconcile.js +215 -18
  323. package/src/lib/server/pos-offline-card-reconcile.js.map +1 -1
  324. package/src/lib/server/pos-offline-sync.d.ts +39 -0
  325. package/src/lib/server/pos-offline-sync.js +190 -55
  326. package/src/lib/server/pos-offline-sync.js.map +1 -1
  327. package/src/lib/server/pos-ops-gate.d.ts +28 -9
  328. package/src/lib/server/pos-ops-gate.js +50 -19
  329. package/src/lib/server/pos-ops-gate.js.map +1 -1
  330. package/src/lib/server/pos-ops-routes.js +24 -0
  331. package/src/lib/server/pos-ops-routes.js.map +1 -1
  332. package/src/lib/server/pos-order-refund-ids.d.ts +28 -0
  333. package/src/lib/server/pos-order-refund-ids.js +31 -0
  334. package/src/lib/server/pos-order-refund-ids.js.map +1 -0
  335. package/src/lib/server/pos-order.js +52 -49
  336. package/src/lib/server/pos-order.js.map +1 -1
  337. package/src/lib/server/pos-payment.js +1 -1
  338. package/src/lib/server/pos-payment.js.map +1 -1
  339. package/src/lib/server/pos-reader-splash-admin.js +30 -32
  340. package/src/lib/server/pos-reader-splash-admin.js.map +1 -1
  341. package/src/lib/server/pos-reader-splash-images-route.d.ts +17 -0
  342. package/src/lib/server/pos-reader-splash-images-route.js +113 -0
  343. package/src/lib/server/pos-reader-splash-images-route.js.map +1 -0
  344. package/src/lib/server/pos-reader-splash-images.d.ts +51 -0
  345. package/src/lib/server/pos-reader-splash-images.js +123 -0
  346. package/src/lib/server/pos-reader-splash-images.js.map +1 -0
  347. package/src/lib/server/pos-reader-splash.d.ts +68 -1
  348. package/src/lib/server/pos-reader-splash.js +182 -11
  349. package/src/lib/server/pos-reader-splash.js.map +1 -1
  350. package/src/lib/server/pos-readers.d.ts +29 -0
  351. package/src/lib/server/pos-readers.js +134 -35
  352. package/src/lib/server/pos-readers.js.map +1 -1
  353. package/src/lib/server/pos-refund-authority.d.ts +3 -1
  354. package/src/lib/server/pos-refund-authority.js +3 -2
  355. package/src/lib/server/pos-refund-authority.js.map +1 -1
  356. package/src/lib/server/pos-return.d.ts +10 -0
  357. package/src/lib/server/pos-return.js +29 -7
  358. package/src/lib/server/pos-return.js.map +1 -1
  359. package/src/lib/server/pos-sale.js +6 -1
  360. package/src/lib/server/pos-sale.js.map +1 -1
  361. package/src/lib/server/pos-shift.js +11 -0
  362. package/src/lib/server/pos-shift.js.map +1 -1
  363. package/src/lib/server/pos-staff-pin.js +29 -24
  364. package/src/lib/server/pos-staff-pin.js.map +1 -1
  365. package/src/lib/server/pos-terminal.d.ts +14 -4
  366. package/src/lib/server/pos-terminal.js +34 -38
  367. package/src/lib/server/pos-terminal.js.map +1 -1
  368. package/src/lib/server/printers.d.ts +7 -3
  369. package/src/lib/server/printers.js +18 -12
  370. package/src/lib/server/printers.js.map +1 -1
  371. package/src/lib/server/product-drafts.d.ts +11 -1
  372. package/src/lib/server/product-drafts.js +12 -8
  373. package/src/lib/server/product-drafts.js.map +1 -1
  374. package/src/lib/server/product.d.ts +15 -1
  375. package/src/lib/server/product.js +16 -3
  376. package/src/lib/server/product.js.map +1 -1
  377. package/src/lib/server/products-write.d.ts +26 -2
  378. package/src/lib/server/products-write.js +19 -7
  379. package/src/lib/server/products-write.js.map +1 -1
  380. package/src/lib/server/refund.js +55 -42
  381. package/src/lib/server/refund.js.map +1 -1
  382. package/src/lib/server/reservation-availability-query.d.ts +8 -0
  383. package/src/lib/server/reservation-availability-query.js +11 -1
  384. package/src/lib/server/reservation-availability-query.js.map +1 -1
  385. package/src/lib/server/reservation-availability.d.ts +1 -1
  386. package/src/lib/server/reservation-availability.js +7 -2
  387. package/src/lib/server/reservation-availability.js.map +1 -1
  388. package/src/lib/server/reservation-guests.d.ts +32 -0
  389. package/src/lib/server/reservation-guests.js +285 -0
  390. package/src/lib/server/reservation-guests.js.map +1 -0
  391. package/src/lib/server/reservation-walk-in.d.ts +11 -1
  392. package/src/lib/server/reservation-walk-in.js +56 -12
  393. package/src/lib/server/reservation-walk-in.js.map +1 -1
  394. package/src/lib/server/reserve.js +18 -5
  395. package/src/lib/server/reserve.js.map +1 -1
  396. package/src/lib/server/returns.js +9 -6
  397. package/src/lib/server/returns.js.map +1 -1
  398. package/src/lib/server/reviews.d.ts +22 -2
  399. package/src/lib/server/reviews.js +88 -20
  400. package/src/lib/server/reviews.js.map +1 -1
  401. package/src/lib/server/shipping-connectors.js +10 -11
  402. package/src/lib/server/shipping-connectors.js.map +1 -1
  403. package/src/lib/server/site-page-resolver.js +20 -3
  404. package/src/lib/server/site-page-resolver.js.map +1 -1
  405. package/src/lib/server/store-day.d.ts +33 -0
  406. package/src/lib/server/store-day.js +46 -0
  407. package/src/lib/server/store-day.js.map +1 -0
  408. package/src/lib/server/store-setup-ai-writer.d.ts +2 -1
  409. package/src/lib/server/store-setup-ai-writer.js +5 -6
  410. package/src/lib/server/store-setup-ai-writer.js.map +1 -1
  411. package/src/lib/server/storefront-tax.d.ts +13 -0
  412. package/src/lib/server/storefront-tax.js +8 -1
  413. package/src/lib/server/storefront-tax.js.map +1 -1
  414. package/src/lib/server/tax-return-source.d.ts +32 -3
  415. package/src/lib/server/tax-return-source.js +99 -20
  416. package/src/lib/server/tax-return-source.js.map +1 -1
  417. package/src/lib/server.js +100 -2
  418. package/src/lib/server.js.map +1 -1
  419. package/src/lib/testing/fake-firestore.js +58 -16
  420. package/src/lib/testing/fake-firestore.js.map +1 -1
  421. package/src/lib/testing/pos-ops-memory-firestore.js +18 -4
  422. package/src/lib/testing/pos-ops-memory-firestore.js.map +1 -1
  423. package/src/lib/testing/site-register-permissions.d.ts +29 -0
  424. package/src/lib/testing/site-register-permissions.js +38 -0
  425. package/src/lib/testing/site-register-permissions.js.map +1 -0
  426. package/src/lib/transfer/tracking.server.js +8 -5
  427. package/src/lib/transfer/tracking.server.js.map +1 -1
  428. package/src/lib/utils/add-to-cart.d.ts +2 -0
  429. package/src/lib/utils/add-to-cart.js +6 -3
  430. package/src/lib/utils/add-to-cart.js.map +1 -1
@@ -0,0 +1,224 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Aglyn LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */ /*==========================================
17
+ * A REGISTER SALE OF HARDWARE BECOMES A HARDWARE ORDER (AGL-4038).
18
+ *
19
+ * The platform's own store sells readers at its register like anything else
20
+ * it sells: its prices, its promotions, its tax rate, its tenders, its
21
+ * account. What follows the sale is a hardware order for the buyer's
22
+ * workspace, built here from the register sale as it was paid — pure, so the
23
+ * money is specced without Firestore.
24
+ *
25
+ * THE HARDWARE'S SHARE OF THE SALE. A sale may hold a reader and a T-shirt.
26
+ * The order takes the hardware lines at the prices they were rung at, and
27
+ * the sale's discount and tax fall on them in proportion — the discount by
28
+ * the lines' share of the items, the tax by their share of what was taxed
29
+ * (the register taxes the whole basket, less its discount, at one rate).
30
+ * Each share is rounded half up to the cent in integer math, and a sale of
31
+ * hardware alone takes the whole discount and the whole tax, to the cent.
32
+ *
33
+ * WHO IT BELONGS TO. A sale a register user attached to an account and a
34
+ * workspace is that workspace's order. Every other one — a kiosk sale, an
35
+ * offline sale, a buyer with no account yet or no workspace yet — is
36
+ * PENDING: kept in the selling workspace's own orders, on its "To attach"
37
+ * list, until it is attached.
38
+ *=========================================*/ import { POS_HARDWARE_CURRENCY, POS_HARDWARE_IN_PERSON_SHIPPING_LABEL, posHardwareBuyerAddress, posHardwareSku } from "./pos-hardware.js";
39
+ import { posHardwareTermsAcceptance, posHardwareTermsAcceptanceOf } from "./pos-hardware-terms.js";
40
+ const whole = (value)=>{
41
+ const number = Number(value);
42
+ return Number.isSafeInteger(number) && number > 0 ? number : 0;
43
+ };
44
+ /** `amount × part / of`, rounded half up, in integer math; 0 when `of` is 0. */ function shareOf(amount, part, of) {
45
+ if (of <= 0 || amount <= 0 || part <= 0) return 0;
46
+ if (part >= of) return amount;
47
+ return Math.floor((amount * part * 2 + of) / (of * 2));
48
+ }
49
+ /**
50
+ * The hardware's share of a register sale, or `null` when the sale sold no
51
+ * hardware. `discountCents` and `taxCents` are the SALE's.
52
+ */ export function posHardwareRegisterShare(input) {
53
+ const lines = [];
54
+ let saleItemsCents = 0;
55
+ for (const line of input.lines){
56
+ const quantity = whole(line.quantity);
57
+ const unitCents = whole(line.unitAmountCents);
58
+ saleItemsCents += quantity * unitCents;
59
+ const sku = line.sku ? posHardwareSku(line.sku) : null;
60
+ if (!sku || !quantity) continue;
61
+ lines.push({
62
+ sku: sku.id,
63
+ name: sku.displayName,
64
+ quantity,
65
+ unitCents,
66
+ lineCents: quantity * unitCents
67
+ });
68
+ }
69
+ if (!lines.length) return null;
70
+ const itemsCents = lines.reduce((sum, line)=>sum + line.lineCents, 0);
71
+ const saleDiscountCents = Math.min(whole(input.discountCents), saleItemsCents);
72
+ const discountCents = shareOf(saleDiscountCents, itemsCents, saleItemsCents);
73
+ const taxableCents = Math.max(0, itemsCents - discountCents);
74
+ const taxCents = shareOf(whole(input.taxCents), taxableCents, saleItemsCents - saleDiscountCents);
75
+ return {
76
+ lines,
77
+ itemsCents,
78
+ discountCents,
79
+ taxableCents,
80
+ taxCents,
81
+ totalCents: taxableCents + taxCents
82
+ };
83
+ }
84
+ /**
85
+ * One unit per reader sold, in line order; accessories carry no serial and
86
+ * have no unit. `serials` are the serial numbers taken at the sale, in the
87
+ * same order, already normalized; a reader with none waits for one.
88
+ */ export function posHardwareUnits(lines, serials = []) {
89
+ const units = [];
90
+ for (const line of lines){
91
+ var _posHardwareSku;
92
+ if (((_posHardwareSku = posHardwareSku(line.sku)) == null ? void 0 : _posHardwareSku.kind) !== 'reader') continue;
93
+ for(let index = 0; index < line.quantity; index += 1){
94
+ units.push({
95
+ sku: line.sku,
96
+ serialNumber: serials[units.length] || null,
97
+ readerId: null,
98
+ hostId: null,
99
+ registeredAtMs: null
100
+ });
101
+ }
102
+ }
103
+ return units;
104
+ }
105
+ /**
106
+ * Whose the order is: the workspace the register attached, or pending. A
107
+ * buyer with an account and a workspace is attached; one with only an
108
+ * account or only an address is pending until they have a workspace.
109
+ */ export function posHardwareAttachmentOf(buyer) {
110
+ var _ref, _ref1;
111
+ var _text, _text1;
112
+ const text = (value)=>typeof value === 'string' && value.trim() ? value.trim() : null;
113
+ const uid = text(buyer == null ? void 0 : buyer.uid);
114
+ const orgId = text(buyer == null ? void 0 : buyer.orgId);
115
+ const attached = Boolean(uid && orgId);
116
+ return {
117
+ state: attached ? 'attached' : 'pending',
118
+ email: (_ref = (_text = text(buyer == null ? void 0 : buyer.email)) == null ? void 0 : _text.toLowerCase()) != null ? _ref : null,
119
+ uid,
120
+ orgId: attached ? orgId : null,
121
+ hostId: attached ? text(buyer == null ? void 0 : buyer.hostId) : null,
122
+ attachedBy: text(buyer == null ? void 0 : buyer.attachedBy),
123
+ attachedAtMs: attached && Number.isFinite(buyer == null ? void 0 : buyer.attachedAtMs) ? Number(buyer == null ? void 0 : buyer.attachedAtMs) : null,
124
+ // The reseller's records of who bought it (AGL-4038), when known.
125
+ name: (_ref1 = (_text1 = text(buyer == null ? void 0 : buyer.name)) == null ? void 0 : _text1.slice(0, 200)) != null ? _ref1 : null,
126
+ address: posHardwareBuyerAddress(buyer == null ? void 0 : buyer.address)
127
+ };
128
+ }
129
+ /**
130
+ * The hardware order a register sale becomes. In-person hardware is handed
131
+ * over at the sale, so the order starts at Delivered, and moves to Set up
132
+ * once its readers are registered.
133
+ *
134
+ * The tax line states the base the store's rate was applied to — the
135
+ * hardware's share of what the register taxed — so the platform's return
136
+ * reads a stated base, never an inferred one.
137
+ */ export function inPersonPosHardwareOrder(sale) {
138
+ var _sale_serials, _ref, _attachment_hostId, _attachment_email, _sale_currency, _posHardwareTermsAcceptanceOf;
139
+ var _sale_taxRegion;
140
+ const attachment = posHardwareAttachmentOf(sale.buyer);
141
+ const attached = attachment.state === 'attached';
142
+ const units = posHardwareUnits(sale.share.lines, (_sale_serials = sale.serials) != null ? _sale_serials : []);
143
+ const state = (_ref = (_sale_taxRegion = sale.taxRegion) == null ? void 0 : _sale_taxRegion.state) != null ? _ref : null;
144
+ const taxLines = sale.share.taxCents > 0 ? [
145
+ {
146
+ amountCents: sale.share.taxCents,
147
+ taxabilityReason: null,
148
+ taxRateId: null,
149
+ taxableAmountCents: sale.share.taxableCents,
150
+ jurisdiction: state,
151
+ rateState: state,
152
+ percentage: sale.ratePct
153
+ }
154
+ ] : [];
155
+ return {
156
+ orgId: attached ? attachment.orgId : sale.sellerOrgId,
157
+ // The buyer's store once they chose one; until then the workspace's,
158
+ // and the buyer picks the store when they set the reader up.
159
+ hostId: attached ? (_attachment_hostId = attachment.hostId) != null ? _attachment_hostId : '' : '',
160
+ createdBy: attachment.uid,
161
+ contactEmail: (_attachment_email = attachment.email) != null ? _attachment_email : sale.receiptEmail,
162
+ lines: sale.share.lines,
163
+ subtotalCents: sale.share.itemsCents,
164
+ discountCents: sale.share.discountCents,
165
+ shipping: {
166
+ method: 'in_person',
167
+ label: POS_HARDWARE_IN_PERSON_SHIPPING_LABEL,
168
+ cents: 0,
169
+ name: null,
170
+ phone: null,
171
+ address: null,
172
+ // Sold at the counter: taxed where the store is, as every sale it rings.
173
+ taxRegion: sale.taxRegion
174
+ },
175
+ taxCents: sale.share.taxCents,
176
+ totalCents: sale.share.totalCents,
177
+ currency: (_sale_currency = sale.currency) != null ? _sale_currency : POS_HARDWARE_CURRENCY,
178
+ automaticTax: false,
179
+ taxLines,
180
+ stripeCheckoutSessionId: null,
181
+ stripePaymentIntentId: null,
182
+ stripeHardwareOrderId: null,
183
+ tracking: null,
184
+ status: 'delivered',
185
+ livemode: sale.livemode,
186
+ createdAtMs: sale.paidAtMs,
187
+ updatedAtMs: sale.paidAtMs,
188
+ paidAtMs: sale.paidAtMs,
189
+ deliveredAtMs: sale.paidAtMs,
190
+ source: 'in_person',
191
+ // Accepted on the tablet or the display before paying, or else agreed by
192
+ // paying under the receipt's and the booth sign's notice (Terms 4.28).
193
+ termsAcceptance: (_posHardwareTermsAcceptanceOf = posHardwareTermsAcceptanceOf(sale.termsAcceptance)) != null ? _posHardwareTermsAcceptanceOf : posHardwareTermsAcceptance({
194
+ method: 'notice',
195
+ atMs: sale.paidAtMs
196
+ }),
197
+ posSale: {
198
+ hostId: sale.sellerHostId,
199
+ orgId: sale.sellerOrgId,
200
+ orderId: sale.registerOrderId,
201
+ number: sale.number,
202
+ registerId: sale.registerId,
203
+ kiosk: sale.kiosk,
204
+ offline: sale.offline,
205
+ paymentLinkSessionId: sale.paymentLinkSessionId
206
+ },
207
+ paidTo: {
208
+ account: 'seller_store',
209
+ hostId: sale.sellerHostId,
210
+ orgId: sale.sellerOrgId,
211
+ tenders: [
212
+ ...new Set(sale.tenders)
213
+ ],
214
+ stripeAccountId: sale.stripeAccountId
215
+ },
216
+ attachment,
217
+ units,
218
+ serialNumbers: units.flatMap((unit)=>unit.serialNumber ? [
219
+ unit.serialNumber
220
+ ] : [])
221
+ };
222
+ }
223
+
224
+ //# sourceMappingURL=pos-hardware-in-person.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../libs/plugins/commerce/src/lib/model/pos-hardware-in-person.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/*==========================================\n * A REGISTER SALE OF HARDWARE BECOMES A HARDWARE ORDER (AGL-4038).\n *\n * The platform's own store sells readers at its register like anything else\n * it sells: its prices, its promotions, its tax rate, its tenders, its\n * account. What follows the sale is a hardware order for the buyer's\n * workspace, built here from the register sale as it was paid — pure, so the\n * money is specced without Firestore.\n *\n * THE HARDWARE'S SHARE OF THE SALE. A sale may hold a reader and a T-shirt.\n * The order takes the hardware lines at the prices they were rung at, and\n * the sale's discount and tax fall on them in proportion — the discount by\n * the lines' share of the items, the tax by their share of what was taxed\n * (the register taxes the whole basket, less its discount, at one rate).\n * Each share is rounded half up to the cent in integer math, and a sale of\n * hardware alone takes the whole discount and the whole tax, to the cent.\n *\n * WHO IT BELONGS TO. A sale a register user attached to an account and a\n * workspace is that workspace's order. Every other one — a kiosk sale, an\n * offline sale, a buyer with no account yet or no workspace yet — is\n * PENDING: kept in the selling workspace's own orders, on its \"To attach\"\n * list, until it is attached.\n *=========================================*/\n\nimport type { OrderHardwareBuyer } from './commerce-orders'\nimport {\n POS_HARDWARE_CURRENCY,\n POS_HARDWARE_IN_PERSON_SHIPPING_LABEL,\n posHardwareBuyerAddress,\n posHardwareSku,\n type PosHardwareAttachment,\n type PosHardwareLine,\n type PosHardwareOrder,\n type PosHardwareSkuId,\n type PosHardwareTaxLine,\n type PosHardwareTaxRegion,\n type PosHardwareUnit,\n} from './pos-hardware'\nimport { posHardwareTermsAcceptance, posHardwareTermsAcceptanceOf } from './pos-hardware-terms'\n\n/** One register line, with the hardware item its product is, when it is one. */\nexport interface PosHardwareRegisterLine {\n sku: PosHardwareSkuId | null\n quantity: number\n unitAmountCents: number\n}\n\nexport interface PosHardwareRegisterShare {\n lines: PosHardwareLine[]\n /** The hardware lines at the prices rung. */\n itemsCents: number\n discountCents: number\n /** What tax was charged on: the items less the discount. */\n taxableCents: number\n taxCents: number\n totalCents: number\n}\n\nconst whole = (value: unknown): number => {\n const number = Number(value)\n return Number.isSafeInteger(number) && number > 0 ? number : 0\n}\n\n/** `amount × part / of`, rounded half up, in integer math; 0 when `of` is 0. */\nfunction shareOf(amount: number, part: number, of: number): number {\n if (of <= 0 || amount <= 0 || part <= 0) return 0\n if (part >= of) return amount\n return Math.floor((amount * part * 2 + of) / (of * 2))\n}\n\n/**\n * The hardware's share of a register sale, or `null` when the sale sold no\n * hardware. `discountCents` and `taxCents` are the SALE's.\n */\nexport function posHardwareRegisterShare(input: {\n lines: readonly PosHardwareRegisterLine[]\n discountCents: number\n taxCents: number\n}): PosHardwareRegisterShare | null {\n const lines: PosHardwareLine[] = []\n let saleItemsCents = 0\n for (const line of input.lines) {\n const quantity = whole(line.quantity)\n const unitCents = whole(line.unitAmountCents)\n saleItemsCents += quantity * unitCents\n const sku = line.sku ? posHardwareSku(line.sku) : null\n if (!sku || !quantity) continue\n lines.push({ sku: sku.id, name: sku.displayName, quantity, unitCents, lineCents: quantity * unitCents })\n }\n if (!lines.length) return null\n const itemsCents = lines.reduce((sum, line) => sum + line.lineCents, 0)\n const saleDiscountCents = Math.min(whole(input.discountCents), saleItemsCents)\n const discountCents = shareOf(saleDiscountCents, itemsCents, saleItemsCents)\n const taxableCents = Math.max(0, itemsCents - discountCents)\n const taxCents = shareOf(whole(input.taxCents), taxableCents, saleItemsCents - saleDiscountCents)\n return { lines, itemsCents, discountCents, taxableCents, taxCents, totalCents: taxableCents + taxCents }\n}\n\n/**\n * One unit per reader sold, in line order; accessories carry no serial and\n * have no unit. `serials` are the serial numbers taken at the sale, in the\n * same order, already normalized; a reader with none waits for one.\n */\nexport function posHardwareUnits(\n lines: readonly PosHardwareLine[],\n serials: readonly string[] = [],\n): PosHardwareUnit[] {\n const units: PosHardwareUnit[] = []\n for (const line of lines) {\n if (posHardwareSku(line.sku)?.kind !== 'reader') continue\n for (let index = 0; index < line.quantity; index += 1) {\n units.push({\n sku: line.sku,\n serialNumber: serials[units.length] || null,\n readerId: null,\n hostId: null,\n registeredAtMs: null,\n })\n }\n }\n return units\n}\n\n/**\n * Whose the order is: the workspace the register attached, or pending. A\n * buyer with an account and a workspace is attached; one with only an\n * account or only an address is pending until they have a workspace.\n */\nexport function posHardwareAttachmentOf(buyer: OrderHardwareBuyer | null | undefined): PosHardwareAttachment {\n const text = (value: unknown) => (typeof value === 'string' && value.trim() ? value.trim() : null)\n const uid = text(buyer?.uid)\n const orgId = text(buyer?.orgId)\n const attached = Boolean(uid && orgId)\n return {\n state: attached ? 'attached' : 'pending',\n email: text(buyer?.email)?.toLowerCase() ?? null,\n uid,\n orgId: attached ? orgId : null,\n hostId: attached ? text(buyer?.hostId) : null,\n attachedBy: text(buyer?.attachedBy),\n attachedAtMs: attached && Number.isFinite(buyer?.attachedAtMs) ? Number(buyer?.attachedAtMs) : null,\n // The reseller's records of who bought it (AGL-4038), when known.\n name: text(buyer?.name)?.slice(0, 200) ?? null,\n address: posHardwareBuyerAddress(buyer?.address),\n }\n}\n\n/** The register sale, as the builder reads it. */\nexport interface InPersonRegisterSale {\n sellerHostId: string\n sellerOrgId: string\n registerOrderId: string\n number: number | null\n registerId: string | null\n kiosk: boolean\n offline: boolean\n share: PosHardwareRegisterShare\n /** When the sale was paid: the order's own stamp. */\n paidAtMs: number\n /** The tenders that paid it, as its payments name them. */\n tenders: string[]\n paymentLinkSessionId: string | null\n /** The address the receipt went to, kept for staff when nobody is attached. */\n receiptEmail: string | null\n buyer: OrderHardwareBuyer | null | undefined\n /** Serial numbers taken at the sale, normalized, in reader order. */\n serials?: readonly string[]\n /** Where the store taxes from: its own address's region. */\n taxRegion: PosHardwareTaxRegion | null\n /** The store's rate, in percent, when it charged one. */\n ratePct: number | null\n stripeAccountId: string | null\n livemode: boolean\n currency?: string\n /**\n * How the buyer agreed to the terms of sale before paying (AGL-4038), from\n * the register sale; absent, the receipt-and-sign notice at the sale.\n */\n termsAcceptance?: unknown\n}\n\n/**\n * The hardware order a register sale becomes. In-person hardware is handed\n * over at the sale, so the order starts at Delivered, and moves to Set up\n * once its readers are registered.\n *\n * The tax line states the base the store's rate was applied to — the\n * hardware's share of what the register taxed — so the platform's return\n * reads a stated base, never an inferred one.\n */\nexport function inPersonPosHardwareOrder(sale: InPersonRegisterSale): PosHardwareOrder {\n const attachment = posHardwareAttachmentOf(sale.buyer)\n const attached = attachment.state === 'attached'\n const units = posHardwareUnits(sale.share.lines, sale.serials ?? [])\n const state = sale.taxRegion?.state ?? null\n const taxLines: PosHardwareTaxLine[] =\n sale.share.taxCents > 0\n ? [\n {\n amountCents: sale.share.taxCents,\n taxabilityReason: null,\n taxRateId: null,\n taxableAmountCents: sale.share.taxableCents,\n jurisdiction: state,\n rateState: state,\n percentage: sale.ratePct,\n },\n ]\n : []\n return {\n orgId: attached ? (attachment.orgId as string) : sale.sellerOrgId,\n // The buyer's store once they chose one; until then the workspace's,\n // and the buyer picks the store when they set the reader up.\n hostId: attached ? (attachment.hostId ?? '') : '',\n createdBy: attachment.uid,\n contactEmail: attachment.email ?? sale.receiptEmail,\n lines: sale.share.lines,\n subtotalCents: sale.share.itemsCents,\n discountCents: sale.share.discountCents,\n shipping: {\n method: 'in_person',\n label: POS_HARDWARE_IN_PERSON_SHIPPING_LABEL,\n cents: 0,\n name: null,\n phone: null,\n address: null,\n // Sold at the counter: taxed where the store is, as every sale it rings.\n taxRegion: sale.taxRegion,\n },\n taxCents: sale.share.taxCents,\n totalCents: sale.share.totalCents,\n currency: sale.currency ?? POS_HARDWARE_CURRENCY,\n automaticTax: false,\n taxLines,\n stripeCheckoutSessionId: null,\n stripePaymentIntentId: null,\n stripeHardwareOrderId: null,\n tracking: null,\n status: 'delivered',\n livemode: sale.livemode,\n createdAtMs: sale.paidAtMs,\n updatedAtMs: sale.paidAtMs,\n paidAtMs: sale.paidAtMs,\n deliveredAtMs: sale.paidAtMs,\n source: 'in_person',\n // Accepted on the tablet or the display before paying, or else agreed by\n // paying under the receipt's and the booth sign's notice (Terms 4.28).\n termsAcceptance:\n posHardwareTermsAcceptanceOf(sale.termsAcceptance) ??\n posHardwareTermsAcceptance({ method: 'notice', atMs: sale.paidAtMs }),\n posSale: {\n hostId: sale.sellerHostId,\n orgId: sale.sellerOrgId,\n orderId: sale.registerOrderId,\n number: sale.number,\n registerId: sale.registerId,\n kiosk: sale.kiosk,\n offline: sale.offline,\n paymentLinkSessionId: sale.paymentLinkSessionId,\n },\n paidTo: {\n account: 'seller_store',\n hostId: sale.sellerHostId,\n orgId: sale.sellerOrgId,\n tenders: [...new Set(sale.tenders)],\n stripeAccountId: sale.stripeAccountId,\n },\n attachment,\n units,\n serialNumbers: units.flatMap((unit) => (unit.serialNumber ? [unit.serialNumber] : [])),\n }\n}\n"],"names":["POS_HARDWARE_CURRENCY","POS_HARDWARE_IN_PERSON_SHIPPING_LABEL","posHardwareBuyerAddress","posHardwareSku","posHardwareTermsAcceptance","posHardwareTermsAcceptanceOf","whole","value","number","Number","isSafeInteger","shareOf","amount","part","of","Math","floor","posHardwareRegisterShare","input","lines","saleItemsCents","line","quantity","unitCents","unitAmountCents","sku","push","id","name","displayName","lineCents","length","itemsCents","reduce","sum","saleDiscountCents","min","discountCents","taxableCents","max","taxCents","totalCents","posHardwareUnits","serials","units","kind","index","serialNumber","readerId","hostId","registeredAtMs","posHardwareAttachmentOf","buyer","text","trim","uid","orgId","attached","Boolean","state","email","toLowerCase","attachedBy","attachedAtMs","isFinite","slice","address","inPersonPosHardwareOrder","sale","attachment","share","taxRegion","taxLines","amountCents","taxabilityReason","taxRateId","taxableAmountCents","jurisdiction","rateState","percentage","ratePct","sellerOrgId","createdBy","contactEmail","receiptEmail","subtotalCents","shipping","method","label","cents","phone","currency","automaticTax","stripeCheckoutSessionId","stripePaymentIntentId","stripeHardwareOrderId","tracking","status","livemode","createdAtMs","paidAtMs","updatedAtMs","deliveredAtMs","source","termsAcceptance","atMs","posSale","sellerHostId","orderId","registerOrderId","registerId","kiosk","offline","paymentLinkSessionId","paidTo","account","tenders","Set","stripeAccountId","serialNumbers","flatMap","unit"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;;;;;;;;;;;;;;;;2CAsB2C,GAG3C,SACEA,qBAAqB,EACrBC,qCAAqC,EACrCC,uBAAuB,EACvBC,cAAc,QAQT,oBAAgB;AACvB,SAASC,0BAA0B,EAAEC,4BAA4B,QAAQ,0BAAsB;AAoB/F,MAAMC,QAAQ,CAACC;IACb,MAAMC,SAASC,OAAOF;IACtB,OAAOE,OAAOC,aAAa,CAACF,WAAWA,SAAS,IAAIA,SAAS;AAC/D;AAEA,8EAA8E,GAC9E,SAASG,QAAQC,MA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@@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Aglyn LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ /**
18
+ * THE PLATFORM'S OWN HARDWARE SALES, SUMMED FOR ONE FILING PERIOD (AGL-4038).
19
+ *
20
+ * The platform is the seller of record for every card reader order, so these
21
+ * are its OWN sales, not facilitated ones, and they belong on its sales tax
22
+ * return. They are recorded in `posHardwareSales` — apart from the invoices
23
+ * the return sums (`platformRevenue`, written only for a paid invoice, which a
24
+ * hardware checkout never makes) and apart from the storefront's tax rows
25
+ * (`storefrontTaxCollected`, whose recorder does not take a hardware session)
26
+ * — so nothing here is already in another figure on the return. The return
27
+ * folds them into its filing figures as the operator's own sales
28
+ * (`server/pos-hardware-tax-return-source.ts`), each sale once.
29
+ *
30
+ * THE RULES, each pinned by `pos-hardware-tax-summary.spec.ts`:
31
+ *
32
+ * - **A sale is in the period it was PAID**, by `paidAtMs`, half-open: the
33
+ * first instant of the period is in, the first instant of the next is not.
34
+ * Its status today does not move it: an order paid in the period and
35
+ * canceled later is still a sale of the period it was paid in.
36
+ * - **Total sales** are receipts excluding the tax itself: the total less
37
+ * the tax (the items and the shipping).
38
+ * - **Taxable sales** are the base Stripe Tax applied its rate to, read from
39
+ * the order's stored breakdown and never inferred. One order's lines are
40
+ * one base taxed at several levels (state, county, city), each line
41
+ * stating the same base, so the order's base is the LARGEST stated, never
42
+ * their sum. An order taxed with no stated base adds nothing and is counted
43
+ * out loud.
44
+ * - **A refund is in the period it was MADE**, by the stamp of the status
45
+ * that refunded it (`refundedAtMs`, or `canceledAtMs` for a cancel), and
46
+ * is stated beside the sales, never netted from them — the platform's own
47
+ * rule for its invoices. Hardware refunds are whole, so the refunded tax is
48
+ * the order's own tax; a partial one is split in the order's own ratio.
49
+ * - **A canceled order with no refund recorded** stays a sale and is counted
50
+ * out loud: the record says canceled and nobody recorded the money coming
51
+ * back.
52
+ * - **Test-mode orders are not sales.** An order made with Stripe's test keys
53
+ * is left out of every figure and counted, never dropped silently.
54
+ * - **Where it shipped decides the jurisdiction**: a shipped sale is sourced
55
+ * to its destination. No ship-to region is `unknown`, counted out loud.
56
+ *
57
+ * Integer cents throughout. Pure and total: no Firestore, no clock.
58
+ */
59
+ import { type TaxLineInput, type TaxReturnJurisdiction } from '@aglyn/aglyn/app-utils/tax-jurisdiction-figures';
60
+ /** A `posHardwareSales/{orderId}` record as the return reads it. */
61
+ export interface PosHardwareTaxRowInput {
62
+ orderId: string;
63
+ totalCents?: unknown;
64
+ taxCents?: unknown;
65
+ currency?: unknown;
66
+ shipTo?: {
67
+ country?: unknown;
68
+ state?: unknown;
69
+ postalCode?: unknown;
70
+ } | null;
71
+ automaticTax?: unknown;
72
+ taxLines?: TaxLineInput[] | null;
73
+ status?: unknown;
74
+ livemode?: unknown;
75
+ paidAtMs?: unknown;
76
+ refundedCents?: unknown;
77
+ refundedAtMs?: unknown;
78
+ canceledAtMs?: unknown;
79
+ /** `in_person` for a reader sold at a store's register (AGL-4038), else sold online. */
80
+ source?: unknown;
81
+ /** The store whose register sold it, for an in-person sale. */
82
+ posHostId?: unknown;
83
+ }
84
+ /** One ship-to jurisdiction: the sales paid in the period and the refunds made in it. */
85
+ export interface PosHardwareTaxJurisdiction extends TaxReturnJurisdiction {
86
+ /** Sales with no tax computed: sold without Stripe Tax. */
87
+ untaxedOrders: number;
88
+ refundedOrders: number;
89
+ /** Refunded receipts excluding tax. */
90
+ refundedSalesCents: number;
91
+ refundedTaxCents: number;
92
+ }
93
+ export interface PosHardwareTaxSummary {
94
+ periodStart: string;
95
+ periodEnd: string;
96
+ /** Live sales paid in the period, in every jurisdiction. */
97
+ orders: number;
98
+ totalSalesCents: number;
99
+ taxableSalesCents: number;
100
+ taxCollectedCents: number;
101
+ byJurisdiction: Record<string, PosHardwareTaxJurisdiction>;
102
+ refunds: {
103
+ orders: number;
104
+ /** Everything refunded, tax included. */
105
+ refundedCents: number;
106
+ refundedSalesCents: number;
107
+ refundedTaxCents: number;
108
+ };
109
+ excluded: {
110
+ /** Test-mode orders paid in the period: in no figure. */
111
+ testModeOrders: number;
112
+ };
113
+ attention: {
114
+ untaxedOrders: number;
115
+ ordersMissingTaxableBase: number;
116
+ ordersMissingShipTo: number;
117
+ canceledWithoutRefund: number;
118
+ };
119
+ }
120
+ /**
121
+ * The base Stripe stated for one order, or null when no line states one: the
122
+ * largest of the stated bases, because each jurisdiction level restates the
123
+ * same base (see the module note).
124
+ */
125
+ export declare function posHardwareTaxableBase(lines: readonly (TaxLineInput | undefined)[] | null | undefined): number | null;
126
+ /** When the order's refund was made: the stamp of the status that made it. */
127
+ export declare function posHardwareRefundStamp(row: PosHardwareTaxRowInput): number | null;
128
+ /** How a row counts in the period: as a sale, as a refund, as both, or not at all. */
129
+ export declare function posHardwareRowInPeriod(row: PosHardwareTaxRowInput, period: {
130
+ start: Date;
131
+ end: Date;
132
+ }): {
133
+ sale: boolean;
134
+ refund: boolean;
135
+ };
136
+ /** The period's figures from the records read for it. See the module note. */
137
+ export declare function posHardwareTaxSummary(rows: readonly PosHardwareTaxRowInput[], period: {
138
+ start: Date;
139
+ end: Date;
140
+ }): PosHardwareTaxSummary;
141
+ /** The part of a storefront row an in-person hardware record accounts for. */
142
+ export interface PosHardwareStorefrontPart {
143
+ storefrontTaxRowId: string;
144
+ /** The hardware's share of the register sale, tax included. */
145
+ totalCents: number;
146
+ taxCents: number;
147
+ }
148
+ /** The parts the hardware section counts, from its records. */
149
+ export declare function posHardwareStorefrontParts(records: ReadonlyArray<{
150
+ source?: unknown;
151
+ storefrontTaxRowId?: unknown;
152
+ totalCents?: unknown;
153
+ taxCents?: unknown;
154
+ livemode?: unknown;
155
+ }>): PosHardwareStorefrontPart[];
156
+ /**
157
+ * The storefront rows with each in-person hardware part taken out: a row's
158
+ * receipts and tax less the hardware's, and a row left with nothing dropped.
159
+ * A row's stated tax lines are kept as they are: a register sale's row is a
160
+ * manual-rate row, which states none.
161
+ */
162
+ export declare function storefrontRowsWithoutInPersonHardware<Row extends {
163
+ id: string;
164
+ grossCents?: unknown;
165
+ taxCents?: unknown;
166
+ }>(rows: readonly Row[], parts: readonly PosHardwareStorefrontPart[]): Row[];
@@ -0,0 +1,225 @@
1
+ import { _ as _extends } from "@swc/helpers/_/_extends";
2
+ /**
3
+ * @license
4
+ * Copyright 2026 Aglyn LLC
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */ /**
18
+ * THE PLATFORM'S OWN HARDWARE SALES, SUMMED FOR ONE FILING PERIOD (AGL-4038).
19
+ *
20
+ * The platform is the seller of record for every card reader order, so these
21
+ * are its OWN sales, not facilitated ones, and they belong on its sales tax
22
+ * return. They are recorded in `posHardwareSales` — apart from the invoices
23
+ * the return sums (`platformRevenue`, written only for a paid invoice, which a
24
+ * hardware checkout never makes) and apart from the storefront's tax rows
25
+ * (`storefrontTaxCollected`, whose recorder does not take a hardware session)
26
+ * — so nothing here is already in another figure on the return. The return
27
+ * folds them into its filing figures as the operator's own sales
28
+ * (`server/pos-hardware-tax-return-source.ts`), each sale once.
29
+ *
30
+ * THE RULES, each pinned by `pos-hardware-tax-summary.spec.ts`:
31
+ *
32
+ * - **A sale is in the period it was PAID**, by `paidAtMs`, half-open: the
33
+ * first instant of the period is in, the first instant of the next is not.
34
+ * Its status today does not move it: an order paid in the period and
35
+ * canceled later is still a sale of the period it was paid in.
36
+ * - **Total sales** are receipts excluding the tax itself: the total less
37
+ * the tax (the items and the shipping).
38
+ * - **Taxable sales** are the base Stripe Tax applied its rate to, read from
39
+ * the order's stored breakdown and never inferred. One order's lines are
40
+ * one base taxed at several levels (state, county, city), each line
41
+ * stating the same base, so the order's base is the LARGEST stated, never
42
+ * their sum. An order taxed with no stated base adds nothing and is counted
43
+ * out loud.
44
+ * - **A refund is in the period it was MADE**, by the stamp of the status
45
+ * that refunded it (`refundedAtMs`, or `canceledAtMs` for a cancel), and
46
+ * is stated beside the sales, never netted from them — the platform's own
47
+ * rule for its invoices. Hardware refunds are whole, so the refunded tax is
48
+ * the order's own tax; a partial one is split in the order's own ratio.
49
+ * - **A canceled order with no refund recorded** stays a sale and is counted
50
+ * out loud: the record says canceled and nobody recorded the money coming
51
+ * back.
52
+ * - **Test-mode orders are not sales.** An order made with Stripe's test keys
53
+ * is left out of every figure and counted, never dropped silently.
54
+ * - **Where it shipped decides the jurisdiction**: a shipped sale is sourced
55
+ * to its destination. No ship-to region is `unknown`, counted out loud.
56
+ *
57
+ * Integer cents throughout. Pure and total: no Firestore, no clock.
58
+ */ import { accumulateTaxWorkingPapers, emptyTaxJurisdiction, taxJurisdictionKey } from "@aglyn/aglyn/app-utils/tax-jurisdiction-figures";
59
+ const cents = (value)=>{
60
+ const parsed = Number(value != null ? value : 0);
61
+ return Number.isFinite(parsed) ? Math.round(parsed) : 0;
62
+ };
63
+ const stamp = (value)=>typeof value === 'number' && Number.isFinite(value) ? value : null;
64
+ function emptyJurisdiction() {
65
+ return _extends({}, emptyTaxJurisdiction(), {
66
+ untaxedOrders: 0,
67
+ refundedOrders: 0,
68
+ refundedSalesCents: 0,
69
+ refundedTaxCents: 0
70
+ });
71
+ }
72
+ /**
73
+ * The base Stripe stated for one order, or null when no line states one: the
74
+ * largest of the stated bases, because each jurisdiction level restates the
75
+ * same base (see the module note).
76
+ */ export function posHardwareTaxableBase(lines) {
77
+ let base = null;
78
+ for (const line of lines != null ? lines : []){
79
+ const stated = line == null ? void 0 : line.taxableAmountCents;
80
+ if (stated === null || stated === undefined || !Number.isFinite(Number(stated))) continue;
81
+ const rounded = Math.round(Number(stated));
82
+ base = base === null ? rounded : Math.max(base, rounded);
83
+ }
84
+ return base;
85
+ }
86
+ /** When the order's refund was made: the stamp of the status that made it. */ export function posHardwareRefundStamp(row) {
87
+ var _stamp, _stamp1, _stamp2;
88
+ if (row.status === 'refunded') return (_stamp = stamp(row.refundedAtMs)) != null ? _stamp : stamp(row.canceledAtMs);
89
+ if (row.status === 'canceled') return (_stamp1 = stamp(row.canceledAtMs)) != null ? _stamp1 : stamp(row.refundedAtMs);
90
+ return (_stamp2 = stamp(row.refundedAtMs)) != null ? _stamp2 : stamp(row.canceledAtMs);
91
+ }
92
+ /** How a row counts in the period: as a sale, as a refund, as both, or not at all. */ export function posHardwareRowInPeriod(row, period) {
93
+ const startMs = period.start.getTime();
94
+ const endMs = period.end.getTime();
95
+ const within = (at)=>at !== null && at >= startMs && at < endMs;
96
+ return {
97
+ sale: within(stamp(row.paidAtMs)),
98
+ refund: cents(row.refundedCents) > 0 && within(posHardwareRefundStamp(row))
99
+ };
100
+ }
101
+ /** The period's figures from the records read for it. See the module note. */ export function posHardwareTaxSummary(rows, period) {
102
+ const summary = {
103
+ periodStart: period.start.toISOString(),
104
+ periodEnd: period.end.toISOString(),
105
+ orders: 0,
106
+ totalSalesCents: 0,
107
+ taxableSalesCents: 0,
108
+ taxCollectedCents: 0,
109
+ byJurisdiction: {},
110
+ refunds: {
111
+ orders: 0,
112
+ refundedCents: 0,
113
+ refundedSalesCents: 0,
114
+ refundedTaxCents: 0
115
+ },
116
+ excluded: {
117
+ testModeOrders: 0
118
+ },
119
+ attention: {
120
+ untaxedOrders: 0,
121
+ ordersMissingTaxableBase: 0,
122
+ ordersMissingShipTo: 0,
123
+ canceledWithoutRefund: 0
124
+ }
125
+ };
126
+ // The reader merges three queries, so an order can arrive twice.
127
+ const seen = new Set();
128
+ for (const row of rows != null ? rows : []){
129
+ var _summary_byJurisdiction, _jurisdiction, _;
130
+ if (!(row == null ? void 0 : row.orderId) || seen.has(row.orderId)) continue;
131
+ seen.add(row.orderId);
132
+ const placed = posHardwareRowInPeriod(row, period);
133
+ if (!placed.sale && !placed.refund) continue;
134
+ if (row.livemode !== true) {
135
+ if (placed.sale) summary.excluded.testModeOrders += 1;
136
+ continue;
137
+ }
138
+ const total = cents(row.totalCents);
139
+ const tax = cents(row.taxCents);
140
+ const jurisdiction = taxJurisdictionKey(row.shipTo);
141
+ const bucket = (_ = (_summary_byJurisdiction = summary.byJurisdiction)[_jurisdiction = jurisdiction]) != null ? _ : _summary_byJurisdiction[_jurisdiction] = emptyJurisdiction();
142
+ if (placed.sale) {
143
+ const lines = Array.isArray(row.taxLines) ? row.taxLines : [];
144
+ const base = posHardwareTaxableBase(lines);
145
+ const sales = total - tax;
146
+ summary.orders += 1;
147
+ summary.totalSalesCents += sales;
148
+ summary.taxableSalesCents += base != null ? base : 0;
149
+ summary.taxCollectedCents += tax;
150
+ bucket.transactionCount += 1;
151
+ bucket.totalSalesCents += sales;
152
+ bucket.taxableSalesCents += base != null ? base : 0;
153
+ bucket.taxCollectedCents += tax;
154
+ accumulateTaxWorkingPapers(bucket, lines);
155
+ if (tax === 0 && row.automaticTax !== true) {
156
+ bucket.untaxedOrders += 1;
157
+ summary.attention.untaxedOrders += 1;
158
+ }
159
+ if (tax > 0 && base === null) summary.attention.ordersMissingTaxableBase += 1;
160
+ if (jurisdiction === 'unknown') summary.attention.ordersMissingShipTo += 1;
161
+ if ((row.status === 'canceled' || row.status === 'refunded') && cents(row.refundedCents) <= 0) {
162
+ summary.attention.canceledWithoutRefund += 1;
163
+ }
164
+ }
165
+ if (placed.refund) {
166
+ const refunded = cents(row.refundedCents);
167
+ // Whole refunds give back the order's own tax; a partial one is split
168
+ // in the order's own ratio, and a row with no total states no ratio.
169
+ const refundedTax = refunded >= total ? tax : total > 0 && tax > 0 ? Math.round(refunded * tax / total) : 0;
170
+ const refundedSales = refunded - refundedTax;
171
+ summary.refunds.orders += 1;
172
+ summary.refunds.refundedCents += refunded;
173
+ summary.refunds.refundedSalesCents += refundedSales;
174
+ summary.refunds.refundedTaxCents += refundedTax;
175
+ bucket.refundedOrders += 1;
176
+ bucket.refundedSalesCents += refundedSales;
177
+ bucket.refundedTaxCents += refundedTax;
178
+ }
179
+ }
180
+ return summary;
181
+ }
182
+ /** The parts the hardware section counts, from its records. */ export function posHardwareStorefrontParts(records) {
183
+ return records.flatMap((record)=>record.source === 'in_person' && record.livemode === true && typeof record.storefrontTaxRowId === 'string' && record.storefrontTaxRowId ? [
184
+ {
185
+ storefrontTaxRowId: record.storefrontTaxRowId,
186
+ totalCents: cents(record.totalCents),
187
+ taxCents: cents(record.taxCents)
188
+ }
189
+ ] : []);
190
+ }
191
+ /**
192
+ * The storefront rows with each in-person hardware part taken out: a row's
193
+ * receipts and tax less the hardware's, and a row left with nothing dropped.
194
+ * A row's stated tax lines are kept as they are: a register sale's row is a
195
+ * manual-rate row, which states none.
196
+ */ export function storefrontRowsWithoutInPersonHardware(rows, parts) {
197
+ const byRow = new Map();
198
+ for (const part of parts){
199
+ var _byRow_get;
200
+ const held = (_byRow_get = byRow.get(part.storefrontTaxRowId)) != null ? _byRow_get : {
201
+ totalCents: 0,
202
+ taxCents: 0
203
+ };
204
+ byRow.set(part.storefrontTaxRowId, {
205
+ totalCents: held.totalCents + part.totalCents,
206
+ taxCents: held.taxCents + part.taxCents
207
+ });
208
+ }
209
+ return rows.flatMap((row)=>{
210
+ const part = byRow.get(row.id);
211
+ if (!part) return [
212
+ row
213
+ ];
214
+ const gross = cents(row.grossCents) - part.totalCents;
215
+ if (gross <= 0) return [];
216
+ return [
217
+ _extends({}, row, {
218
+ grossCents: gross,
219
+ taxCents: Math.max(0, cents(row.taxCents) - part.taxCents)
220
+ })
221
+ ];
222
+ });
223
+ }
224
+
225
+ //# sourceMappingURL=pos-hardware-tax-summary.js.map