@mj-biz-apps/orders-entities 5.32.0 → 5.33.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.
Files changed (70) hide show
  1. package/dist/ExternalPaymentBehavior.d.ts +45 -3
  2. package/dist/ExternalPaymentBehavior.d.ts.map +1 -1
  3. package/dist/ExternalPaymentBehavior.js +81 -7
  4. package/dist/ExternalPaymentBehavior.js.map +1 -1
  5. package/dist/KeptPartyOrganizationsCompanion.d.ts +60 -0
  6. package/dist/KeptPartyOrganizationsCompanion.d.ts.map +1 -0
  7. package/dist/KeptPartyOrganizationsCompanion.js +78 -0
  8. package/dist/KeptPartyOrganizationsCompanion.js.map +1 -0
  9. package/dist/OrderHeaderEntity.d.ts +41 -3
  10. package/dist/OrderHeaderEntity.d.ts.map +1 -1
  11. package/dist/OrderHeaderEntity.js +78 -5
  12. package/dist/OrderHeaderEntity.js.map +1 -1
  13. package/dist/attendee-seats.d.ts +42 -0
  14. package/dist/attendee-seats.d.ts.map +1 -0
  15. package/dist/attendee-seats.js +70 -0
  16. package/dist/attendee-seats.js.map +1 -0
  17. package/dist/booked-money.d.ts +1 -1
  18. package/dist/booked-money.d.ts.map +1 -1
  19. package/dist/booked-money.js +1 -0
  20. package/dist/booked-money.js.map +1 -1
  21. package/dist/coverage-overlap.d.ts +36 -0
  22. package/dist/coverage-overlap.d.ts.map +1 -0
  23. package/dist/coverage-overlap.js +45 -0
  24. package/dist/coverage-overlap.js.map +1 -0
  25. package/dist/generated/entities/__mj_BizAppsOrders.d.ts +1082 -186
  26. package/dist/generated/entities/__mj_BizAppsOrders.d.ts.map +1 -1
  27. package/dist/generated/entities/__mj_BizAppsOrders.js +1752 -420
  28. package/dist/generated/entities/__mj_BizAppsOrders.js.map +1 -1
  29. package/dist/generated/remote_operations.d.ts +234 -7
  30. package/dist/generated/remote_operations.d.ts.map +1 -1
  31. package/dist/generated/remote_operations.js +37 -1
  32. package/dist/generated/remote_operations.js.map +1 -1
  33. package/dist/index.d.ts +4 -0
  34. package/dist/index.d.ts.map +1 -1
  35. package/dist/index.js +5 -0
  36. package/dist/index.js.map +1 -1
  37. package/dist/pricing/ChargeEngine.d.ts +16 -0
  38. package/dist/pricing/ChargeEngine.d.ts.map +1 -1
  39. package/dist/pricing/ChargeEngine.js +38 -18
  40. package/dist/pricing/ChargeEngine.js.map +1 -1
  41. package/dist/pricing/ConcessionBehavior.d.ts +98 -7
  42. package/dist/pricing/ConcessionBehavior.d.ts.map +1 -1
  43. package/dist/pricing/ConcessionBehavior.js +108 -15
  44. package/dist/pricing/ConcessionBehavior.js.map +1 -1
  45. package/dist/pricing/OrderPricingService.d.ts +8 -3
  46. package/dist/pricing/OrderPricingService.d.ts.map +1 -1
  47. package/dist/pricing/OrderPricingService.js +32 -22
  48. package/dist/pricing/OrderPricingService.js.map +1 -1
  49. package/dist/pricing/PriceResolver.d.ts.map +1 -1
  50. package/dist/pricing/PriceResolver.js +6 -5
  51. package/dist/pricing/PriceResolver.js.map +1 -1
  52. package/dist/pricing/PricingBehavior.d.ts +28 -0
  53. package/dist/pricing/PricingBehavior.d.ts.map +1 -1
  54. package/dist/pricing/PricingBehavior.js +28 -1
  55. package/dist/pricing/PricingBehavior.js.map +1 -1
  56. package/dist/pricing/PromotionBehavior.d.ts +3 -1
  57. package/dist/pricing/PromotionBehavior.d.ts.map +1 -1
  58. package/dist/pricing/PromotionBehavior.js +18 -3
  59. package/dist/pricing/PromotionBehavior.js.map +1 -1
  60. package/dist/pricing/PromotionEngine.d.ts.map +1 -1
  61. package/dist/pricing/PromotionEngine.js +116 -19
  62. package/dist/pricing/PromotionEngine.js.map +1 -1
  63. package/dist/pricing/applicability.d.ts.map +1 -1
  64. package/dist/pricing/applicability.js +2 -1
  65. package/dist/pricing/applicability.js.map +1 -1
  66. package/dist/sql-guards.d.ts +36 -0
  67. package/dist/sql-guards.d.ts.map +1 -0
  68. package/dist/sql-guards.js +56 -0
  69. package/dist/sql-guards.js.map +1 -0
  70. package/package.json +2 -2
@@ -1,5 +1,6 @@
1
1
  /**
2
- * @fileoverview Pure decisions for money that arrives on an external rail (Bill.com), read by
2
+ * @fileoverview Pure decisions for money that arrives on an external rail (Bill.com, HubSpot
3
+ * Payments), read by
3
4
  * `Orders.PollExternalPayments`. No I/O, no entities — every rule here is a table or a function of
4
5
  * its arguments, so it can be tested exhaustively and read by a finance reviewer.
5
6
  *
@@ -20,7 +21,12 @@
20
21
  * @module @mj-biz-apps/orders-entities
21
22
  */
22
23
  export type ExternalPaymentDisposition = 'Captured' | 'Held' | 'Unmatched' | 'Refused' | 'Ignored' | 'Reapplied' | 'ReversalNeeded';
23
- export type RailPaymentClass = 'Cleared' | 'Pending' | 'Reversed';
24
+ /**
25
+ * What a rail's payment status means for cash. `Attention` is a payment that cleared and then had
26
+ * something happen to it that a person has to book (a refund in flight, a partial refund, an open
27
+ * dispute): never captured while it reads that way, and reported for a person if it was captured.
28
+ */
29
+ export type RailPaymentClass = 'Cleared' | 'Pending' | 'Reversed' | 'Attention';
24
30
  /**
25
31
  * Bill.com `receivable-payments.status` → what it means for cash. Keys are upper-cased.
26
32
  *
@@ -39,7 +45,40 @@ export type RailPaymentClass = 'Cleared' | 'Pending' | 'Reversed';
39
45
  * `ReversalNeeded` for a person.
40
46
  */
41
47
  export declare const BILLCOM_PAYMENT_STATUS: Readonly<Record<string, RailPaymentClass>>;
42
- export declare function ClassifyPaymentStatus(status: string | null | undefined): RailPaymentClass | 'Unknown';
48
+ /**
49
+ * HubSpot `commerce_payments.hs_latest_status` → what it means for cash. Keys are upper-cased.
50
+ *
51
+ * HubSpot documents ten values. `SUCCEEDED` is the only one that is money collected and kept.
52
+ * `FAILED` never collected anything; `REFUNDED` and `DISPUTED_LOST` gave all of it back. The rest are
53
+ * `Attention`: `PARTIALLY_REFUNDED` kept some of the money, and a refund in flight or an open dispute
54
+ * may still go either way. `DISPUTED_WON` is absent on purpose: it is reached only after a dispute,
55
+ * which the payment's earlier `Attention` status already put in front of a person, so it falls to
56
+ * `Unknown` and holds rather than capturing on its own.
57
+ */
58
+ export declare const HUBSPOT_PAYMENT_STATUS: Readonly<Record<string, RailPaymentClass>>;
59
+ /** One rail's status table, with the names the decision's reasons use for it. */
60
+ export interface PaymentStatusVocabulary {
61
+ /** The rail as a person knows it, e.g. `Bill.com`. */
62
+ RailName: string;
63
+ /** The constant to extend when a status turns up that the table does not know. */
64
+ TableName: string;
65
+ Table: Readonly<Record<string, RailPaymentClass>>;
66
+ /**
67
+ * True when the rail reports which of our invoices a payment was applied to (Bill.com's
68
+ * `invoicePayments[]`). Only then can a captured payment be checked for re-application; a rail
69
+ * that reports none would read every captured payment as moved.
70
+ */
71
+ ReportsInvoiceApplications: boolean;
72
+ }
73
+ export declare const BILLCOM_STATUS_VOCABULARY: PaymentStatusVocabulary;
74
+ export declare const HUBSPOT_STATUS_VOCABULARY: PaymentStatusVocabulary;
75
+ /**
76
+ * The status vocabulary for a payment provider type. Keyed by the type's `Code`, which is also the
77
+ * rail's ClassFactory key. A type with no table of its own reads Bill.com's, which was the only rail
78
+ * before HubSpot Payments.
79
+ */
80
+ export declare function PaymentStatusVocabularyFor(typeCode: string | null | undefined): PaymentStatusVocabulary;
81
+ export declare function ClassifyPaymentStatus(status: string | null | undefined, table?: Readonly<Record<string, RailPaymentClass>>): RailPaymentClass | 'Unknown';
43
82
  export interface PaymentSeen {
44
83
  ExternalPaymentRef: string;
45
84
  Status: string | null;
@@ -55,6 +94,8 @@ export interface PaymentSeen {
55
94
  ApplicationsChanged?: boolean;
56
95
  /** What the last pass did with this payment, or null when it has never been seen. */
57
96
  PriorDisposition: ExternalPaymentDisposition | null;
97
+ /** The rail's status table and names. Bill.com's when omitted. */
98
+ Vocabulary?: PaymentStatusVocabulary;
58
99
  }
59
100
  export type ExternalPaymentAction = 'Capture' | 'Hold' | 'Ignore' | 'Reapplied' | 'ReversalNeeded';
60
101
  export interface ExternalPaymentDecision {
@@ -120,4 +161,5 @@ export declare function TenderFor(p: {
120
161
  OnlinePayment: boolean | null;
121
162
  ReceivablesType: string | null;
122
163
  }): OrdersTenderCode;
164
+ export declare function HubSpotTenderFor(methodType: string | null | undefined): OrdersTenderCode | null;
123
165
  //# sourceMappingURL=ExternalPaymentBehavior.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ExternalPaymentBehavior.d.ts","sourceRoot":"","sources":["../src/ExternalPaymentBehavior.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,MAAM,MAAM,0BAA0B,GAAG,UAAU,GAAG,MAAM,GAAG,WAAW,GAAG,SAAS,GAAG,SAAS,GAAG,WAAW,GAAG,gBAAgB,CAAC;AAEpI,MAAM,MAAM,gBAAgB,GAAG,SAAS,GAAG,SAAS,GAAG,UAAU,CAAC;AAElE;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,sBAAsB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAM5E,CAAC;AAEH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,gBAAgB,GAAG,SAAS,CAGrG;AAED,MAAM,WAAW,WAAW;IACxB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB;;;;;;;;OAQG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,qFAAqF;IACrF,gBAAgB,EAAE,0BAA0B,GAAG,IAAI,CAAC;CACvD;AAED,MAAM,MAAM,qBAAqB,GAAG,SAAS,GAAG,MAAM,GAAG,QAAQ,GAAG,WAAW,GAAG,gBAAgB,CAAC;AAEnG,MAAM,WAAW,uBAAuB;IACpC,MAAM,EAAE,qBAAqB,CAAC;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf;;;;;;;;OAQG;IACH,WAAW,CAAC,EAAE,0BAA0B,CAAC;IACzC;;;OAGG;IACH,eAAe,CAAC,EAAE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that arrives on an external rail (Bill.com, HubSpot
3
+ * Payments), read by
3
4
  * `Orders.PollExternalPayments`. No I/O, no entities — every rule here is a table or a function of
4
5
  * its arguments, so it can be tested exhaustively and read by a finance reviewer.
5
6
  *
@@ -43,13 +44,56 @@ export const BILLCOM_PAYMENT_STATUS = Object.freeze({
43
44
  CANCELED: 'Reversed',
44
45
  ESCHEATED: 'Reversed',
45
46
  });
46
- export function ClassifyPaymentStatus(status) {
47
+ /**
48
+ * HubSpot `commerce_payments.hs_latest_status` → what it means for cash. Keys are upper-cased.
49
+ *
50
+ * HubSpot documents ten values. `SUCCEEDED` is the only one that is money collected and kept.
51
+ * `FAILED` never collected anything; `REFUNDED` and `DISPUTED_LOST` gave all of it back. The rest are
52
+ * `Attention`: `PARTIALLY_REFUNDED` kept some of the money, and a refund in flight or an open dispute
53
+ * may still go either way. `DISPUTED_WON` is absent on purpose: it is reached only after a dispute,
54
+ * which the payment's earlier `Attention` status already put in front of a person, so it falls to
55
+ * `Unknown` and holds rather than capturing on its own.
56
+ */
57
+ export const HUBSPOT_PAYMENT_STATUS = Object.freeze({
58
+ SUCCEEDED: 'Cleared',
59
+ PROCESSING: 'Pending',
60
+ FAILED: 'Reversed',
61
+ REFUNDED: 'Reversed',
62
+ DISPUTED_LOST: 'Reversed',
63
+ PARTIALLY_REFUNDED: 'Attention',
64
+ PROCESSING_REFUND: 'Attention',
65
+ DISPUTED_ACTION_REQUIRED: 'Attention',
66
+ DISPUTED_AWAITING_DECISION: 'Attention',
67
+ });
68
+ export const BILLCOM_STATUS_VOCABULARY = Object.freeze({
69
+ RailName: 'Bill.com',
70
+ TableName: 'BILLCOM_PAYMENT_STATUS',
71
+ Table: BILLCOM_PAYMENT_STATUS,
72
+ ReportsInvoiceApplications: true,
73
+ });
74
+ export const HUBSPOT_STATUS_VOCABULARY = Object.freeze({
75
+ RailName: 'HubSpot',
76
+ TableName: 'HUBSPOT_PAYMENT_STATUS',
77
+ Table: HUBSPOT_PAYMENT_STATUS,
78
+ ReportsInvoiceApplications: false,
79
+ });
80
+ /**
81
+ * The status vocabulary for a payment provider type. Keyed by the type's `Code`, which is also the
82
+ * rail's ClassFactory key. A type with no table of its own reads Bill.com's, which was the only rail
83
+ * before HubSpot Payments.
84
+ */
85
+ export function PaymentStatusVocabularyFor(typeCode) {
86
+ return typeCode === 'HubSpotPayments' ? HUBSPOT_STATUS_VOCABULARY : BILLCOM_STATUS_VOCABULARY;
87
+ }
88
+ export function ClassifyPaymentStatus(status, table = BILLCOM_PAYMENT_STATUS) {
47
89
  if (!status)
48
90
  return 'Unknown';
49
- return BILLCOM_PAYMENT_STATUS[status.trim().toUpperCase()] ?? 'Unknown';
91
+ return table[status.trim().toUpperCase()] ?? 'Unknown';
50
92
  }
51
93
  export function DecideExternalPayment(p) {
52
- const cls = ClassifyPaymentStatus(p.Status);
94
+ const vocab = p.Vocabulary ?? BILLCOM_STATUS_VOCABULARY;
95
+ const rail = vocab.RailName;
96
+ const cls = ClassifyPaymentStatus(p.Status, vocab.Table);
53
97
  const ref = p.ExternalPaymentRef;
54
98
  // A CAPTURED PAYMENT AND A RE-APPLIED ONE ARE THE SAME QUESTION, asked a poll apart. Both have
55
99
  // cash recorded against them, so both are re-examined the same way — and `Reapplied` is NOT a
@@ -60,7 +104,15 @@ export function DecideExternalPayment(p) {
60
104
  // hour after it was raised — leaving the wrong allocation in place with nothing flagging it.
61
105
  if (p.PriorDisposition === 'Captured' || p.PriorDisposition === 'Reapplied') {
62
106
  if (cls === 'Reversed') {
63
- return { Action: 'ReversalNeeded', Reason: `${ref} was captured and Bill.com now reports it '${p.Status}'. The cash has to be reversed (bank-return path, O-US13); nothing is changed automatically.` };
107
+ return { Action: 'ReversalNeeded', Reason: `${ref} was captured and ${rail} now reports it '${p.Status}'. The cash has to be reversed (bank-return path, O-US13); nothing is changed automatically.` };
108
+ }
109
+ if (cls === 'Attention') {
110
+ // A refund or dispute against cash already booked. Not a full reversal, and not something
111
+ // to ignore: the refund or the chargeback has to be booked by a person.
112
+ return {
113
+ Action: 'ReversalNeeded',
114
+ Reason: `${ref} was captured and ${rail} now reports it '${p.Status}' (a refund or a dispute). Book the refund or chargeback against the captured payment; nothing is changed automatically.`,
115
+ };
64
116
  }
65
117
  // THE RAIL CAN MOVE MONEY WE ALREADY RECORDED. Bill.com lets Finance re-apply a receipt:
66
118
  // 700.00 recorded against invoice A last week becomes 300.00 on A and 400.00 on B today, or
@@ -115,13 +167,18 @@ export function DecideExternalPayment(p) {
115
167
  case 'Cleared':
116
168
  return { Action: 'Capture', Reason: `${ref} is '${p.Status}': cleared and not yet captured.` };
117
169
  case 'Pending':
118
- return { Action: 'Hold', Reason: `${ref} is '${p.Status}': promised, not yet banked. Held until Bill.com reports it cleared.` };
170
+ return { Action: 'Hold', Reason: `${ref} is '${p.Status}': promised, not yet banked. Held until ${rail} reports it cleared.` };
119
171
  case 'Reversed':
120
172
  return { Action: 'Ignore', Reason: `${ref} is '${p.Status}' and was never captured; there is nothing to reverse.` };
173
+ case 'Attention':
174
+ return {
175
+ Action: 'Hold',
176
+ Reason: `${ref} is '${p.Status}' (a refund or a dispute) and was never captured. Held: record what was kept by hand, or wait for ${rail} to settle it.`,
177
+ };
121
178
  default:
122
179
  return {
123
180
  Action: 'Hold',
124
- Reason: `${ref} has an unknown Bill.com status '${p.Status ?? '(none)'}'. Held rather than guessed — add the status to BILLCOM_PAYMENT_STATUS once its meaning is confirmed.`,
181
+ Reason: `${ref} has an unknown ${rail} status '${p.Status ?? '(none)'}'. Held rather than guessed — add the status to ${vocab.TableName} once its meaning is confirmed.`,
125
182
  };
126
183
  }
127
184
  }
@@ -214,4 +271,21 @@ export function TenderFor(p) {
214
271
  return mapped;
215
272
  return 'ACH';
216
273
  }
274
+ /**
275
+ * HubSpot `hs_payment_method_type` → an Orders `PaymentType.Code`. `card` is a card; the bank debits
276
+ * HubSpot Payments offers (`ach`, and `sepa`, `bacs`, `pads` outside the US) book as `ACH`, Orders'
277
+ * bank-debit type. Anything else (`cash`, `check`, `wire_transfer`, `other`) is a payment recorded in
278
+ * HubSpot and collected elsewhere, which the HubSpot rail sets aside before a tender is needed, so
279
+ * null here means "not a HubSpot-collected method".
280
+ */
281
+ const HUBSPOT_TENDER = Object.freeze({
282
+ CARD: 'CreditCard',
283
+ ACH: 'ACH',
284
+ SEPA: 'ACH',
285
+ BACS: 'ACH',
286
+ PADS: 'ACH',
287
+ });
288
+ export function HubSpotTenderFor(methodType) {
289
+ return HUBSPOT_TENDER[(methodType ?? '').trim().toUpperCase()] ?? null;
290
+ }
217
291
  //# sourceMappingURL=ExternalPaymentBehavior.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ExternalPaymentBehavior.js","sourceRoot":"","sources":["../src/ExternalPaymentBehavior.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAMH;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAA+C,MAAM,CAAC,MAAM,CAAC;IAC5F,IAAI,EAAE,SAAS;IACf,SAAS,EAAE,SAAS;IACpB,IAAI,EAAE,UAAU;IAChB,QAAQ,EAAE,UAAU;IACpB,SAAS,EAAE,UAAU;CACxB,CAAC,CAAC;AAEH,MAAM,UAAU,qBAAqB,CAAC,MAAiC;IACnE,IAAI,CAAC,MAAM;QAAE,OAAO,SAAS,CAAC;IAC9B,OAAO,sBAAsB,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,IAAI,SAAS,CAAC;AAC5E,CAAC;AAyCD,MAAM,UAAU,qBAAqB,CAAC,CAAc;IAChD,MAAM,GAAG,GAAG,qBAAqB,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;IAC5C,MAAM,GAAG,GAAG,CAAC,CAAC,kBAAkB,CAAC;IAEjC,+FAA+F;IAC/F,8FAA8F;IAC9F,6FAA6F;IAC7F,kGAAkG;IAClG,4FAA4F;IAC5F,8FAA8F;IAC9F,6FAA6F;IAC7F,IAAI,CAAC,CA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AAK,EAAE,OAAO;IACd,WAAW,EAAE,YAAY;IACzB,YAAY,EAAE,YAAY;IAC1B,GAAG,EAAE,KAAK;IACV,8CAA8C;IAC9C,KAAK,EAAE,MAAM;CAChB,CAAC,CAAC;AAKH,MAAM,UAAU,SAAS,CAAC,CAAoE;IAC1F,MAAM,MAAM,GAAG,cAAc,CAAC,CAAC,CAAC,CAAC,eAAe,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,CAAC;IAC9E,IAAI,MAAM;QAAE,OAAO,MAAM,CAAC;IAC1B,OAAO,KAAK,CAAC;AACjB,CAAC;AAED;;;;;;GAMG;AACH,MAAM,cAAc,GAA+C,MAAM,CAAC,MAAM,CAAC;IAC7E,IAAI,EAAE,YAAY;IAClB,GAAG,EAAE,KAAK;IACV,IAAI,EAAE,KAAK;IACX,IAAI,EAAE,KAAK;IACX,IAAI,EAAE,KAAK;CACd,CAAC,CAAC;AAEH,MAAM,UAAU,gBAAgB,CAAC,UAAqC;IAClE,OAAO,cAAc,CAAC,CAAC,UAAU,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,IAAI,IAAI,CAAC;AAC3E,CAAC"}
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Party organizations a writer chose to keep when it replaced the person on that side.
3
+ *
4
+ * When a save replaces the bill-to or ship-to person, the server save clears that side's
5
+ * organization if it is the previous person's employer, so the replacement brings their own
6
+ * (bizapps-orders#542). Nothing records whether a default stamped that employer or someone chose
7
+ * it, and an unchanged organization does not count as changed in the save, so a writer that means
8
+ * to keep it has to say so. The order form says so when the user undoes its cleared-employer
9
+ * notice; any other writer calls `OrderHeaderEntity.KeepPartyOrganization`.
10
+ *
11
+ * Each entry names the person the organization is kept against. The server honors it only while
12
+ * that person is the one being replaced, so a stale entry left on a browser's order object does
13
+ * not keep an organization through a later replacement.
14
+ *
15
+ * @module @mj-biz-apps/orders-entities
16
+ */
17
+ import { EntityCompanion, type EntityCompanionDeserializeMode, type EntitySavePlan } from '@memberjunction/core';
18
+ export type KeptPartyOrganizationField = 'BillToOrganizationID' | 'ShipToOrganizationID';
19
+ export interface KeptPartyOrganization {
20
+ Field: KeptPartyOrganizationField;
21
+ /** The person being replaced on that side, whose employer the organization may be. */
22
+ FromPersonID: string;
23
+ }
24
+ export type KeptPartyOrganizationsWire = {
25
+ Kept: KeptPartyOrganization[];
26
+ };
27
+ export declare class KeptPartyOrganizationsCompanion extends EntityCompanion<KeptPartyOrganizationsWire> {
28
+ /** The wire key. Renaming it drops kept organizations from payloads written by the other tier. */
29
+ readonly Name = "KeptPartyOrganizations";
30
+ private kept;
31
+ get Items(): readonly KeptPartyOrganization[];
32
+ /** Keep `field`'s organization through the replacement of `fromPersonID`. */
33
+ Keep(field: KeptPartyOrganizationField, fromPersonID: string): void;
34
+ /** True when `field`'s organization is kept through the replacement of `fromPersonID`. */
35
+ IsKept(field: KeptPartyOrganizationField, fromPersonID: string): boolean;
36
+ Clear(): void;
37
+ Serialize(): Promise<KeptPartyOrganizationsWire | null>;
38
+ Deserialize(data: KeptPartyOrganizationsWire, _mode: EntityCompanionDeserializeMode): Promise<void>;
39
+ /**
40
+ * Dirty only while a kept side's person is changing in this save, the one save the entry
41
+ * matters to. An entry alone never makes an otherwise clean order save.
42
+ */
43
+ get Dirty(): boolean;
44
+ /**
45
+ * Sends a save that carries a kept organization to the server as a graph save, the only save
46
+ * that carries companions.
47
+ *
48
+ * A client save whose plan holds only the order's own row takes the plain GraphQL update,
49
+ * which sends field values and nothing else (MemberJunction/MJ#5528). The entry would not
50
+ * reach the server, and the server save would clear the organization the writer kept. A
51
+ * second node makes the client route the save through `MJ.SaveEntityGraph`, which restores
52
+ * companions before saving. The client never runs the plan's nodes; the server builds its
53
+ * own plan, where this companion adds nothing and the order saves once.
54
+ *
55
+ * Not added on a provider with entity transactions: that save runs here, where the entry is
56
+ * already in memory, and the node would save the order a second time.
57
+ */
58
+ ContributeSaveWork(plan: EntitySavePlan): void;
59
+ }
60
+ //# sourceMappingURL=KeptPartyOrganizationsCompanion.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"KeptPartyOrganizationsCompanion.d.ts","sourceRoot":"","sources":["../src/KeptPartyOrganizationsCompanion.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,eAAe,EAAE,KAAK,8BAA8B,EAAE,KAAK,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAGjH,MAAM,MAAM,0BAA0B,GAAG,sBAAsB,GAAG,sBAAsB,CAAC;AAEzF,MAAM,WAAW,qBAAqB;IAClC,KAAK,EAAE,0BAA0B,CAAC;IAClC,sFAAsF;IACtF,YAAY,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,MAAM,0BAA0B,GAAG;IAAE,IAAI,EAAE,qBAAqB,EAAE,CAAA;CAAE,CAAC;AAO3E,qBAAa,+BAAgC,SAAQ,eAAe,CAAC,0BAA0B,CAAC;IAC5F,kGAAkG;IAClG,SAAgB,IAAI,4BAA4B;IAEhD,OAAO,CAAC,IAAI,CAA+B;IAE3C,IAAW,KAAK,IAAI,SAAS,qBAAqB,EAAE,CAEnD;IAED,6EAA6E;IACtE,IAAI,CAAC,KAAK,EAAE,0BAA0B,EAAE,YAAY,EAAE,MAAM,GAAG,IAAI;IAI1E,0FAA0F;IACnF,MAAM,CAAC,KAAK,EAAE,0BAA0B,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO;IAIxE,KAAK,IAAI,IAAI;IAIP,SAAS,IAAI,OAAO,CAAC,0BAA0B,GAAG,IAAI,CAAC;IAIvD,WAAW,CAAC,IAAI,EAAE,0BAA0B,EAAE,KAAK,EAAE,8BAA8B,GAAG,OAAO,CAAC,IAAI,CAAC;IAQhH;;;OAGG;IACH,IAAoB,KAAK,IAAI,OAAO,CAEnC;IAED;;;;;;;;;;;;;OAaG;IACa,kBAAkB,CAAC,IAAI,EAAE,cAAc,GAAG,IAAI;CAIjE"}
@@ -0,0 +1,78 @@
1
+ /**
2
+ * Party organizations a writer chose to keep when it replaced the person on that side.
3
+ *
4
+ * When a save replaces the bill-to or ship-to person, the server save clears that side's
5
+ * organization if it is the previous person's employer, so the replacement brings their own
6
+ * (bizapps-orders#542). Nothing records whether a default stamped that employer or someone chose
7
+ * it, and an unchanged organization does not count as changed in the save, so a writer that means
8
+ * to keep it has to say so. The order form says so when the user undoes its cleared-employer
9
+ * notice; any other writer calls `OrderHeaderEntity.KeepPartyOrganization`.
10
+ *
11
+ * Each entry names the person the organization is kept against. The server honors it only while
12
+ * that person is the one being replaced, so a stale entry left on a browser's order object does
13
+ * not keep an organization through a later replacement.
14
+ *
15
+ * @module @mj-biz-apps/orders-entities
16
+ */
17
+ import { EntityCompanion } from '@memberjunction/core';
18
+ import { UUIDsEqual } from '@memberjunction/global';
19
+ const PERSON_FIELD = {
20
+ BillToOrganizationID: 'BillToPersonID',
21
+ ShipToOrganizationID: 'ShipToPersonID',
22
+ };
23
+ export class KeptPartyOrganizationsCompanion extends EntityCompanion {
24
+ constructor() {
25
+ super(...arguments);
26
+ /** The wire key. Renaming it drops kept organizations from payloads written by the other tier. */
27
+ this.Name = 'KeptPartyOrganizations';
28
+ this.kept = [];
29
+ }
30
+ get Items() {
31
+ return this.kept;
32
+ }
33
+ /** Keep `field`'s organization through the replacement of `fromPersonID`. */
34
+ Keep(field, fromPersonID) {
35
+ this.kept = [...this.kept.filter((k) => k.Field !== field), { Field: field, FromPersonID: fromPersonID }];
36
+ }
37
+ /** True when `field`'s organization is kept through the replacement of `fromPersonID`. */
38
+ IsKept(field, fromPersonID) {
39
+ return this.kept.some((k) => k.Field === field && UUIDsEqual(k.FromPersonID, fromPersonID));
40
+ }
41
+ Clear() {
42
+ this.kept = [];
43
+ }
44
+ async Serialize() {
45
+ return this.kept.length ? { Kept: [...this.kept] } : null;
46
+ }
47
+ async Deserialize(data, _mode) {
48
+ const kept = Array.isArray(data?.Kept) ? data.Kept : [];
49
+ this.kept = kept.filter((k) => !!k && (k.Field === 'BillToOrganizationID' || k.Field === 'ShipToOrganizationID') && typeof k.FromPersonID === 'string');
50
+ }
51
+ /**
52
+ * Dirty only while a kept side's person is changing in this save, the one save the entry
53
+ * matters to. An entry alone never makes an otherwise clean order save.
54
+ */
55
+ get Dirty() {
56
+ return this.kept.some((k) => this.Owner.GetFieldByName(PERSON_FIELD[k.Field])?.Dirty === true);
57
+ }
58
+ /**
59
+ * Sends a save that carries a kept organization to the server as a graph save, the only save
60
+ * that carries companions.
61
+ *
62
+ * A client save whose plan holds only the order's own row takes the plain GraphQL update,
63
+ * which sends field values and nothing else (MemberJunction/MJ#5528). The entry would not
64
+ * reach the server, and the server save would clear the organization the writer kept. A
65
+ * second node makes the client route the save through `MJ.SaveEntityGraph`, which restores
66
+ * companions before saving. The client never runs the plan's nodes; the server builds its
67
+ * own plan, where this companion adds nothing and the order saves once.
68
+ *
69
+ * Not added on a provider with entity transactions: that save runs here, where the entry is
70
+ * already in memory, and the node would save the order a second time.
71
+ */
72
+ ContributeSaveWork(plan) {
73
+ if (!this.Dirty || this.Owner.ProviderToUse?.SupportsEntityTransactions === true)
74
+ return;
75
+ plan.Add({ Entity: this.Owner, Operation: 'Save', Label: `${this.Name} (routes the save through the graph)`, SelfOnly: true });
76
+ }
77
+ }
78
+ //# sourceMappingURL=KeptPartyOrganizationsCompanion.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"KeptPartyOrganizationsCompanion.js","sourceRoot":"","sources":["../src/KeptPartyOrganizationsCompanion.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,eAAe,EAA4D,MAAM,sBAAsB,CAAC;AACjH,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAYpD,MAAM,YAAY,GAA4E;IAC1F,oBAAoB,EAAE,gBAAgB;IACtC,oBAAoB,EAAE,gBAAgB;CACzC,CAAC;AAEF,MAAM,OAAO,+BAAgC,SAAQ,eAA2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CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,KAAK,sBAAsB,IAAI,CAAC,CAAC,KAAK,KAAK,sBAAsB,CAAC,IAAI,OAAO,CAAC,CAAC,YAAY,KAAK,QAAQ,CAC9H,CAAC;IACN,CAAC;IAED;;;OAGG;IACH,IAAoB,KAAK;QACrB,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,YAAY,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,KAAK,IAAI,CAAC,CAAC;IACnG,CAAC;IAED;;;;;;;;;;;;;OAaG;IACa,kBAAkB,CAAC,IAAoB;QACnD,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,aAAa,EAAE,0BAA0B,KAAK,IAAI;YAAE,OAAO;QACzF,IAAI,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC,IAAI,sCAAsC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;IACnI,CAAC;CACJ"}
@@ -34,6 +34,7 @@ import { mjBizAppsOrdersOrderHeaderEntity } from './generated/entity_subclasses.
34
34
  import { type TransitionVerdict } from './OrderStatusBehavior.js';
35
35
  import { PromotionCodesCompanion } from './PromotionCodesCompanion.js';
36
36
  import { InitialPaymentIntentCompanion } from './InitialPaymentIntentCompanion.js';
37
+ import { KeptPartyOrganizationsCompanion } from './KeptPartyOrganizationsCompanion.js';
37
38
  import { type DisplacedTermStart } from './displaced-term-start.js';
38
39
  /** What {@link OrderHeaderEntity.Confirm} reports beyond success. */
39
40
  export interface OrderConfirmOutcome {
@@ -49,6 +50,8 @@ import { type OrderAddressSnapshot } from './order-address-snapshot.js';
49
50
  export interface PartyOrganizationClear {
50
51
  Field: 'BillToOrganizationID' | 'ShipToOrganizationID';
51
52
  OrganizationID: string;
53
+ /** The cleared person whose employer it is. */
54
+ FromPersonID: string;
52
55
  }
53
56
  /**
54
57
  * The sentence the order form shows after {@link OrderHeaderEntity.ClearPersonParty} clears
@@ -78,6 +81,11 @@ export declare class OrderHeaderEntity extends mjBizAppsOrdersOrderHeaderEntity
78
81
  * and `OrderEntityServer.createInitialPayment` turns it into a `PaymentDetail`.
79
82
  */
80
83
  readonly InitialPaymentIntent: InitialPaymentIntentCompanion;
84
+ /**
85
+ * Party organizations to keep through this save's replacement of that side's person. See
86
+ * {@link KeepPartyOrganization}.
87
+ */
88
+ readonly KeptPartyOrganizations: KeptPartyOrganizationsCompanion;
81
89
  ClearInitialPaymentDetail(): void;
82
90
  ClearBillToAddress(): void;
83
91
  ClearShipToAddress(): void;
@@ -259,6 +267,14 @@ export declare class OrderHeaderEntity extends mjBizAppsOrdersOrderHeaderEntity
259
267
  * the decision to the server.
260
268
  */
261
269
  LinesMissingServicePeriod(): OrderHeaderEntity['Lines']['Items'];
270
+ /**
271
+ * Splits a line of an event that requires attendee information into one quantity-1 line per
272
+ * seat, each with its own attendee record, and returns the added lines. Returns none when the
273
+ * line needs no split. See {@link SplitIntoSeatLines}.
274
+ *
275
+ * Reads `OrdersEngine`; the caller loads it.
276
+ */
277
+ SplitLineIntoSeats(line: OrderHeaderEntity['Lines']['Items'][number]): Promise<OrderHeaderEntity['Lines']['Items']>;
262
278
  /**
263
279
  * Confirm — the irreversible step.
264
280
  *
@@ -342,11 +358,28 @@ export declare class OrderHeaderEntity extends mjBizAppsOrdersOrderHeaderEntity
342
358
  * 1. Copy the bill-to person into an empty ship-to when the bill-to person changed in this
343
359
  * save. Never the other way: an empty ship-to already means "same as bill to", while
344
360
  * filling an empty bill-to would change who pays.
345
- * 2. Stamp the employer organization only on a side whose person changed in this save.
361
+ * 2. On a side whose person this save replaces with another, clear the organization when it
362
+ * is the previous person's employer, by the rule {@link ClearPersonParty} applies on the
363
+ * form (#542). Not when this save also sets that organization, and not when the writer
364
+ * kept it ({@link KeepPartyOrganization}).
365
+ * 3. Stamp the employer organization only on a side whose person changed in this save.
346
366
  *
347
367
  * Skips booked/voided orders.
348
368
  */
349
369
  ApplySavePartyDefaults(): Promise<void>;
370
+ /**
371
+ * Keep `field`'s organization through this save's replacement of that side's person, so the
372
+ * server save does not clear it as the previous person's employer. For writers that replace a
373
+ * person and mean the organization to stay; an organization set in the same save needs no call.
374
+ */
375
+ KeepPartyOrganization(field: PartyOrganizationClear['Field']): void;
376
+ /**
377
+ * When this save replaces `side`'s person with another, clear that side's organization if it is
378
+ * the previous person's employer, so the stamp that follows brings the new person's. Leaves an
379
+ * organization this save sets, one the writer kept, and a side whose person is only cleared:
380
+ * an order may bill an organization with no person.
381
+ */
382
+ private clearReplacedPersonsEmployer;
350
383
  /** Copy `from`'s person into `to` when `to` has none and the user did not empty it in this save. */
351
384
  private copyPersonAcross;
352
385
  /**
@@ -371,7 +404,8 @@ export declare class OrderHeaderEntity extends mjBizAppsOrdersOrderHeaderEntity
371
404
  ClearPersonParty(side: 'BillTo' | 'ShipTo', clearedPersonID: string | null): Promise<PartyOrganizationClear[]>;
372
405
  /**
373
406
  * Put back organizations {@link ClearPersonParty} cleared by the employer rule, replacing any
374
- * employer a new person brought since. They then count as the user's.
407
+ * employer a new person brought since. They then count as the user's, and the server save
408
+ * keeps them through the replacement ({@link KeptPartyOrganizations}).
375
409
  */
376
410
  RestorePartyOrganizations(cleared: readonly PartyOrganizationClear[]): void;
377
411
  /** `personID`'s employer by the rule {@link AutoPopulateEmployerOrganization} stamps with, or null. */
@@ -385,7 +419,11 @@ export declare class OrderHeaderEntity extends mjBizAppsOrdersOrderHeaderEntity
385
419
  * copy {@link ClearPersonParty} took away does not count.
386
420
  */
387
421
  private wasClearedThisSave;
388
- /** True when this save sets `field` to a value it did not have on disk. */
422
+ /**
423
+ * True when this save sets `field` to a value it did not have on disk. On a new record every
424
+ * value counts: MemberJunction records the first value set on a fresh field as its old value,
425
+ * so `Dirty` is false for a field set once before the first save.
426
+ */
389
427
  private isChangedThisSave;
390
428
  /**
391
429
  * Stamp BillToOrganizationID or ShipToOrganizationID from the person's longest
@@ -1 +1 @@
1
- {"version":3,"file":"OrderHeaderEntity.d.ts","sourceRoot":"","sources":["../src/OrderHeaderEntity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,OAAO,EAAwE,gBAAgB,EAAW,KAAK,oBAAoB,EAAyB,MAAM,sBAAsB,CAAC;AAGzL,OAAO,EAAE,gCAAgC,EAAsC,MAAM,+BAA+B,CAAC;AACrH,OAAO,EAA4C,KAAK,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAEzG,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AAEhF,OAAO,EAA2B,KAAK,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAI1F,qEAAqE;AACrE,MAAM,WAAW,mBAAmB;IAChC,yFAAyF;IACzF,mBAAmB,EAAE,kBAAkB,EAAE,CAAC;CAC7C;AAID,OAAO,EAAwB,KAAK,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAQ3F,uEAAuE;AACvE;;;GAGG;AACH,MAAM,WAAW,sBAAsB;IACnC,KAAK,EAAE,sBAAsB,GAAG,sBAAsB,CAAC;IACvD,cAAc,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CACpC,OAAO,EAAE,SAAS,sBAAsB,EAAE,EAC1C,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,sBAAsB,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,CAAC,GACpF,MAAM,CAOR;AAED,MAAM,MAAM,kBAAkB,GAAG,QAAQ,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,GAAG,SAAS,CAAC;AAKxF,q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