@mohasinac/appkit 4.61.0 → 4.62.1

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 (281) hide show
  1. package/dist/.build-stamp.json +3 -3
  2. package/dist/_internal/client/features/lottery/LotteryAdminEditView.js +19 -3
  3. package/dist/_internal/client/features/maintenance/views/AnalysisRunnerView.js +1 -1
  4. package/dist/_internal/client/features/maintenance/views/CloudLogsListView.js +1 -1
  5. package/dist/_internal/server/features/checkout/actions.d.ts +80 -0
  6. package/dist/_internal/server/features/checkout/actions.js +542 -26
  7. package/dist/_internal/server/features/invoicing/allocate.d.ts +63 -0
  8. package/dist/_internal/server/features/invoicing/allocate.js +162 -0
  9. package/dist/_internal/server/features/invoicing/credit-note.d.ts +57 -0
  10. package/dist/_internal/server/features/invoicing/credit-note.js +126 -0
  11. package/dist/_internal/server/features/invoicing/gstr1.d.ts +74 -0
  12. package/dist/_internal/server/features/invoicing/gstr1.js +251 -0
  13. package/dist/_internal/server/features/invoicing/issue.d.ts +96 -0
  14. package/dist/_internal/server/features/invoicing/issue.js +202 -0
  15. package/dist/_internal/server/features/orders/actions.d.ts +8 -1
  16. package/dist/_internal/server/features/orders/actions.js +81 -8
  17. package/dist/_internal/server/features/orders/adapters.js +33 -0
  18. package/dist/_internal/server/features/orders/cancellation-refund.d.ts +15 -9
  19. package/dist/_internal/server/features/orders/cancellation-refund.js +15 -9
  20. package/dist/_internal/server/features/points/award.js +46 -4
  21. package/dist/_internal/server/features/refunds/actions.js +26 -0
  22. package/dist/_internal/server/features/shipping/courier-block.d.ts +69 -0
  23. package/dist/_internal/server/features/shipping/courier-block.js +239 -0
  24. package/dist/_internal/server/features/site-settings/adapters.d.ts +1 -1
  25. package/dist/_internal/server/features/site-settings/adapters.js +15 -0
  26. package/dist/_internal/server/features/stores/adapters.d.ts +2 -2
  27. package/dist/_internal/server/features/stores/adapters.js +51 -0
  28. package/dist/_internal/server/functions/scheduled.js +38 -1
  29. package/dist/_internal/server/jobs/core/autoPayoutEligibility.js +9 -2
  30. package/dist/_internal/server/jobs/core/dailyStatusDigest.d.ts +4 -0
  31. package/dist/_internal/server/jobs/core/dailyStatusDigest.js +19 -2
  32. package/dist/_internal/server/jobs/core/index.d.ts +2 -1
  33. package/dist/_internal/server/jobs/core/index.js +2 -1
  34. package/dist/_internal/server/jobs/core/onJobCreated.d.ts +30 -7
  35. package/dist/_internal/server/jobs/core/onJobCreated.js +78 -45
  36. package/dist/_internal/server/jobs/core/onOrderStatusChange.d.ts +7 -0
  37. package/dist/_internal/server/jobs/core/onOrderStatusChange.js +62 -0
  38. package/dist/_internal/server/jobs/core/paymentReconcile.js +87 -97
  39. package/dist/_internal/server/jobs/core/paymentWindowTimeout.js +33 -0
  40. package/dist/_internal/server/jobs/core/runJobOnce.d.ts +48 -0
  41. package/dist/_internal/server/jobs/core/runJobOnce.js +195 -0
  42. package/dist/_internal/server/jobs/core/weeklyPayoutEligibility.js +10 -2
  43. package/dist/_internal/server/jobs/handlers/onOrderStatusChange.js +17 -0
  44. package/dist/_internal/server/notifications/channel-health.d.ts +26 -3
  45. package/dist/_internal/shared/actions/action-registry.js +177 -9
  46. package/dist/_internal/shared/checkout/coupon-discount.d.ts +43 -1
  47. package/dist/_internal/shared/checkout/coupon-discount.js +26 -1
  48. package/dist/_internal/shared/checkout/order-math.d.ts +145 -0
  49. package/dist/_internal/shared/checkout/order-math.js +173 -0
  50. package/dist/_internal/shared/checkout/refundable-base.d.ts +25 -0
  51. package/dist/_internal/shared/checkout/refundable-base.js +13 -1
  52. package/dist/_internal/shared/checkout/split.d.ts +87 -0
  53. package/dist/_internal/shared/checkout/split.js +100 -0
  54. package/dist/_internal/shared/content/disclaimers.d.ts +88 -0
  55. package/dist/_internal/shared/content/disclaimers.js +217 -0
  56. package/dist/_internal/shared/content/published-values.d.ts +88 -0
  57. package/dist/_internal/shared/content/published-values.js +198 -0
  58. package/dist/_internal/shared/features/admin/integrations.d.ts +109 -0
  59. package/dist/_internal/shared/features/admin/integrations.js +253 -0
  60. package/dist/_internal/shared/features/orders/dispute-reasons.d.ts +113 -0
  61. package/dist/_internal/shared/features/orders/dispute-reasons.js +181 -0
  62. package/dist/_internal/shared/features/orders/refund-copy.d.ts +1 -1
  63. package/dist/_internal/shared/features/orders/refund-copy.js +18 -1
  64. package/dist/_internal/shared/features/points/accepts.d.ts +36 -0
  65. package/dist/_internal/shared/features/points/accepts.js +43 -0
  66. package/dist/_internal/shared/features/shipping/shared-purchase.d.ts +91 -0
  67. package/dist/_internal/shared/features/shipping/shared-purchase.js +108 -0
  68. package/dist/_internal/shared/features/site-settings/types.d.ts +11 -0
  69. package/dist/_internal/shared/fees/calculator.d.ts +33 -1
  70. package/dist/_internal/shared/fees/calculator.js +32 -2
  71. package/dist/_internal/shared/media/limits.d.ts +10 -0
  72. package/dist/_internal/shared/media/limits.js +10 -0
  73. package/dist/_internal/shared/types/action-result.js +15 -1
  74. package/dist/client/api/surface-error.js +16 -2
  75. package/dist/client/api/useApiMutation.js +17 -1
  76. package/dist/client.d.ts +12 -1
  77. package/dist/client.js +31 -1
  78. package/dist/constants/api-endpoints.d.ts +45 -0
  79. package/dist/constants/api-endpoints.js +15 -0
  80. package/dist/constants/field-names.d.ts +18 -0
  81. package/dist/constants/field-names.js +28 -0
  82. package/dist/contracts/index.d.ts +1 -1
  83. package/dist/contracts/shipping.d.ts +45 -0
  84. package/dist/contracts/shipping.js +15 -0
  85. package/dist/core/server-action.js +19 -3
  86. package/dist/errors/error-mapping.js +26 -1
  87. package/dist/features/about/components/AboutView.js +1 -1
  88. package/dist/features/account/components/BuyerAuctionsGuideView.js +4 -1
  89. package/dist/features/account/components/UserOffersPanel.js +5 -3
  90. package/dist/features/account/components/UserOrdersView.js +19 -33
  91. package/dist/features/admin/components/AdminActionIndexView.js +100 -5
  92. package/dist/features/admin/components/AdminAddressClustersView.js +21 -2
  93. package/dist/features/admin/components/AdminBlogEditorView.js +8 -8
  94. package/dist/features/admin/components/AdminCarouselEditorView.js +1 -1
  95. package/dist/features/admin/components/AdminCarouselView.js +96 -4
  96. package/dist/features/admin/components/AdminCouponEditorView.js +17 -0
  97. package/dist/features/admin/components/AdminFulfillmentView.js +3 -2
  98. package/dist/features/admin/components/AdminInvoicingView.d.ts +2 -0
  99. package/dist/features/admin/components/AdminInvoicingView.js +65 -0
  100. package/dist/features/admin/components/AdminMediaView.js +36 -3
  101. package/dist/features/admin/components/AdminNavigationView.js +4 -1
  102. package/dist/features/admin/components/AdminOffersView.js +2 -1
  103. package/dist/features/admin/components/AdminOrderEditorView.d.ts +18 -1
  104. package/dist/features/admin/components/AdminOrderEditorView.js +11 -2
  105. package/dist/features/admin/components/AdminOrdersGuideView.js +23 -2
  106. package/dist/features/admin/components/AdminOrdersView.js +67 -5
  107. package/dist/features/admin/components/AdminPaymentClustersView.js +19 -2
  108. package/dist/features/admin/components/AdminProductEditorView.js +2 -2
  109. package/dist/features/admin/components/AdminSectionsView.d.ts +10 -0
  110. package/dist/features/admin/components/AdminSectionsView.js +486 -224
  111. package/dist/features/admin/components/OwnerQuickActions.js +24 -2
  112. package/dist/features/admin/components/ReferenceRecordEditor.js +1 -1
  113. package/dist/features/admin/constants/filter-tabs.d.ts +6 -0
  114. package/dist/features/admin/constants/filter-tabs.js +6 -0
  115. package/dist/features/admin/constants/site-settings-tabs.d.ts +1 -1
  116. package/dist/features/admin/hooks/useAdminListingData.js +16 -0
  117. package/dist/features/admin/hooks/useOptimisticRowFlag.d.ts +33 -0
  118. package/dist/features/admin/hooks/useOptimisticRowFlag.js +87 -0
  119. package/dist/features/admin/repository/notification.repository.d.ts +15 -0
  120. package/dist/features/admin/repository/notification.repository.js +32 -0
  121. package/dist/features/admin/schemas/action-index-form.d.ts +34 -0
  122. package/dist/features/admin/schemas/action-index-form.js +115 -0
  123. package/dist/features/admin/schemas/admin-user-form.d.ts +2 -2
  124. package/dist/features/admin/schemas/firestore.d.ts +30 -0
  125. package/dist/features/admin/schemas/firestore.js +5 -0
  126. package/dist/features/audit-log/schemas/firestore.d.ts +30 -0
  127. package/dist/features/audit-log/schemas/firestore.js +15 -0
  128. package/dist/features/auth/components/RegisterForm.js +2 -1
  129. package/dist/features/auth/permissions/constants.js +13 -0
  130. package/dist/features/cart/components/CartPriceBreakdown.d.ts +13 -0
  131. package/dist/features/cart/components/CartPriceBreakdown.js +6 -2
  132. package/dist/features/cart/components/PointsTenderPicker.d.ts +61 -0
  133. package/dist/features/cart/components/PointsTenderPicker.js +15 -0
  134. package/dist/features/cart/components/StoreAddonsPicker.js +2 -1
  135. package/dist/features/cart/components/index.d.ts +2 -0
  136. package/dist/features/cart/components/index.js +1 -0
  137. package/dist/features/cart/repository/cart.repository.d.ts +19 -0
  138. package/dist/features/cart/repository/cart.repository.js +27 -0
  139. package/dist/features/cart/schemas/firestore.d.ts +92 -0
  140. package/dist/features/catalogue/components/CatalogueItemEditorView.js +3 -3
  141. package/dist/features/contact/email.d.ts +27 -10
  142. package/dist/features/contact/email.js +20 -3
  143. package/dist/features/dispute-reasons/repository/dispute-reasons.repository.d.ts +38 -0
  144. package/dist/features/dispute-reasons/repository/dispute-reasons.repository.js +80 -0
  145. package/dist/features/dispute-reasons/schemas/firestore.d.ts +64 -0
  146. package/dist/features/dispute-reasons/schemas/firestore.js +40 -0
  147. package/dist/features/events/components/AdminEventEditorView.js +8 -6
  148. package/dist/features/faq/components/FAQAccordion.d.ts +13 -1
  149. package/dist/features/faq/components/FAQAccordion.js +29 -4
  150. package/dist/features/invoicing/schemas/firestore.d.ts +112 -0
  151. package/dist/features/invoicing/schemas/firestore.js +45 -0
  152. package/dist/features/invoicing/utils/financial-year.d.ts +43 -0
  153. package/dist/features/invoicing/utils/financial-year.js +53 -0
  154. package/dist/features/jobs/actions/enqueue-job.js +18 -1
  155. package/dist/features/jobs/repository/jobs.repository.d.ts +62 -1
  156. package/dist/features/jobs/repository/jobs.repository.js +84 -1
  157. package/dist/features/jobs/schemas/firestore.d.ts +80 -0
  158. package/dist/features/jobs/schemas/firestore.js +37 -0
  159. package/dist/features/layout/hooks/useFormBottomActions.js +20 -1
  160. package/dist/features/lottery/schemas/zod.d.ts +6 -6
  161. package/dist/features/media/MediaImage.js +22 -1
  162. package/dist/features/media/upload/ImageUpload.js +1 -1
  163. package/dist/features/obligations/constants/policies.js +24 -1
  164. package/dist/features/orders/components/EmiInstallmentsPanel.js +25 -7
  165. package/dist/features/orders/components/OrderPaymentSummary.js +10 -1
  166. package/dist/features/orders/components/OrderProvenanceCard.d.ts +8 -0
  167. package/dist/features/orders/components/OrderProvenanceCard.js +185 -0
  168. package/dist/features/orders/components/RaiseDisputeForm.d.ts +14 -0
  169. package/dist/features/orders/components/RaiseDisputeForm.js +111 -0
  170. package/dist/features/orders/components/RefundRequestView.js +22 -4
  171. package/dist/features/orders/components/index.d.ts +4 -0
  172. package/dist/features/orders/components/index.js +2 -0
  173. package/dist/features/orders/constants/order-lane-tabs.d.ts +69 -0
  174. package/dist/features/orders/constants/order-lane-tabs.js +88 -0
  175. package/dist/features/orders/repository/orders.repository.d.ts +57 -0
  176. package/dist/features/orders/repository/orders.repository.js +145 -0
  177. package/dist/features/orders/schemas/firestore.d.ts +196 -1
  178. package/dist/features/orders/schemas/index.d.ts +60 -12
  179. package/dist/features/orders/schemas/index.js +12 -0
  180. package/dist/features/orders/types/index.d.ts +26 -0
  181. package/dist/features/orders/utils/courier-block.d.ts +25 -0
  182. package/dist/features/orders/utils/courier-block.js +23 -0
  183. package/dist/features/payment-cases/schemas/firestore.d.ts +26 -1
  184. package/dist/features/payment-cases/schemas/firestore.js +1 -0
  185. package/dist/features/products/components/GroupMemberPicker.js +4 -1
  186. package/dist/features/products/components/PrizeDrawDetailPageView.js +2 -2
  187. package/dist/features/products/components/PrizeDrawEntryActions.js +2 -1
  188. package/dist/features/products/components/ProductDetailActions.js +2 -1
  189. package/dist/features/products/components/ProductDetailPageView.d.ts +17 -1
  190. package/dist/features/products/components/ProductDetailPageView.js +2 -2
  191. package/dist/features/products/schemas/product-features.validators.d.ts +10 -10
  192. package/dist/features/promotions/actions/coupon-stacking.d.ts +30 -3
  193. package/dist/features/promotions/actions/coupon-stacking.js +21 -2
  194. package/dist/features/promotions/components/CouponCard.js +13 -0
  195. package/dist/features/promotions/constants/coupon-help.d.ts +2 -2
  196. package/dist/features/promotions/constants/coupon-help.js +9 -1
  197. package/dist/features/promotions/schemas/firestore.d.ts +24 -0
  198. package/dist/features/promotions/schemas/firestore.js +4 -0
  199. package/dist/features/promotions/types/index.d.ts +19 -1
  200. package/dist/features/scams/components/ScamProfileView.js +2 -2
  201. package/dist/features/scams/components/ScamRegistryView.js +2 -2
  202. package/dist/features/search/action-index/tab-entries.js +1 -1
  203. package/dist/features/seller/actions/seller-actions.js +33 -3
  204. package/dist/features/seller/components/FulfillmentView.js +3 -2
  205. package/dist/features/seller/components/SellerAddressesView.js +32 -4
  206. package/dist/features/seller/components/SellerAnalyticsAlertsView.js +62 -3
  207. package/dist/features/seller/components/SellerBundlesView.js +53 -14
  208. package/dist/features/seller/components/SellerGroupedListingsView.js +23 -3
  209. package/dist/features/seller/components/SellerListingTypeView.js +56 -10
  210. package/dist/features/seller/components/SellerOrdersView.js +129 -27
  211. package/dist/features/seller/components/SellerPayoutMethodsView.js +33 -1
  212. package/dist/features/seller/components/SellerPayoutSettingsView.js +48 -9
  213. package/dist/features/seller/components/SellerProductsView.js +5 -1
  214. package/dist/features/seller/components/SellerShippingConfigsView.js +33 -1
  215. package/dist/features/seller/components/SellerShippingView.js +2 -1
  216. package/dist/features/seller/components/SellerStoreCategoriesView.js +33 -1
  217. package/dist/features/seller/components/SellerSupportView.js +69 -2
  218. package/dist/features/seller/hooks/useSellerListingData.js +25 -0
  219. package/dist/features/shell/SectionForm.js +20 -16
  220. package/dist/features/shell/build-sections.js +14 -1
  221. package/dist/features/shipments/components/AdminShipmentLotItemsView.js +54 -1
  222. package/dist/features/shipments/components/AdminShipmentProjectionsView.js +3 -2
  223. package/dist/features/shipments/schemas/validation.d.ts +4 -4
  224. package/dist/features/shipping-boxes/repository/shipping-boxes.repository.d.ts +43 -0
  225. package/dist/features/shipping-boxes/repository/shipping-boxes.repository.js +90 -0
  226. package/dist/features/shipping-boxes/schemas/firestore.d.ts +82 -0
  227. package/dist/features/shipping-boxes/schemas/firestore.js +53 -0
  228. package/dist/features/sticker-trace/components/StickerCommitPanel.js +2 -1
  229. package/dist/features/sticker-trace/components/StickerPrintPanel.js +2 -1
  230. package/dist/features/sticker-trace/components/StickerRetryPanel.js +24 -4
  231. package/dist/features/sticker-trace/components/StickerTraceStudio.js +2 -1
  232. package/dist/features/store-extensions/schemas/report-create-form.d.ts +2 -2
  233. package/dist/features/store-extensions/schemas/shipping-config-form.d.ts +2 -2
  234. package/dist/features/stores/components/StoreOrdersGuideView.js +6 -1
  235. package/dist/features/stores/schemas/firestore.d.ts +71 -0
  236. package/dist/features/stores/types/index.d.ts +19 -0
  237. package/dist/features/support/schemas/index.d.ts +6 -6
  238. package/dist/features/tester/components/AdminTesterFeedbackIssuesView.js +3 -2
  239. package/dist/features/wishlist/hooks/useWishlistWithGuest.d.ts +1 -1
  240. package/dist/index.d.ts +11 -2
  241. package/dist/index.js +17 -2
  242. package/dist/next/routing/route-map.d.ts +24 -0
  243. package/dist/next/routing/route-map.js +19 -0
  244. package/dist/providers/shipping-shiprocket/index.d.ts +27 -1
  245. package/dist/providers/shipping-shiprocket/index.js +84 -1
  246. package/dist/schemas/registry.d.ts +51 -22
  247. package/dist/schemas/sieve.d.ts +5 -5
  248. package/dist/server-entry.d.ts +2 -2
  249. package/dist/server-entry.js +8 -1
  250. package/dist/server.d.ts +11 -2
  251. package/dist/server.js +40 -2
  252. package/dist/styles.css +64 -80
  253. package/dist/tailwind-utilities.css +1 -1
  254. package/dist/tokens/themes/default-dark.js +1 -0
  255. package/dist/tokens/themes/default-light.js +1 -0
  256. package/dist/tokens/themes/required.d.ts +1 -1
  257. package/dist/tokens/themes/required.js +1 -0
  258. package/dist/tokens/tokens.css +15 -0
  259. package/dist/ui/components/Checkbox.js +10 -2
  260. package/dist/ui/components/DateInput.js +8 -1
  261. package/dist/ui/components/Disclaimer.d.ts +19 -0
  262. package/dist/ui/components/Disclaimer.js +74 -0
  263. package/dist/ui/components/Input.js +22 -2
  264. package/dist/ui/components/PaginatedSelect.d.ts +8 -19
  265. package/dist/ui/components/PaginatedSelect.js +43 -9
  266. package/dist/ui/components/Radio.js +8 -1
  267. package/dist/ui/components/Select.js +10 -2
  268. package/dist/ui/components/TagInput.d.ts +8 -1
  269. package/dist/ui/components/TagInput.js +4 -3
  270. package/dist/ui/components/Textarea.js +10 -2
  271. package/dist/ui/components/tabs-overflow.js +64 -11
  272. package/dist/ui/forms/FieldCheckbox.js +1 -1
  273. package/dist/ui/forms/FormErrorList.d.ts +0 -16
  274. package/dist/ui/forms/FormErrorList.js +34 -1
  275. package/dist/ui/forms/apply-zod-issues.d.ts +19 -1
  276. package/dist/ui/forms/apply-zod-issues.js +23 -1
  277. package/dist/ui/index.d.ts +2 -0
  278. package/dist/ui/index.js +6 -0
  279. package/dist/ui/rich-text/RichText.style.css +48 -79
  280. package/package.json +1 -1
  281. package/scripts/seed-cli.mjs +1831 -1822
@@ -783,6 +783,52 @@ class OrderRepository extends BaseRepository {
783
783
  reason: ctx?.reason ?? target.reason,
784
784
  }, "orderRepository.settleRefund", order);
785
785
  }
786
+ /**
787
+ * Stamp a credit-note number onto one settled refund event (Phase 7, 7c).
788
+ *
789
+ * ## 🛑 Why this is a repository method and not an inline update
790
+ *
791
+ * `refunds[]` is written by re-mapping the whole array, exactly as
792
+ * `settleRefund` directly above does — because a read-modify-write of
793
+ * `[...existing, event]` LOSES a concurrent event (D6), and that defect is
794
+ * just as reachable from a credit-note stamp as from a refund append.
795
+ * Letting the invoicing feature touch the array directly would reintroduce
796
+ * it one caller away from the fix.
797
+ *
798
+ * It goes through `updateWithHistory` for the same reason every other
799
+ * mutator here does: the transition guard and the status-history entry live
800
+ * there, and this is a real recorded event on the order.
801
+ *
802
+ * 🛑 A missing refund event is a NO-OP, not a throw. The caller is the
803
+ * refund settle path, where money has already moved; raising here would turn
804
+ * a successful refund into a reported failure. See
805
+ * `issueCreditNoteForRefund`'s own 🛑.
806
+ */
807
+ async setRefundCreditNote(orderId, refundId, note, ctx) {
808
+ const order = await this.findById(orderId);
809
+ if (!order)
810
+ return null;
811
+ const existing = order.refunds ?? [];
812
+ const target = existing.find((r) => r.refundId === refundId);
813
+ if (!target)
814
+ return null;
815
+ // Already numbered — never overwrite. A credit-note number is issued once,
816
+ // and a second number for one reversal is a permanent gap in the series.
817
+ if (target.creditNoteNumber)
818
+ return order;
819
+ const stamped = existing.map((r) => r.refundId === refundId ? { ...r, ...note } : r);
820
+ return this.updateWithHistory(orderId, { refunds: stamped, updatedAt: new Date() }, {
821
+ ...ctx,
822
+ extraChanges: {
823
+ creditNote: {
824
+ from: null,
825
+ to: { refundId, creditNoteNumber: note.creditNoteNumber },
826
+ },
827
+ },
828
+ actor: ctx?.actor ?? { uid: "system:invoicing", role: "system" },
829
+ reason: ctx?.reason ?? `Credit note ${note.creditNoteNumber} issued`,
830
+ }, "orderRepository.setRefundCreditNote", order);
831
+ }
786
832
  /**
787
833
  * 🛑 LEGACY — prefer `reserveRefund` + `settleRefund`.
788
834
  *
@@ -878,6 +924,68 @@ class OrderRepository extends BaseRepository {
878
924
  * `paymentProofUrl != null` filter would silently exclude every doc where
879
925
  * the field isn't set at all — the opposite of what's needed here.
880
926
  */
927
+ /**
928
+ * Orders invoiced within a window — the GSTR-1 export's only query
929
+ * (Phase 7d).
930
+ *
931
+ * ## 🛑 Windowed on `invoiceIssuedAt`, not on the order date
932
+ *
933
+ * A COD order placed on 30 March and paid on 2 April is invoiced in the NEW
934
+ * financial year, and that is the period its tax belongs to. Numbering
935
+ * happens at the payment transition for exactly this reason, so the invoice
936
+ * date is the only correct axis — windowing on `orderDate` would file that
937
+ * order's tax in the year before it was invoiced.
938
+ *
939
+ * ## 🛑 It also returns PAID orders with no invoice number, deliberately
940
+ *
941
+ * Those are the ones the export must warn about rather than omit — a paid
942
+ * order silently absent from a tax return is the single error this whole
943
+ * feature exists to prevent. Firestore cannot OR across two fields, so the
944
+ * second query is a separate one and the caller merges; the alternative
945
+ * (one query on `paymentStatus`, filtered in memory) would scan every paid
946
+ * order ever placed.
947
+ *
948
+ * Unbounded `.limit(2000)`: a quarter's orders at this volume is a few
949
+ * hundred, and an export that silently truncated would understate a tax
950
+ * return. If this ever saturates, the fix is pagination with an explicit
951
+ * "more rows exist" signal in the CSV — never a higher cap.
952
+ */
953
+ async listInvoicedBetween(from, to) {
954
+ const [invoiced, paidUnnumbered] = await Promise.all([
955
+ this.db
956
+ .collection(this.collection)
957
+ .where("invoiceIssuedAt", ">=", from)
958
+ .where("invoiceIssuedAt", "<=", to)
959
+ .limit(2000)
960
+ .get(),
961
+ /*
962
+ * The exceptions. Bounded on `orderDate` because an un-invoiced order
963
+ * has no invoice date to window on — which is the whole problem with it
964
+ * — and because `paymentStatus == paid` alone would match every paid
965
+ * order in the collection's history.
966
+ */
967
+ this.db
968
+ .collection(this.collection)
969
+ .where(ORDER_FIELDS.PAYMENT_STATUS, "==", "paid")
970
+ .where(ORDER_FIELDS.ORDER_DATE, ">=", from)
971
+ .where(ORDER_FIELDS.ORDER_DATE, "<=", to)
972
+ .limit(2000)
973
+ .get(),
974
+ ]);
975
+ const byId = new Map();
976
+ for (const d of invoiced.docs) {
977
+ byId.set(d.id, { id: d.id, ...d.data() });
978
+ }
979
+ for (const d of paidUnnumbered.docs) {
980
+ const data = { id: d.id, ...d.data() };
981
+ // Only the genuinely un-numbered ones — a paid, numbered order is
982
+ // already in the first set, and adding it again would double every one
983
+ // of its rows in the return.
984
+ if (!data.invoiceNumber && !byId.has(d.id))
985
+ byId.set(d.id, data);
986
+ }
987
+ return [...byId.values()];
988
+ }
881
989
  async getExpiredPaymentDeadlines() {
882
990
  const snap = await this.db
883
991
  .collection(this.collection)
@@ -1056,6 +1164,27 @@ class OrderRepository extends BaseRepository {
1056
1164
  * early. Withholding is recoverable — the next sweep picks it up;
1057
1165
  * releasing early is not, because the money has gone.
1058
1166
  */
1167
+ /*
1168
+ * 🛑 A BUYER'S OWN CONFIRMATION RELEASES THE PAYOUT IMMEDIATELY.
1169
+ *
1170
+ * The owner's rule: an order is CONFIRMED when it is delivered and
1171
+ * either the buyer says they received it, or 7 days pass. This filter
1172
+ * only ever implemented the second half — `deliveryDate <= cutoff` —
1173
+ * so a buyer who pressed "Mark complete" on day one still made their
1174
+ * seller wait out the full hold. The fast path existed and bought the
1175
+ * seller nothing.
1176
+ *
1177
+ * Safe in the direction that matters, and not by luck:
1178
+ * `markOrderCompleteAction` is the only writer of `completedAt`, and it
1179
+ * REFUSES while a return in any state, a posted refund or a buyer
1180
+ * dispute is live — the same precondition the `order-complete`
1181
+ * obligation carries. So honouring it here cannot release money while
1182
+ * an issue is open; the hold is skipped only because the one party the
1183
+ * hold protects has said they are satisfied.
1184
+ */
1185
+ const completedAt = toDateOrNull(o.data.completedAt);
1186
+ if (completedAt)
1187
+ return true;
1059
1188
  const anchor = toDateOrNull(o.data.deliveryDate) ?? toDateOrNull(o.data.updatedAt);
1060
1189
  if (!o.data.deliveryDate)
1061
1190
  missingAnchor++;
@@ -1162,6 +1291,22 @@ OrderRepository.SELLER_SIEVE_FIELDS = {
1162
1291
  orderDate: { canFilter: true, canSort: true, parseValue: parseSieveDateValue },
1163
1292
  createdAt: { canFilter: true, canSort: true, parseValue: parseSieveDateValue },
1164
1293
  contestable: { canFilter: true, canSort: false },
1294
+ /*
1295
+ * Lane segregation on the SELLER's order list — the same provenance axis
1296
+ * `/user/orders` has had.
1297
+ *
1298
+ * 🛑 It was absent, and absence here is SILENT: `sieve.ts` sets
1299
+ * `throwExceptions: false`, so an unallowlisted field does not raise —
1300
+ * `findField` returns undefined and the clause is simply dropped. A lane
1301
+ * chip emitting `orderType==auction` would therefore have returned the
1302
+ * seller's ENTIRE order list while looking exactly like a working filter
1303
+ * (Root Cause #62). Checked before wiring the chip, not after.
1304
+ *
1305
+ * 🛑 Never pushed as `orderType==standard`, for the same reason the admin
1306
+ * set above carries that note: orders written before the field existed have
1307
+ * no value to match. `/api/store/orders` refines that one case in memory.
1308
+ */
1309
+ orderType: { canFilter: true, canSort: false },
1165
1310
  // Fulfilment flags. Filterable so "which of my orders need gift wrap?" is a
1166
1311
  // query against the orders themselves — the whole point of recording the
1167
1312
  // add-on on the order rather than keeping a side list of who asked for what.
@@ -7,6 +7,7 @@ import type { BaseDocument } from "../../../_internal/shared/types/base-document
7
7
  import type { ListingType } from "../../products/types";
8
8
  import type { StatusChangeEntry } from "../../../_internal/shared/history/index";
9
9
  import type { ReturnReason } from "../../../_internal/shared/features/orders/return-reasons";
10
+ import type { DisputeKind } from "../../../_internal/shared/features/orders/dispute-reasons";
10
11
  import type { ReturnCustodyState } from "../../../_internal/shared/features/returns/custody";
11
12
  import type { ActualShipmentCost, SelectedShippingQuote, ShippingReconciliation } from "../../../_internal/shared/shipping/quote";
12
13
  import type { Encrypted, Plaintext } from "../../../security/encrypted";
@@ -352,6 +353,25 @@ export interface OrderRefundEvent {
352
353
  proofDocumentMimeType?: string;
353
354
  /** Required for Razorpay-override path ("failed auto-refund, settled manually"). */
354
355
  overrideReason?: string;
356
+ /**
357
+ * The credit note that documents this refund, e.g. `LIRCN/26-27/0001`
358
+ * (Phase 7, D12).
359
+ *
360
+ * 🛑 Per REFUND EVENT, not per order — an order can legitimately be refunded
361
+ * several times, and each reversal of tax needs its own numbered document
362
+ * referencing the original invoice. That is why the allocation claim for a
363
+ * credit note is keyed `${orderId}_${refundId}` while an invoice's is keyed
364
+ * on the order alone: keying a credit note on the order would refuse the
365
+ * second one.
366
+ *
367
+ * Only ever set on a refund that actually SETTLED. A `reserved` entry that
368
+ * failed is not a reversal of anything, and numbering it would leave a
369
+ * credit note in the series for money that never moved.
370
+ */
371
+ creditNoteNumber?: string;
372
+ creditNoteIssuedAt?: Date;
373
+ /** Private storage path — same no-public-URL rule as `invoiceStoragePath`. */
374
+ creditNoteStoragePath?: string;
355
375
  }
356
376
  /** One applied discount/coupon saved on the order for accounting and display */
357
377
  export interface AppliedOrderDiscount {
@@ -426,6 +446,21 @@ export interface OrderDocument extends BaseDocument {
426
446
  */
427
447
  acceptedAt?: Date;
428
448
  shippingDate?: Date;
449
+ /**
450
+ * The COURIER's estimated delivery date, captured at dispatch.
451
+ *
452
+ * 🛑 Not to be confused with `OrderSourcePreOrder.expectedDeliveryDate`,
453
+ * which is when a pre-ordered product RELEASES — a different concept that
454
+ * this field was mistaken for while planning the dispute gates.
455
+ *
456
+ * Optional, and will stay mostly empty for now: nothing platform-books yet
457
+ * (`createShipment` has zero callers), and a self-shipping seller types a
458
+ * tracking number with no estimate attached. `resolveDisputeEtd` therefore
459
+ * falls back to `shippingDate + DISPUTE_TRANSIT_WINDOW_DAYS` — without that
460
+ * fallback the `not_reached` dispute gate would be unreachable for every
461
+ * parcel currently shipped.
462
+ */
463
+ estimatedDeliveryDate?: Date;
429
464
  deliveryDate?: Date;
430
465
  /**
431
466
  * When the order was marked COMPLETE — the fact that awards points and
@@ -481,6 +516,37 @@ export interface OrderDocument extends BaseDocument {
481
516
  * figure the order may since have changed.
482
517
  */
483
518
  pointsAwarded?: number;
519
+ /**
520
+ * Points SPENT on this order as part-payment, in points (1 point = ₹1).
521
+ *
522
+ * 🛑 Distinct from `pointsAwarded` directly above, which is what the buyer
523
+ * EARNED. Both can be non-zero on one order — a buyer can pay partly with
524
+ * points and still earn on the goods value — and conflating them would make
525
+ * the ledger unexplainable in exactly the place it matters most.
526
+ *
527
+ * Written at order creation from `resolvePointsTender`, never from a request
528
+ * body. The ledger's `redemption` entry is keyed on this order, so this field
529
+ * and that entry must agree; the order carries it so a payout deduction and a
530
+ * refund can both answer "how much of this was points" without re-deriving a
531
+ * percentage of a total that may since have changed.
532
+ */
533
+ pointsApplied?: number;
534
+ /**
535
+ * What the buyer actually pays: `totalPrice − pointsApplied`.
536
+ *
537
+ * ## 🛑 THE FIGURE THE GATEWAY CAPTURES, and the one the guard compares
538
+ *
539
+ * `totalPrice` stays the full value of the order — that is what the invoice
540
+ * declares and what GST is computed against, because points are a DISCOUNT
541
+ * and not a reduction in the value of the supply (decision 5). `amountDue` is
542
+ * the cash leg.
543
+ *
544
+ * Absent means "nothing was tendered", so every order written before this
545
+ * existed reads correctly as `amountDue === totalPrice`. 🛑 Readers must use
546
+ * `amountDue ?? totalPrice` rather than defaulting to 0 — treating absence as
547
+ * zero would say every historical order was fully paid in points.
548
+ */
549
+ amountDue?: number;
484
550
  cancellationDate?: Date;
485
551
  cancellationReason?: string;
486
552
  /**
@@ -668,6 +734,25 @@ export interface OrderDocument extends BaseDocument {
668
734
  igst: number;
669
735
  gstAmount: number;
670
736
  }>;
737
+ /**
738
+ * The buyer's state — the PLACE OF SUPPLY (Phase 7).
739
+ *
740
+ * 🛑 This is the input the CGST/SGST-vs-IGST decision was made FROM, and it
741
+ * was not recorded anywhere. `isIntraStateSupply(buyerState, storeState)`
742
+ * runs at checkout and only its *result* survived, in the shape of which tax
743
+ * fields got populated — so an order could not state why it split the way it
744
+ * did, and GSTR-1 has a mandatory place-of-supply column that nothing could
745
+ * fill.
746
+ *
747
+ * `shippingAddress` is a flat STRING on this document and contains the state
748
+ * somewhere inside it; parsing a state back out of free text to file a tax
749
+ * return is not a thing to do. The value is in scope at order creation, so
750
+ * it is written there.
751
+ *
752
+ * Absent on orders placed before this, which the export reports rather than
753
+ * silently blanks.
754
+ */
755
+ placeOfSupply?: string;
671
756
  /**
672
757
  * OUR GST registration as it stood at the moment of supply — LetItRip is the
673
758
  * seller of record and invoices under its own GSTIN.
@@ -689,6 +774,58 @@ export interface OrderDocument extends BaseDocument {
689
774
  supplierGstin?: string;
690
775
  supplierLegalName?: string;
691
776
  supplierAddress?: string;
777
+ /**
778
+ * The invoice number from the gapless FY series, e.g. `LIR/26-27/0001`.
779
+ *
780
+ * 🛑 Allocated on `paymentStatus → paid`, never at order creation — a number
781
+ * burned on an abandoned COD order is a gap nobody can explain. Written once
782
+ * and never rewritten: a GST invoice is issued once, and an adjustment is a
783
+ * CREDIT NOTE, not a re-issue.
784
+ *
785
+ * Absence means "not yet invoiced", which is the correct state for a pending
786
+ * order and for every order placed before this phase.
787
+ */
788
+ invoiceNumber?: string;
789
+ /** When the number was allocated — the invoice's own date. */
790
+ invoiceIssuedAt?: Date;
791
+ /**
792
+ * Where the rendered PDF lives.
793
+ *
794
+ * 🛑 **`private/invoices/{orderId}/{uuid}.pdf`, with NO `mediaAssets` row and
795
+ * a RANDOM object name.** An invoice carries the buyer's full name, address
796
+ * and phone. `/api/media/[...slug]` applies **no authentication** over a
797
+ * bucket whose storage rule is `allow read: if true`, and the slug resolves
798
+ * through `mediaAssets` — so no row means no public URL exists at all.
799
+ *
800
+ * The random name is deliberately AGAINST the content-derived SEO-slug
801
+ * convention used everywhere else in this codebase, because guessable is the
802
+ * one property this must not have. `generateInvoiceFilename` is
803
+ * content-derived and is therefore the wrong tool here. Same reasoning as the
804
+ * digital-content decision (D103).
805
+ */
806
+ invoiceStoragePath?: string;
807
+ /**
808
+ * The arrangement's fees, SNAPSHOTTED at checkout.
809
+ *
810
+ * 🛑 Snapshotted, not re-read. A coordinator commits against a quoted total;
811
+ * if the rates were read again at settle a seller could raise them
812
+ * afterwards and the coordinator would absorb it. The precedent is exact —
813
+ * the refund path reads `finalSale` from this document rather than the live
814
+ * product, "because re-reading the live product would let a seller flip the
815
+ * switch afterwards" — and D61 generalises it to every agreement with a gap
816
+ * between terms-agreed and money-taken.
817
+ *
818
+ * Absent on every ordinary single-destination order, which is almost all of
819
+ * them.
820
+ */
821
+ sharedPurchase?: {
822
+ /** Distinct destinations, including the first. Always ≥ 2 when present. */
823
+ destinationCount: number;
824
+ /** Flat per-arrangement fee, as charged. */
825
+ handlingFee: number;
826
+ /** Extra shipping for destinations beyond the first, as charged. */
827
+ extraShippingFee: number;
828
+ };
692
829
  emiEnabled?: boolean;
693
830
  /** Number of monthly installments the buyer chose (2–6). */
694
831
  emiTenureMonths?: number;
@@ -776,6 +913,38 @@ export interface OrderDocument extends BaseDocument {
776
913
  * requires evidence and approval before anything is paid.
777
914
  */
778
915
  platformBookedShipment?: boolean;
916
+ /**
917
+ * We tried to book a courier for this order and could not.
918
+ *
919
+ * ## 🛑 ITS WHOLE PURPOSE IS TO STOP AN AUTO-CANCELLATION
920
+ *
921
+ * `seller-dispatch` is an `onDue: "act"` obligation on a 2-business-day
922
+ * clock. Without this field, an order sitting on OUR empty courier wallet is
923
+ * auto-cancelled and the buyer refunded — with the seller recorded as having
924
+ * failed to dispatch. The buyer paid, the seller did nothing wrong, and the
925
+ * platform's own funding state caused the cancellation.
926
+ *
927
+ * So every `onDue: "act"` policy anchored at or after dispatch gates its
928
+ * `precondition` on `!hasOpenCourierBlock(order)`. The obligation engine
929
+ * re-evaluates `precondition` at fire time and closes `superseded` when it
930
+ * returns false, so the clock pauses and resumes with no new mechanism.
931
+ *
932
+ * Absent means no block — which is every order ever written, so this needs
933
+ * no migration and changes nothing until something sets it.
934
+ *
935
+ * `reason` is the operator's word, not the seller's: the seller is told only
936
+ * that we could not book a courier right now, because our balance is our
937
+ * problem and not theirs.
938
+ */
939
+ courierBlock?: {
940
+ reason: "insufficient_funds" | "provider_error" | "unserviceable";
941
+ at: Date;
942
+ lastAttemptAt?: Date;
943
+ /** Attempts so far, so the digest can distinguish stuck from transient. */
944
+ attempts: number;
945
+ /** Upstream detail, for the admin surface only. Never shown to a seller. */
946
+ detail?: string;
947
+ };
779
948
  /**
780
949
  * The self-shipped reimbursement workflow: evidence in, approved amount out.
781
950
  *
@@ -970,11 +1139,37 @@ export interface OrderDocument extends BaseDocument {
970
1139
  /** True when `paymentReviewAutoApprove` approved this order after 2 hours of no manual admin review. */
971
1140
  autoApproved?: boolean;
972
1141
  autoApprovedAt?: Date;
973
- /** Buyer/seller/admin dispute raised against an auto-approved order — surfaces to the admin queue, does not itself reverse payment/order status. */
1142
+ /**
1143
+ * A buyer/seller/admin dispute. Surfaces to the admin queue; does not itself
1144
+ * reverse payment or order status.
1145
+ *
1146
+ * 🛑 This used to say "against an auto-approved order", and that was the
1147
+ * whole scope: `raiseOrderDisputeAction` refused anything else, telling the
1148
+ * caller to use the return/refund flow. Disputes are now GENERAL — any
1149
+ * delivered-or-late order can be disputed, gated by `disputeKind`.
1150
+ */
974
1151
  disputeRaised?: boolean;
975
1152
  disputeRaisedBy?: string;
976
1153
  disputeRaisedAt?: Date;
1154
+ /**
1155
+ * The reason's LABEL, snapshotted at the moment the dispute was raised.
1156
+ *
1157
+ * 🛑 A snapshot, not a lookup, and that is the point: `disputeReasons` rows
1158
+ * can be retired or reworded by staff, and neither may rewrite what a buyer
1159
+ * said months ago. `disputeReasonId` below is the join key for analytics;
1160
+ * THIS is the record.
1161
+ *
1162
+ * Still a plain `string` and still the field every existing surface renders,
1163
+ * so pre-2026-10-22 disputes (free text typed by the buyer) keep displaying
1164
+ * unchanged rather than being orphaned beside a new field.
1165
+ */
977
1166
  disputeReason?: string;
1167
+ /** Which gate this dispute passed. Absent on pre-2026-10-22 disputes. */
1168
+ disputeKind?: DisputeKind;
1169
+ /** `disputeReasons/{id}`. The join key for "what are buyers reporting". */
1170
+ disputeReasonId?: string;
1171
+ /** The buyer's own words. Free text, never parsed, never gated on. */
1172
+ disputeDetail?: string;
978
1173
  disputeStatus?: "open" | "resolved";
979
1174
  /**
980
1175
  * Same-shape payment record regardless of how the buyer paid — manual
@@ -53,8 +53,8 @@ export declare const emiInstallmentSchema: z.ZodObject<{
53
53
  }, z.ZodTypeAny, "passthrough">>]>>;
54
54
  }, "strip", z.ZodTypeAny, {
55
55
  status: "paid" | "pending" | "overdue";
56
- amount: number;
57
56
  index: number;
57
+ amount: number;
58
58
  dueDate: string | Date | z.objectOutputType<{
59
59
  toDate: z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodDate>;
60
60
  }, z.ZodTypeAny, "passthrough">;
@@ -68,8 +68,8 @@ export declare const emiInstallmentSchema: z.ZodObject<{
68
68
  }, z.ZodTypeAny, "passthrough"> | undefined;
69
69
  }, {
70
70
  status: "paid" | "pending" | "overdue";
71
- amount: number;
72
71
  index: number;
72
+ amount: number;
73
73
  dueDate: string | Date | z.objectInputType<{
74
74
  toDate: z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodDate>;
75
75
  }, z.ZodTypeAny, "passthrough">;
@@ -145,6 +145,15 @@ export declare const orderRefundEventSchema: z.ZodObject<{
145
145
  proofDocumentUrl: z.ZodOptional<z.ZodString>;
146
146
  proofDocumentMimeType: z.ZodOptional<z.ZodString>;
147
147
  overrideReason: z.ZodOptional<z.ZodString>;
148
+ creditNoteNumber: z.ZodOptional<z.ZodString>;
149
+ creditNoteIssuedAt: z.ZodOptional<z.ZodUnion<[z.ZodDate, z.ZodString, z.ZodObject<{
150
+ toDate: z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodDate>;
151
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
152
+ toDate: z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodDate>;
153
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
154
+ toDate: z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodDate>;
155
+ }, z.ZodTypeAny, "passthrough">>]>>;
156
+ creditNoteStoragePath: z.ZodOptional<z.ZodString>;
148
157
  }, "strip", z.ZodTypeAny, {
149
158
  type: "full" | "partial";
150
159
  amount: number;
@@ -155,8 +164,8 @@ export declare const orderRefundEventSchema: z.ZodObject<{
155
164
  }, z.ZodTypeAny, "passthrough">;
156
165
  refundedBy: string;
157
166
  status?: "failed" | "processed" | "reserved" | undefined;
158
- failureReason?: string | undefined;
159
167
  gateway?: string | undefined;
168
+ failureReason?: string | undefined;
160
169
  itemIds?: string[] | undefined;
161
170
  reasonCode?: string | undefined;
162
171
  gatewayRefundId?: string | undefined;
@@ -166,6 +175,11 @@ export declare const orderRefundEventSchema: z.ZodObject<{
166
175
  proofDocumentUrl?: string | undefined;
167
176
  proofDocumentMimeType?: string | undefined;
168
177
  overrideReason?: string | undefined;
178
+ creditNoteNumber?: string | undefined;
179
+ creditNoteIssuedAt?: string | Date | z.objectOutputType<{
180
+ toDate: z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodDate>;
181
+ }, z.ZodTypeAny, "passthrough"> | undefined;
182
+ creditNoteStoragePath?: string | undefined;
169
183
  }, {
170
184
  type: "full" | "partial";
171
185
  amount: number;
@@ -176,8 +190,8 @@ export declare const orderRefundEventSchema: z.ZodObject<{
176
190
  }, z.ZodTypeAny, "passthrough">;
177
191
  refundedBy: string;
178
192
  status?: "failed" | "processed" | "reserved" | undefined;
179
- failureReason?: string | undefined;
180
193
  gateway?: string | undefined;
194
+ failureReason?: string | undefined;
181
195
  itemIds?: string[] | undefined;
182
196
  reasonCode?: string | undefined;
183
197
  gatewayRefundId?: string | undefined;
@@ -187,6 +201,11 @@ export declare const orderRefundEventSchema: z.ZodObject<{
187
201
  proofDocumentUrl?: string | undefined;
188
202
  proofDocumentMimeType?: string | undefined;
189
203
  overrideReason?: string | undefined;
204
+ creditNoteNumber?: string | undefined;
205
+ creditNoteIssuedAt?: string | Date | z.objectInputType<{
206
+ toDate: z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodDate>;
207
+ }, z.ZodTypeAny, "passthrough"> | undefined;
208
+ creditNoteStoragePath?: string | undefined;
190
209
  }>;
191
210
  export declare const appliedOrderDiscountSchema: z.ZodObject<{
192
211
  code: z.ZodString;
@@ -405,8 +424,8 @@ export declare const orderFirestoreSchema: z.ZodObject<{
405
424
  }, z.ZodTypeAny, "passthrough">>]>>;
406
425
  }, "strip", z.ZodTypeAny, {
407
426
  status: "paid" | "pending" | "overdue";
408
- amount: number;
409
427
  index: number;
428
+ amount: number;
410
429
  dueDate: string | Date | z.objectOutputType<{
411
430
  toDate: z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodDate>;
412
431
  }, z.ZodTypeAny, "passthrough">;
@@ -420,8 +439,8 @@ export declare const orderFirestoreSchema: z.ZodObject<{
420
439
  }, z.ZodTypeAny, "passthrough"> | undefined;
421
440
  }, {
422
441
  status: "paid" | "pending" | "overdue";
423
- amount: number;
424
442
  index: number;
443
+ amount: number;
425
444
  dueDate: string | Date | z.objectInputType<{
426
445
  toDate: z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodDate>;
427
446
  }, z.ZodTypeAny, "passthrough">;
@@ -499,6 +518,15 @@ export declare const orderFirestoreSchema: z.ZodObject<{
499
518
  proofDocumentUrl: z.ZodOptional<z.ZodString>;
500
519
  proofDocumentMimeType: z.ZodOptional<z.ZodString>;
501
520
  overrideReason: z.ZodOptional<z.ZodString>;
521
+ creditNoteNumber: z.ZodOptional<z.ZodString>;
522
+ creditNoteIssuedAt: z.ZodOptional<z.ZodUnion<[z.ZodDate, z.ZodString, z.ZodObject<{
523
+ toDate: z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodDate>;
524
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
525
+ toDate: z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodDate>;
526
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
527
+ toDate: z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodDate>;
528
+ }, z.ZodTypeAny, "passthrough">>]>>;
529
+ creditNoteStoragePath: z.ZodOptional<z.ZodString>;
502
530
  }, "strip", z.ZodTypeAny, {
503
531
  type: "full" | "partial";
504
532
  amount: number;
@@ -509,8 +537,8 @@ export declare const orderFirestoreSchema: z.ZodObject<{
509
537
  }, z.ZodTypeAny, "passthrough">;
510
538
  refundedBy: string;
511
539
  status?: "failed" | "processed" | "reserved" | undefined;
512
- failureReason?: string | undefined;
513
540
  gateway?: string | undefined;
541
+ failureReason?: string | undefined;
514
542
  itemIds?: string[] | undefined;
515
543
  reasonCode?: string | undefined;
516
544
  gatewayRefundId?: string | undefined;
@@ -520,6 +548,11 @@ export declare const orderFirestoreSchema: z.ZodObject<{
520
548
  proofDocumentUrl?: string | undefined;
521
549
  proofDocumentMimeType?: string | undefined;
522
550
  overrideReason?: string | undefined;
551
+ creditNoteNumber?: string | undefined;
552
+ creditNoteIssuedAt?: string | Date | z.objectOutputType<{
553
+ toDate: z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodDate>;
554
+ }, z.ZodTypeAny, "passthrough"> | undefined;
555
+ creditNoteStoragePath?: string | undefined;
523
556
  }, {
524
557
  type: "full" | "partial";
525
558
  amount: number;
@@ -530,8 +563,8 @@ export declare const orderFirestoreSchema: z.ZodObject<{
530
563
  }, z.ZodTypeAny, "passthrough">;
531
564
  refundedBy: string;
532
565
  status?: "failed" | "processed" | "reserved" | undefined;
533
- failureReason?: string | undefined;
534
566
  gateway?: string | undefined;
567
+ failureReason?: string | undefined;
535
568
  itemIds?: string[] | undefined;
536
569
  reasonCode?: string | undefined;
537
570
  gatewayRefundId?: string | undefined;
@@ -541,6 +574,11 @@ export declare const orderFirestoreSchema: z.ZodObject<{
541
574
  proofDocumentUrl?: string | undefined;
542
575
  proofDocumentMimeType?: string | undefined;
543
576
  overrideReason?: string | undefined;
577
+ creditNoteNumber?: string | undefined;
578
+ creditNoteIssuedAt?: string | Date | z.objectInputType<{
579
+ toDate: z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodDate>;
580
+ }, z.ZodTypeAny, "passthrough"> | undefined;
581
+ creditNoteStoragePath?: string | undefined;
544
582
  }>, "many">>;
545
583
  contestable: z.ZodOptional<z.ZodBoolean>;
546
584
  adminBypassBy: z.ZodOptional<z.ZodString>;
@@ -684,8 +722,8 @@ export declare const orderFirestoreSchema: z.ZodObject<{
684
722
  emiSurchargeAmount?: number | undefined;
685
723
  emiInstallments?: {
686
724
  status: "paid" | "pending" | "overdue";
687
- amount: number;
688
725
  index: number;
726
+ amount: number;
689
727
  dueDate: string | Date | z.objectOutputType<{
690
728
  toDate: z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodDate>;
691
729
  }, z.ZodTypeAny, "passthrough">;
@@ -711,8 +749,8 @@ export declare const orderFirestoreSchema: z.ZodObject<{
711
749
  }, z.ZodTypeAny, "passthrough">;
712
750
  refundedBy: string;
713
751
  status?: "failed" | "processed" | "reserved" | undefined;
714
- failureReason?: string | undefined;
715
752
  gateway?: string | undefined;
753
+ failureReason?: string | undefined;
716
754
  itemIds?: string[] | undefined;
717
755
  reasonCode?: string | undefined;
718
756
  gatewayRefundId?: string | undefined;
@@ -722,6 +760,11 @@ export declare const orderFirestoreSchema: z.ZodObject<{
722
760
  proofDocumentUrl?: string | undefined;
723
761
  proofDocumentMimeType?: string | undefined;
724
762
  overrideReason?: string | undefined;
763
+ creditNoteNumber?: string | undefined;
764
+ creditNoteIssuedAt?: string | Date | z.objectOutputType<{
765
+ toDate: z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodDate>;
766
+ }, z.ZodTypeAny, "passthrough"> | undefined;
767
+ creditNoteStoragePath?: string | undefined;
725
768
  }[] | undefined;
726
769
  contestable?: boolean | undefined;
727
770
  adminBypassBy?: string | undefined;
@@ -838,8 +881,8 @@ export declare const orderFirestoreSchema: z.ZodObject<{
838
881
  emiSurchargeAmount?: number | undefined;
839
882
  emiInstallments?: {
840
883
  status: "paid" | "pending" | "overdue";
841
- amount: number;
842
884
  index: number;
885
+ amount: number;
843
886
  dueDate: string | Date | z.objectInputType<{
844
887
  toDate: z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodDate>;
845
888
  }, z.ZodTypeAny, "passthrough">;
@@ -865,8 +908,8 @@ export declare const orderFirestoreSchema: z.ZodObject<{
865
908
  }, z.ZodTypeAny, "passthrough">;
866
909
  refundedBy: string;
867
910
  status?: "failed" | "processed" | "reserved" | undefined;
868
- failureReason?: string | undefined;
869
911
  gateway?: string | undefined;
912
+ failureReason?: string | undefined;
870
913
  itemIds?: string[] | undefined;
871
914
  reasonCode?: string | undefined;
872
915
  gatewayRefundId?: string | undefined;
@@ -876,6 +919,11 @@ export declare const orderFirestoreSchema: z.ZodObject<{
876
919
  proofDocumentUrl?: string | undefined;
877
920
  proofDocumentMimeType?: string | undefined;
878
921
  overrideReason?: string | undefined;
922
+ creditNoteNumber?: string | undefined;
923
+ creditNoteIssuedAt?: string | Date | z.objectInputType<{
924
+ toDate: z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodDate>;
925
+ }, z.ZodTypeAny, "passthrough"> | undefined;
926
+ creditNoteStoragePath?: string | undefined;
879
927
  }[] | undefined;
880
928
  contestable?: boolean | undefined;
881
929
  adminBypassBy?: string | undefined;
@@ -87,6 +87,18 @@ export const orderRefundEventSchema = z.object({
87
87
  proofDocumentUrl: z.string().optional(),
88
88
  proofDocumentMimeType: z.string().optional(),
89
89
  overrideReason: z.string().optional(),
90
+ /*
91
+ * Phase 7 credit note. Added HERE in the same change as the interface, per
92
+ * the 🛑 above: `z.object()` STRIPS unknown keys, so a field present on the
93
+ * interface and absent here is REMOVED on parse — it does not error, it
94
+ * vanishes. That is exactly how this schema silently discarded
95
+ * `razorpayRefundId`, and a credit-note number discarded on parse is a
96
+ * numbered document with nothing pointing at it: the number is consumed, the
97
+ * series has no gap, and no refund claims it.
98
+ */
99
+ creditNoteNumber: z.string().optional(),
100
+ creditNoteIssuedAt: firestoreDateSchema.optional(),
101
+ creditNoteStoragePath: z.string().optional(),
90
102
  });
91
103
  export const appliedOrderDiscountSchema = z.object({
92
104
  code: z.string(),