@mj-biz-apps/orders-core-entities-server 0.0.1 → 5.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +183 -0
- package/README.md +141 -2
- package/dist/AccountingBridge.d.ts +65 -0
- package/dist/AccountingBridge.d.ts.map +1 -0
- package/dist/AccountingBridge.js +102 -0
- package/dist/AccountingBridge.js.map +1 -0
- package/dist/AdvanceOrderStateOperation.d.ts +80 -0
- package/dist/AdvanceOrderStateOperation.d.ts.map +1 -0
- package/dist/AdvanceOrderStateOperation.js +267 -0
- package/dist/AdvanceOrderStateOperation.js.map +1 -0
- package/dist/ApplyAccountCreditOperation.d.ts +97 -0
- package/dist/ApplyAccountCreditOperation.d.ts.map +1 -0
- package/dist/ApplyAccountCreditOperation.js +275 -0
- package/dist/ApplyAccountCreditOperation.js.map +1 -0
- package/dist/BaseDeliveryChannel.d.ts +106 -0
- package/dist/BaseDeliveryChannel.d.ts.map +1 -0
- package/dist/BaseDeliveryChannel.js +36 -0
- package/dist/BaseDeliveryChannel.js.map +1 -0
- package/dist/BasePaymentProvider.d.ts +239 -0
- package/dist/BasePaymentProvider.d.ts.map +1 -0
- package/dist/BasePaymentProvider.js +91 -0
- package/dist/BasePaymentProvider.js.map +1 -0
- package/dist/BundleBehavior.d.ts +139 -0
- package/dist/BundleBehavior.d.ts.map +1 -0
- package/dist/BundleBehavior.js +173 -0
- package/dist/BundleBehavior.js.map +1 -0
- package/dist/BundleEngine.d.ts +60 -0
- package/dist/BundleEngine.d.ts.map +1 -0
- package/dist/BundleEngine.js +197 -0
- package/dist/BundleEngine.js.map +1 -0
- package/dist/CancelSubscriptionOperation.d.ts +98 -0
- package/dist/CancelSubscriptionOperation.d.ts.map +1 -0
- package/dist/CancelSubscriptionOperation.js +317 -0
- package/dist/CancelSubscriptionOperation.js.map +1 -0
- package/dist/CapturePaymentOperation.d.ts +62 -0
- package/dist/CapturePaymentOperation.d.ts.map +1 -0
- package/dist/CapturePaymentOperation.js +463 -0
- package/dist/CapturePaymentOperation.js.map +1 -0
- package/dist/CheckEntitlementOperation.d.ts +27 -0
- package/dist/CheckEntitlementOperation.d.ts.map +1 -0
- package/dist/CheckEntitlementOperation.js +45 -0
- package/dist/CheckEntitlementOperation.js.map +1 -0
- package/dist/CheckoutSessionService.d.ts +258 -0
- package/dist/CheckoutSessionService.d.ts.map +1 -0
- package/dist/CheckoutSessionService.js +1557 -0
- package/dist/CheckoutSessionService.js.map +1 -0
- package/dist/DeliveryBehavior.d.ts +121 -0
- package/dist/DeliveryBehavior.d.ts.map +1 -0
- package/dist/DeliveryBehavior.js +145 -0
- package/dist/DeliveryBehavior.js.map +1 -0
- package/dist/DeliveryRecipientResolver.d.ts +38 -0
- package/dist/DeliveryRecipientResolver.d.ts.map +1 -0
- package/dist/DeliveryRecipientResolver.js +93 -0
- package/dist/DeliveryRecipientResolver.js.map +1 -0
- package/dist/DeliveryResolver.d.ts +14 -0
- package/dist/DeliveryResolver.d.ts.map +1 -0
- package/dist/DeliveryResolver.js +45 -0
- package/dist/DeliveryResolver.js.map +1 -0
- package/dist/EmailDeliveryChannel.d.ts +31 -0
- package/dist/EmailDeliveryChannel.d.ts.map +1 -0
- package/dist/EmailDeliveryChannel.js +158 -0
- package/dist/EmailDeliveryChannel.js.map +1 -0
- package/dist/EntitlementBehavior.d.ts +235 -0
- package/dist/EntitlementBehavior.d.ts.map +1 -0
- package/dist/EntitlementBehavior.js +330 -0
- package/dist/EntitlementBehavior.js.map +1 -0
- package/dist/EntitlementEngine.d.ts +97 -0
- package/dist/EntitlementEngine.d.ts.map +1 -0
- package/dist/EntitlementEngine.js +338 -0
- package/dist/EntitlementEngine.js.map +1 -0
- package/dist/EntitlementGrantClaimDriver.d.ts +42 -0
- package/dist/EntitlementGrantClaimDriver.d.ts.map +1 -0
- package/dist/EntitlementGrantClaimDriver.js +158 -0
- package/dist/EntitlementGrantClaimDriver.js.map +1 -0
- package/dist/EntitlementRead.d.ts +82 -0
- package/dist/EntitlementRead.d.ts.map +1 -0
- package/dist/EntitlementRead.js +368 -0
- package/dist/EntitlementRead.js.map +1 -0
- package/dist/FulfillOrderLinesOperation.d.ts +34 -0
- package/dist/FulfillOrderLinesOperation.d.ts.map +1 -0
- package/dist/FulfillOrderLinesOperation.js +208 -0
- package/dist/FulfillOrderLinesOperation.js.map +1 -0
- package/dist/FulfillmentBehavior.d.ts +101 -0
- package/dist/FulfillmentBehavior.d.ts.map +1 -0
- package/dist/FulfillmentBehavior.js +145 -0
- package/dist/FulfillmentBehavior.js.map +1 -0
- package/dist/GLAccountResolver.d.ts +123 -0
- package/dist/GLAccountResolver.d.ts.map +1 -0
- package/dist/GLAccountResolver.js +175 -0
- package/dist/GLAccountResolver.js.map +1 -0
- package/dist/GetFulfillmentQueueOperation.d.ts +35 -0
- package/dist/GetFulfillmentQueueOperation.d.ts.map +1 -0
- package/dist/GetFulfillmentQueueOperation.js +221 -0
- package/dist/GetFulfillmentQueueOperation.js.map +1 -0
- package/dist/GetOverdueWorklistOperation.d.ts +41 -0
- package/dist/GetOverdueWorklistOperation.d.ts.map +1 -0
- package/dist/GetOverdueWorklistOperation.js +210 -0
- package/dist/GetOverdueWorklistOperation.js.map +1 -0
- package/dist/GiftCardBehavior.d.ts +97 -0
- package/dist/GiftCardBehavior.d.ts.map +1 -0
- package/dist/GiftCardBehavior.js +121 -0
- package/dist/GiftCardBehavior.js.map +1 -0
- package/dist/GiftCardEngine.d.ts +59 -0
- package/dist/GiftCardEngine.d.ts.map +1 -0
- package/dist/GiftCardEngine.js +197 -0
- package/dist/GiftCardEngine.js.map +1 -0
- package/dist/GuestOrderClaimDriver.d.ts +36 -0
- package/dist/GuestOrderClaimDriver.d.ts.map +1 -0
- package/dist/GuestOrderClaimDriver.js +161 -0
- package/dist/GuestOrderClaimDriver.js.map +1 -0
- package/dist/InvoiceBehavior.d.ts +394 -0
- package/dist/InvoiceBehavior.d.ts.map +1 -0
- package/dist/InvoiceBehavior.js +496 -0
- package/dist/InvoiceBehavior.js.map +1 -0
- package/dist/InvoiceBuilder.d.ts +48 -0
- package/dist/InvoiceBuilder.d.ts.map +1 -0
- package/dist/InvoiceBuilder.js +352 -0
- package/dist/InvoiceBuilder.js.map +1 -0
- package/dist/InvoiceDisplay.d.ts +96 -0
- package/dist/InvoiceDisplay.d.ts.map +1 -0
- package/dist/InvoiceDisplay.js +121 -0
- package/dist/InvoiceDisplay.js.map +1 -0
- package/dist/ListEntitlementsOperation.d.ts +21 -0
- package/dist/ListEntitlementsOperation.d.ts.map +1 -0
- package/dist/ListEntitlementsOperation.js +39 -0
- package/dist/ListEntitlementsOperation.js.map +1 -0
- package/dist/ManualPaymentProvider.d.ts +19 -0
- package/dist/ManualPaymentProvider.d.ts.map +1 -0
- package/dist/ManualPaymentProvider.js +92 -0
- package/dist/ManualPaymentProvider.js.map +1 -0
- package/dist/OrderEntityServer.d.ts +542 -0
- package/dist/OrderEntityServer.d.ts.map +1 -0
- package/dist/OrderEntityServer.js +2100 -0
- package/dist/OrderEntityServer.js.map +1 -0
- package/dist/OrderJournalEntryFactory.d.ts +140 -0
- package/dist/OrderJournalEntryFactory.d.ts.map +1 -0
- package/dist/OrderJournalEntryFactory.js +466 -0
- package/dist/OrderJournalEntryFactory.js.map +1 -0
- package/dist/OrderLineEntityServer.d.ts +90 -0
- package/dist/OrderLineEntityServer.d.ts.map +1 -0
- package/dist/OrderLineEntityServer.js +260 -0
- package/dist/OrderLineEntityServer.js.map +1 -0
- package/dist/OrdersSettings.d.ts +36 -0
- package/dist/OrdersSettings.d.ts.map +1 -0
- package/dist/OrdersSettings.js +147 -0
- package/dist/OrdersSettings.js.map +1 -0
- package/dist/PaymentAllocationFactory.d.ts +128 -0
- package/dist/PaymentAllocationFactory.d.ts.map +1 -0
- package/dist/PaymentAllocationFactory.js +235 -0
- package/dist/PaymentAllocationFactory.js.map +1 -0
- package/dist/PaymentHeaderEntityServer.d.ts +180 -0
- package/dist/PaymentHeaderEntityServer.d.ts.map +1 -0
- package/dist/PaymentHeaderEntityServer.js +656 -0
- package/dist/PaymentHeaderEntityServer.js.map +1 -0
- package/dist/PaymentIntentService.d.ts +101 -0
- package/dist/PaymentIntentService.d.ts.map +1 -0
- package/dist/PaymentIntentService.js +150 -0
- package/dist/PaymentIntentService.js.map +1 -0
- package/dist/PaymentJournalEntryFactory.d.ts +99 -0
- package/dist/PaymentJournalEntryFactory.d.ts.map +1 -0
- package/dist/PaymentJournalEntryFactory.js +127 -0
- package/dist/PaymentJournalEntryFactory.js.map +1 -0
- package/dist/PaymentLineEntityServer.d.ts +73 -0
- package/dist/PaymentLineEntityServer.d.ts.map +1 -0
- package/dist/PaymentLineEntityServer.js +303 -0
- package/dist/PaymentLineEntityServer.js.map +1 -0
- package/dist/PaymentProviderBehavior.d.ts +222 -0
- package/dist/PaymentProviderBehavior.d.ts.map +1 -0
- package/dist/PaymentProviderBehavior.js +368 -0
- package/dist/PaymentProviderBehavior.js.map +1 -0
- package/dist/PaymentProviderResolver.d.ts +84 -0
- package/dist/PaymentProviderResolver.d.ts.map +1 -0
- package/dist/PaymentProviderResolver.js +220 -0
- package/dist/PaymentProviderResolver.js.map +1 -0
- package/dist/PaymentReversalFactory.d.ts +107 -0
- package/dist/PaymentReversalFactory.d.ts.map +1 -0
- package/dist/PaymentReversalFactory.js +174 -0
- package/dist/PaymentReversalFactory.js.map +1 -0
- package/dist/PaymentSettlement.d.ts +56 -0
- package/dist/PaymentSettlement.d.ts.map +1 -0
- package/dist/PaymentSettlement.js +243 -0
- package/dist/PaymentSettlement.js.map +1 -0
- package/dist/PaymentTermsBehavior.d.ts +109 -0
- package/dist/PaymentTermsBehavior.d.ts.map +1 -0
- package/dist/PaymentTermsBehavior.js +172 -0
- package/dist/PaymentTermsBehavior.js.map +1 -0
- package/dist/PaymentWebhookHandler.d.ts +103 -0
- package/dist/PaymentWebhookHandler.d.ts.map +1 -0
- package/dist/PaymentWebhookHandler.js +246 -0
- package/dist/PaymentWebhookHandler.js.map +1 -0
- package/dist/PreviewPriceOperation.d.ts +62 -0
- package/dist/PreviewPriceOperation.d.ts.map +1 -0
- package/dist/PreviewPriceOperation.js +161 -0
- package/dist/PreviewPriceOperation.js.map +1 -0
- package/dist/PriceOrderOperation.d.ts +93 -0
- package/dist/PriceOrderOperation.d.ts.map +1 -0
- package/dist/PriceOrderOperation.js +146 -0
- package/dist/PriceOrderOperation.js.map +1 -0
- package/dist/ProductPriceEntityServer.d.ts +34 -0
- package/dist/ProductPriceEntityServer.d.ts.map +1 -0
- package/dist/ProductPriceEntityServer.js +97 -0
- package/dist/ProductPriceEntityServer.js.map +1 -0
- package/dist/RefundPaymentOperation.d.ts +61 -0
- package/dist/RefundPaymentOperation.d.ts.map +1 -0
- package/dist/RefundPaymentOperation.js +177 -0
- package/dist/RefundPaymentOperation.js.map +1 -0
- package/dist/RevenueRecognition.d.ts +76 -0
- package/dist/RevenueRecognition.d.ts.map +1 -0
- package/dist/RevenueRecognition.js +133 -0
- package/dist/RevenueRecognition.js.map +1 -0
- package/dist/ReversalBehavior.d.ts +82 -0
- package/dist/ReversalBehavior.d.ts.map +1 -0
- package/dist/ReversalBehavior.js +100 -0
- package/dist/ReversalBehavior.js.map +1 -0
- package/dist/ReversalResolver.d.ts +37 -0
- package/dist/ReversalResolver.d.ts.map +1 -0
- package/dist/ReversalResolver.js +96 -0
- package/dist/ReversalResolver.js.map +1 -0
- package/dist/SpawnRenewalsOperation.d.ts +109 -0
- package/dist/SpawnRenewalsOperation.d.ts.map +1 -0
- package/dist/SpawnRenewalsOperation.js +295 -0
- package/dist/SpawnRenewalsOperation.js.map +1 -0
- package/dist/StoredValuePaymentProvider.d.ts +52 -0
- package/dist/StoredValuePaymentProvider.d.ts.map +1 -0
- package/dist/StoredValuePaymentProvider.js +205 -0
- package/dist/StoredValuePaymentProvider.js.map +1 -0
- package/dist/StripeACHPaymentProvider.d.ts +50 -0
- package/dist/StripeACHPaymentProvider.d.ts.map +1 -0
- package/dist/StripeACHPaymentProvider.js +211 -0
- package/dist/StripeACHPaymentProvider.js.map +1 -0
- package/dist/StripePaymentProvider.d.ts +83 -0
- package/dist/StripePaymentProvider.d.ts.map +1 -0
- package/dist/StripePaymentProvider.js +442 -0
- package/dist/StripePaymentProvider.js.map +1 -0
- package/dist/SubscriptionBehavior.d.ts +197 -0
- package/dist/SubscriptionBehavior.d.ts.map +1 -0
- package/dist/SubscriptionBehavior.js +415 -0
- package/dist/SubscriptionBehavior.js.map +1 -0
- package/dist/checkoutCaptureAlert.d.ts +16 -0
- package/dist/checkoutCaptureAlert.d.ts.map +1 -0
- package/dist/checkoutCaptureAlert.js +55 -0
- package/dist/checkoutCaptureAlert.js.map +1 -0
- package/dist/checkoutCaptureRetry.d.ts +27 -0
- package/dist/checkoutCaptureRetry.d.ts.map +1 -0
- package/dist/checkoutCaptureRetry.js +50 -0
- package/dist/checkoutCaptureRetry.js.map +1 -0
- package/dist/claimDriverHelpers.d.ts +15 -0
- package/dist/claimDriverHelpers.d.ts.map +1 -0
- package/dist/claimDriverHelpers.js +34 -0
- package/dist/claimDriverHelpers.js.map +1 -0
- package/dist/entity-names.d.ts +15 -0
- package/dist/entity-names.d.ts.map +1 -0
- package/dist/entity-names.js +15 -0
- package/dist/entity-names.js.map +1 -0
- package/dist/identityClaimContracts.d.ts +118 -0
- package/dist/identityClaimContracts.d.ts.map +1 -0
- package/dist/identityClaimContracts.js +58 -0
- package/dist/identityClaimContracts.js.map +1 -0
- package/dist/index.d.ts +126 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +115 -0
- package/dist/index.js.map +1 -0
- package/dist/sql-guards.d.ts +78 -0
- package/dist/sql-guards.d.ts.map +1 -0
- package/dist/sql-guards.js +115 -0
- package/dist/sql-guards.js.map +1 -0
- package/package.json +50 -5
package/LICENSE
ADDED
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
Business Source License 1.1
|
|
2
|
+
|
|
3
|
+
License text copyright (c) 2024 MariaDB plc, All Rights Reserved.
|
|
4
|
+
"Business Source License" is a trademark of MariaDB plc.
|
|
5
|
+
|
|
6
|
+
-----------------------------------------------------------------------------
|
|
7
|
+
|
|
8
|
+
Parameters
|
|
9
|
+
|
|
10
|
+
Licensor: Blue Cypress, Inc.
|
|
11
|
+
|
|
12
|
+
Licensed Work: MemberJunction.
|
|
13
|
+
The Licensed Work is (c) 2023-2026 Blue Cypress, Inc.
|
|
14
|
+
|
|
15
|
+
Additional Use Grant: Subject to the terms of this License, Licensor grants
|
|
16
|
+
you the following additional rights to make Production
|
|
17
|
+
Use of the Licensed Work.
|
|
18
|
+
|
|
19
|
+
1. Internal Use
|
|
20
|
+
|
|
21
|
+
You may make production use of the Licensed Work for
|
|
22
|
+
your own internal business or organizational operations.
|
|
23
|
+
|
|
24
|
+
2. Nonprofit Use
|
|
25
|
+
|
|
26
|
+
If you are a Nonprofit, you may make production use of
|
|
27
|
+
the Licensed Work for the operations and activities of
|
|
28
|
+
your Organizational Family.
|
|
29
|
+
|
|
30
|
+
3. MemberJunction Certified Program Use
|
|
31
|
+
|
|
32
|
+
If you are authorized by Licensor under the
|
|
33
|
+
MemberJunction Certified Program to provide professional
|
|
34
|
+
services using the Licensed Work, you may make
|
|
35
|
+
production use of the Licensed Work in providing such
|
|
36
|
+
professional services to a client, provided that:
|
|
37
|
+
|
|
38
|
+
(a) the Licensed Work is deployed in, and the applicable
|
|
39
|
+
production use occurs within, an environment owned,
|
|
40
|
+
leased, licensed, subscribed to, or otherwise controlled
|
|
41
|
+
by that client; and
|
|
42
|
+
|
|
43
|
+
(b) the production use is for that client's own internal
|
|
44
|
+
business or organizational operations or is otherwise
|
|
45
|
+
independently permitted to that client under this
|
|
46
|
+
Additional Use Grant.
|
|
47
|
+
|
|
48
|
+
4. Definitions Applicable to the Additional Use Grant
|
|
49
|
+
|
|
50
|
+
"Affiliate" means, with respect to a specified Person,
|
|
51
|
+
any other Person that directly or indirectly Controls,
|
|
52
|
+
is Controlled by, or is under common Control with such
|
|
53
|
+
specified Person.
|
|
54
|
+
|
|
55
|
+
"Control" (including the terms "Controls," "Controlled
|
|
56
|
+
by," and "under common Control with") means the direct
|
|
57
|
+
or indirect possession of the power to direct or cause
|
|
58
|
+
the direction of the management and policies of a
|
|
59
|
+
Person, whether through ownership of voting interests,
|
|
60
|
+
by contract, or otherwise.
|
|
61
|
+
|
|
62
|
+
"Organizational Family" means, with respect to a Person,
|
|
63
|
+
(a) such Person and its Affiliates, and (b) any
|
|
64
|
+
nonprofit organization, governmental entity, chapter,
|
|
65
|
+
division, local affiliate, regional affiliate, state
|
|
66
|
+
affiliate, national affiliate, or other entity that is
|
|
67
|
+
formally affiliated with such Person through governing
|
|
68
|
+
documents, a charter, bylaws, a membership agreement, or
|
|
69
|
+
another written organizational instrument, and is
|
|
70
|
+
recognized under such documents as part of the same
|
|
71
|
+
organizational structure.
|
|
72
|
+
|
|
73
|
+
"Nonprofit" means a Person recognized by the Internal
|
|
74
|
+
Revenue Service as exempt from federal income taxation
|
|
75
|
+
under Section 501(c)(3), 501(c)(4), 501(c)(5), or
|
|
76
|
+
501(c)(6) of the Internal Revenue Code, or a foreign
|
|
77
|
+
organization recognized under substantially equivalent
|
|
78
|
+
laws.
|
|
79
|
+
|
|
80
|
+
A Person claiming eligibility as a Nonprofit shall, upon
|
|
81
|
+
Licensor's reasonable request, provide documentation
|
|
82
|
+
reasonably sufficient to demonstrate that it qualifies
|
|
83
|
+
as a Nonprofit. If such Person materially misrepresents,
|
|
84
|
+
or is unable to demonstrate, its qualification as a
|
|
85
|
+
Nonprofit, the rights granted to such Person under
|
|
86
|
+
Section 2 of this Additional Use Grant shall terminate.
|
|
87
|
+
|
|
88
|
+
"MemberJunction Certified Program" means Licensor's
|
|
89
|
+
then-current program for certifying and authorizing a
|
|
90
|
+
Person to provide professional services using the
|
|
91
|
+
Licensed Work.
|
|
92
|
+
|
|
93
|
+
"Person" means any individual, corporation, limited
|
|
94
|
+
liability company, partnership, association, nonprofit
|
|
95
|
+
organization, governmental entity, or other legal or
|
|
96
|
+
organizational entity.
|
|
97
|
+
|
|
98
|
+
Change Date: Four (4) years from the date the Licensed Work is first
|
|
99
|
+
made available.
|
|
100
|
+
|
|
101
|
+
Change License: MIT License.
|
|
102
|
+
|
|
103
|
+
For information about alternative licensing arrangements for the Licensed
|
|
104
|
+
Work, please contact Blue Cypress, Inc.
|
|
105
|
+
|
|
106
|
+
-----------------------------------------------------------------------------
|
|
107
|
+
|
|
108
|
+
Terms
|
|
109
|
+
|
|
110
|
+
The Licensor hereby grants you the right to copy, modify, create derivative
|
|
111
|
+
works, redistribute, and make non-production use of the Licensed Work. The
|
|
112
|
+
Licensor may make an Additional Use Grant, above, permitting limited
|
|
113
|
+
production use.
|
|
114
|
+
|
|
115
|
+
Effective on the Change Date, or the fourth anniversary of the first publicly
|
|
116
|
+
available distribution of a specific version of the Licensed Work under this
|
|
117
|
+
License, whichever comes first, the Licensor hereby grants you rights under
|
|
118
|
+
the terms of the Change License, and the rights granted in the paragraph
|
|
119
|
+
above terminate.
|
|
120
|
+
|
|
121
|
+
If your use of the Licensed Work does not comply with the requirements
|
|
122
|
+
currently in effect as described in this License, you must purchase a
|
|
123
|
+
commercial license from the Licensor, its affiliated entities, or authorized
|
|
124
|
+
resellers, or you must refrain from using the Licensed Work.
|
|
125
|
+
|
|
126
|
+
All copies of the original and modified Licensed Work, and derivative works
|
|
127
|
+
of the Licensed Work, are subject to this License. This License applies
|
|
128
|
+
separately for each version of the Licensed Work and the Change Date may vary
|
|
129
|
+
for each version of the Licensed Work released by Licensor.
|
|
130
|
+
|
|
131
|
+
You must conspicuously display this License on each original or modified copy
|
|
132
|
+
of the Licensed Work. If you receive the Licensed Work in original or
|
|
133
|
+
modified form from a third party, the terms and conditions set forth in this
|
|
134
|
+
License apply to your use of that work.
|
|
135
|
+
|
|
136
|
+
Any use of the Licensed Work in violation of this License will automatically
|
|
137
|
+
terminate your rights under this License for the current and all other
|
|
138
|
+
versions of the Licensed Work.
|
|
139
|
+
|
|
140
|
+
This License does not grant you any right in any trademark or logo of
|
|
141
|
+
Licensor or its affiliates (provided that you may use a trademark or logo of
|
|
142
|
+
Licensor as expressly required by this License).
|
|
143
|
+
|
|
144
|
+
TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON
|
|
145
|
+
AN "AS IS" BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS,
|
|
146
|
+
EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF
|
|
147
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND
|
|
148
|
+
TITLE.
|
|
149
|
+
|
|
150
|
+
MariaDB hereby grants you permission to use this License's text to license
|
|
151
|
+
your works, and to refer to it using the trademark "Business Source License",
|
|
152
|
+
as long as you comply with the Covenants of Licensor below.
|
|
153
|
+
|
|
154
|
+
-----------------------------------------------------------------------------
|
|
155
|
+
|
|
156
|
+
Covenants of Licensor
|
|
157
|
+
|
|
158
|
+
In consideration of the right to use this License's text and the "Business
|
|
159
|
+
Source License" name and trademark, Licensor covenants to MariaDB, and to all
|
|
160
|
+
other recipients of the licensed work to be provided by Licensor:
|
|
161
|
+
|
|
162
|
+
1. To specify as the Change License the GPL Version 2.0 or any later version,
|
|
163
|
+
or a license that is compatible with GPL Version 2.0 or a later version,
|
|
164
|
+
where "compatible" means that software provided under the Change License
|
|
165
|
+
can be included in a program with software provided under GPL Version 2.0
|
|
166
|
+
or a later version. Licensor may specify additional Change Licenses without
|
|
167
|
+
limitation.
|
|
168
|
+
|
|
169
|
+
2. To either: (a) specify an additional grant of rights to use that does not
|
|
170
|
+
impose any additional restriction on the right granted in this License, as
|
|
171
|
+
the Additional Use Grant; or (b) insert the text "None".
|
|
172
|
+
|
|
173
|
+
3. To specify a Change Date.
|
|
174
|
+
|
|
175
|
+
4. Not to modify this License in any other way.
|
|
176
|
+
|
|
177
|
+
-----------------------------------------------------------------------------
|
|
178
|
+
|
|
179
|
+
Notice
|
|
180
|
+
|
|
181
|
+
The Business Source License (this document, or the "License") is not an Open
|
|
182
|
+
Source license. However, the Licensed Work will eventually be made available
|
|
183
|
+
under an Open Source License, as stated in this License.
|
package/README.md
CHANGED
|
@@ -1,3 +1,142 @@
|
|
|
1
|
-
#
|
|
1
|
+
# `@mj-biz-apps/orders-core-entities-server`
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**Every rule that decides money lives here.** Entity subclasses that override `Save()`, the pure
|
|
4
|
+
engines they call, and the remotable operations that expose multi-step work.
|
|
5
|
+
|
|
6
|
+
This package is server-only. Import it from the server bootstrap so its `@RegisterClass` decorators
|
|
7
|
+
fire — nothing here is reachable until they do.
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## The shape: pure core, server shell
|
|
12
|
+
|
|
13
|
+
Each domain is split in two, and the split is deliberate rather than tidy.
|
|
14
|
+
|
|
15
|
+
| Pure (no DB, no entities) | Server (needs a database) |
|
|
16
|
+
|---|---|
|
|
17
|
+
| `PricingBehavior` | `PriceResolver` |
|
|
18
|
+
| `PromotionBehavior` | `PromotionEngine` |
|
|
19
|
+
| `ChargeBehavior` | `ChargeEngine` |
|
|
20
|
+
| `SubscriptionBehavior` | `OrderEntityServer` |
|
|
21
|
+
| `TaxResolver` *(the walk)* | `TaxResolver` *(the lookups)* |
|
|
22
|
+
|
|
23
|
+
**Why:** the arithmetic is where the money is, and money should be provable without a database. Two
|
|
24
|
+
10% promotions are 19% or 20% depending on one setting; a Volume band and a Tiered band give 800 and
|
|
25
|
+
900 for identical inputs. Those facts are asserted in unit tests that run in milliseconds, and the
|
|
26
|
+
server half is then only responsible for finding the right rows.
|
|
27
|
+
|
|
28
|
+
## The order confirm, end to end
|
|
29
|
+
|
|
30
|
+
`OrderEntityServer.Save()` is the spine. Everything happens in ONE transaction:
|
|
31
|
+
|
|
32
|
+
```
|
|
33
|
+
BeginTransaction
|
|
34
|
+
assign OrderNumber
|
|
35
|
+
save the header
|
|
36
|
+
── per line, IN MEMORY ─────────────────────────────
|
|
37
|
+
proration (subscription terms)
|
|
38
|
+
event service period
|
|
39
|
+
price resolution → UnitPrice, ProductPriceID
|
|
40
|
+
decide promotions → DiscountAmount
|
|
41
|
+
decide charges + resolve tax → LineTax, ChargeAmount
|
|
42
|
+
── persist ─────────────────────────────────────────
|
|
43
|
+
save lines
|
|
44
|
+
write adjustment + charge + component rows
|
|
45
|
+
materialize subscriptions
|
|
46
|
+
book journal entries
|
|
47
|
+
create the initial payment
|
|
48
|
+
CommitTransaction
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
**Everything that changes a line's money happens BEFORE the insert.** That ordering is forced, not
|
|
52
|
+
stylistic: a Confirmed line is frozen by trigger 51003, and because MJ's CRUD procs run under
|
|
53
|
+
`INSERT-EXEC`, a trigger rollback surfaces as *"Cannot use the ROLLBACK statement within an
|
|
54
|
+
INSERT-EXEC statement"* — an error naming neither the line nor the rule it broke. Correcting a line
|
|
55
|
+
after insert is not an option, so nothing may need correcting.
|
|
56
|
+
|
|
57
|
+
## Resolution walks
|
|
58
|
+
|
|
59
|
+
Two resolvers walk the **same path**, on purpose — anyone who understands one understands the other,
|
|
60
|
+
and they cannot drift into disagreeing about what "the product's category tree" means:
|
|
61
|
+
|
|
62
|
+
```
|
|
63
|
+
product → its category → that category's ancestors → the company → default
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
- **`GLAccountResolver`** — role → GL account. Nothing resolving is a hard failure; a guessed account
|
|
67
|
+
still balances, so the misposting would be invisible.
|
|
68
|
+
- **`PriceResolver`** — product → price, with `BasePriceResolver` pluggable at any level.
|
|
69
|
+
|
|
70
|
+
`TaxResolver` uses the same chain for taxability (product → category → ancestors → type), with the
|
|
71
|
+
type as a NOT NULL backstop so the walk always terminates.
|
|
72
|
+
|
|
73
|
+
## Refusals are a feature
|
|
74
|
+
|
|
75
|
+
This package refuses more than it computes, and each refusal exists because the alternative is a
|
|
76
|
+
plausible wrong answer:
|
|
77
|
+
|
|
78
|
+
| Situation | Refused because |
|
|
79
|
+
|---|---|
|
|
80
|
+
| Two price rules of equal priority | The winner would be whatever the database returned first — arbitrary, stable in test, liable to flip in production |
|
|
81
|
+
| No GL account for a role or charge | A guessed account still balances; the entry would post and be wrong |
|
|
82
|
+
| A manual discount with no `SalesAuthority` | Absence of an authority is not permission |
|
|
83
|
+
| A captured payment whose lines ≠ its amount | The remainder would have no home in the ledger |
|
|
84
|
+
| An intercompany pair with no mapping | Cash collected by A against B's line would credit A's receivable |
|
|
85
|
+
|
|
86
|
+
**The recurring shape: the wrong answer still looks like a right one.** A wrong price is still a
|
|
87
|
+
price; a mis-oriented intercompany pair still balances. Where a zero is a legitimate outcome, the
|
|
88
|
+
REASON is recorded — tax writes a zero-amount `OrderLinePriceComponent` saying which of the four
|
|
89
|
+
reasons applied.
|
|
90
|
+
|
|
91
|
+
## Remotable operations
|
|
92
|
+
|
|
93
|
+
Multi-step work with guards, exposed through `BaseRemotableOperation`. Logical refusals come back
|
|
94
|
+
**inside** the output as `Success: false` with a reason; only genuine faults throw.
|
|
95
|
+
|
|
96
|
+
| Operation | Does |
|
|
97
|
+
|---|---|
|
|
98
|
+
| `Orders.PreviewPrice` | Dry-run pricing. **Runs the real pipeline** — a preview that diverges from what is charged is worse than none |
|
|
99
|
+
| `Orders.ApplyAccountCredit` | Spends an order's negative balance on another order. Zero-amount payment, two offsetting lines |
|
|
100
|
+
| `Orders.RefundPayment` | Mirrors a capture (D53), proportionally across the orders it settled |
|
|
101
|
+
| `Orders.CancelSubscription` | Cancels with the term's own rules. Revokes standing grants when access-through has already passed |
|
|
102
|
+
| `Orders.SpawnRenewals` | Spawns renewal orders as Drafts |
|
|
103
|
+
| `Orders.CheckEntitlement` | Does this person currently have this capability? Evaluated, not a poll of `Status`. Fail closed |
|
|
104
|
+
| `Orders.ListEntitlements` | The person's library, one row per Code, same evaluator |
|
|
105
|
+
|
|
106
|
+
## Accounting boundary
|
|
107
|
+
|
|
108
|
+
`AccountingBridge` is the only place that knows about bizapps-accounting. Orders resolves accounts
|
|
109
|
+
and submits balanced drafts; accounting owns the ledger.
|
|
110
|
+
|
|
111
|
+
Two constraints that shape everything: accounting derives an entry's company **from its accounts**,
|
|
112
|
+
so a cross-company entry cannot be booked at all — which is why intercompany legs are per company
|
|
113
|
+
rather than one spanning entry. And it rejects negative amounts, so a reversal is the **mirror** of
|
|
114
|
+
an entry (sides swapped, positive amounts), never a negation.
|
|
115
|
+
|
|
116
|
+
## Testing
|
|
117
|
+
|
|
118
|
+
- **Unit** (`src/__tests__`, vitest, no DB) — the pure engines. Volume vs Tiered, stacking
|
|
119
|
+
arithmetic, charge basis, the taxability walk, allocation.
|
|
120
|
+
- **Integration** — `@mj-biz-apps/orders-integration-tests`, transaction-per-check with rollback.
|
|
121
|
+
|
|
122
|
+
Both suites are mutation-tested: break the code deliberately, confirm the checks catch it. Worth the
|
|
123
|
+
effort here because every wrong answer in this domain produces a plausible number *and* a balanced
|
|
124
|
+
entry.
|
|
125
|
+
|
|
126
|
+
## Adding behaviour
|
|
127
|
+
|
|
128
|
+
Prefer a plugin over an edit:
|
|
129
|
+
|
|
130
|
+
```ts
|
|
131
|
+
@RegisterClass(BasePriceResolver, `Company:${companyId}`)
|
|
132
|
+
export class AcmePricing extends BasePriceResolver { /* return null to decline */ }
|
|
133
|
+
|
|
134
|
+
@RegisterClass(BasePromotionQualifier, 'LOYALTY-2YR')
|
|
135
|
+
export class TwoYearMember extends BasePromotionQualifier { /* ... */ }
|
|
136
|
+
|
|
137
|
+
@RegisterClass(BaseTaxJurisdictionResolver)
|
|
138
|
+
export class RooftopResolver extends BaseTaxJurisdictionResolver { /* ... */ }
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
If you must edit an engine: put the arithmetic in the pure half with a unit test, and keep the
|
|
142
|
+
server half to finding rows.
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one place orders reaches into accounting.
|
|
3
|
+
*
|
|
4
|
+
* Both booking paths — order confirm (`Dr AR / Cr Revenue`) and payment capture
|
|
5
|
+
* (`Dr Cash / Cr AR`) — need the same two things: a `GLAccountResolver` wired to the accounting
|
|
6
|
+
* engine, and the MJ entity IDs the polymorphic `GLAccountLink` rows hang off. This module owns
|
|
7
|
+
* both so there is exactly one copy of the coupling rather than one per entity server.
|
|
8
|
+
*
|
|
9
|
+
* `@mj-biz-apps/accounting-engine-base` is imported STATICALLY, like every other import in the repo
|
|
10
|
+
* (CLAUDE.md forbids dynamic require/import). This file used to load the engine through
|
|
11
|
+
* `await import(...)`, justified as keeping a peer dependency out of bundles that do not already
|
|
12
|
+
* have it — but the justification never held, because `pickActiveLinkIndex` below has always been a
|
|
13
|
+
* static import from the same package. The module was therefore already resolved and evaluated at
|
|
14
|
+
* load time; the dynamic form bought nothing and only cost us a lazy failure mode, where a missing
|
|
15
|
+
* peer surfaced deep inside a booking call instead of at import.
|
|
16
|
+
*
|
|
17
|
+
* Load ORDER still matters — accounting's server package registers the remote operation this class
|
|
18
|
+
* resolves by key — but that is a different package (`accounting-server`, wired up by the host app's
|
|
19
|
+
* resolver paths) and is unaffected by how this one is imported.
|
|
20
|
+
*/
|
|
21
|
+
import { IMetadataProvider, UserInfo } from '@memberjunction/core';
|
|
22
|
+
import { GLAccountResolver, type ResolverEntityIDs } from './GLAccountResolver.js';
|
|
23
|
+
/** The subset of `AccountingEngineBase` used here, declared structurally so there is no type import. */
|
|
24
|
+
export interface AccountingEngineSurface {
|
|
25
|
+
ConfigEx(options: {
|
|
26
|
+
forceRefresh?: boolean;
|
|
27
|
+
contextUser?: UserInfo;
|
|
28
|
+
provider?: IMetadataProvider;
|
|
29
|
+
}): Promise<unknown>;
|
|
30
|
+
ResolveLinkedAccount(entityId: string, recordId: string, role: string, asOfDate: Date): {
|
|
31
|
+
Link?: {
|
|
32
|
+
GLAccountID?: string;
|
|
33
|
+
};
|
|
34
|
+
} | null;
|
|
35
|
+
GLAccountByID(glAccountId: string): {
|
|
36
|
+
CompanyID?: string;
|
|
37
|
+
} | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* The raw cached links and roles, needed for the COMPANY-SCOPED lookup (D71): a globally-shared
|
|
40
|
+
* record such as a charge type has one link per company, and `ResolveLinkedAccount` has no
|
|
41
|
+
* company dimension to choose between them.
|
|
42
|
+
*/
|
|
43
|
+
GLAccountLinks: Array<{
|
|
44
|
+
EntityID: string;
|
|
45
|
+
RecordID: string;
|
|
46
|
+
GLAccountID: string;
|
|
47
|
+
GLAccountRoleID: string;
|
|
48
|
+
Status: 'Pending' | 'Active' | 'Disabled';
|
|
49
|
+
StartedAt: Date | null;
|
|
50
|
+
EndedAt: Date | null;
|
|
51
|
+
}>;
|
|
52
|
+
GLAccountRoles: Array<{
|
|
53
|
+
ID: string;
|
|
54
|
+
Name: string;
|
|
55
|
+
}>;
|
|
56
|
+
}
|
|
57
|
+
/** MJ entity ID for a name, with an error that says which name failed rather than `undefined`. */
|
|
58
|
+
export declare function EntityIDFor(name: string): string;
|
|
59
|
+
/** The entity IDs the account-link walk needs. */
|
|
60
|
+
export declare function ResolverEntities(): ResolverEntityIDs;
|
|
61
|
+
/** Load the accounting engine and make sure its caches are populated. */
|
|
62
|
+
export declare function LoadAccountingEngine(provider: IMetadataProvider, user: UserInfo): Promise<AccountingEngineSurface>;
|
|
63
|
+
/** A resolver bound to the live accounting engine. */
|
|
64
|
+
export declare function BuildGLAccountResolver(provider: IMetadataProvider, user: UserInfo): Promise<GLAccountResolver>;
|
|
65
|
+
//# sourceMappingURL=AccountingBridge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AccountingBridge.d.ts","sourceRoot":"","sources":["../src/AccountingBridge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAAE,iBAAiB,EAAY,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAE7E,OAAO,EAAE,iBAAiB,EAAE,KAAK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,EAAE,QAAQ,GACf,OAAO,CAAC,uBAAuB,CAAC,CASlC;AAED,sDAAsD;AACtD,wBAAsB,sBAAsB,CACxC,QAAQ,EAAE,iBAAiB,EAC3B,IAAI,EAAE,QAAQ,GACf,OAAO,CAAC,iBAAiB,CAAC,CA2C5B"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one place orders reaches into accounting.
|
|
3
|
+
*
|
|
4
|
+
* Both booking paths — order confirm (`Dr AR / Cr Revenue`) and payment capture
|
|
5
|
+
* (`Dr Cash / Cr AR`) — need the same two things: a `GLAccountResolver` wired to the accounting
|
|
6
|
+
* engine, and the MJ entity IDs the polymorphic `GLAccountLink` rows hang off. This module owns
|
|
7
|
+
* both so there is exactly one copy of the coupling rather than one per entity server.
|
|
8
|
+
*
|
|
9
|
+
* `@mj-biz-apps/accounting-engine-base` is imported STATICALLY, like every other import in the repo
|
|
10
|
+
* (CLAUDE.md forbids dynamic require/import). This file used to load the engine through
|
|
11
|
+
* `await import(...)`, justified as keeping a peer dependency out of bundles that do not already
|
|
12
|
+
* have it — but the justification never held, because `pickActiveLinkIndex` below has always been a
|
|
13
|
+
* static import from the same package. The module was therefore already resolved and evaluated at
|
|
14
|
+
* load time; the dynamic form bought nothing and only cost us a lazy failure mode, where a missing
|
|
15
|
+
* peer surfaced deep inside a booking call instead of at import.
|
|
16
|
+
*
|
|
17
|
+
* Load ORDER still matters — accounting's server package registers the remote operation this class
|
|
18
|
+
* resolves by key — but that is a different package (`accounting-server`, wired up by the host app's
|
|
19
|
+
* resolver paths) and is unaffected by how this one is imported.
|
|
20
|
+
*/
|
|
21
|
+
import { Metadata } from '@memberjunction/core';
|
|
22
|
+
import { AccountingEngineBase, pickActiveLinkIndex } from '@mj-biz-apps/accounting-engine-base';
|
|
23
|
+
import { GLAccountResolver } from './GLAccountResolver.js';
|
|
24
|
+
const PRODUCT_ENTITY = 'MJ_BizApps_Orders: Products';
|
|
25
|
+
const PRODUCT_CATEGORY_ENTITY = 'MJ_BizApps_Orders: Product Categories';
|
|
26
|
+
const PRODUCT_TYPE_ENTITY = 'MJ_BizApps_Orders: Product Types';
|
|
27
|
+
const COMPANY_ENTITY = 'MJ: Companies';
|
|
28
|
+
/** MJ entity ID for a name, with an error that says which name failed rather than `undefined`. */
|
|
29
|
+
export function EntityIDFor(name) {
|
|
30
|
+
// EntityByName, not Entities.find: it is case- and trim-insensitive and O(1), and it side-steps
|
|
31
|
+
// the global-provider footgun in code paths that were handed a provider (Marcelo, PR #15).
|
|
32
|
+
const entity = new Metadata().EntityByName(name);
|
|
33
|
+
if (!entity) {
|
|
34
|
+
throw new Error(`Entity '${name}' not found in metadata. Has CodeGen run for this schema?`);
|
|
35
|
+
}
|
|
36
|
+
return entity.ID;
|
|
37
|
+
}
|
|
38
|
+
/** The entity IDs the account-link walk needs. */
|
|
39
|
+
export function ResolverEntities() {
|
|
40
|
+
return {
|
|
41
|
+
Product: EntityIDFor(PRODUCT_ENTITY),
|
|
42
|
+
ProductCategory: EntityIDFor(PRODUCT_CATEGORY_ENTITY),
|
|
43
|
+
ProductType: EntityIDFor(PRODUCT_TYPE_ENTITY),
|
|
44
|
+
Company: EntityIDFor(COMPANY_ENTITY),
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
/** Load the accounting engine and make sure its caches are populated. */
|
|
48
|
+
export async function LoadAccountingEngine(provider, user) {
|
|
49
|
+
const engine = AccountingEngineBase.Instance;
|
|
50
|
+
// Force a refresh. ORD-WORLD (and any other process) writes links through BaseEntity
|
|
51
|
+
// in a different Node process than MJAPI; those events never reach this cache, so a
|
|
52
|
+
// Config(false) after startup keeps serving an empty link set and every confirm
|
|
53
|
+
// reports "No GL account is linked for role 'Accounts Receivable'". Reloading a few
|
|
54
|
+
// dozen link rows on a booking is cheaper than a silent miss.
|
|
55
|
+
await engine.ConfigEx({ forceRefresh: true, contextUser: user, provider });
|
|
56
|
+
return engine;
|
|
57
|
+
}
|
|
58
|
+
/** A resolver bound to the live accounting engine. */
|
|
59
|
+
export async function BuildGLAccountResolver(provider, user) {
|
|
60
|
+
const engine = await LoadAccountingEngine(provider, user);
|
|
61
|
+
return new GLAccountResolver(ResolverEntities(), provider, user, (entityId, recordId, role, asOf, forCompanyID) => {
|
|
62
|
+
// COMPANY-SCOPED LOOKUP (D71). Some linked records are GLOBAL while their accounts are
|
|
63
|
+
// per-company — a charge type is one config row shared by every company, but 'shipping
|
|
64
|
+
// revenue' is a different account in each one. `ResolveLinkedAccount` answers "which link
|
|
65
|
+
// wins for this record", which for a global record means picking arbitrarily between several
|
|
66
|
+
// companies' accounts and then failing D6's cross-company guard.
|
|
67
|
+
//
|
|
68
|
+
// When the caller names the company, filter the candidates by the ACCOUNT's company first
|
|
69
|
+
// and let the ordinary window/status rules choose among what is left.
|
|
70
|
+
if (forCompanyID) {
|
|
71
|
+
const key = (v) => (v ?? '').trim().toLowerCase();
|
|
72
|
+
const candidates = engine.GLAccountLinks.filter((l) => {
|
|
73
|
+
if (key(l.EntityID) !== key(entityId))
|
|
74
|
+
return false;
|
|
75
|
+
if (key(l.RecordID) !== key(recordId))
|
|
76
|
+
return false;
|
|
77
|
+
const linkRole = engine.GLAccountRoles.find((r) => key(r.ID) === key(l.GLAccountRoleID));
|
|
78
|
+
if (!linkRole || linkRole.Name.trim().toLowerCase() !== role.trim().toLowerCase())
|
|
79
|
+
return false;
|
|
80
|
+
const acct = engine.GLAccountByID(l.GLAccountID);
|
|
81
|
+
return key(acct?.CompanyID) === key(forCompanyID);
|
|
82
|
+
});
|
|
83
|
+
const winner = pickActiveLinkIndex(candidates.map((l) => ({ Status: l.Status, StartedAt: l.StartedAt, EndedAt: l.EndedAt })), asOf);
|
|
84
|
+
if (winner === -1)
|
|
85
|
+
return null;
|
|
86
|
+
const chosen = candidates[winner];
|
|
87
|
+
const acct = engine.GLAccountByID(chosen.GLAccountID);
|
|
88
|
+
return { GLAccountID: chosen.GLAccountID, CompanyID: acct?.CompanyID ?? '' };
|
|
89
|
+
}
|
|
90
|
+
// ResolveLinkedAccount returns { Link, Dimensions } — the account is on the link.
|
|
91
|
+
const hit = engine.ResolveLinkedAccount(entityId, recordId, role, asOf);
|
|
92
|
+
const glAccountID = hit?.Link?.GLAccountID;
|
|
93
|
+
if (!glAccountID)
|
|
94
|
+
return null;
|
|
95
|
+
// The company comes from the ACCOUNT, not the link. Accounting derives the entry's company
|
|
96
|
+
// that way (their CH-2), so it is the value D6's cross-company guard must compare — reading
|
|
97
|
+
// it off the link would compare the wrong thing and let a mismatch through.
|
|
98
|
+
const account = engine.GLAccountByID(glAccountID);
|
|
99
|
+
return { GLAccountID: glAccountID, CompanyID: account?.CompanyID ?? '' };
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=AccountingBridge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AccountingBridge.js","sourceRoot":"","sources":["../src/AccountingBridge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAAqB,QAAQ,EAAY,MAAM,sBAAsB,CAAC;AAC7E,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAChG,OAAO,EAAE,iBAAiB,EAA0B,MAAM,wBAAwB,CAAC;AAEnF,MAAM,cAAc,GAAG,6BAA6B,CAAC;AACrD,MAAM,uBAAuB,GAAG,uCAAuC,CAAC;AACxE,MAAM,mBAAmB,GAAG,kCAAkC,CAAC;AAC/D,MAAM,cAAc,GAAG,eAAe,CAAC;AAiCvC,kGAAkG;AAClG,MAAM,UAAU,WAAW,CAAC,IAAY;IACpC,gGAAgG;IAChG,2FAA2F;IAC3F,MAAM,MAAM,GAAG,IAAI,QAAQ,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;IACjD,IAAI,CAAC,MAAM,EAAE,CAAC;QACV,MAAM,IAAI,KAAK,CAAC,WAAW,IAAI,2DAA2D,CAAC,CAAC;IA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MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;YACtD,OAAO,EAAE,WAAW,EAAE,MAAM,CAAC,WAAW,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,IAAI,EAAE,EAAE,CAAC;QACjF,CAAC;QAED,kFAAkF;QAClF,MAAM,GAAG,GAAG,MAAM,CAAC,oBAAoB,CAAC,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;QACxE,MAAM,WAAW,GAAG,GAAG,EAAE,IAAI,EAAE,WAAW,CAAC;QAC3C,IAAI,CAAC,WAAW;YAAE,OAAO,IAAI,CAAC;QAE9B,2FAA2F;QAC3F,4FAA4F;QAC5F,4EAA4E;QAC5E,MAAM,OAAO,GAAG,MAAM,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC;QAClD,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,SAAS,IAAI,EAAE,EAAE,CAAC;IAC7E,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview `Orders.AdvanceOrderState` — move a booked order up the status ladder.
|
|
3
|
+
*
|
|
4
|
+
* WHAT THIS IS FOR. Back-office entry of something that has ALREADY happened: a sale taken at a
|
|
5
|
+
* counter, a shipment that went out before anyone opened the system, a migration from whatever came
|
|
6
|
+
* before. The order needs to land in its final state without a human clicking through
|
|
7
|
+
* Confirmed → Posted → Fulfilled (D17).
|
|
8
|
+
*
|
|
9
|
+
* WHAT IT REPLACED, AND WHY IT SHRANK. This was `Orders.CreateOrderInState`, which took an
|
|
10
|
+
* `OrderDraft` — a hand-maintained mirror of the order entity — created the order by delegating to
|
|
11
|
+
* `Orders.ConfirmOrder`, and only then advanced it. Both halves of that are gone: composing and
|
|
12
|
+
* booking an order is now `order.Save()` through MJ's entity graph, which runs the identical booking
|
|
13
|
+
* walk on the server subclass. What is left is the part a save cannot do, and that part is this file.
|
|
14
|
+
*
|
|
15
|
+
* WHY THE LADDER STILL NEEDS AN OPERATION. Advancing to Posted is a plain save. Advancing to
|
|
16
|
+
* Fulfilled is not: the fulfillable LINES have to be marked first, and whether the order may move at
|
|
17
|
+
* all depends on how many could not be. That is a decision over a set of rows, taken on the server,
|
|
18
|
+
* with a caller-supplied override — a save on one header has nowhere to put it.
|
|
19
|
+
*
|
|
20
|
+
* NOTHING HERE BOOKS. Journal entries, subscriptions and entitlements are the confirm's business and
|
|
21
|
+
* have already happened by the time this runs. This operation reads the ledger back only to REPORT
|
|
22
|
+
* it, so a caller can tell "advanced an order that booked" from "advanced an order that did not".
|
|
23
|
+
*
|
|
24
|
+
* @module @mj-biz-apps/orders-core-entities-server
|
|
25
|
+
*/
|
|
26
|
+
import { BaseRemotableOperation, type IMetadataProvider, type UserInfo } from '@memberjunction/core';
|
|
27
|
+
import { type BlockerResult, type OrderStateTransition } from '@mj-biz-apps/orders-entities';
|
|
28
|
+
interface AdvanceOrderStateInput {
|
|
29
|
+
OrderHeaderID: string;
|
|
30
|
+
TargetStatus: string;
|
|
31
|
+
ForceFulfillment?: boolean;
|
|
32
|
+
Reason?: string | null;
|
|
33
|
+
}
|
|
34
|
+
interface AdvanceOrderStateOutput {
|
|
35
|
+
Success: boolean;
|
|
36
|
+
Message?: string | null;
|
|
37
|
+
OrderHeaderID: string | null;
|
|
38
|
+
OrderNumber: string | null;
|
|
39
|
+
Status: string | null;
|
|
40
|
+
RequestedStatus: string;
|
|
41
|
+
Transitions: OrderStateTransition[];
|
|
42
|
+
EntryCount: number;
|
|
43
|
+
AllBalanced: boolean;
|
|
44
|
+
UnfulfilledLineCount: number;
|
|
45
|
+
Blockers: BlockerResult[];
|
|
46
|
+
}
|
|
47
|
+
export declare class AdvanceOrderStateOperation extends BaseRemotableOperation<AdvanceOrderStateInput, AdvanceOrderStateOutput> {
|
|
48
|
+
OperationKey: string;
|
|
49
|
+
protected InternalExecute(input: AdvanceOrderStateInput, provider: IMetadataProvider, user: UserInfo): Promise<AdvanceOrderStateOutput>;
|
|
50
|
+
/**
|
|
51
|
+
* What booked against this order's lines, read back rather than assumed.
|
|
52
|
+
*
|
|
53
|
+
* The confirm happened on a different call — possibly on a different day, for a migration — so
|
|
54
|
+
* this operation has no first-hand knowledge of it. Reporting zero entries because nobody looked
|
|
55
|
+
* is indistinguishable from an order that never booked, and this whole file exists to keep those
|
|
56
|
+
* two apart.
|
|
57
|
+
*/
|
|
58
|
+
private readBookedEntries;
|
|
59
|
+
/** Move the header, reporting a refusal rather than throwing — a stalled advance is still a result. */
|
|
60
|
+
private setStatus;
|
|
61
|
+
/**
|
|
62
|
+
* Mark every line that is awaiting fulfilment, and report how many would not go.
|
|
63
|
+
*
|
|
64
|
+
* The three lookups are per-order rather than per-line on purpose: a migration advances orders in
|
|
65
|
+
* bulk, and a per-line product/type round trip turns a hundred-line order into three hundred
|
|
66
|
+
* queries.
|
|
67
|
+
*/
|
|
68
|
+
private fulfillLines;
|
|
69
|
+
/** The order is booked and moved as far as it could, but not as far as asked. */
|
|
70
|
+
private stopped;
|
|
71
|
+
private blocker;
|
|
72
|
+
private refuse;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Force the class registration. Tree-shaking removes a class nobody imports, and the decorator only
|
|
76
|
+
* runs if the module is loaded — so the server's bootstrap calls this.
|
|
77
|
+
*/
|
|
78
|
+
export declare function LoadAdvanceOrderStateOperation(): void;
|
|
79
|
+
export {};
|
|
80
|
+
//# sourceMappingURL=AdvanceOrderStateOperation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AdvanceOrderStateOperation.d.ts","sourceRoot":"","sources":["../src/AdvanceOrderStateOperation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,OAAO,EACH,sBAAsB,EAEtB,KAAK,iBAAiB,EAEtB,KAAK,QAAQ,EAChB,MAAM,sBAAsB,CAAC;AAE9B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