@mj-biz-apps/orders-core-entities-server 5.44.0 → 5.46.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.
@@ -323,6 +323,8 @@ export declare class OrderEntityServer extends OrderHeaderEntity {
323
323
  * processes that save without one are not direct entry.
324
324
  */
325
325
  private passesOrderReviewGate;
326
+ /** Refuse a confirm of an order with no deal by a user outside the NoDealConfirmRoles setting (golive #390). */
327
+ private passesNoDealConfirmGate;
326
328
  /**
327
329
  * A save of an unconfirmed order that changes its bill-to, company, prices or service dates sends a
328
330
  * deal-created or already-reviewed order (back) to review, and an edit to a renewal's carried-forward
@@ -449,6 +451,26 @@ export declare class OrderEntityServer extends OrderHeaderEntity {
449
451
  private loadRowsForDelete;
450
452
  private deleteRowsForDelete;
451
453
  private deleteEach;
454
+ /**
455
+ * The user a draft's cleanup reads and deletes as, once {@link passesCleanupRight} has passed.
456
+ *
457
+ * The rows a removed draft line or a deleted draft order leaves behind — the line itself, its
458
+ * price components, dimensions, concessions, adjustments and allocations — are written by
459
+ * Orders' own saves and never edited by hand, so the business roles hold Create and Update on
460
+ * them and not Delete. Deleting them as the signed-in user refused every line removal for those
461
+ * roles (golive #461). The person's right is checked once, at the order, and the deletes that
462
+ * follow are Orders' own. The change log names the system user as the deleter; the order's own
463
+ * save names the person.
464
+ */
465
+ private cleanupUser;
466
+ /** Delete `row` as {@link cleanupUser}, then give it back its own user. */
467
+ private deleteAsCleanupUser;
468
+ /**
469
+ * Whether the signed-in user may make this change at all, asked before the cleanup runs as the
470
+ * system user. Removing a line needs Update on the order and on its lines; deleting a draft
471
+ * order needs Delete on the order. A save with no saved line removed asks nothing.
472
+ */
473
+ private passesCleanupRight;
452
474
  /**
453
475
  * Issue the deletes this save's line pass would otherwise never issue (golive #187).
454
476
  *
@@ -477,8 +499,9 @@ export declare class OrderEntityServer extends OrderHeaderEntity {
477
499
  * `EventOrderLine` is an IS-A child rather than a dependent row, and `BaseEntity.Delete()`
478
500
  * already walks that chain itself.
479
501
  *
480
- * Deletes go through the entity so row-level security and the change log see them; the repo has
481
- * no raw-DELETE precedent and this is not the place to start one.
502
+ * Deletes go through the entity so the change log sees them; the repo has no raw-DELETE
503
+ * precedent and this is not the place to start one. They run as the system user — see
504
+ * {@link cleanupUser}.
482
505
  */
483
506
  private deleteLineDependents;
484
507
  private savePendingLines;
@@ -1 +1 @@
1
- {"version":3,"file":"OrderEntityServer.d.ts","sourceRoot":"","sources":["../src/OrderEntityServer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,OAAO,EAKH,mBAAmB,EACnB,iBAAiB,EAUjB,gBAAgB,EACnB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAGH,iBAAiB,EAIjB,8BAA8B,EAoBjC,MAAM,8BAA8B,CAAC;AAStC,OAAO,EAAmE,KAAK,eAAe,EAAE,MAAM,uBAAuB,CAAC;AA+C9H,OAAO,EAAuX,KAAK,qBAAqB,EAAgD,KAAK,eAAe,EAAiH,MAAM,8BAA8B,CAAC;AAIlnB,OAAO,EAWH,KAAK,eAAe,EACpB,KAAK,uBAAuB,EAE/B,MAAM,2BAA2B,CAAC;AAanC,+FAA+F;AAC/F,MAAM,WAAW,mBAAmB;IAChC,IAAI,EAAE,8BAA8B,CAAC;IACrC,QAAQ,EAAE,uBAAuB,CAAC;IAClC,QAAQ,EAAE,eAAe,EAAE,CAAC;CAC/B;AAkJD,qBACa,iBAAkB,SAAQ,iBAAiB;IACpD,yHAAyH;cACtG,4BAA4B,IAAI,OAAO;IAI1D,6FAA6F;IAC7F,OAAO,CAAC,gBAAgB,CAA4D;IACpF,6FAA6F;IAC7F,OAAO,CAAC,mBAAmB,CAAqD;IAEhF;;;;;;;;OAQG;IACI,iBAAiB,CAAC,IAAI,EAAE,8BAA8B,GAAG,IAAI;IAIpE,uGAAuG;IACvG,OAAO,CAAC,sBAAsB;IAS9B;;;;;;OAMG;IACa,aAAa,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@ -32,8 +32,9 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
32
32
  * RESOLVER: GLAccountResolver (./GLAccountResolver.ts)
33
33
  * OP: 'Accounting.CreateJournalEntries' (@mj-biz-apps/accounting-core-entities-server)
34
34
  */
35
- import { BaseEntity, BaseEntityResult, CompositeKey, EntitySaveOptions, LogError, LogStatus, Metadata, RunView, ValidationErrorInfo, ValidationErrorType, } from '@memberjunction/core';
35
+ import { BaseEntity, BaseEntityResult, CompositeKey, EntityPermissionType, EntitySaveOptions, LogError, LogStatus, Metadata, RunView, ValidationErrorInfo, ValidationErrorType, } from '@memberjunction/core';
36
36
  import { MJGlobal, RegisterClass, UUIDsEqual } from '@memberjunction/global';
37
+ import { UserCache } from '@memberjunction/generic-database-provider';
37
38
  import { ADDRESS_SNAPSHOT_FIELDS, BuildAddressSnapshot, OrderHeaderEntity, OrderLineEntity, mjBizAppsOrdersEventOrderLineEntity, ToISODate, IsEditable, REVIEWED_HEADER_FIELDS, REVIEWED_LINE_FIELDS, HostOrderConfirmVeto, ResolveOrderConfirmRefusal, HostOrderLineEditVeto, ResolveOrderLineEditRefusal, RunAlongsideRefusal, InitialPaymentDay, } from '@mj-biz-apps/orders-entities';
38
39
  import { CalendarDayOrToday } from './calendar-day.js';
39
40
  import { ResolveLineParty } from './LineParty.js';
@@ -56,7 +57,7 @@ import { EscapeSQLString, RequireUUID, RequireUUIDs } from './sql-guards.js';
56
57
  import { ExplainMissingAttendees, LoadLinesWithAttendee, LoadProductsRequiringAttendees } from './AttendeeRequirement.js';
57
58
  import { FindUnapprovedConcessions } from './ConcessionGate.js';
58
59
  import { RaisePriceBelowEngineExceptions } from './PriceBelowEngineExceptions.js';
59
- import { CheckOrderReviewAtConfirm, CheckOrderReviewOnChange } from './OrderReview.js';
60
+ import { CheckNoDealConfirm, CheckOrderReviewAtConfirm, CheckOrderReviewOnChange } from './OrderReview.js';
60
61
  import { IsSystemOriginWrite, OriginWriteRefusal } from './SystemOrderOrigin.js';
61
62
  import { RaiseTermLengthExceptions } from './TermLengthExceptions.js';
62
63
  import { DimensionDefaultResolver } from './DimensionDefaultResolver.js';
@@ -470,6 +471,11 @@ let OrderEntityServer = class OrderEntityServer extends OrderHeaderEntity {
470
471
  return false;
471
472
  await this.ApplySavePartyDefaults();
472
473
  const booking = this.willBookOnThisSave();
474
+ // A form that saved the draft and then confirmed reloads the HEADER only. Booking needs the
475
+ // collection before the gates below, which read the lines (a renewal-only order is exempt from
476
+ // review and the no-deal check), and before it decides subscriptions.
477
+ if (booking && this.IsSaved && !this.Lines.IsLoaded)
478
+ await this.Lines.Load();
473
479
  // NO CONFIRM AHEAD OF A CONCESSION'S APPROVAL. Checked before anything is priced or booked,
474
480
  // for the same reason as the status move above: a refused confirm must change nothing.
475
481
  if (booking && !(await this.passesConcessionGate()))
@@ -477,8 +483,15 @@ let OrderEntityServer = class OrderEntityServer extends OrderHeaderEntity {
477
483
  // A REMOVAL ANOTHER APP REFUSES FAILS THE SAVE, before anything is written (#799).
478
484
  if (!booking && !(await this.passesRemovalVeto()))
479
485
  return false;
486
+ // AND ONE THE PERSON MAY NOT MAKE, before the cleanup runs as the system user (golive #461).
487
+ if (!this.passesCleanupRight('remove lines from', EntityPermissionType.Update))
488
+ return false;
480
489
  // NO CONFIRM AHEAD OF AN ORDER REVIEW (golive #320 §5), once concessions are decided, so the
481
490
  // reviewer sees the order as it will book. Off until a host switches a trigger on.
491
+ // ONLY THE ROLES THE NoDealConfirmRoles SETTING NAMES CONFIRM AN ORDER NO DEAL CREATED (golive
492
+ // #390), ahead of the review so a confirm the user may not make raises no review. Off by default.
493
+ if (booking && !(await this.passesNoDealConfirmGate()))
494
+ return false;
482
495
  if (booking && !(await this.passesOrderReviewGate()))
483
496
  return false;
484
497
  // ORDINARY PATH — no booking, and no line work to do.
@@ -617,11 +630,6 @@ let OrderEntityServer = class OrderEntityServer extends OrderHeaderEntity {
617
630
  // lines, subscription decisions settle the quantities, and each line is priced. None of
618
631
  // it writes a row, and none of it needs the header's key — the collection stamps the
619
632
  // foreign key itself.
620
- // A form that saved the draft and then confirmed reloads the HEADER only.
621
- // Booking is the only caller that MUST have the collection before it decides subscriptions.
622
- if (booking && this.IsSaved && !this.Lines.IsLoaded) {
623
- await this.Lines.Load();
624
- }
625
633
  await this.expandBundles();
626
634
  // EVERY LINE'S PRODUCT IN THE CATALOG CACHE, reloaded once if any is missing (golive #301).
627
635
  // Subscription decisions, the company stamp, dimension tags and booking all read the
@@ -1078,6 +1086,20 @@ let OrderEntityServer = class OrderEntityServer extends OrderHeaderEntity {
1078
1086
  this.RegisterResultHistoryEntry(this.buildFailureResult(new Error(refusal)));
1079
1087
  return false;
1080
1088
  }
1089
+ /** Refuse a confirm of an order with no deal by a user outside the NoDealConfirmRoles setting (golive #390). */
1090
+ async passesNoDealConfirmGate() {
1091
+ const user = this.ContextCurrentUser;
1092
+ if (!user)
1093
+ return true;
1094
+ const refusal = await CheckNoDealConfirm(this.reviewOrderInput(), {
1095
+ Provider: this.ProviderToUse,
1096
+ User: user,
1097
+ });
1098
+ if (!refusal)
1099
+ return true;
1100
+ this.RegisterResultHistoryEntry(this.buildFailureResult(new Error(refusal)));
1101
+ return false;
1102
+ }
1081
1103
  /**
1082
1104
  * A save of an unconfirmed order that changes its bill-to, company, prices or service dates sends a
1083
1105
  * deal-created or already-reviewed order (back) to review, and an edit to a renewal's carried-forward
@@ -1475,6 +1497,8 @@ let OrderEntityServer = class OrderEntityServer extends OrderHeaderEntity {
1475
1497
  }
1476
1498
  if (!this.IsSaved)
1477
1499
  return super.Delete(options);
1500
+ if (!this.passesCleanupRight('delete', EntityPermissionType.Delete))
1501
+ return false;
1478
1502
  const dbProvider = this.ProviderToUse;
1479
1503
  try {
1480
1504
  await dbProvider.BeginTransaction();
@@ -1511,7 +1535,7 @@ let OrderEntityServer = class OrderEntityServer extends OrderHeaderEntity {
1511
1535
  const lines = await this.loadRowsForDelete('MJ_BizApps_Orders: Order Lines', byOrder);
1512
1536
  for (const line of ChildLinesFirst(lines)) {
1513
1537
  await this.deleteLineDependents(line);
1514
- if (!(await line.Delete())) {
1538
+ if (!(await this.deleteAsCleanupUser(line))) {
1515
1539
  throw new Error(`Failed to delete order line ${line.LineNumber}: ${ExtractEntityErrorMessage(line)}`);
1516
1540
  }
1517
1541
  }
@@ -1533,7 +1557,7 @@ let OrderEntityServer = class OrderEntityServer extends OrderHeaderEntity {
1533
1557
  }
1534
1558
  async loadRowsForDelete(entityName, filter) {
1535
1559
  const rv = new RunView(this.ProviderToUse);
1536
- const result = await rv.RunView({ EntityName: entityName, ExtraFilter: filter, ResultType: 'entity_object', MaxRows: DEPENDENT_ROW_CAP }, this.ContextCurrentUser);
1560
+ const result = await rv.RunView({ EntityName: entityName, ExtraFilter: filter, ResultType: 'entity_object', MaxRows: DEPENDENT_ROW_CAP }, this.cleanupUser());
1537
1561
  if (!result?.Success) {
1538
1562
  throw new Error(`Failed to read ${entityName} for order ${this.OrderNumber ?? ''}: ${result?.ErrorMessage ?? 'unknown error'}`);
1539
1563
  }
@@ -1558,6 +1582,52 @@ let OrderEntityServer = class OrderEntityServer extends OrderHeaderEntity {
1558
1582
  }
1559
1583
  }
1560
1584
  }
1585
+ /**
1586
+ * The user a draft's cleanup reads and deletes as, once {@link passesCleanupRight} has passed.
1587
+ *
1588
+ * The rows a removed draft line or a deleted draft order leaves behind — the line itself, its
1589
+ * price components, dimensions, concessions, adjustments and allocations — are written by
1590
+ * Orders' own saves and never edited by hand, so the business roles hold Create and Update on
1591
+ * them and not Delete. Deleting them as the signed-in user refused every line removal for those
1592
+ * roles (golive #461). The person's right is checked once, at the order, and the deletes that
1593
+ * follow are Orders' own. The change log names the system user as the deleter; the order's own
1594
+ * save names the person.
1595
+ */
1596
+ cleanupUser() {
1597
+ const system = UserCache.Instance.GetSystemUser();
1598
+ if (!system)
1599
+ throw new Error('Deleting a draft order line needs the MJ system user, and the user cache does not hold it.');
1600
+ return system;
1601
+ }
1602
+ /** Delete `row` as {@link cleanupUser}, then give it back its own user. */
1603
+ async deleteAsCleanupUser(row) {
1604
+ const own = row.ContextCurrentUser;
1605
+ row.ContextCurrentUser = this.cleanupUser();
1606
+ try {
1607
+ return await row.Delete();
1608
+ }
1609
+ finally {
1610
+ row.ContextCurrentUser = own;
1611
+ }
1612
+ }
1613
+ /**
1614
+ * Whether the signed-in user may make this change at all, asked before the cleanup runs as the
1615
+ * system user. Removing a line needs Update on the order and on its lines; deleting a draft
1616
+ * order needs Delete on the order. A save with no saved line removed asks nothing.
1617
+ */
1618
+ passesCleanupRight(verb, onOrder) {
1619
+ const removing = onOrder === EntityPermissionType.Update;
1620
+ if (removing && !this.Lines.Removed.some((line) => line.IsSaved))
1621
+ return true;
1622
+ const user = this.ContextCurrentUser;
1623
+ const lineRight = () => !!this.ProviderToUse.EntityByName(ORDER_LINE_ENTITY)?.GetUserPermisions(user).CanUpdate;
1624
+ const allowed = !!user && this.CheckPermissions(onOrder, false) && (!removing || lineRight());
1625
+ if (allowed)
1626
+ return true;
1627
+ const message = `You do not have permission to ${verb} order ${this.OrderNumber ?? ''}. Nothing was changed.`;
1628
+ this.RegisterResultHistoryEntry(removing ? this.buildFailureResult(new Error(message)) : this.buildDeleteFailure(message));
1629
+ return false;
1630
+ }
1561
1631
  /**
1562
1632
  * Issue the deletes this save's line pass would otherwise never issue (golive #187).
1563
1633
  *
@@ -1600,7 +1670,7 @@ let OrderEntityServer = class OrderEntityServer extends OrderHeaderEntity {
1600
1670
  */
1601
1671
  const serverLine = line;
1602
1672
  serverLine.BypassExternalEditVeto = this.bookingInFlight;
1603
- if (!(await line.Delete())) {
1673
+ if (!(await this.deleteAsCleanupUser(line))) {
1604
1674
  throw new Error(`Failed to delete removed order line ${line.LineNumber}: ${ExtractEntityErrorMessage(line)}`);
1605
1675
  }
1606
1676
  }
@@ -1619,8 +1689,9 @@ let OrderEntityServer = class OrderEntityServer extends OrderHeaderEntity {
1619
1689
  * `EventOrderLine` is an IS-A child rather than a dependent row, and `BaseEntity.Delete()`
1620
1690
  * already walks that chain itself.
1621
1691
  *
1622
- * Deletes go through the entity so row-level security and the change log see them; the repo has
1623
- * no raw-DELETE precedent and this is not the place to start one.
1692
+ * Deletes go through the entity so the change log sees them; the repo has no raw-DELETE
1693
+ * precedent and this is not the place to start one. They run as the system user — see
1694
+ * {@link cleanupUser}.
1624
1695
  */
1625
1696
  async deleteLineDependents(line) {
1626
1697
  const rv = new RunView(this.ProviderToUse);
@@ -1631,7 +1702,7 @@ let OrderEntityServer = class OrderEntityServer extends OrderHeaderEntity {
1631
1702
  ExtraFilter: filter,
1632
1703
  ResultType: 'entity_object',
1633
1704
  MaxRows: DEPENDENT_ROW_CAP,
1634
- }, this.ContextCurrentUser);
1705
+ }, this.cleanupUser());
1635
1706
  const rows = result?.Results ?? [];
1636
1707
  // The cap is a guard, not a page size: silently deleting the first thousand and leaving
1637
1708
  // the rest would fail the line's own delete with an opaque FK error a row later.