@mj-biz-apps/sales-core-entities-server 5.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +183 -0
- package/dist/CloseDealOperation.d.ts +176 -0
- package/dist/CloseDealOperation.d.ts.map +1 -0
- package/dist/CloseDealOperation.js +1107 -0
- package/dist/CloseDealOperation.js.map +1 -0
- package/dist/CloseWonTaskService.d.ts +249 -0
- package/dist/CloseWonTaskService.d.ts.map +1 -0
- package/dist/CloseWonTaskService.js +460 -0
- package/dist/CloseWonTaskService.js.map +1 -0
- package/dist/DealEntityServer.d.ts +625 -0
- package/dist/DealEntityServer.d.ts.map +1 -0
- package/dist/DealEntityServer.js +1529 -0
- package/dist/DealEntityServer.js.map +1 -0
- package/dist/LiveContractsSeam.d.ts +212 -0
- package/dist/LiveContractsSeam.d.ts.map +1 -0
- package/dist/LiveContractsSeam.js +362 -0
- package/dist/LiveContractsSeam.js.map +1 -0
- package/dist/LiveOrdersSeam.d.ts +68 -0
- package/dist/LiveOrdersSeam.d.ts.map +1 -0
- package/dist/LiveOrdersSeam.js +80 -0
- package/dist/LiveOrdersSeam.js.map +1 -0
- package/dist/SaveDealOperation.d.ts +45 -0
- package/dist/SaveDealOperation.d.ts.map +1 -0
- package/dist/SaveDealOperation.js +268 -0
- package/dist/SaveDealOperation.js.map +1 -0
- package/dist/SequenceService.d.ts +39 -0
- package/dist/SequenceService.d.ts.map +1 -0
- package/dist/SequenceService.js +44 -0
- package/dist/SequenceService.js.map +1 -0
- package/dist/activities/ActivityIngestService.d.ts +111 -0
- package/dist/activities/ActivityIngestService.d.ts.map +1 -0
- package/dist/activities/ActivityIngestService.js +485 -0
- package/dist/activities/ActivityIngestService.js.map +1 -0
- package/dist/activities/ActivityReader.d.ts +68 -0
- package/dist/activities/ActivityReader.d.ts.map +1 -0
- package/dist/activities/ActivityReader.js +147 -0
- package/dist/activities/ActivityReader.js.map +1 -0
- package/dist/activities/ActivitySource.d.ts +142 -0
- package/dist/activities/ActivitySource.d.ts.map +1 -0
- package/dist/activities/ActivitySource.js +2 -0
- package/dist/activities/ActivitySource.js.map +1 -0
- package/dist/activities/ActivitySyncJob.d.ts +72 -0
- package/dist/activities/ActivitySyncJob.d.ts.map +1 -0
- package/dist/activities/ActivitySyncJob.js +146 -0
- package/dist/activities/ActivitySyncJob.js.map +1 -0
- package/dist/activities/ActivityWriterService.d.ts +119 -0
- package/dist/activities/ActivityWriterService.d.ts.map +1 -0
- package/dist/activities/ActivityWriterService.js +270 -0
- package/dist/activities/ActivityWriterService.js.map +1 -0
- package/dist/activities/DealMatcher.d.ts +58 -0
- package/dist/activities/DealMatcher.d.ts.map +1 -0
- package/dist/activities/DealMatcher.js +109 -0
- package/dist/activities/DealMatcher.js.map +1 -0
- package/dist/activities/FixtureActivitySource.d.ts +37 -0
- package/dist/activities/FixtureActivitySource.d.ts.map +1 -0
- package/dist/activities/FixtureActivitySource.js +58 -0
- package/dist/activities/FixtureActivitySource.js.map +1 -0
- package/dist/activities/GraphMessageMapper.d.ts +47 -0
- package/dist/activities/GraphMessageMapper.d.ts.map +1 -0
- package/dist/activities/GraphMessageMapper.js +141 -0
- package/dist/activities/GraphMessageMapper.js.map +1 -0
- package/dist/activities/ImportedGraphActivitySource.d.ts +16 -0
- package/dist/activities/ImportedGraphActivitySource.d.ts.map +1 -0
- package/dist/activities/ImportedGraphActivitySource.js +84 -0
- package/dist/activities/ImportedGraphActivitySource.js.map +1 -0
- package/dist/activities/MSGraphActivitySource.d.ts +67 -0
- package/dist/activities/MSGraphActivitySource.d.ts.map +1 -0
- package/dist/activities/MSGraphActivitySource.js +186 -0
- package/dist/activities/MSGraphActivitySource.js.map +1 -0
- package/dist/activities/MSGraphCalendarSource.d.ts +72 -0
- package/dist/activities/MSGraphCalendarSource.d.ts.map +1 -0
- package/dist/activities/MSGraphCalendarSource.js +225 -0
- package/dist/activities/MSGraphCalendarSource.js.map +1 -0
- package/dist/activities/RelevanceFilter.d.ts +101 -0
- package/dist/activities/RelevanceFilter.d.ts.map +1 -0
- package/dist/activities/RelevanceFilter.js +148 -0
- package/dist/activities/RelevanceFilter.js.map +1 -0
- package/dist/activities/activity-vocabulary.d.ts +103 -0
- package/dist/activities/activity-vocabulary.d.ts.map +1 -0
- package/dist/activities/activity-vocabulary.js +79 -0
- package/dist/activities/activity-vocabulary.js.map +1 -0
- package/dist/forecast/FixtureForecastSource.d.ts +22 -0
- package/dist/forecast/FixtureForecastSource.d.ts.map +1 -0
- package/dist/forecast/FixtureForecastSource.js +16 -0
- package/dist/forecast/FixtureForecastSource.js.map +1 -0
- package/dist/forecast/ForecastSnapshotJob.d.ts +78 -0
- package/dist/forecast/ForecastSnapshotJob.d.ts.map +1 -0
- package/dist/forecast/ForecastSnapshotJob.js +225 -0
- package/dist/forecast/ForecastSnapshotJob.js.map +1 -0
- package/dist/forecast/ForecastSource.d.ts +74 -0
- package/dist/forecast/ForecastSource.d.ts.map +1 -0
- package/dist/forecast/ForecastSource.js +25 -0
- package/dist/forecast/ForecastSource.js.map +1 -0
- package/dist/forecast/QueryForecastSource.d.ts +76 -0
- package/dist/forecast/QueryForecastSource.d.ts.map +1 -0
- package/dist/forecast/QueryForecastSource.js +164 -0
- package/dist/forecast/QueryForecastSource.js.map +1 -0
- package/dist/index.d.ts +117 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +125 -0
- package/dist/index.js.map +1 -0
- package/dist/orders-availability.d.ts +15 -0
- package/dist/orders-availability.d.ts.map +1 -0
- package/dist/orders-availability.js +47 -0
- package/dist/orders-availability.js.map +1 -0
- package/package.json +43 -0
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.
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview `Sales.CloseDeal` and `Sales.ReopenDeal` — master plan §7.
|
|
3
|
+
*
|
|
4
|
+
* ONE TRANSACTION, ALL-OR-NONE. A partial close — contract created, order missing, lock applied — is
|
|
5
|
+
* the exact failure the transaction exists to prevent (§7.2). Everything below happens inside a single
|
|
6
|
+
* provider transaction, and any throw rolls the whole thing back.
|
|
7
|
+
*
|
|
8
|
+
* ── THE PATH IS RESOLVED FROM FLAGS, NEVER NAMES ────────────────────────────────────────────────
|
|
9
|
+
*
|
|
10
|
+
* The operation is called `CloseDeal`, not `WinDeal`, on purpose. It reads `IsWon` / `IsLost` /
|
|
11
|
+
* `LocksDeal` off the target `DealStatusType` row and branches on those. Nothing here compares a
|
|
12
|
+
* status name, a pipeline name, or the strings "B2B" / "D2C" — a deployment renames those freely and a
|
|
13
|
+
* rename must not change what a close does. Routing comes from `Pipeline.CloseWonPolicy`, which is
|
|
14
|
+
* config-as-data, and from nowhere else. The CI vocabulary grep enforces this.
|
|
15
|
+
*
|
|
16
|
+
* ── SALES STILL COMPUTES NO MONEY ───────────────────────────────────────────────────────────────
|
|
17
|
+
*
|
|
18
|
+
* The close routes lines and passes intent. It does not price them, total them, or apply a discount.
|
|
19
|
+
* Every figure comes back from orders, and while the downstream is stubbed no figure exists at all —
|
|
20
|
+
* which is honest rather than convenient.
|
|
21
|
+
*
|
|
22
|
+
* @module @mj-biz-apps/sales-core-entities-server
|
|
23
|
+
*/
|
|
24
|
+
import { IMetadataProvider, UserInfo } from '@memberjunction/core';
|
|
25
|
+
import { SalesCloseDealOperation as SalesCloseDealOperationBase, SalesReopenDealOperation as SalesReopenDealOperationBase, type IDownstreamSeam, type SalesCloseDealInput, type SalesCloseDealOutput, type SalesReopenDealInput, type SalesReopenDealOutput } from '@mj-biz-apps/sales-entities';
|
|
26
|
+
/** Swap the downstream implementation. Returns the previous one so a test can restore it. */
|
|
27
|
+
export declare function SetDownstreamSeam(seam: IDownstreamSeam): IDownstreamSeam;
|
|
28
|
+
export declare function GetDownstreamSeam(): IDownstreamSeam;
|
|
29
|
+
/**
|
|
30
|
+
* Undo {@link SetDownstreamSeam} and return to DEPLOYMENT-BASED selection.
|
|
31
|
+
*
|
|
32
|
+
* Needed because `SetDownstreamSeam` latches: it records that a caller took control, so auto-selection
|
|
33
|
+
* stops second-guessing them. A test that installs a fake and then merely sets the old value back would
|
|
34
|
+
* leave that latch on, and every later check in the process would keep using whatever it restored —
|
|
35
|
+
* silently, and only on hosts where the live seam would otherwise have been chosen.
|
|
36
|
+
*/
|
|
37
|
+
export declare function ResetDownstreamSeam(): void;
|
|
38
|
+
export declare class CloseDealOperation extends SalesCloseDealOperationBase {
|
|
39
|
+
protected InternalExecute(input: SalesCloseDealInput, provider: IMetadataProvider, user: UserInfo): Promise<SalesCloseDealOutput>;
|
|
40
|
+
/**
|
|
41
|
+
* What this close requires before it may proceed.
|
|
42
|
+
*
|
|
43
|
+
* The loss-reason rule is the app's ONLY mandatory field and the friction is deliberate: loss
|
|
44
|
+
* reasons are the highest-value and most consistently-skipped data in any CRM (§7.2).
|
|
45
|
+
*/
|
|
46
|
+
private validate;
|
|
47
|
+
/**
|
|
48
|
+
* Pipeline default, with the caller's overrides merged over it (§7.1, D-CF6).
|
|
49
|
+
*
|
|
50
|
+
* A malformed policy is a WARNING-shaped failure that falls back to defaults rather than throwing:
|
|
51
|
+
* a pipeline with unparseable JSON should not make its deals uncloseable, and the effective policy
|
|
52
|
+
* is returned to the caller so the fallback is visible rather than silent.
|
|
53
|
+
*/
|
|
54
|
+
private resolvePolicy;
|
|
55
|
+
/**
|
|
56
|
+
* What the policy says should happen, before anything is attempted.
|
|
57
|
+
*
|
|
58
|
+
* ── THERE IS NO LONGER AN ORDER ROUTE, AND THAT IS THE POINT ──
|
|
59
|
+
*
|
|
60
|
+
* Close-won used to create the order. It no longer does: the order is an EMBEDDED RECORD created
|
|
61
|
+
* with the deal and carrying its lines from the start (S-US4), so by the time a deal closes the
|
|
62
|
+
* order already exists. S-US5 is explicit that Closed Won leaves its status ALONE and editable, so
|
|
63
|
+
* finance can review and correct before the Confirm that locks it and triggers invoicing.
|
|
64
|
+
*
|
|
65
|
+
* So close-won no longer counts lines at all — there are none on the deal to count. What it plans
|
|
66
|
+
* is the CONTRACT (B2B only), and the still-unbuilt Subscription materialization.
|
|
67
|
+
*/
|
|
68
|
+
private planRouting;
|
|
69
|
+
/** Attempt one planned route through the seam, recording honestly whether it executed. */
|
|
70
|
+
private execute;
|
|
71
|
+
/**
|
|
72
|
+
* The stage a close should land in, when the caller did not name one.
|
|
73
|
+
*
|
|
74
|
+
* ── THE MIRROR OF `priorStageFromCloseEvent`, AND THE OTHER HALF OF DN-18 ───────────────────────
|
|
75
|
+
*
|
|
76
|
+
* `CD18` proves a reopen restores the stage the deal came from. It could not help a deal closed
|
|
77
|
+
* through the browser, because `DealWorkspaceComponent.ConfirmClose()` sends no `ClosingStageID` — so
|
|
78
|
+
* no browser-driven close ever moved the stage, every close event recorded
|
|
79
|
+
* `FromStageID === ToStageID`, and the reopen correctly derived the stage the deal was already in.
|
|
80
|
+
* The mechanism was right and the UI could not reach it. `71-lost-and-reopen` is the spec that names
|
|
81
|
+
* this.
|
|
82
|
+
*
|
|
83
|
+
* Fixed in the OPERATION rather than in `ConfirmClose`, for the fourth time and the same reason: an
|
|
84
|
+
* agent, an importer and an API caller all close deals too, and a rule the app owns belongs on the
|
|
85
|
+
* write path. `input.ClosingStageID` stays an override.
|
|
86
|
+
*
|
|
87
|
+
* ── CHOSEN BY FLAG, WHICH IS THE ONLY WAY THIS CAN WORK ────────────────────────────────────────
|
|
88
|
+
*
|
|
89
|
+
* The stage on the deal's OWN pipeline whose declared `DealStatusType` matches the outcome being
|
|
90
|
+
* recorded — `IsWon` for a won close, `IsLost` for a lost one. Never a name: a pipeline is free to
|
|
91
|
+
* call its winning stage "Signed", "Booked" or anything else, and §3 is what makes that a label.
|
|
92
|
+
*
|
|
93
|
+
* Returns null rather than guessing when the pipeline declares no such stage. A deal on a pipeline
|
|
94
|
+
* with no losing stage closes as lost without moving, exactly as it did before this existed — the
|
|
95
|
+
* close is never blocked by the absence of somewhere to put it.
|
|
96
|
+
*
|
|
97
|
+
* ── AND IT LEANS ON TWO GUARDS THAT ARE NOW LOAD-BEARING ───────────────────────────────────────
|
|
98
|
+
*
|
|
99
|
+
* Moving into a stage that declares a LOCKING status is only safe because `applyStageDefaults` refuses
|
|
100
|
+
* to derive a locking status (`SD35`), so the stage cannot close the deal a second time; and the
|
|
101
|
+
* closing status stays authoritative because a declared transition suppresses stage defaults entirely
|
|
102
|
+
* (`CD17`). Both are mutant-proven. Without them this change would double-close every deal it touched.
|
|
103
|
+
*/
|
|
104
|
+
private closingStageForOutcome;
|
|
105
|
+
/**
|
|
106
|
+
* Append the provenance row and stamp the deal.
|
|
107
|
+
*
|
|
108
|
+
* `DealStageEvent` is APPEND-ONLY and stamps `AmountAtTransition` / `ProbabilityAtTransition`,
|
|
109
|
+
* because "what did we think this was worth when we closed it" is unanswerable later once amounts
|
|
110
|
+
* change. The routing outcome goes into `Notes` — which is what preserves the intent of a close
|
|
111
|
+
* whose downstream was stubbed (D-CF1).
|
|
112
|
+
*
|
|
113
|
+
* §7 also calls for writing an `Activity` here. The Activity spine does not exist in common or MJ
|
|
114
|
+
* core, so that step is skipped and recorded in CLOSE-FLOW-DECISIONS.md D-CF5 rather than faked.
|
|
115
|
+
*/
|
|
116
|
+
private stampClose;
|
|
117
|
+
/** A human-readable record of what the policy routed, and what actually happened. */
|
|
118
|
+
private routingNote;
|
|
119
|
+
private loadStatusFlags;
|
|
120
|
+
/** Split by the type's `IsRecurring` FLAG. A join, so one read rather than one per line. */
|
|
121
|
+
private dealTypeRequiresRenewalSource;
|
|
122
|
+
private buildContractInput;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* `Sales.ReopenDeal` — the only sanctioned exit from the close lock (§7.3).
|
|
126
|
+
*
|
|
127
|
+
* Writes its own `DealStageEvent` first, so the fact that a close HAPPENED survives the close being
|
|
128
|
+
* undone. Provenance is append-only: reopening adds to the record rather than erasing it.
|
|
129
|
+
*/
|
|
130
|
+
export declare class ReopenDealOperation extends SalesReopenDealOperationBase {
|
|
131
|
+
protected InternalExecute(input: SalesReopenDealInput, provider: IMetadataProvider, user: UserInfo): Promise<SalesReopenDealOutput>;
|
|
132
|
+
private resolveTarget;
|
|
133
|
+
/**
|
|
134
|
+
* The stage a deal was in before it was closed, from the append-only log.
|
|
135
|
+
*
|
|
136
|
+
* ── WHY THE OPERATION DERIVES THIS AND THE WORKSPACE DOES NOT SUPPLY IT ─────────────────────────
|
|
137
|
+
*
|
|
138
|
+
* DN-18. The story says a reopened deal returns to its prior stage; `DealStageEvent.FromStageID`
|
|
139
|
+
* records exactly that, and `input.StageID` already existed. The only missing piece was that nobody
|
|
140
|
+
* sent it — so nothing ever re-entered a stage, `OrderStatusOnEntry` never fired, and a reopened deal
|
|
141
|
+
* sat pointing at a `Voided` order with nothing on screen saying so.
|
|
142
|
+
*
|
|
143
|
+
* Deriving it HERE rather than in the workspace keeps `input.StageID` an override instead of a
|
|
144
|
+
* requirement, and means an agent, an importer and an API caller get the same restoration a rep does.
|
|
145
|
+
* That is the same write-path principle as the deal number, the company stamp, the owner stamp and the
|
|
146
|
+
* embedded order: if the rule is the app's, the server owns it.
|
|
147
|
+
*
|
|
148
|
+
* ── WHICH EVENT, AND BY FLAG RATHER THAN BY NAME ────────────────────────────────────────────────
|
|
149
|
+
*
|
|
150
|
+
* The most recent event whose `ToDealStatusTypeID` carries `LocksDeal` — the closing transition. Read
|
|
151
|
+
* as a set of status ids first because `RunView` cannot join, and selected by the flag so a pipeline
|
|
152
|
+
* calling its winning stage "Signed" and its status "Booked" is unaffected (§3).
|
|
153
|
+
*
|
|
154
|
+
* A deal closed more than once has several such events; `ChangedAt DESC` takes the last one, which is
|
|
155
|
+
* the close being undone.
|
|
156
|
+
*
|
|
157
|
+
* ── THE TWO CASES THAT MAKE THIS CORRECT RATHER THAN CONVENIENT ─────────────────────────────────
|
|
158
|
+
*
|
|
159
|
+
* · **A stage-moving close** stamped `FromStageID` = the stage before the close and `ToStageID` = the
|
|
160
|
+
* closing stage. Restoring `FromStageID` moves the stage back, so the order-status writer fires
|
|
161
|
+
* through the existing mechanism and the order follows — or refuses, and says so.
|
|
162
|
+
* · **A status-only close** (no `ClosingStageID`) never moved the stage, so the event holds
|
|
163
|
+
* `FromStageID === ToStageID`. Restoring it assigns the stage the deal is already in, the writer's
|
|
164
|
+
* own comparison finds no move, and NOTHING fires. There is nothing to restore and nothing
|
|
165
|
+
* happens — which is the behaviour that has to hold for this to be safe, and it holds without a
|
|
166
|
+
* special case.
|
|
167
|
+
*
|
|
168
|
+
* Returns null when there is no close event to read — a deal closed by SQL, an import that wrote no
|
|
169
|
+
* provenance, or a log that was never written. The reopen then leaves the stage alone rather than
|
|
170
|
+
* guessing, which is the same answer as "the caller sent no StageID" and needs no extra branch.
|
|
171
|
+
*/
|
|
172
|
+
private priorStageFromCloseEvent;
|
|
173
|
+
/** The default landing status — chosen by the `IsOpen` FLAG, never by a status name. */
|
|
174
|
+
private firstOpenStatus;
|
|
175
|
+
}
|
|
176
|
+
//# sourceMappingURL=CloseDealOperation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CloseDealOperation.d.ts","sourceRoot":"","sources":["../src/CloseDealOperation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,OAAO,EAGH,iBAAiB,EAIjB,QAAQ,EACX,MAAM,sBAAsB,CAAC;AAa9B,OAAO,EACH,uBAAuB,IAAI,2BAA2B,EACtD,wBAAwB,IAAI,4BAA4B,EAKxD,KAAK,eAAe,EACpB,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EAIzB,KAAK,oBAAoB,EACzB,KAAK,qBAAqB,EAC7B,MAAM,6BAA6B,CAAC;AAsJrC,6FAA6F;AAC7F,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,eAAe,GAAG,eAAe,CAKxE;AAED,wBAAgB,iBAAiB,IAAI,eAAe,CAEnD;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,IAAI,IAAI,CAG1C;AAyCD,qBACa,kBAAmB,SAAQ,2BAA2B;cAC/C,eAAe,CAC3B,KAAK,EAAE,mBAAmB,EAC1B,QAAQ,EAAE,iBAAiB,EAC3B,IAAI,EAAE,QAAQ,GACf,OAAO,CAAC,oBAAoB,CAAC;IAmRhC;;;;;OAKG;YACW,QAAQ;IA0CtB;;;;;;OAMG;YACW,aAAa;IAgC3B;;;;;;;;;;;;OAYG;YACW,WAAW;IA4BzB,0FAA0F;YAC5E,OAAO;IAoCrB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAgCG;YACW,sBAAsB;IAgDpC;;;;;;;;;;OAUG;IACH,OAAO,CAAC,UAAU;IAkDlB,qFAAqF;IACrF,OAAO,CAAC,WAAW;YAqBL,eAAe;IA+B7B,4FAA4F;YAC9E,6BAA6B;YAsB7B,kBAAkB;CAgDnC;AAED;;;;;GAKG;AACH,qBACa,mBAAoB,SAAQ,4BAA4B;cACjD,eAAe,CAC3B,KAAK,EAAE,oBAAoB,EAC3B,QAAQ,EAAE,iBAAiB,EAC3B,IAAI,EAAE,QAAQ,GACf,OAAO,CAAC,qBAAqB,CAAC;YA8MnB,aAAa;IAmB3B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAsCG;YACW,wBAAwB;IA6CtC,wFAAwF;YAC1E,eAAe;CAkBhC"}
|