@mj-biz-apps/orders-ng 5.52.0 → 5.53.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 (64) hide show
  1. package/dist/lib/pages/payments/account-credit.page.d.ts +21 -0
  2. package/dist/lib/pages/payments/account-credit.page.d.ts.map +1 -1
  3. package/dist/lib/pages/payments/account-credit.page.js +145 -82
  4. package/dist/lib/pages/payments/account-credit.page.js.map +1 -1
  5. package/dist/lib/pages/receivables/billing-issue.d.ts +14 -0
  6. package/dist/lib/pages/receivables/billing-issue.d.ts.map +1 -0
  7. package/dist/lib/pages/receivables/billing-issue.js +17 -0
  8. package/dist/lib/pages/receivables/billing-issue.js.map +1 -0
  9. package/dist/lib/pages/receivables/billing.page.d.ts +135 -19
  10. package/dist/lib/pages/receivables/billing.page.d.ts.map +1 -1
  11. package/dist/lib/pages/receivables/billing.page.js +748 -163
  12. package/dist/lib/pages/receivables/billing.page.js.map +1 -1
  13. package/dist/lib/pages/receivables/customer-ar.page.d.ts +12 -0
  14. package/dist/lib/pages/receivables/customer-ar.page.d.ts.map +1 -1
  15. package/dist/lib/pages/receivables/customer-ar.page.js +40 -14
  16. package/dist/lib/pages/receivables/customer-ar.page.js.map +1 -1
  17. package/dist/lib/pages/receivables/external-invoicing-queue.page.d.ts +157 -26
  18. package/dist/lib/pages/receivables/external-invoicing-queue.page.d.ts.map +1 -1
  19. package/dist/lib/pages/receivables/external-invoicing-queue.page.js +1278 -316
  20. package/dist/lib/pages/receivables/external-invoicing-queue.page.js.map +1 -1
  21. package/dist/lib/pages/receivables/overdue-page.model.d.ts +55 -0
  22. package/dist/lib/pages/receivables/overdue-page.model.d.ts.map +1 -0
  23. package/dist/lib/pages/receivables/overdue-page.model.js +112 -0
  24. package/dist/lib/pages/receivables/overdue-page.model.js.map +1 -0
  25. package/dist/lib/pages/receivables/overdue.page.d.ts +104 -16
  26. package/dist/lib/pages/receivables/overdue.page.d.ts.map +1 -1
  27. package/dist/lib/pages/receivables/overdue.page.js +476 -125
  28. package/dist/lib/pages/receivables/overdue.page.js.map +1 -1
  29. package/dist/lib/pages/receivables/progress.page.d.ts +69 -8
  30. package/dist/lib/pages/receivables/progress.page.d.ts.map +1 -1
  31. package/dist/lib/pages/receivables/progress.page.js +574 -248
  32. package/dist/lib/pages/receivables/progress.page.js.map +1 -1
  33. package/dist/lib/pages/receivables/worklist-view.model.d.ts +229 -0
  34. package/dist/lib/pages/receivables/worklist-view.model.d.ts.map +1 -0
  35. package/dist/lib/pages/receivables/worklist-view.model.js +402 -0
  36. package/dist/lib/pages/receivables/worklist-view.model.js.map +1 -0
  37. package/dist/lib/panels/aging-bar.component.d.ts +7 -1
  38. package/dist/lib/panels/aging-bar.component.d.ts.map +1 -1
  39. package/dist/lib/panels/aging-bar.component.js +89 -33
  40. package/dist/lib/panels/aging-bar.component.js.map +1 -1
  41. package/dist/lib/panels/side-panel.component.d.ts +41 -0
  42. package/dist/lib/panels/side-panel.component.d.ts.map +1 -0
  43. package/dist/lib/panels/side-panel.component.js +126 -0
  44. package/dist/lib/panels/side-panel.component.js.map +1 -0
  45. package/dist/lib/panels/worklist-bar.component.d.ts +81 -0
  46. package/dist/lib/panels/worklist-bar.component.d.ts.map +1 -0
  47. package/dist/lib/panels/worklist-bar.component.js +291 -0
  48. package/dist/lib/panels/worklist-bar.component.js.map +1 -0
  49. package/dist/lib/panels/worklist-table.component.d.ts +47 -5
  50. package/dist/lib/panels/worklist-table.component.d.ts.map +1 -1
  51. package/dist/lib/panels/worklist-table.component.js +283 -79
  52. package/dist/lib/panels/worklist-table.component.js.map +1 -1
  53. package/dist/lib/sections/orders-sections.component.d.ts.map +1 -1
  54. package/dist/lib/sections/orders-sections.component.js +13 -5
  55. package/dist/lib/sections/orders-sections.component.js.map +1 -1
  56. package/dist/lib/sections/section-nav.model.js +1 -1
  57. package/dist/lib/sections/section-nav.model.js.map +1 -1
  58. package/dist/lib/sections/section-shell.component.js +2 -2
  59. package/dist/lib/styles/orders-kit.css +10 -0
  60. package/dist/public-api.d.ts +2 -0
  61. package/dist/public-api.d.ts.map +1 -1
  62. package/dist/public-api.js +2 -0
  63. package/dist/public-api.js.map +1 -1
  64. package/package.json +2 -2
@@ -1,128 +1,495 @@
1
1
  import { ChangeDetectorRef, Component, EventEmitter, Output, inject } from '@angular/core';
2
2
  import { CommonModule } from '@angular/common';
3
3
  import { RunView } from '@memberjunction/core';
4
- import { MJAlertComponent, MJButtonDirective, MJConfirmService } from '@memberjunction/ng-ui-components';
5
- import { OrdersGetExternalInvoicingWorklistOperation, OrdersIssueExternalInvoiceOperation, OrdersPollExternalPaymentsOperation, OrdersSendExternalInvoicesOperation, ClassifyPollJobGroups, IsBefore, LoadPollJobs, PlanSetAside, SetAsideExternalPayments, } from '@mj-biz-apps/orders-entities';
4
+ import { MJAlertComponent, MJButtonDirective, MJConfirmService, MJDialogActionsComponent, MJDialogComponent } from '@memberjunction/ng-ui-components';
5
+ import { OrdersGetExternalInvoicingWorklistOperation, OrdersIssueExternalInvoiceOperation, OrdersPollExternalPaymentsOperation, OrdersSendExternalInvoicesOperation, ClassifyPollJobGroups, LoadPollJobs, PlanSetAside, RequireUUID, SetAsideExternalPayments, Today, ToISODate, } from '@mj-biz-apps/orders-entities';
6
+ import { MJOSidePanelComponent } from '../../panels/side-panel.component.js';
6
7
  import { MJOStatTileComponent } from '../../panels/stat-tile.component.js';
7
8
  import { MJOWorklistTableComponent } from '../../panels/worklist-table.component.js';
8
9
  import { FormatDate, FormatMoney } from '../../panels/money-format.js';
9
10
  import { DispositionChipClass, DispositionLabel } from '../../panels/external-invoice-view.js';
11
+ import { MJOWorklistBarComponent } from '../../panels/worklist-bar.component.js';
12
+ import { InvoicedDay } from './customer-ar-page.model.js';
13
+ import { BuildWorklistExport, AddressKey, AdoptCompanyChoice, AdoptWindow, COMPANY_ADDRESS_KEY, CUSTOM_WINDOW, CompaniesToAddress, ExportFileName, FilterByCompanies, InDayRange, IsOpenRange, MatchesText, NextSort, ReadWorklistState, ReconcileCompanies, ResolveWindow, RestoreSort, RestoreWindow, SameChoice, SameWindow, ShownSummary, SortRows, WindowToAddress, WriteSharedCompanies, WriteWorklistState, } from './worklist-view.model.js';
10
14
  import * as i0 from "@angular/core";
11
- const _c0 = () => [];
12
- function MJOExternalInvoicingQueuePageComponent_Conditional_4_Template(rf, ctx) { if (rf & 1) {
13
- i0.ɵɵelementStart(0, "mj-alert", 4)(1, "strong");
15
+ const _forTrack0 = ($index, $item) => $item.Key;
16
+ const _forTrack1 = ($index, $item) => $item.ID;
17
+ const _forTrack2 = ($index, $item) => $item.Row.ID;
18
+ function MJOExternalInvoicingQueuePageComponent_Conditional_0_For_6_Template(rf, ctx) { if (rf & 1) {
19
+ i0.ɵɵelementStart(0, "option", 24);
20
+ i0.ɵɵtext(1);
21
+ i0.ɵɵelementEnd();
22
+ } if (rf & 2) {
23
+ const option_r3 = ctx.$implicit;
24
+ const ctx_r1 = i0.ɵɵnextContext(2);
25
+ i0.ɵɵproperty("value", option_r3.Key)("selected", option_r3.Key === ctx_r1.Window.Key);
26
+ i0.ɵɵadvance();
27
+ i0.ɵɵtextInterpolate(option_r3.Label);
28
+ } }
29
+ function MJOExternalInvoicingQueuePageComponent_Conditional_0_Conditional_7_Template(rf, ctx) { if (rf & 1) {
30
+ const _r4 = i0.ɵɵgetCurrentView();
31
+ i0.ɵɵelementStart(0, "label", 22)(1, "span", 16);
32
+ i0.ɵɵtext(2, "From");
33
+ i0.ɵɵelementEnd();
34
+ i0.ɵɵelementStart(3, "input", 25);
35
+ i0.ɵɵlistener("change", function MJOExternalInvoicingQueuePageComponent_Conditional_0_Conditional_7_Template_input_change_3_listener($event) { i0.ɵɵrestoreView(_r4); const ctx_r1 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r1.OnCustomDay("From", $event.target.value)); });
36
+ i0.ɵɵelementEnd()();
37
+ i0.ɵɵelementStart(4, "label", 22)(5, "span", 16);
38
+ i0.ɵɵtext(6, "To");
39
+ i0.ɵɵelementEnd();
40
+ i0.ɵɵelementStart(7, "input", 26);
41
+ i0.ɵɵlistener("change", function MJOExternalInvoicingQueuePageComponent_Conditional_0_Conditional_7_Template_input_change_7_listener($event) { i0.ɵɵrestoreView(_r4); const ctx_r1 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r1.OnCustomDay("To", $event.target.value)); });
42
+ i0.ɵɵelementEnd()();
43
+ } if (rf & 2) {
44
+ const ctx_r1 = i0.ɵɵnextContext(2);
45
+ i0.ɵɵadvance(3);
46
+ i0.ɵɵproperty("value", ctx_r1.Window.From ?? "");
47
+ i0.ɵɵadvance(4);
48
+ i0.ɵɵproperty("value", ctx_r1.Window.To ?? "");
49
+ } }
50
+ function MJOExternalInvoicingQueuePageComponent_Conditional_0_Template(rf, ctx) { if (rf & 1) {
51
+ const _r1 = i0.ɵɵgetCurrentView();
52
+ i0.ɵɵelementStart(0, "mjo-worklist-bar", 21);
53
+ i0.ɵɵlistener("CompanyPicksChange", function MJOExternalInvoicingQueuePageComponent_Conditional_0_Template_mjo_worklist_bar_CompanyPicksChange_0_listener($event) { i0.ɵɵrestoreView(_r1); const ctx_r1 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r1.OnCompanies($event)); })("SearchChange", function MJOExternalInvoicingQueuePageComponent_Conditional_0_Template_mjo_worklist_bar_SearchChange_0_listener($event) { i0.ɵɵrestoreView(_r1); const ctx_r1 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r1.OnSearch($event)); })("ActiveFilterCleared", function MJOExternalInvoicingQueuePageComponent_Conditional_0_Template_mjo_worklist_bar_ActiveFilterCleared_0_listener() { i0.ɵɵrestoreView(_r1); const ctx_r1 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r1.OnPreset("all")); })("RefreshRequested", function MJOExternalInvoicingQueuePageComponent_Conditional_0_Template_mjo_worklist_bar_RefreshRequested_0_listener() { i0.ɵɵrestoreView(_r1); const ctx_r1 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r1.Refresh()); });
54
+ i0.ɵɵelementStart(1, "label", 22)(2, "span", 16);
55
+ i0.ɵɵtext(3, "Due");
56
+ i0.ɵɵelementEnd();
57
+ i0.ɵɵelementStart(4, "select", 23);
58
+ i0.ɵɵlistener("change", function MJOExternalInvoicingQueuePageComponent_Conditional_0_Template_select_change_4_listener($event) { i0.ɵɵrestoreView(_r1); const ctx_r1 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r1.OnWindow($event.target.value)); });
59
+ i0.ɵɵrepeaterCreate(5, MJOExternalInvoicingQueuePageComponent_Conditional_0_For_6_Template, 2, 3, "option", 24, _forTrack0);
60
+ i0.ɵɵelementEnd()();
61
+ i0.ɵɵconditionalCreate(7, MJOExternalInvoicingQueuePageComponent_Conditional_0_Conditional_7_Template, 8, 2);
62
+ i0.ɵɵelementEnd();
63
+ } if (rf & 2) {
64
+ const ctx_r1 = i0.ɵɵnextContext();
65
+ i0.ɵɵproperty("Companies", ctx_r1.Companies)("CompanyPicks", ctx_r1.CompanyPicks)("Search", ctx_r1.Search)("ActiveFilter", ctx_r1.Preset === "all" ? null : ctx_r1.PresetLabel)("Summary", ctx_r1.InvoiceSummary)("Loading", ctx_r1.Loading)("BuildExport", ctx_r1.BuildInvoiceExport)("CanExport", ctx_r1.Rows.length > 0);
66
+ i0.ɵɵadvance(4);
67
+ i0.ɵɵproperty("value", ctx_r1.Window.Key);
68
+ i0.ɵɵadvance();
69
+ i0.ɵɵrepeater(ctx_r1.Windows);
70
+ i0.ɵɵadvance(2);
71
+ i0.ɵɵconditional(ctx_r1.IsCustomWindow ? 7 : -1);
72
+ } }
73
+ function MJOExternalInvoicingQueuePageComponent_Conditional_1_Template(rf, ctx) { if (rf & 1) {
74
+ const _r5 = i0.ɵɵgetCurrentView();
75
+ i0.ɵɵelementStart(0, "mjo-worklist-bar", 27);
76
+ i0.ɵɵlistener("CompanyPicksChange", function MJOExternalInvoicingQueuePageComponent_Conditional_1_Template_mjo_worklist_bar_CompanyPicksChange_0_listener($event) { i0.ɵɵrestoreView(_r5); const ctx_r1 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r1.OnCompanies($event)); })("SearchChange", function MJOExternalInvoicingQueuePageComponent_Conditional_1_Template_mjo_worklist_bar_SearchChange_0_listener($event) { i0.ɵɵrestoreView(_r5); const ctx_r1 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r1.OnPaymentSearch($event)); })("RefreshRequested", function MJOExternalInvoicingQueuePageComponent_Conditional_1_Template_mjo_worklist_bar_RefreshRequested_0_listener() { i0.ɵɵrestoreView(_r5); const ctx_r1 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r1.Refresh()); });
77
+ i0.ɵɵelementEnd();
78
+ } if (rf & 2) {
79
+ const ctx_r1 = i0.ɵɵnextContext();
80
+ i0.ɵɵproperty("Companies", ctx_r1.PaymentCompanies)("CompanyPicks", ctx_r1.PaymentCompanyPicks)("Search", ctx_r1.PaymentSearch)("Summary", ctx_r1.PaymentSummary)("Loading", ctx_r1.Loading)("BuildExport", ctx_r1.BuildPaymentExport)("CanExport", ctx_r1.ShownExceptions.length > 0);
81
+ } }
82
+ function MJOExternalInvoicingQueuePageComponent_Conditional_6_Template(rf, ctx) { if (rf & 1) {
83
+ i0.ɵɵelementStart(0, "mj-alert", 6)(1, "strong");
14
84
  i0.ɵɵtext(2, "The queue did not load.");
15
85
  i0.ɵɵelementEnd();
16
86
  i0.ɵɵtext(3);
17
87
  i0.ɵɵelementEnd();
18
88
  } if (rf & 2) {
19
- const ctx_r0 = i0.ɵɵnextContext();
89
+ const ctx_r1 = i0.ɵɵnextContext();
20
90
  i0.ɵɵadvance(3);
21
- i0.ɵɵtextInterpolate1(" ", ctx_r0.LoadError, " ");
91
+ i0.ɵɵtextInterpolate1(" ", ctx_r1.LoadError, " ");
22
92
  } }
23
- function MJOExternalInvoicingQueuePageComponent_Conditional_5_Template(rf, ctx) { if (rf & 1) {
24
- i0.ɵɵelementStart(0, "mj-alert", 5);
93
+ function MJOExternalInvoicingQueuePageComponent_Conditional_7_Template(rf, ctx) { if (rf & 1) {
94
+ i0.ɵɵelementStart(0, "mj-alert", 7);
25
95
  i0.ɵɵtext(1);
26
96
  i0.ɵɵelementEnd();
27
97
  } if (rf & 2) {
28
- const ctx_r0 = i0.ɵɵnextContext();
29
- i0.ɵɵproperty("Variant", ctx_r0.Notice.Tone);
98
+ const ctx_r1 = i0.ɵɵnextContext();
99
+ i0.ɵɵproperty("Variant", ctx_r1.Notice.Tone);
30
100
  i0.ɵɵadvance();
31
- i0.ɵɵtextInterpolate(ctx_r0.Notice.Text);
101
+ i0.ɵɵtextInterpolate(ctx_r1.Notice.Text);
32
102
  } }
33
- function MJOExternalInvoicingQueuePageComponent_Conditional_6_Template(rf, ctx) { if (rf & 1) {
34
- i0.ɵɵelementStart(0, "mj-alert", 6)(1, "strong");
103
+ function MJOExternalInvoicingQueuePageComponent_Conditional_8_Template(rf, ctx) { if (rf & 1) {
104
+ i0.ɵɵelementStart(0, "mj-alert", 8)(1, "strong");
35
105
  i0.ɵɵtext(2, "List truncated.");
36
106
  i0.ɵɵelementEnd();
37
- i0.ɵɵtext(3, " Not every waiting unit is shown. ");
107
+ i0.ɵɵtext(3, " Not every waiting invoice is shown. ");
38
108
  i0.ɵɵelementEnd();
39
109
  } }
40
- function MJOExternalInvoicingQueuePageComponent_Conditional_22_Conditional_10_Template(rf, ctx) { if (rf & 1) {
41
- i0.ɵɵelementStart(0, "span", 13);
110
+ function MJOExternalInvoicingQueuePageComponent_Conditional_18_Conditional_9_Conditional_23_Template(rf, ctx) { if (rf & 1) {
111
+ i0.ɵɵelementStart(0, "dt");
42
112
  i0.ɵɵtext(1);
43
113
  i0.ɵɵelementEnd();
114
+ i0.ɵɵelementStart(2, "dd");
115
+ i0.ɵɵtext(3);
116
+ i0.ɵɵelementEnd();
44
117
  } if (rf & 2) {
45
- const row_r3 = ctx;
46
- const ctx_r0 = i0.ɵɵnextContext(2);
118
+ const row_r8 = i0.ɵɵnextContext();
119
+ const ctx_r1 = i0.ɵɵnextContext(2);
47
120
  i0.ɵɵadvance();
48
- i0.ɵɵtextInterpolate3("", row_r3.DocumentNumber, " \u00B7 ", ctx_r0.money(row_r3.Amount), " \u00B7 ", row_r3.CompanyName);
121
+ i0.ɵɵtextInterpolate(row_r8.State === "Unsent" ? "Waiting since" : "Last attempt");
122
+ i0.ɵɵadvance(2);
123
+ i0.ɵɵtextInterpolate(ctx_r1.instant(row_r8.SinceAt));
124
+ } }
125
+ function MJOExternalInvoicingQueuePageComponent_Conditional_18_Conditional_9_Conditional_24_Template(rf, ctx) { if (rf & 1) {
126
+ i0.ɵɵelementStart(0, "dt");
127
+ i0.ɵɵtext(1, "Last error");
128
+ i0.ɵɵelementEnd();
129
+ i0.ɵɵelementStart(2, "dd");
130
+ i0.ɵɵtext(3);
131
+ i0.ɵɵelementEnd();
132
+ } if (rf & 2) {
133
+ const row_r8 = i0.ɵɵnextContext();
134
+ i0.ɵɵadvance(3);
135
+ i0.ɵɵtextInterpolate(row_r8.LastError);
49
136
  } }
50
- function MJOExternalInvoicingQueuePageComponent_Conditional_22_Template(rf, ctx) { if (rf & 1) {
51
- const _r2 = i0.ɵɵgetCurrentView();
52
- i0.ɵɵelementStart(0, "div", 14)(1, "button", 11);
53
- i0.ɵɵlistener("click", function MJOExternalInvoicingQueuePageComponent_Conditional_22_Template_button_click_1_listener() { i0.ɵɵrestoreView(_r2); const ctx_r0 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r0.OpenSelected()); });
54
- i0.ɵɵelement(2, "i", 15);
55
- i0.ɵɵtext(3, " Open order ");
137
+ function MJOExternalInvoicingQueuePageComponent_Conditional_18_Conditional_9_Template(rf, ctx) { if (rf & 1) {
138
+ const _r7 = i0.ɵɵgetCurrentView();
139
+ i0.ɵɵelementStart(0, "div", 33)(1, "mjo-side-panel", 34);
140
+ i0.ɵɵlistener("Closed", function MJOExternalInvoicingQueuePageComponent_Conditional_18_Conditional_9_Template_mjo_side_panel_Closed_1_listener() { i0.ɵɵrestoreView(_r7); const ctx_r1 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r1.SelectedInvoice = null); });
141
+ i0.ɵɵelementStart(2, "div", 35);
142
+ i0.ɵɵtext(3);
143
+ i0.ɵɵelementEnd();
144
+ i0.ɵɵelementStart(4, "dl", 36)(5, "dt");
145
+ i0.ɵɵtext(6, "Customer");
146
+ i0.ɵɵelementEnd();
147
+ i0.ɵɵelementStart(7, "dd");
148
+ i0.ɵɵtext(8);
149
+ i0.ɵɵelementEnd();
150
+ i0.ɵɵelementStart(9, "dt");
151
+ i0.ɵɵtext(10, "Order");
152
+ i0.ɵɵelementEnd();
153
+ i0.ɵɵelementStart(11, "dd")(12, "button", 37);
154
+ i0.ɵɵlistener("click", function MJOExternalInvoicingQueuePageComponent_Conditional_18_Conditional_9_Template_button_click_12_listener() { const row_r8 = i0.ɵɵrestoreView(_r7); const ctx_r1 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r1.OpenOrder(row_r8)); });
155
+ i0.ɵɵtext(13);
56
156
  i0.ɵɵelementEnd();
57
- i0.ɵɵelementStart(4, "button", 16);
58
- i0.ɵɵlistener("click", function MJOExternalInvoicingQueuePageComponent_Conditional_22_Template_button_click_4_listener() { i0.ɵɵrestoreView(_r2); const ctx_r0 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r0.SendSelected()); });
59
- i0.ɵɵelement(5, "i", 17);
60
- i0.ɵɵtext(6, " Send this one ");
157
+ i0.ɵɵtext(14);
61
158
  i0.ɵɵelementEnd();
62
- i0.ɵɵelementStart(7, "button", 11);
63
- i0.ɵɵlistener("click", function MJOExternalInvoicingQueuePageComponent_Conditional_22_Template_button_click_7_listener() { i0.ɵɵrestoreView(_r2); const ctx_r0 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r0.RunSweep()); });
64
- i0.ɵɵelement(8, "i", 12);
65
- i0.ɵɵtext(9);
159
+ i0.ɵɵelementStart(15, "dt");
160
+ i0.ɵɵtext(16, "Billed by");
66
161
  i0.ɵɵelementEnd();
67
- i0.ɵɵconditionalCreate(10, MJOExternalInvoicingQueuePageComponent_Conditional_22_Conditional_10_Template, 2, 3, "span", 13);
162
+ i0.ɵɵelementStart(17, "dd");
163
+ i0.ɵɵtext(18);
68
164
  i0.ɵɵelementEnd();
69
- i0.ɵɵelementStart(11, "mjo-worklist-table", 18);
70
- i0.ɵɵlistener("PresetChanged", function MJOExternalInvoicingQueuePageComponent_Conditional_22_Template_mjo_worklist_table_PresetChanged_11_listener($event) { i0.ɵɵrestoreView(_r2); const ctx_r0 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r0.OnPreset($event)); })("RowClicked", function MJOExternalInvoicingQueuePageComponent_Conditional_22_Template_mjo_worklist_table_RowClicked_11_listener($event) { i0.ɵɵrestoreView(_r2); const ctx_r0 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r0.SelectedInvoice = $event); });
165
+ i0.ɵɵelementStart(19, "dt");
166
+ i0.ɵɵtext(20, "Due");
71
167
  i0.ɵɵelementEnd();
168
+ i0.ɵɵelementStart(21, "dd");
169
+ i0.ɵɵtext(22);
170
+ i0.ɵɵelementEnd();
171
+ i0.ɵɵconditionalCreate(23, MJOExternalInvoicingQueuePageComponent_Conditional_18_Conditional_9_Conditional_23_Template, 4, 2);
172
+ i0.ɵɵconditionalCreate(24, MJOExternalInvoicingQueuePageComponent_Conditional_18_Conditional_9_Conditional_24_Template, 4, 1);
173
+ i0.ɵɵelementEnd();
174
+ i0.ɵɵelementStart(25, "div", 38)(26, "button", 20);
175
+ i0.ɵɵlistener("click", function MJOExternalInvoicingQueuePageComponent_Conditional_18_Conditional_9_Template_button_click_26_listener() { i0.ɵɵrestoreView(_r7); const ctx_r1 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r1.SendSelected()); });
176
+ i0.ɵɵelement(27, "i", 31);
177
+ i0.ɵɵtext(28);
178
+ i0.ɵɵelementEnd();
179
+ i0.ɵɵelementStart(29, "button", 19);
180
+ i0.ɵɵlistener("click", function MJOExternalInvoicingQueuePageComponent_Conditional_18_Conditional_9_Template_button_click_29_listener() { const row_r8 = i0.ɵɵrestoreView(_r7); const ctx_r1 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r1.OpenOrder(row_r8)); });
181
+ i0.ɵɵelement(30, "i", 39);
182
+ i0.ɵɵtext(31, " Open order ");
183
+ i0.ɵɵelementEnd()()()();
72
184
  } if (rf & 2) {
73
- let tmp_5_0;
74
- const ctx_r0 = i0.ɵɵnextContext();
185
+ const row_r8 = ctx;
186
+ const ctx_r1 = i0.ɵɵnextContext(2);
187
+ i0.ɵɵadvance();
188
+ i0.ɵɵproperty("Title", row_r8.DocumentNumber)("Chip", ctx_r1.stateLabel(row_r8.State))("ChipClass", ctx_r1.stateChip(row_r8));
189
+ i0.ɵɵadvance(2);
190
+ i0.ɵɵtextInterpolate(ctx_r1.money(row_r8.Amount));
191
+ i0.ɵɵadvance(5);
192
+ i0.ɵɵtextInterpolate(row_r8.CustomerName);
193
+ i0.ɵɵadvance(5);
194
+ i0.ɵɵtextInterpolate(row_r8.OrderNumber);
75
195
  i0.ɵɵadvance();
76
- i0.ɵɵproperty("disabled", !ctx_r0.SelectedInvoice);
196
+ i0.ɵɵtextInterpolate1(" \u00B7 ", row_r8.InstallmentNumber ? "installment " + row_r8.InstallmentNumber : "whole order", " ");
197
+ i0.ɵɵadvance(4);
198
+ i0.ɵɵtextInterpolate(row_r8.CompanyName || "\u2014");
199
+ i0.ɵɵadvance(4);
200
+ i0.ɵɵtextInterpolate(ctx_r1.date(row_r8.DueDate));
201
+ i0.ɵɵadvance();
202
+ i0.ɵɵconditional(row_r8.SinceAt ? 23 : -1);
203
+ i0.ɵɵadvance();
204
+ i0.ɵɵconditional(row_r8.LastError ? 24 : -1);
205
+ i0.ɵɵadvance(2);
206
+ i0.ɵɵproperty("disabled", ctx_r1.Busy);
207
+ i0.ɵɵadvance(2);
208
+ i0.ɵɵtextInterpolate1(" ", row_r8.State === "Unsent" ? "Send this invoice" : "Send again", " ");
209
+ } }
210
+ function MJOExternalInvoicingQueuePageComponent_Conditional_18_Template(rf, ctx) { if (rf & 1) {
211
+ const _r6 = i0.ɵɵgetCurrentView();
212
+ i0.ɵɵelementStart(0, "div", 12)(1, "div", 28)(2, "div", 29)(3, "button", 30);
213
+ i0.ɵɵlistener("click", function MJOExternalInvoicingQueuePageComponent_Conditional_18_Template_button_click_3_listener() { i0.ɵɵrestoreView(_r6); const ctx_r1 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r1.RunSweep()); });
214
+ i0.ɵɵelement(4, "i", 31);
215
+ i0.ɵɵtext(5);
216
+ i0.ɵɵelementEnd();
217
+ i0.ɵɵelementStart(6, "span", 16);
218
+ i0.ɵɵtext(7, "Select an invoice to see its detail or send it on its own.");
219
+ i0.ɵɵelementEnd()();
220
+ i0.ɵɵelementStart(8, "mjo-worklist-table", 32);
221
+ i0.ɵɵlistener("SortChanged", function MJOExternalInvoicingQueuePageComponent_Conditional_18_Template_mjo_worklist_table_SortChanged_8_listener($event) { i0.ɵɵrestoreView(_r6); const ctx_r1 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r1.OnInvoiceSort($event)); })("LinkClicked", function MJOExternalInvoicingQueuePageComponent_Conditional_18_Template_mjo_worklist_table_LinkClicked_8_listener($event) { i0.ɵɵrestoreView(_r6); const ctx_r1 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r1.OpenOrder($event.Row)); })("RowClicked", function MJOExternalInvoicingQueuePageComponent_Conditional_18_Template_mjo_worklist_table_RowClicked_8_listener($event) { i0.ɵɵrestoreView(_r6); const ctx_r1 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r1.OnInvoiceRow($event)); });
222
+ i0.ɵɵelementEnd()();
223
+ i0.ɵɵconditionalCreate(9, MJOExternalInvoicingQueuePageComponent_Conditional_18_Conditional_9_Template, 32, 13, "div", 33);
224
+ i0.ɵɵelementEnd();
225
+ } if (rf & 2) {
226
+ let tmp_13_0;
227
+ const ctx_r1 = i0.ɵɵnextContext();
77
228
  i0.ɵɵadvance(3);
78
- i0.ɵɵproperty("disabled", !ctx_r0.SelectedInvoice || ctx_r0.Busy);
229
+ i0.ɵɵproperty("disabled", ctx_r1.Busy || !ctx_r1.InScope.length);
230
+ i0.ɵɵadvance(2);
231
+ i0.ɵɵtextInterpolate1(" ", ctx_r1.Busy ? "Working\u2026" : "Send all waiting", " ");
79
232
  i0.ɵɵadvance(3);
80
- i0.ɵɵproperty("disabled", ctx_r0.Busy || !ctx_r0.Rows.length);
233
+ i0.ɵɵproperty("Columns", ctx_r1.InvoiceColumns)("Rows", ctx_r1.Rows)("Searchable", false)("Loading", ctx_r1.Loading)("Totals", ctx_r1.InvoiceTotals)("SortKey", ctx_r1.InvoiceSort.Key)("SortDescending", ctx_r1.InvoiceSort.Descending)("SelectedKey", (ctx_r1.SelectedInvoice == null ? null : ctx_r1.SelectedInvoice.DocumentNumber) ?? null)("EmptyTitle", ctx_r1.AllRows.length ? "Nothing matches" : "Nothing waiting")("EmptyHint", ctx_r1.AllRows.length ? "No waiting invoice matches these filters. Clear one to see more." : "Every invoice has been sent.");
234
+ i0.ɵɵadvance();
235
+ i0.ɵɵconditional((tmp_13_0 = ctx_r1.SelectedInvoice) ? 9 : -1, tmp_13_0);
236
+ } }
237
+ function MJOExternalInvoicingQueuePageComponent_Conditional_19_Conditional_12_Template(rf, ctx) { if (rf & 1) {
238
+ const _r10 = i0.ɵɵgetCurrentView();
239
+ i0.ɵɵelementStart(0, "div", 33)(1, "mjo-side-panel", 46);
240
+ i0.ɵɵlistener("Closed", function MJOExternalInvoicingQueuePageComponent_Conditional_19_Conditional_12_Template_mjo_side_panel_Closed_1_listener() { i0.ɵɵrestoreView(_r10); const ctx_r1 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r1.SelectedPayment = null); });
241
+ i0.ɵɵelementStart(2, "div", 35);
242
+ i0.ɵɵtext(3);
243
+ i0.ɵɵelementEnd();
244
+ i0.ɵɵelementStart(4, "dl", 36)(5, "dt");
245
+ i0.ɵɵtext(6, "Dated");
246
+ i0.ɵɵelementEnd();
247
+ i0.ɵɵelementStart(7, "dd");
248
+ i0.ɵɵtext(8);
249
+ i0.ɵɵelementEnd();
250
+ i0.ɵɵelementStart(9, "dt");
251
+ i0.ɵɵtext(10, "Received through");
252
+ i0.ɵɵelementEnd();
253
+ i0.ɵɵelementStart(11, "dd");
254
+ i0.ɵɵtext(12);
255
+ i0.ɵɵelementEnd();
256
+ i0.ɵɵelementStart(13, "dt");
257
+ i0.ɵɵtext(14, "Customer");
258
+ i0.ɵɵelementEnd();
259
+ i0.ɵɵelementStart(15, "dd");
260
+ i0.ɵɵtext(16);
261
+ i0.ɵɵelementEnd();
262
+ i0.ɵɵelementStart(17, "dt");
263
+ i0.ɵɵtext(18, "Customer reference");
264
+ i0.ɵɵelementEnd();
265
+ i0.ɵɵelementStart(19, "dd");
266
+ i0.ɵɵtext(20);
267
+ i0.ɵɵelementEnd();
268
+ i0.ɵɵelementStart(21, "dt");
269
+ i0.ɵɵtext(22, "Provider status");
270
+ i0.ɵɵelementEnd();
271
+ i0.ɵɵelementStart(23, "dd");
272
+ i0.ɵɵtext(24);
273
+ i0.ɵɵelementEnd();
274
+ i0.ɵɵelementStart(25, "dt");
275
+ i0.ɵɵtext(26, "What happened");
276
+ i0.ɵɵelementEnd();
277
+ i0.ɵɵelementStart(27, "dd");
278
+ i0.ɵɵtext(28);
279
+ i0.ɵɵelementEnd();
280
+ i0.ɵɵelementStart(29, "dt");
281
+ i0.ɵɵtext(30, "First seen");
282
+ i0.ɵɵelementEnd();
283
+ i0.ɵɵelementStart(31, "dd");
284
+ i0.ɵɵtext(32);
285
+ i0.ɵɵelementEnd();
286
+ i0.ɵɵelementStart(33, "dt");
287
+ i0.ɵɵtext(34, "Last seen");
288
+ i0.ɵɵelementEnd();
289
+ i0.ɵɵelementStart(35, "dd");
290
+ i0.ɵɵtext(36);
291
+ i0.ɵɵelementEnd()();
292
+ i0.ɵɵelementStart(37, "div", 38)(38, "button", 20);
293
+ i0.ɵɵlistener("click", function MJOExternalInvoicingQueuePageComponent_Conditional_19_Conditional_12_Template_button_click_38_listener() { const row_r11 = i0.ɵɵrestoreView(_r10); const ctx_r1 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r1.OpenSetAside([row_r11.ID])); });
294
+ i0.ɵɵelement(39, "i", 42);
295
+ i0.ɵɵtext(40, " Set aside ");
296
+ i0.ɵɵelementEnd()()()();
297
+ } if (rf & 2) {
298
+ const row_r11 = ctx;
299
+ const ctx_r1 = i0.ɵɵnextContext(2);
300
+ i0.ɵɵadvance();
301
+ i0.ɵɵproperty("Title", row_r11.ExternalPaymentRef)("Chip", ctx_r1.dispositionLabel(row_r11))("ChipClass", ctx_r1.dispositionChip(row_r11));
302
+ i0.ɵɵadvance(2);
303
+ i0.ɵɵtextInterpolate(ctx_r1.money(row_r11.Amount));
304
+ i0.ɵɵadvance(5);
305
+ i0.ɵɵtextInterpolate(ctx_r1.date(row_r11.PaymentDate));
306
+ i0.ɵɵadvance(4);
307
+ i0.ɵɵtextInterpolate(ctx_r1.providerText(row_r11));
308
+ i0.ɵɵadvance(4);
309
+ i0.ɵɵtextInterpolate(ctx_r1.customerOf(row_r11) || "Not matched to a customer");
310
+ i0.ɵɵadvance(4);
311
+ i0.ɵɵtextInterpolate(row_r11.ExternalCustomerRef || "\u2014");
312
+ i0.ɵɵadvance(4);
313
+ i0.ɵɵtextInterpolate(row_r11.ExternalStatus || "\u2014");
314
+ i0.ɵɵadvance(4);
315
+ i0.ɵɵtextInterpolate(row_r11.DispositionReason || "\u2014");
316
+ i0.ɵɵadvance(4);
317
+ i0.ɵɵtextInterpolate(ctx_r1.instant(row_r11.FirstSeenAt));
318
+ i0.ɵɵadvance(4);
319
+ i0.ɵɵtextInterpolate(ctx_r1.instant(row_r11.LastSeenAt));
320
+ i0.ɵɵadvance(2);
321
+ i0.ɵɵproperty("disabled", ctx_r1.Busy);
322
+ } }
323
+ function MJOExternalInvoicingQueuePageComponent_Conditional_19_Template(rf, ctx) { if (rf & 1) {
324
+ const _r9 = i0.ɵɵgetCurrentView();
325
+ i0.ɵɵelementStart(0, "div", 12)(1, "div", 28)(2, "div", 40)(3, "button", 41);
326
+ i0.ɵɵlistener("click", function MJOExternalInvoicingQueuePageComponent_Conditional_19_Template_button_click_3_listener() { i0.ɵɵrestoreView(_r9); const ctx_r1 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r1.OpenSetAside(ctx_r1.CheckedIDs)); });
327
+ i0.ɵɵelement(4, "i", 42);
328
+ i0.ɵɵtext(5);
329
+ i0.ɵɵelementEnd();
330
+ i0.ɵɵelementStart(6, "button", 43);
331
+ i0.ɵɵlistener("click", function MJOExternalInvoicingQueuePageComponent_Conditional_19_Template_button_click_6_listener() { i0.ɵɵrestoreView(_r9); const ctx_r1 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r1.RunPoll()); });
332
+ i0.ɵɵelement(7, "i", 44);
333
+ i0.ɵɵtext(8);
334
+ i0.ɵɵelementEnd();
335
+ i0.ɵɵelementStart(9, "span", 16);
336
+ i0.ɵɵtext(10);
337
+ i0.ɵɵelementEnd()();
338
+ i0.ɵɵelementStart(11, "mjo-worklist-table", 45);
339
+ i0.ɵɵlistener("SelectionChanged", function MJOExternalInvoicingQueuePageComponent_Conditional_19_Template_mjo_worklist_table_SelectionChanged_11_listener($event) { i0.ɵɵrestoreView(_r9); const ctx_r1 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r1.CheckedIDs = $event); })("SortChanged", function MJOExternalInvoicingQueuePageComponent_Conditional_19_Template_mjo_worklist_table_SortChanged_11_listener($event) { i0.ɵɵrestoreView(_r9); const ctx_r1 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r1.OnPaymentSort($event)); })("RowClicked", function MJOExternalInvoicingQueuePageComponent_Conditional_19_Template_mjo_worklist_table_RowClicked_11_listener($event) { i0.ɵɵrestoreView(_r9); const ctx_r1 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r1.OnPaymentRow($event)); });
340
+ i0.ɵɵelementEnd()();
341
+ i0.ɵɵconditionalCreate(12, MJOExternalInvoicingQueuePageComponent_Conditional_19_Conditional_12_Template, 41, 13, "div", 33);
342
+ i0.ɵɵelementEnd();
343
+ } if (rf & 2) {
344
+ let tmp_19_0;
345
+ const ctx_r1 = i0.ɵɵnextContext();
346
+ i0.ɵɵadvance(3);
347
+ i0.ɵɵproperty("disabled", ctx_r1.Busy || !ctx_r1.CheckedIDs.length);
81
348
  i0.ɵɵadvance(2);
82
- i0.ɵɵtextInterpolate1(" ", ctx_r0.Busy ? "Working\u2026" : "Send all waiting", " ");
349
+ i0.ɵɵtextInterpolate1(" Set aside", ctx_r1.CheckedIDs.length ? " (" + ctx_r1.CheckedIDs.length + ")" : "", " ");
83
350
  i0.ɵɵadvance();
84
- i0.ɵɵconditional((tmp_5_0 = ctx_r0.SelectedInvoice) ? 10 : -1, tmp_5_0);
351
+ i0.ɵɵproperty("disabled", ctx_r1.Busy || ctx_r1.PollBlocked);
352
+ i0.ɵɵadvance(2);
353
+ i0.ɵɵtextInterpolate1(" ", ctx_r1.Busy ? "Working\u2026" : (ctx_r1.PollJob == null ? null : ctx_r1.PollJob.State) === "Preview" ? "Preview payment check" : "Check for payments now", " ");
354
+ i0.ɵɵadvance(2);
355
+ i0.ɵɵtextInterpolate(ctx_r1.PollHint);
356
+ i0.ɵɵadvance();
357
+ i0.ɵɵproperty("Columns", ctx_r1.PaymentColumns)("Rows", ctx_r1.ShownExceptions)("Searchable", false)("Loading", ctx_r1.Loading)("Totals", ctx_r1.PaymentTotals)("SortKey", ctx_r1.PaymentSort.Key)("SortDescending", ctx_r1.PaymentSort.Descending)("SelectedKey", (ctx_r1.SelectedPayment == null ? null : ctx_r1.SelectedPayment.ID) ?? null)("Selectable", true)("SelectedKeys", ctx_r1.CheckedIDs)("RowLabel", ctx_r1.PaymentTickLabel)("EmptyTitle", ctx_r1.Exceptions.length ? "Nothing matches" : "Nothing needs attention")("EmptyHint", ctx_r1.Exceptions.length ? "No payment matches these filters. Clear one to see more." : "Every payment reported has been recorded or set aside.");
85
358
  i0.ɵɵadvance();
86
- i0.ɵɵproperty("Columns", ctx_r0.InvoiceColumns)("Rows", ctx_r0.Rows)("Presets", ctx_r0.Presets)("ActivePreset", ctx_r0.Preset)("Searchable", false)("SelectedKey", (ctx_r0.SelectedInvoice == null ? null : ctx_r0.SelectedInvoice.DocumentNumber) ?? null);
359
+ i0.ɵɵconditional((tmp_19_0 = ctx_r1.SelectedPayment) ? 12 : -1, tmp_19_0);
87
360
  } }
88
- function MJOExternalInvoicingQueuePageComponent_Conditional_23_Template(rf, ctx) { if (rf & 1) {
89
- const _r4 = i0.ɵɵgetCurrentView();
90
- i0.ɵɵelementStart(0, "div", 19)(1, "label", 20)(2, "span", 13);
91
- i0.ɵɵtext(3, "Paid before");
361
+ function MJOExternalInvoicingQueuePageComponent_Conditional_27_Template(rf, ctx) { if (rf & 1) {
362
+ const _r12 = i0.ɵɵgetCurrentView();
363
+ i0.ɵɵelementStart(0, "label", 15)(1, "span", 16);
364
+ i0.ɵɵtext(2, "Include unmatched payments dated before");
365
+ i0.ɵɵelementEnd();
366
+ i0.ɵɵelementStart(3, "input", 47);
367
+ i0.ɵɵlistener("change", function MJOExternalInvoicingQueuePageComponent_Conditional_27_Template_input_change_3_listener($event) { i0.ɵɵrestoreView(_r12); const ctx_r1 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r1.OnSetAsideBefore($event.target.value)); });
92
368
  i0.ɵɵelementEnd();
93
- i0.ɵɵelementStart(4, "input", 21);
94
- i0.ɵɵlistener("change", function MJOExternalInvoicingQueuePageComponent_Conditional_23_Template_input_change_4_listener($event) { i0.ɵɵrestoreView(_r4); const ctx_r0 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r0.OnPaidBefore($event.target.value)); });
369
+ i0.ɵɵelementStart(4, "span", 16);
370
+ i0.ɵɵtext(5, "An unmatched payment may be waiting for an invoice still to be loaded, so in a batch only those dated before this day are set aside. Held and refused payments are set aside whatever their date.");
95
371
  i0.ɵɵelementEnd()();
96
- i0.ɵɵelementStart(5, "label", 22)(6, "span", 13);
97
- i0.ɵɵtext(7, "Reason for setting aside");
372
+ } if (rf & 2) {
373
+ const ctx_r1 = i0.ɵɵnextContext();
374
+ i0.ɵɵadvance(3);
375
+ i0.ɵɵproperty("value", ctx_r1.SetAsideBefore ?? "");
376
+ } }
377
+ function MJOExternalInvoicingQueuePageComponent_Conditional_28_Conditional_3_For_3_Template(rf, ctx) { if (rf & 1) {
378
+ i0.ɵɵelementStart(0, "tr")(1, "td", 50);
379
+ i0.ɵɵtext(2);
380
+ i0.ɵɵelementEnd();
381
+ i0.ɵɵelementStart(3, "td");
382
+ i0.ɵɵtext(4);
383
+ i0.ɵɵelementEnd();
384
+ i0.ɵɵelementStart(5, "td");
385
+ i0.ɵɵtext(6);
98
386
  i0.ɵɵelementEnd();
99
- i0.ɵɵelementStart(8, "input", 23);
100
- i0.ɵɵlistener("input", function MJOExternalInvoicingQueuePageComponent_Conditional_23_Template_input_input_8_listener($event) { i0.ɵɵrestoreView(_r4); const ctx_r0 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r0.SetAsideReason = $event.target.value); });
387
+ i0.ɵɵelementStart(7, "td", 51);
388
+ i0.ɵɵtext(8);
101
389
  i0.ɵɵelementEnd()();
102
- i0.ɵɵelementStart(9, "button", 11);
103
- i0.ɵɵlistener("click", function MJOExternalInvoicingQueuePageComponent_Conditional_23_Template_button_click_9_listener() { i0.ɵɵrestoreView(_r4); const ctx_r0 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r0.SetAsideChecked()); });
104
- i0.ɵɵelement(10, "i", 24);
105
- i0.ɵɵtext(11);
390
+ } if (rf & 2) {
391
+ const row_r13 = ctx.$implicit;
392
+ const ctx_r1 = i0.ɵɵnextContext(3);
393
+ i0.ɵɵadvance(2);
394
+ i0.ɵɵtextInterpolate(row_r13.ExternalPaymentRef);
395
+ i0.ɵɵadvance(2);
396
+ i0.ɵɵtextInterpolate(ctx_r1.date(row_r13.PaymentDate));
397
+ i0.ɵɵadvance(2);
398
+ i0.ɵɵtextInterpolate(ctx_r1.dispositionLabel(row_r13));
399
+ i0.ɵɵadvance(2);
400
+ i0.ɵɵtextInterpolate(ctx_r1.money(row_r13.Amount));
401
+ } }
402
+ function MJOExternalInvoicingQueuePageComponent_Conditional_28_Conditional_3_Conditional_4_Template(rf, ctx) { if (rf & 1) {
403
+ i0.ɵɵelementStart(0, "div", 16);
404
+ i0.ɵɵtext(1);
405
+ i0.ɵɵelementEnd();
406
+ } if (rf & 2) {
407
+ const plan_r14 = i0.ɵɵnextContext(2);
408
+ const ctx_r1 = i0.ɵɵnextContext();
409
+ i0.ɵɵadvance();
410
+ i0.ɵɵtextInterpolate1("and ", plan_r14.Eligible.length - ctx_r1.setAsideListed.length, " more");
411
+ } }
412
+ function MJOExternalInvoicingQueuePageComponent_Conditional_28_Conditional_3_Template(rf, ctx) { if (rf & 1) {
413
+ i0.ɵɵelementStart(0, "table", 49)(1, "tbody");
414
+ i0.ɵɵrepeaterCreate(2, MJOExternalInvoicingQueuePageComponent_Conditional_28_Conditional_3_For_3_Template, 9, 4, "tr", null, _forTrack1);
106
415
  i0.ɵɵelementEnd()();
107
- i0.ɵɵelementStart(12, "mjo-worklist-table", 25);
108
- i0.ɵɵlistener("SelectionChanged", function MJOExternalInvoicingQueuePageComponent_Conditional_23_Template_mjo_worklist_table_SelectionChanged_12_listener($event) { i0.ɵɵrestoreView(_r4); const ctx_r0 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r0.CheckedIDs = $event); });
416
+ i0.ɵɵconditionalCreate(4, MJOExternalInvoicingQueuePageComponent_Conditional_28_Conditional_3_Conditional_4_Template, 2, 1, "div", 16);
417
+ } if (rf & 2) {
418
+ const plan_r14 = i0.ɵɵnextContext();
419
+ const ctx_r1 = i0.ɵɵnextContext();
420
+ i0.ɵɵadvance(2);
421
+ i0.ɵɵrepeater(ctx_r1.setAsideListed);
422
+ i0.ɵɵadvance(2);
423
+ i0.ɵɵconditional(plan_r14.Eligible.length > ctx_r1.setAsideListed.length ? 4 : -1);
424
+ } }
425
+ function MJOExternalInvoicingQueuePageComponent_Conditional_28_Conditional_4_For_2_Template(rf, ctx) { if (rf & 1) {
426
+ i0.ɵɵelementStart(0, "li")(1, "span", 50);
427
+ i0.ɵɵtext(2);
428
+ i0.ɵɵelementEnd();
429
+ i0.ɵɵtext(3);
109
430
  i0.ɵɵelementEnd();
110
431
  } if (rf & 2) {
111
- const ctx_r0 = i0.ɵɵnextContext();
112
- i0.ɵɵadvance(4);
113
- i0.ɵɵproperty("value", ctx_r0.PaidBefore ?? "");
114
- i0.ɵɵadvance(4);
115
- i0.ɵɵproperty("value", ctx_r0.SetAsideReason);
432
+ const item_r15 = ctx.$implicit;
433
+ i0.ɵɵadvance(2);
434
+ i0.ɵɵtextInterpolate(item_r15.Row.ExternalPaymentRef);
116
435
  i0.ɵɵadvance();
117
- i0.ɵɵproperty("disabled", ctx_r0.Busy || !ctx_r0.CheckedIDs.length || !ctx_r0.SetAsideReason.trim());
436
+ i0.ɵɵtextInterpolate1(" is left out. ", item_r15.Why);
437
+ } }
438
+ function MJOExternalInvoicingQueuePageComponent_Conditional_28_Conditional_4_Template(rf, ctx) { if (rf & 1) {
439
+ i0.ɵɵelementStart(0, "ul", 48);
440
+ i0.ɵɵrepeaterCreate(1, MJOExternalInvoicingQueuePageComponent_Conditional_28_Conditional_4_For_2_Template, 4, 2, "li", null, _forTrack2);
441
+ i0.ɵɵelementEnd();
442
+ } if (rf & 2) {
443
+ const plan_r14 = i0.ɵɵnextContext();
444
+ i0.ɵɵadvance();
445
+ i0.ɵɵrepeater(plan_r14.Excluded);
446
+ } }
447
+ function MJOExternalInvoicingQueuePageComponent_Conditional_28_Template(rf, ctx) { if (rf & 1) {
448
+ i0.ɵɵelementStart(0, "div", 18)(1, "strong");
449
+ i0.ɵɵtext(2);
450
+ i0.ɵɵelementEnd();
451
+ i0.ɵɵconditionalCreate(3, MJOExternalInvoicingQueuePageComponent_Conditional_28_Conditional_3_Template, 5, 1);
452
+ i0.ɵɵconditionalCreate(4, MJOExternalInvoicingQueuePageComponent_Conditional_28_Conditional_4_Template, 3, 0, "ul", 48);
453
+ i0.ɵɵelementEnd();
454
+ } if (rf & 2) {
455
+ const plan_r14 = ctx;
456
+ const ctx_r1 = i0.ɵɵnextContext();
118
457
  i0.ɵɵadvance(2);
119
- i0.ɵɵtextInterpolate1(" Set aside", ctx_r0.CheckedIDs.length ? " (" + ctx_r0.CheckedIDs.length + ")" : "", " ");
458
+ i0.ɵɵtextInterpolate3("", plan_r14.Eligible.length, " of ", ctx_r1.SetAsideTargets.length, " will be set aside \u00B7 ", ctx_r1.money(ctx_r1.setAsideTotal));
120
459
  i0.ɵɵadvance();
121
- i0.ɵɵproperty("Columns", ctx_r0.PaymentColumns)("Rows", ctx_r0.ShownExceptions)("Presets", i0.ɵɵpureFunction0(11, _c0))("Searchable", false)("Selectable", true)("SelectedKeys", ctx_r0.CheckedIDs)("FootNote", ctx_r0.ExceptionFootNote);
460
+ i0.ɵɵconditional(plan_r14.Eligible.length ? 3 : -1);
461
+ i0.ɵɵadvance();
462
+ i0.ɵɵconditional(plan_r14.Excluded.length ? 4 : -1);
122
463
  } }
464
+ /** Which due dates the Invoices to send tab lists. An invoice with no due date only shows under "Any due date". */
465
+ export const QUEUE_WINDOWS = [
466
+ { Key: 'all', Label: 'Any due date', FromOffset: null, ToOffset: null },
467
+ { Key: 'pastdue', Label: 'Past due', FromOffset: null, ToOffset: -1 },
468
+ { Key: '30', Label: 'Next 30 days', FromOffset: 0, ToOffset: 30 },
469
+ { Key: CUSTOM_WINDOW, Label: 'Custom dates…', FromOffset: null, ToOffset: null },
470
+ ];
471
+ const DEFAULT_WINDOW = { Key: 'all', From: null, To: null };
472
+ const QUEUE_STATE_KEY = 'mjOrders.invoicingQueue.view';
473
+ /** The tab-address keys for this page's due-date filter and its open tab. */
474
+ const DUE_ADDRESS_KEY = 'queueDue';
475
+ const TAB_ADDRESS_KEY = 'queueTab';
476
+ const PRESET_LABELS = { all: 'All', unsent: 'Not yet sent', failed: 'Failed' };
123
477
  const EXTERNAL_PAYMENT_ENTITY = 'MJ_BizApps_Orders: External Payments';
478
+ const PAYMENT_PROVIDER_ENTITY = 'MJ_BizApps_Orders: Payment Providers';
479
+ const EXTERNAL_CUSTOMER_ENTITY = 'MJ_BizApps_Orders: External Customers';
480
+ /**
481
+ * How many invoices one "Send all waiting" sends. The operation's own default, passed explicitly so
482
+ * the number the dialog states is the number the run is held to.
483
+ */
484
+ const SWEEP_MAX = 25;
485
+ /** How many payments the set-aside dialog names before it says "and N more". */
486
+ const SET_ASIDE_LISTED = 12;
124
487
  /** Dispositions that mean money is waiting on a person. `Captured` and `Ignored` are finished. */
125
488
  const EXCEPTION_DISPOSITIONS = ['Held', 'Unmatched', 'Refused', 'Reapplied', 'ReversalNeeded'];
489
+ /** How an invoice's send state reads on screen. */
490
+ function stateLabel(state) {
491
+ return state === 'InFlight' ? 'Sending' : state === 'Unsent' ? 'Not sent' : state;
492
+ }
126
493
  /**
127
494
  * `mjo-external-invoicing-queue-page` — the two queues the scheduled jobs leave behind.
128
495
  *
@@ -135,13 +502,20 @@ const EXCEPTION_DISPOSITIONS = ['Held', 'Unmatched', 'Refused', 'Reapplied', 'Re
135
502
  * TWO TABS, BECAUSE THEY ARE TWO JOBS. Invoices out and payments in fail for unrelated reasons and are
136
503
  * fixed by different people. Merging them into one list would bury both.
137
504
  *
505
+ * A ROW OPENS BESIDE ITS LIST, with the whole of what the columns cut short (a failed send's error,
506
+ * what happened to a payment) and the act on that one row. The tiles are the quick filters.
507
+ *
508
+ * SETTING PAYMENTS ASIDE ASKS IN A DIALOG. Its reason and its "dated before" guard belong to that act,
509
+ * so they are asked for when it is taken, with the plan (what will be set aside, what is left out and
510
+ * why) shown before anything is written.
511
+ *
138
512
  * NAMED FROM DATA. Nothing here says Bill.com: the rail is a seam, and a company on a different
139
513
  * provider must read correctly on the same screen.
140
514
  *
141
515
  * ## Example
142
516
  *
143
517
  * ```html
144
- * <mjo-external-invoicing-queue-page (OrderOpened)="open($event)" />
518
+ * <mjo-external-invoicing-queue-page (OrderOpened)="open($event)" (AddressChanged)="write($event)" />
145
519
  * ```
146
520
  *
147
521
  * @module @mj-biz-apps/orders-ng
@@ -150,89 +524,219 @@ export class MJOExternalInvoicingQueuePageComponent {
150
524
  cdr = inject(ChangeDetectorRef);
151
525
  confirm = inject(MJConfirmService);
152
526
  OrderOpened = new EventEmitter();
527
+ /** The company choice, the due-date filter or the open tab changed: the section writes it to the tab's address. A null value removes the key. */
528
+ AddressChanged = new EventEmitter();
153
529
  String = String;
154
530
  money = (n) => FormatMoney(n);
531
+ stateLabel = stateLabel;
155
532
  Tab = 'invoices';
156
533
  LoadError = null;
157
534
  Notice = null;
158
535
  Truncated = false;
159
536
  Busy = false;
537
+ Loading = false;
538
+ /** Every waiting invoice the operation returned. */
160
539
  AllRows = [];
540
+ /** `AllRows` for the chosen companies. The tiles count these, and "Send all waiting" sends these. */
541
+ InScope = [];
542
+ /** `InScope` under the due dates, the search and the quick filter, in the sorted order. */
161
543
  Rows = [];
544
+ /** The invoice open in the side panel. */
162
545
  SelectedInvoice = null;
163
546
  Preset = 'all';
547
+ Windows = QUEUE_WINDOWS;
548
+ Companies = [];
549
+ /** The chosen companies that are offered: what the filter shows. */
550
+ CompanyPicks = [];
551
+ /** The company choice as chosen, shared across Receivables. */
552
+ companyChoice = [];
553
+ Search = '';
554
+ Window = DEFAULT_WINDOW;
555
+ InvoiceSort = { Key: null, Descending: false };
556
+ PaymentSearch = '';
557
+ PaymentSort = { Key: null, Descending: false };
558
+ /** The totals rows. Fields: a getter would hand the table a new object on every pass. */
559
+ InvoiceTotals = null;
560
+ PaymentTotals = null;
164
561
  Exceptions = [];
165
- /** `Exceptions` narrowed by the "paid before" day. */
562
+ /** `Exceptions` under the company filter and the search, in the sorted order. */
166
563
  ShownExceptions = [];
167
- /** The "paid before" cut day (`YYYY-MM-DD`), or null for every exception. */
168
- PaidBefore = null;
169
- /** Rows checked for setting aside; always a subset of `ShownExceptions`. */
564
+ /** The payment open in the side panel. */
565
+ SelectedPayment = null;
566
+ /** Rows ticked for setting aside; always a subset of `ShownExceptions`. */
170
567
  CheckedIDs = [];
568
+ /** Payment provider ID (lower case) -> the company it belongs to: a payment reaches its company through its provider. */
569
+ providerCompany = new Map();
570
+ /** Provider ID (lower case) and the provider's customer reference -> our customer's name. */
571
+ customerNames = new Map();
572
+ /** The Company filter's choices on Payment exceptions: the companies that have one, through their payment provider. */
573
+ PaymentCompanies = [];
574
+ /** The chosen companies that have payment exceptions: what the filter shows on that tab. */
575
+ PaymentCompanyPicks = [];
576
+ /** The set-aside dialog: the payments it is for, its two inputs, and what they would do. */
577
+ SetAsideOpen = false;
578
+ SetAsideTargets = [];
171
579
  SetAsideReason = '';
172
- /** The scheduled poll job's state, which decides what the button may do. Null when it could not be read. */
580
+ /** The cut day (`YYYY-MM-DD`): unmatched payments dated before it may be set aside in a batch. */
581
+ SetAsideBefore = null;
582
+ SetAsidePlan = null;
173
583
  /**
174
584
  * The most permissive state across the poll jobs (one per provider a job names, plus the jobs that
175
585
  * name none). The button follows it; the operation then gates each provider by its own job.
586
+ * Null when the jobs could not be read.
176
587
  */
177
588
  PollJob = null;
178
589
  /** The poll jobs are not all in the same state, so a check treats providers differently. */
179
590
  PollJobsMixed = false;
591
+ address = {};
592
+ companyKey = new AddressKey(COMPANY_ADDRESS_KEY);
593
+ dueKey = new AddressKey(DUE_ADDRESS_KEY);
594
+ tabKey = new AddressKey(TAB_ADDRESS_KEY);
595
+ /** Counts loads, so a slow answer to an earlier read cannot overwrite a later one. */
596
+ loadSeq = 0;
597
+ ready = false;
180
598
  InvoiceColumns = [
181
- { Key: 'DocumentNumber', Label: 'Document', Kind: 'mono', Width: '150px', Secondary: (r) => (r.InstallmentNumber ? `installment ${r.InstallmentNumber}` : 'whole order') },
182
- { Key: 'CustomerName', Label: 'Customer' },
183
- { Key: 'CompanyName', Label: 'Billed by', HideBelow: 1000 },
184
- { Key: 'Amount', Label: 'Amount', Kind: 'money', Width: '120px', Format: (r) => FormatMoney(r.Amount) },
185
- { Key: 'DueDate', Label: 'Due', Kind: 'date', Width: '110px', Format: (r) => (r.DueDate ? FormatDate(r.DueDate, { Short: true }) : '—') },
599
+ { Key: 'DocumentNumber', Label: 'Document', Kind: 'mono', Width: '150px', Sortable: true, Secondary: (r) => (r.InstallmentNumber ? `installment ${r.InstallmentNumber}` : 'whole order') },
600
+ { Key: 'OrderNumber', Label: 'Order', Kind: 'link', LinkHint: 'Open the order', Width: '130px', HideBelow: 760, Sortable: true },
601
+ { Key: 'CustomerName', Label: 'Customer', Sortable: true },
602
+ { Key: 'CompanyName', Label: 'Billed by', HideBelow: 1000, Sortable: true },
603
+ { Key: 'Amount', Label: 'Amount', Kind: 'money', Width: '120px', Sortable: true, Format: (r) => FormatMoney(r.Amount) },
604
+ { Key: 'DueDate', Label: 'Due', Kind: 'date', Width: '120px', Sortable: true, Format: (r) => this.date(r.DueDate) },
186
605
  {
187
606
  Key: 'State',
188
- Label: 'State',
607
+ Label: 'Status',
189
608
  Kind: 'chip',
190
609
  Width: '120px',
191
- ChipClass: (r) => (r.State === 'Failed' ? 'mjo-chip--error' : r.State === 'InFlight' ? 'mjo-chip--info' : 'mjo-chip--outline'),
192
- Format: (r) => (r.State === 'InFlight' ? 'In flight' : r.State),
610
+ Sortable: true,
611
+ SortValue: (r) => stateLabel(r.State),
612
+ ChipClass: (r) => this.stateChip(r),
613
+ Format: (r) => stateLabel(r.State),
193
614
  Secondary: (r) => r.LastError ?? null,
194
615
  },
195
616
  ];
196
617
  PaymentColumns = [
197
- { Key: 'ExternalPaymentRef', Label: 'Rail payment', Kind: 'mono', Width: '190px' },
198
- { Key: 'Amount', Label: 'Amount', Kind: 'money', Width: '120px', Format: (r) => FormatMoney(r.Amount) },
199
- { Key: 'PaymentDate', Label: 'Dated', Kind: 'date', Width: '110px', Format: (r) => (r.PaymentDate ? FormatDate(r.PaymentDate, { Short: true }) : '—') },
618
+ { Key: 'ExternalPaymentRef', Label: 'Payment reference', Kind: 'mono', Width: '190px', Sortable: true },
619
+ { Key: 'PaymentProvider', Label: 'Received through', HideBelow: 1000, Sortable: true, Format: (r) => r.PaymentProvider || '—', Secondary: (r) => this.companyOf(r) },
620
+ { Key: 'ExternalCustomerRef', Label: 'Customer', HideBelow: 1000, Sortable: true, SortValue: (r) => this.customerOf(r) ?? r.ExternalCustomerRef, Format: (r) => this.customerOf(r) ?? '—', Secondary: (r) => r.ExternalCustomerRef || null },
621
+ { Key: 'Amount', Label: 'Amount', Kind: 'money', Width: '120px', Sortable: true, SortValue: (r) => Number(r.Amount), Format: (r) => FormatMoney(r.Amount) },
622
+ { Key: 'PaymentDate', Label: 'Dated', Kind: 'date', Width: '120px', Sortable: true, SortValue: (r) => ToISODate(r.PaymentDate), Format: (r) => this.date(r.PaymentDate) },
200
623
  {
201
624
  Key: 'Disposition',
202
- Label: 'Why',
625
+ Label: 'Status',
203
626
  Kind: 'chip',
204
- Width: '150px',
627
+ Width: '160px',
628
+ Sortable: true,
629
+ SortValue: (r) => DispositionLabel(r.Disposition),
205
630
  ChipClass: (r) => DispositionChipClass(r.Disposition),
206
631
  Format: (r) => DispositionLabel(r.Disposition),
207
632
  },
208
- { Key: 'DispositionReason', Label: 'What happened', Format: (r) => r.DispositionReason ?? '—' },
633
+ { Key: 'DispositionReason', Label: 'What happened', HideBelow: 760, Sortable: true, Format: (r) => r.DispositionReason ?? '—' },
634
+ ];
635
+ PaymentTickLabel = (row) => `Select payment ${row.ExternalPaymentRef}, ${FormatMoney(row.Amount)}`;
636
+ invoiceExportFields = [
637
+ { Name: 'DocumentNumber', Label: 'Document', Value: (r) => r.DocumentNumber },
638
+ { Name: 'OrderNumber', Label: 'Order', Value: (r) => r.OrderNumber },
639
+ { Name: 'InstallmentNumber', Label: 'Installment', Type: 'number', Value: (r) => r.InstallmentNumber },
640
+ { Name: 'CustomerName', Label: 'Customer', Value: (r) => r.CustomerName },
641
+ { Name: 'CompanyName', Label: 'Billed by', Value: (r) => r.CompanyName },
642
+ { Name: 'Amount', Label: 'Amount', Type: 'money', Value: (r) => r.Amount },
643
+ { Name: 'DueDate', Label: 'Due date', Type: 'date', Value: (r) => r.DueDate },
644
+ { Name: 'State', Label: 'Status', Value: (r) => stateLabel(r.State) },
645
+ { Name: 'LastError', Label: 'Last error', Value: (r) => r.LastError },
209
646
  ];
210
- Presets = [];
647
+ paymentExportFields = [
648
+ { Name: 'ExternalPaymentRef', Label: 'Payment reference', Value: (r) => r.ExternalPaymentRef },
649
+ { Name: 'PaymentProvider', Label: 'Received through', Value: (r) => r.PaymentProvider },
650
+ { Name: 'Company', Label: 'Company', Value: (r) => this.companyOf(r) },
651
+ { Name: 'Customer', Label: 'Customer', Value: (r) => this.customerOf(r) },
652
+ { Name: 'ExternalCustomerRef', Label: 'Customer reference', Value: (r) => r.ExternalCustomerRef },
653
+ { Name: 'Amount', Label: 'Amount', Type: 'money', Value: (r) => r.Amount },
654
+ { Name: 'PaymentDate', Label: 'Dated', Type: 'date', Value: (r) => ToISODate(r.PaymentDate) },
655
+ { Name: 'Disposition', Label: 'Status', Value: (r) => DispositionLabel(r.Disposition) },
656
+ { Name: 'DispositionReason', Label: 'What happened', Value: (r) => r.DispositionReason },
657
+ { Name: 'ExternalStatus', Label: 'Provider status', Value: (r) => r.ExternalStatus },
658
+ ];
659
+ /** The invoices listed, as an export file. Fields, so the bar is handed the same function every pass. */
660
+ BuildInvoiceExport = (format) => ({
661
+ FileName: ExportFileName('invoices-waiting-to-send', this.CompanyPicks, this.Companies, Today()),
662
+ ...BuildWorklistExport(this.invoiceExportFields, this.Rows, format),
663
+ });
664
+ BuildPaymentExport = (format) => ({
665
+ FileName: ExportFileName('payment-exceptions', this.PaymentCompanyPicks, this.PaymentCompanies, Today()),
666
+ ...BuildWorklistExport(this.paymentExportFields, this.ShownExceptions, format),
667
+ });
211
668
  async ngOnInit() {
669
+ const saved = ReadWorklistState(globalThis.localStorage, QUEUE_STATE_KEY);
670
+ if (saved) {
671
+ this.Window = RestoreWindow(saved.Window, QUEUE_WINDOWS, DEFAULT_WINDOW);
672
+ this.InvoiceSort = RestoreSort(saved.Sort, this.InvoiceColumns);
673
+ }
674
+ this.adoptAddress();
675
+ await this.load();
676
+ // An address that arrived while that first load was out was kept, not followed. Follow it now.
677
+ this.adoptAddress();
678
+ this.applyInvoiceView();
679
+ this.applyExceptionFilter();
680
+ this.ready = true;
681
+ this.cdr.detectChanges();
682
+ }
683
+ /**
684
+ * The tab's address, from the section: `company` is shared across Receivables; `queueDue` is the
685
+ * due-date filter and `queueTab` the open tab of this page.
686
+ */
687
+ ApplyAddress(params) {
688
+ this.address = params;
689
+ if (!this.ready)
690
+ return;
691
+ this.adoptAddress();
692
+ this.applyInvoiceView();
693
+ this.applyExceptionFilter();
694
+ // Back, Forward and links arrive outside any event of this page's own, so nothing else repaints it.
695
+ this.cdr.detectChanges();
696
+ }
697
+ /** Shown again after another page: an invoice issued there is now waiting here. */
698
+ async OnShown() {
699
+ if (!this.ready || this.Busy)
700
+ return;
212
701
  await this.load();
213
702
  this.cdr.detectChanges();
214
703
  }
215
704
  /* ── Tiles ──────────────────────────────────────────────────────────── */
216
705
  get UnsentCount() {
217
- return this.AllRows.filter((r) => r.State === 'Unsent').length;
706
+ return this.InScope.filter((r) => r.State === 'Unsent').length;
218
707
  }
219
708
  get FailedCount() {
220
- return this.AllRows.filter((r) => r.State === 'Failed').length;
709
+ return this.InScope.filter((r) => r.State === 'Failed').length;
221
710
  }
222
711
  get UnsentDetail() {
223
- const total = this.AllRows.filter((r) => r.State === 'Unsent').reduce((s, r) => s + r.Amount, 0);
224
- return this.UnsentCount ? `${FormatMoney(total, { Round: true })} of invoices` : 'The queue is clear';
712
+ const total = this.InScope.filter((r) => r.State === 'Unsent').reduce((s, r) => s + r.Amount, 0);
713
+ return this.UnsentCount ? FormatMoney(total, { Round: true }) : 'Nothing is waiting';
225
714
  }
226
715
  get ExceptionDetail() {
227
716
  const reversals = this.Exceptions.filter((e) => e.Disposition === 'ReversalNeeded').length;
228
717
  if (!this.Exceptions.length)
229
- return 'Nothing waiting';
230
- return reversals ? `${reversals} needing a reversal` : 'Money the poll could not place';
718
+ return 'Nothing is waiting';
719
+ return reversals ? `${reversals} need${reversals === 1 ? 's' : ''} a reversal` : 'Payments that could not be recorded';
720
+ }
721
+ get PresetLabel() {
722
+ return PRESET_LABELS[this.Preset];
723
+ }
724
+ get IsCustomWindow() {
725
+ return this.Window.Key === CUSTOM_WINDOW;
726
+ }
727
+ get InvoiceSummary() {
728
+ return this.LoadError || (this.Loading && !this.AllRows.length) ? '' : ShownSummary(this.Rows.length, this.AllRows.length, 'invoice');
231
729
  }
232
- get ExceptionFootNote() {
233
- if (!this.PaidBefore)
730
+ get PaymentSummary() {
731
+ return this.Loading && !this.Exceptions.length ? '' : ShownSummary(this.ShownExceptions.length, this.Exceptions.length, 'payment');
732
+ }
733
+ /** The one chosen company's name, or "the N companies chosen"; null when the filter is off. */
734
+ get companyScopeText() {
735
+ if (!this.CompanyPicks.length)
234
736
  return null;
235
- return `${this.ShownExceptions.length} of ${this.Exceptions.length} dated before ${FormatDate(this.PaidBefore, { Short: true })}.`;
737
+ if (this.CompanyPicks.length === 1)
738
+ return this.Companies.find((o) => o.Value === this.CompanyPicks[0])?.Text ?? 'the company chosen';
739
+ return `the ${this.CompanyPicks.length} companies chosen`;
236
740
  }
237
741
  /** The poll job is off or missing: the server would refuse, so the button does not offer it. */
238
742
  get PollBlocked() {
@@ -245,26 +749,91 @@ export class MJOExternalInvoicingQueuePageComponent {
245
749
  return `Recording payments is off: ${this.PollJob.Why}.`;
246
750
  case 'Preview':
247
751
  return this.PollJobsMixed
248
- ? 'No poll job is live, so a check here records nothing; providers whose job is off are skipped.'
249
- : 'The scheduled poll job is in Preview, so a check here records nothing.';
752
+ ? 'No payment job is live, so a check here records nothing; providers whose job is off are skipped.'
753
+ : 'The scheduled payment job is in Preview, so a check here records nothing.';
250
754
  case 'Live':
251
755
  return this.PollJobsMixed
252
- ? 'Payments are recorded only for providers whose poll job is live; the rest are previewed or skipped.'
253
- : 'Captured payments are not listed — only what the poll could not finish.';
756
+ ? 'Payments are recorded only for providers whose job is live; the rest are previewed or skipped.'
757
+ : 'Recorded payments are not listed here, only those that could not be.';
254
758
  default:
255
- return 'The poll job could not be read; the server decides whether a check records anything.';
759
+ return 'The payment job could not be read; the server decides whether a check records anything.';
256
760
  }
257
761
  }
258
- /* ── Actions ────────────────────────────────────────────────────────── */
762
+ /* ── Filters ────────────────────────────────────────────────────────── */
763
+ OnTab(tab) {
764
+ if (this.Tab === tab)
765
+ return;
766
+ this.Tab = tab;
767
+ this.AddressChanged.emit(this.tabKey.Write(tab === 'payments' ? 'payments' : null));
768
+ }
769
+ /** A tile opens Invoices to send with its quick filter on; the same tile again turns the filter off. */
770
+ OnTile(preset) {
771
+ const on = this.Tab === 'invoices' && this.Preset === preset;
772
+ if (this.Tab !== 'invoices')
773
+ this.OnTab('invoices');
774
+ this.Preset = on ? 'all' : preset;
775
+ this.applyInvoiceView();
776
+ }
259
777
  OnPreset(preset) {
260
778
  this.Preset = preset;
261
- this.applyPreset();
779
+ this.applyInvoiceView();
780
+ }
781
+ OnCompanies(picks) {
782
+ this.companyChoice = picks;
783
+ WriteSharedCompanies(globalThis.localStorage, picks);
784
+ this.AddressChanged.emit(this.companyKey.Write(CompaniesToAddress(picks)));
785
+ this.applyInvoiceView();
786
+ this.applyExceptionFilter();
787
+ }
788
+ OnSearch(text) {
789
+ this.Search = text;
790
+ this.applyInvoiceView();
791
+ }
792
+ OnWindow(key) {
793
+ if (!QUEUE_WINDOWS.some((o) => o.Key === key))
794
+ return;
795
+ this.Window = { Key: key, From: null, To: null };
796
+ // Custom is not a choice until it has a day: nothing is saved or written to the address before then.
797
+ if (key !== CUSTOM_WINDOW)
798
+ this.saveView();
799
+ this.applyInvoiceView();
262
800
  }
263
- OpenSelected() {
264
- if (this.SelectedInvoice)
265
- this.OrderOpened.emit({ ID: this.SelectedInvoice.OrderHeaderID });
801
+ OnCustomDay(side, day) {
802
+ this.Window = { ...this.Window, Key: CUSTOM_WINDOW, [side]: day || null };
803
+ this.saveView();
804
+ this.applyInvoiceView();
266
805
  }
267
- /** One unit, deliberately. A Failed or in-flight unit needs the person to have checked the rail. */
806
+ OnInvoiceSort(key) {
807
+ this.InvoiceSort = NextSort(this.InvoiceSort, key, this.InvoiceColumns);
808
+ WriteWorklistState(globalThis.localStorage, QUEUE_STATE_KEY, { Window: this.Window, Sort: this.InvoiceSort });
809
+ this.applyInvoiceView();
810
+ }
811
+ OnPaymentSearch(text) {
812
+ this.PaymentSearch = text;
813
+ this.applyExceptionFilter();
814
+ }
815
+ OnPaymentSort(key) {
816
+ this.PaymentSort = NextSort(this.PaymentSort, key, this.PaymentColumns);
817
+ this.applyExceptionFilter();
818
+ }
819
+ async Refresh() {
820
+ this.Notice = null;
821
+ await this.load();
822
+ this.cdr.detectChanges();
823
+ }
824
+ /* ── Rows ───────────────────────────────────────────────────────────── */
825
+ /** Clicking a row opens it beside the list; clicking the open row closes it. */
826
+ OnInvoiceRow(row) {
827
+ this.SelectedInvoice = this.SelectedInvoice?.DocumentNumber === row.DocumentNumber ? null : row;
828
+ }
829
+ OnPaymentRow(row) {
830
+ this.SelectedPayment = this.SelectedPayment?.ID === row.ID ? null : row;
831
+ }
832
+ OpenOrder(row) {
833
+ this.OrderOpened.emit({ ID: row.OrderHeaderID });
834
+ }
835
+ /* ── Sending ────────────────────────────────────────────────────────── */
836
+ /** One invoice, deliberately. A failed or in-flight one needs the person to have checked the provider. */
268
837
  async SendSelected() {
269
838
  const row = this.SelectedInvoice;
270
839
  if (!row || this.Busy)
@@ -274,7 +843,7 @@ export class MJOExternalInvoicingQueuePageComponent {
274
843
  title: `Send ${row.DocumentNumber}?`,
275
844
  message: `${row.CustomerName} · ${FormatMoney(row.Amount)} · billed by ${row.CompanyName}.`,
276
845
  detail: risky
277
- ? 'This unit has been attempted before. Check the rail first: if an invoice already exists there, sending again bills the customer twice.'
846
+ ? 'A send was attempted before. Check the payment provider first: if the invoice already exists there, sending again bills the customer twice.'
278
847
  : 'The scheduled send would pick this up on its own; this sends it now.',
279
848
  type: 'warning',
280
849
  confirmText: 'Send it',
@@ -293,70 +862,28 @@ export class MJOExternalInvoicingQueuePageComponent {
293
862
  if (!result.Success || !out?.Success) {
294
863
  return { Tone: 'error', Text: out?.Message?.trim() || result.ErrorMessage?.trim() || 'The invoice could not be sent.' };
295
864
  }
296
- this.SelectedInvoice = null;
297
- this.cdr.detectChanges();
298
865
  return { Tone: 'success', Text: out.Message ?? `${row.DocumentNumber} sent.` };
299
866
  });
300
867
  }
301
- OnPaidBefore(day) {
302
- this.PaidBefore = day || null;
303
- this.applyExceptionFilter();
304
- }
305
- /**
306
- * Set the checked exceptions aside (bc-aidp-next-golive#449). Permanent: a payment set aside is never
307
- * captured, even once its invoice is loaded. So the confirmation says what the bulk guard leaves out
308
- * (`PlanSetAside`: recent Unmatched rows that may be waiting for an invoice, rows with cash recorded),
309
- * and `SetAsideExternalPayments` applies the same guard again to what the database holds.
310
- */
311
- async SetAsideChecked() {
312
- const reason = this.SetAsideReason.trim();
313
- const rows = this.ShownExceptions.filter((r) => this.CheckedIDs.includes(r.ID));
314
- if (this.Busy || !rows.length || !reason)
315
- return;
316
- const plan = PlanSetAside(rows, { PaidBefore: this.PaidBefore });
317
- if (!plan.Eligible.length) {
318
- this.Notice = { Tone: 'warning', Text: `Nothing was set aside. ${plan.Excluded.map((x) => `${x.Row.ExternalPaymentRef}: ${x.Why}`).join(' ')}` };
319
- this.cdr.detectChanges();
320
- return;
321
- }
322
- const total = plan.Eligible.reduce((s, r) => s + Number(r.Amount), 0);
323
- const unmatched = plan.Eligible.filter((r) => r.Disposition === 'Unmatched').length;
324
- const proceed = await this.confirm.Confirm({
325
- title: `Set aside ${plan.Eligible.length} payment${plan.Eligible.length === 1 ? '' : 's'}?`,
326
- message: `${FormatMoney(total)} will stop showing here and will never be recorded as cash, even if the invoice is loaded later.`,
327
- detail: [
328
- unmatched ? `${unmatched} of them ${unmatched === 1 ? 'is' : 'are'} Unmatched: check none is waiting for an invoice still to be loaded.` : '',
329
- plan.Excluded.length ? `${plan.Excluded.length} checked row${plan.Excluded.length === 1 ? ' is' : 's are'} left out: recent Unmatched payments, or ones with cash recorded.` : '',
330
- `Reason: ${reason}`,
331
- ]
332
- .filter(Boolean)
333
- .join(' '),
334
- type: 'warning',
335
- confirmText: 'Set aside',
336
- cancelText: 'Not yet',
337
- });
338
- if (!proceed)
339
- return;
340
- await this.run(async () => {
341
- const result = await SetAsideExternalPayments({ IDs: plan.Eligible.map((r) => r.ID), Reason: reason, PaidBefore: this.PaidBefore });
342
- this.CheckedIDs = [];
343
- if (!result.Failed.length && !result.Excluded.length)
344
- this.SetAsideReason = '';
345
- this.cdr.detectChanges();
346
- const left = [...result.Excluded, ...result.Failed].map((x) => `${x.ExternalPaymentRef}: ${x.Why}`);
347
- const skipped = plan.Excluded.length ? ` ${plan.Excluded.length} checked row(s) were left out by the bulk guard.` : '';
348
- const text = `${result.SetAside.length} payment(s) set aside.${skipped}${left.length ? ` Not set aside: ${left.join(' ')}` : ''}`;
349
- return { Tone: left.length ? 'warning' : 'success', Text: text };
350
- });
351
- }
352
- /** The sweep, by hand. Never retries a unit a person has to look at — the operation decides that. */
868
+ /** The sweep, by hand. Never retries an invoice a person has to look at — the operation decides that. */
353
869
  async RunSweep() {
354
870
  if (this.Busy)
355
871
  return;
872
+ // The sweep follows the Company filter and nothing else: the due dates, the search and the
873
+ // quick filter change what is listed, not what is sent. The dialog says so when they differ.
874
+ const scope = this.companyScopeText;
875
+ const companyIDs = this.CompanyPicks.slice();
876
+ const waiting = this.UnsentCount;
877
+ const listedUnsent = this.Rows.filter((r) => r.State === 'Unsent').length;
878
+ // What the run does, as the operation does it: at most SWEEP_MAX in one run, and a failed send
879
+ // is tried again when its failure was one that can pass on a retry.
356
880
  const proceed = await this.confirm.Confirm({
357
- title: 'Send every waiting invoice?',
358
- message: `${this.UnsentCount} unit${this.UnsentCount === 1 ? '' : 's'} would go out now.`,
359
- detail: 'Units that failed permanently, or whose last send was never confirmed, are left for a person.',
881
+ title: scope ? `Send the waiting invoices for ${scope}?` : 'Send the waiting invoices?',
882
+ message: `${waiting} invoice${waiting === 1 ? ' is' : 's are'} waiting to send. One run sends up to ${SWEEP_MAX}` +
883
+ (waiting + this.FailedCount > SWEEP_MAX ? `, so it may take another run to send the rest.` : '.') +
884
+ (listedUnsent !== waiting ? ` The due dates, the search and the quick filter change what is listed, not what is sent: only the Company filter limits that.` : ''),
885
+ detail: (this.FailedCount ? 'A failed send is tried again when its error was temporary. ' : '') +
886
+ 'Invoices whose send failed for good, or was never confirmed, are left for review.',
360
887
  type: 'warning',
361
888
  confirmText: 'Send them',
362
889
  cancelText: 'Not yet',
@@ -364,16 +891,69 @@ export class MJOExternalInvoicingQueuePageComponent {
364
891
  if (!proceed)
365
892
  return;
366
893
  await this.run(async () => {
367
- const result = await new OrdersSendExternalInvoicesOperation().Execute({ Preview: false });
894
+ const result = await new OrdersSendExternalInvoicesOperation().Execute({ Preview: false, MaxCount: SWEEP_MAX, ...(companyIDs.length ? { CompanyIDs: companyIDs } : {}) });
368
895
  const out = result.Output;
369
896
  if (!result.Success || !out) {
370
- return { Tone: 'error', Text: result.ErrorMessage?.trim() || 'The sweep could not run.' };
897
+ return { Tone: 'error', Text: result.ErrorMessage?.trim() || 'The invoices could not be sent.' };
371
898
  }
372
- this.SelectedInvoice = null;
373
- this.cdr.detectChanges();
374
899
  return { Tone: out.Success ? 'success' : 'warning', Text: out.Message ?? `${out.Sent} sent.` };
375
900
  });
376
901
  }
902
+ /* ── Setting payments aside ─────────────────────────────────────────── */
903
+ /**
904
+ * Open the set-aside dialog for these payments (bc-aidp-next-golive#449). Setting aside is
905
+ * permanent: a payment set aside is never captured, even once its invoice is loaded. So the dialog
906
+ * shows the plan before anything is written: what will be set aside, and what the bulk guard leaves
907
+ * out and why (`PlanSetAside`: recent Unmatched rows that may be waiting for an invoice, rows with
908
+ * cash recorded). `SetAsideExternalPayments` applies the same guard again to what the database holds.
909
+ */
910
+ OpenSetAside(ids) {
911
+ const wanted = new Set(ids);
912
+ this.SetAsideTargets = this.ShownExceptions.filter((r) => wanted.has(r.ID));
913
+ if (!this.SetAsideTargets.length)
914
+ return;
915
+ // A reason belongs to one act: one typed for an earlier, cancelled attempt must not ride along to other payments.
916
+ this.SetAsideReason = '';
917
+ this.SetAsideBefore = null;
918
+ this.planSetAside();
919
+ this.SetAsideOpen = true;
920
+ }
921
+ OnSetAsideBefore(day) {
922
+ this.SetAsideBefore = day || null;
923
+ this.planSetAside();
924
+ }
925
+ CloseSetAside() {
926
+ this.SetAsideOpen = false;
927
+ }
928
+ /** The payments the dialog names: the first few of those that will be set aside. */
929
+ get setAsideListed() {
930
+ return (this.SetAsidePlan?.Eligible ?? []).slice(0, SET_ASIDE_LISTED);
931
+ }
932
+ get setAsideTotal() {
933
+ return (this.SetAsidePlan?.Eligible ?? []).reduce((s, r) => s + Number(r.Amount), 0);
934
+ }
935
+ async ApplySetAside() {
936
+ const reason = this.SetAsideReason.trim();
937
+ const plan = this.SetAsidePlan;
938
+ if (this.Busy || !plan?.Eligible.length || !reason)
939
+ return;
940
+ const before = this.SetAsideBefore;
941
+ this.SetAsideOpen = false;
942
+ await this.run(async () => {
943
+ const result = await SetAsideExternalPayments({ IDs: plan.Eligible.map((r) => r.ID), Reason: reason, PaidBefore: before });
944
+ this.CheckedIDs = [];
945
+ this.SelectedPayment = null;
946
+ this.cdr.detectChanges();
947
+ const left = [...result.Excluded, ...result.Failed].map((x) => `${x.ExternalPaymentRef}: ${x.Why}`);
948
+ const skipped = plan.Excluded.length ? ` ${plan.Excluded.length} selected payment${plan.Excluded.length === 1 ? ' was' : 's were'} left out.` : '';
949
+ const text = `${result.SetAside.length} payment${result.SetAside.length === 1 ? '' : 's'} set aside.${skipped}${left.length ? ` Not set aside: ${left.join(' ')}` : ''}`;
950
+ return { Tone: left.length ? 'warning' : 'success', Text: text };
951
+ });
952
+ }
953
+ planSetAside() {
954
+ this.SetAsidePlan = PlanSetAside(this.SetAsideTargets, { PaidBefore: this.SetAsideBefore });
955
+ }
956
+ /* ── Checking for payments ──────────────────────────────────────────── */
377
957
  /**
378
958
  * The poll, by hand, following the scheduled jobs: all off → not offered; none live → a preview,
379
959
  * no confirmation since nothing is written; any live (or unreadable) → confirm, because this
@@ -388,8 +968,8 @@ export class MJOExternalInvoicingQueuePageComponent {
388
968
  if (!preview) {
389
969
  const proceed = await this.confirm.Confirm({
390
970
  title: 'Record payments now?',
391
- message: 'This reads the payments the rail reported since the last poll and records each cleared one as cash against its orders.',
392
- detail: 'The scheduled poll would do this on its own at its next run.',
971
+ message: 'This reads the payments reported since the last check and records each cleared one as cash against its orders.',
972
+ detail: 'The scheduled job would do this on its own at its next run.',
393
973
  type: 'warning',
394
974
  confirmText: 'Record payments',
395
975
  cancelText: 'Not yet',
@@ -428,50 +1008,111 @@ export class MJOExternalInvoicingQueuePageComponent {
428
1008
  }
429
1009
  /* ── Loading ────────────────────────────────────────────────────────── */
430
1010
  async load() {
431
- await Promise.all([this.loadInvoices(), this.loadExceptions(), this.loadPollJob()]);
1011
+ const seq = ++this.loadSeq;
1012
+ this.Loading = true;
432
1013
  this.cdr.detectChanges();
1014
+ try {
1015
+ await Promise.all([this.loadInvoices(seq), this.loadExceptions(seq), this.loadPollJob()]);
1016
+ }
1017
+ finally {
1018
+ if (seq === this.loadSeq)
1019
+ this.Loading = false;
1020
+ this.cdr.detectChanges();
1021
+ }
433
1022
  }
434
- async loadInvoices() {
1023
+ async loadInvoices(seq) {
435
1024
  const result = await new OrdersGetExternalInvoicingWorklistOperation().Execute({ IncludeFailed: true });
1025
+ if (seq !== this.loadSeq)
1026
+ return;
436
1027
  const output = result.Output;
437
1028
  if (!result.Success || !output?.Success) {
438
1029
  // An empty queue and a broken one look identical, and "nothing waiting" is the most
439
1030
  // reassuring sentence here — so a failure has to say so.
440
1031
  this.LoadError = output?.Message?.trim() || result.ErrorMessage?.trim() || 'The invoicing worklist could not be loaded.';
441
1032
  this.AllRows = [];
442
- this.Rows = [];
443
- this.Presets = [];
1033
+ this.applyInvoiceView();
444
1034
  this.cdr.detectChanges();
445
1035
  return;
446
1036
  }
447
1037
  this.LoadError = null;
448
1038
  this.AllRows = output.Rows;
449
1039
  this.Truncated = output.Truncated;
450
- this.applyPreset();
451
- if (this.SelectedInvoice) {
452
- this.SelectedInvoice = this.Rows.find((r) => r.DocumentNumber === this.SelectedInvoice.DocumentNumber) ?? null;
453
- }
1040
+ this.applyInvoiceView();
454
1041
  this.cdr.detectChanges();
455
1042
  }
456
- async loadExceptions() {
1043
+ /**
1044
+ * Whose payments these are. The provider names its customer by its own reference; `ExternalCustomer`
1045
+ * says which of our bill-to parties that is, per provider. Context for a column: a failed read, or a
1046
+ * reference with no row, leaves the name blank and the reference still shows.
1047
+ */
1048
+ async loadCustomers(rv, rows) {
1049
+ const names = new Map();
1050
+ try {
1051
+ const providers = [...new Set(rows.map((r) => String(r.PaymentProviderID ?? '')).filter(Boolean))].map((id) => `'${RequireUUID(id, 'PaymentProviderID')}'`);
1052
+ if (providers.length) {
1053
+ const customers = await rv.RunView({
1054
+ EntityName: EXTERNAL_CUSTOMER_ENTITY,
1055
+ ExtraFilter: `PaymentProviderID IN (${providers.join(',')})`,
1056
+ Fields: ['PaymentProviderID', 'ExternalCustomerRef', 'BillToOrganization', 'BillToPerson'],
1057
+ ResultType: 'simple',
1058
+ });
1059
+ for (const c of customers.Results ?? []) {
1060
+ const name = c.BillToOrganization ?? c.BillToPerson;
1061
+ if (name)
1062
+ names.set(`${String(c.PaymentProviderID).toLowerCase()}|${c.ExternalCustomerRef}`, name);
1063
+ }
1064
+ }
1065
+ }
1066
+ catch {
1067
+ // Context only: the provider's own reference still identifies the payer.
1068
+ }
1069
+ return names;
1070
+ }
1071
+ async loadExceptions(seq) {
457
1072
  const rv = new RunView();
458
1073
  const list = EXCEPTION_DISPOSITIONS.map((d) => `'${d}'`).join(',');
459
- const result = await rv.RunView({
460
- EntityName: EXTERNAL_PAYMENT_ENTITY,
461
- ExtraFilter: `Disposition IN (${list})`,
462
- OrderBy: 'LastSeenAt DESC',
463
- ResultType: 'simple',
464
- });
1074
+ const [result, providers] = await Promise.all([
1075
+ rv.RunView({
1076
+ EntityName: EXTERNAL_PAYMENT_ENTITY,
1077
+ ExtraFilter: `Disposition IN (${list})`,
1078
+ OrderBy: 'LastSeenAt DESC',
1079
+ ResultType: 'simple',
1080
+ }),
1081
+ // Which company each provider belongs to. Context for a column: a failure leaves it blank.
1082
+ rv.RunView({ EntityName: PAYMENT_PROVIDER_ENTITY, Fields: ['ID', 'CompanyID', 'Company'], ResultType: 'simple' }).catch(() => null),
1083
+ ]);
1084
+ if (seq !== this.loadSeq)
1085
+ return;
1086
+ const customerNames = await this.loadCustomers(rv, result.Success ? (result.Results ?? []) : []);
1087
+ if (seq !== this.loadSeq)
1088
+ return;
1089
+ this.customerNames = customerNames;
1090
+ this.providerCompany = new Map((providers?.Results ?? []).filter((p) => p.CompanyID).map((p) => [String(p.ID).toLowerCase(), { ID: String(p.CompanyID).toLowerCase(), Name: String(p.Company ?? '') }]));
465
1091
  this.Exceptions = result.Success ? (result.Results ?? []) : [];
466
1092
  this.applyExceptionFilter();
467
1093
  this.cdr.detectChanges();
468
1094
  }
469
- /** Narrow to the "paid before" day, and drop checked rows that are no longer shown. */
1095
+ /** Narrow to the chosen companies and the search, sort, and let go of ticked or open rows that are no longer shown. */
470
1096
  applyExceptionFilter() {
471
- const cut = this.PaidBefore;
472
- this.ShownExceptions = cut ? this.Exceptions.filter((r) => IsBefore(r.PaymentDate, cut)) : this.Exceptions;
1097
+ const company = { ID: (r) => this.providerOf(r)?.ID, Name: (r) => this.providerOf(r)?.Name };
1098
+ // The same choice as Invoices to send, counted here by payments. A payment whose provider's
1099
+ // company could not be read belongs to no company, so it is only listed when none is chosen.
1100
+ const companies = ReconcileCompanies(this.Exceptions, company, this.companyChoice);
1101
+ this.PaymentCompanies = companies.Options;
1102
+ this.PaymentCompanyPicks = companies.Picks;
1103
+ const matched = FilterByCompanies(this.Exceptions, this.PaymentCompanyPicks, company.ID).filter((r) => MatchesText([r.ExternalPaymentRef, r.ExternalCustomerRef, this.customerOf(r), r.PaymentProvider, r.DispositionReason, DispositionLabel(r.Disposition), r.ExternalStatus], this.PaymentSearch));
1104
+ this.ShownExceptions = SortRows(matched, this.PaymentColumns, this.PaymentSort);
1105
+ this.PaymentTotals = {
1106
+ ExternalPaymentRef: 'Total',
1107
+ PaymentProvider: `${this.ShownExceptions.length} payment${this.ShownExceptions.length === 1 ? '' : 's'}`,
1108
+ Amount: FormatMoney(this.ShownExceptions.reduce((s, r) => s + Number(r.Amount), 0)),
1109
+ };
473
1110
  const shown = new Set(this.ShownExceptions.map((r) => r.ID));
474
1111
  this.CheckedIDs = this.CheckedIDs.filter((id) => shown.has(id));
1112
+ if (this.SelectedPayment) {
1113
+ const key = this.SelectedPayment.ID;
1114
+ this.SelectedPayment = this.ShownExceptions.find((r) => r.ID === key) ?? null;
1115
+ }
475
1116
  }
476
1117
  async loadPollJob() {
477
1118
  try {
@@ -479,7 +1120,7 @@ export class MJOExternalInvoicingQueuePageComponent {
479
1120
  const rank = { NotInstalled: 0, Inactive: 1, Preview: 2, Live: 3 };
480
1121
  this.PollJob = groups.length
481
1122
  ? groups.reduce((best, g) => (rank[g.State] > rank[best.State] ? g : best))
482
- : { State: 'NotInstalled', Why: 'no scheduled poll job is installed' };
1123
+ : { State: 'NotInstalled', Why: 'no scheduled payment job is installed' };
483
1124
  this.PollJobsMixed = new Set(groups.map((g) => g.State)).size > 1;
484
1125
  }
485
1126
  catch {
@@ -489,105 +1130,291 @@ export class MJOExternalInvoicingQueuePageComponent {
489
1130
  }
490
1131
  this.cdr.detectChanges();
491
1132
  }
492
- applyPreset() {
493
- this.Presets = [
494
- { Key: 'all', Label: 'Everything waiting', Count: this.AllRows.length },
495
- { Key: 'unsent', Label: 'Never sent', Count: this.UnsentCount },
496
- { Key: 'failed', Label: 'Failed', Count: this.FailedCount, Icon: 'fa-solid fa-triangle-exclamation' },
497
- ];
498
- this.Rows =
499
- this.Preset === 'unsent'
500
- ? this.AllRows.filter((r) => r.State === 'Unsent')
501
- : this.Preset === 'failed'
502
- ? this.AllRows.filter((r) => r.State === 'Failed')
503
- : this.AllRows;
1133
+ /** Take the company choice, the due-date filter and the open tab from the tab's address; see the Billing worklist for the rule. */
1134
+ adoptAddress() {
1135
+ const picks = AdoptCompanyChoice(this.companyKey, this.address, globalThis.localStorage);
1136
+ if (!SameChoice(picks, this.companyChoice))
1137
+ this.companyChoice = picks;
1138
+ const window = AdoptWindow(this.dueKey, this.address, QUEUE_WINDOWS, this.Window, DEFAULT_WINDOW);
1139
+ if (!SameWindow(window, this.Window)) {
1140
+ this.Window = window;
1141
+ // Saved as well, so the next visit opens on what the address last said, as it does for the company.
1142
+ WriteWorklistState(globalThis.localStorage, QUEUE_STATE_KEY, { Window: this.Window, Sort: this.InvoiceSort });
1143
+ }
1144
+ // The tab follows the address once the address has named one; before that it stays where it is.
1145
+ const tab = this.tabKey.Read(this.address);
1146
+ if (tab !== null)
1147
+ this.Tab = tab === 'payments' ? 'payments' : 'invoices';
1148
+ }
1149
+ /**
1150
+ * Rebuild the Invoices to send list from what was loaded. The Company filter sets the scope the
1151
+ * tiles count and the sweep sends; the due dates, the search and the quick filter then narrow what
1152
+ * is listed. An open invoice the filters hide is closed, so "Send this invoice" never acts on a row
1153
+ * that is not on screen.
1154
+ */
1155
+ applyInvoiceView() {
1156
+ const companies = ReconcileCompanies(this.AllRows, { ID: (r) => r.CompanyID, Name: (r) => r.CompanyName }, this.companyChoice);
1157
+ this.Companies = companies.Options;
1158
+ this.CompanyPicks = companies.Picks;
1159
+ this.InScope = FilterByCompanies(this.AllRows, this.CompanyPicks, (r) => r.CompanyID);
1160
+ const range = ResolveWindow(this.Window, QUEUE_WINDOWS, Today());
1161
+ const listed = IsOpenRange(range) && !this.Search.trim()
1162
+ ? this.InScope
1163
+ : this.InScope.filter((r) => InDayRange(r.DueDate, range) && MatchesText([r.CustomerName, r.DocumentNumber, r.OrderNumber], this.Search));
1164
+ const shown = this.Preset === 'unsent' ? listed.filter((r) => r.State === 'Unsent') : this.Preset === 'failed' ? listed.filter((r) => r.State === 'Failed') : listed;
1165
+ this.Rows = SortRows(shown, this.InvoiceColumns, this.InvoiceSort);
1166
+ this.InvoiceTotals = {
1167
+ DocumentNumber: 'Total',
1168
+ CustomerName: `${this.Rows.length} invoice${this.Rows.length === 1 ? '' : 's'}`,
1169
+ Amount: FormatMoney(this.Rows.reduce((s, r) => s + r.Amount, 0)),
1170
+ };
1171
+ if (this.SelectedInvoice) {
1172
+ const key = this.SelectedInvoice.DocumentNumber;
1173
+ this.SelectedInvoice = this.Rows.find((r) => r.DocumentNumber === key) ?? null;
1174
+ }
1175
+ }
1176
+ saveView() {
1177
+ WriteWorklistState(globalThis.localStorage, QUEUE_STATE_KEY, { Window: this.Window, Sort: this.InvoiceSort });
1178
+ this.AddressChanged.emit(this.dueKey.Write(SameWindow(this.Window, DEFAULT_WINDOW) ? null : WindowToAddress(this.Window)));
1179
+ }
1180
+ /* ── Display helpers ────────────────────────────────────────────────── */
1181
+ stateChip(row) {
1182
+ return row.State === 'Failed' ? 'mjo-chip--error' : row.State === 'InFlight' ? 'mjo-chip--info' : 'mjo-chip--outline';
1183
+ }
1184
+ dispositionLabel(row) {
1185
+ return DispositionLabel(row.Disposition);
1186
+ }
1187
+ dispositionChip(row) {
1188
+ return DispositionChipClass(row.Disposition);
1189
+ }
1190
+ /** Our customer for a payment, when the provider's reference maps to one. */
1191
+ customerOf(row) {
1192
+ if (!row.ExternalCustomerRef)
1193
+ return null;
1194
+ return this.customerNames.get(`${String(row.PaymentProviderID ?? '').toLowerCase()}|${row.ExternalCustomerRef}`) ?? null;
1195
+ }
1196
+ /** The company a payment's provider belongs to, when it could be read. */
1197
+ companyOf(row) {
1198
+ return this.providerOf(row)?.Name || null;
1199
+ }
1200
+ providerOf(row) {
1201
+ return this.providerCompany.get(String(row.PaymentProviderID ?? '').toLowerCase());
1202
+ }
1203
+ providerText(row) {
1204
+ const company = this.companyOf(row);
1205
+ return [row.PaymentProvider, company].filter(Boolean).join(' · ') || '—';
1206
+ }
1207
+ /** Every date on the page reads MM/DD/YYYY, as on Customer A/R. A cell may carry a time; only its day is shown. */
1208
+ date(value) {
1209
+ const day = ToISODate(value);
1210
+ return day ? FormatDate(day, { Numeric: true }) : '—';
1211
+ }
1212
+ /** A moment (when something was sent or seen), as its day on the business calendar. */
1213
+ instant(value) {
1214
+ const day = InvoicedDay(value);
1215
+ return day ? FormatDate(day, { Numeric: true }) : '—';
504
1216
  }
505
1217
  static ɵfac = function MJOExternalInvoicingQueuePageComponent_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || MJOExternalInvoicingQueuePageComponent)(); };
506
- static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: MJOExternalInvoicingQueuePageComponent, selectors: [["mjo-external-invoicing-queue-page"]], outputs: { OrderOpened: "OrderOpened" }, decls: 24, vars: 23, consts: [[1, "mj-stat-grid", "mjo-xq__tiles"], ["Label", "Waiting to send", "Icon", "fa-solid fa-paper-plane", 3, "Tone", "Value", "Detail"], ["Label", "Sends that failed", "Icon", "fa-solid fa-triangle-exclamation", "Detail", "A person has to look at these", 3, "Tone", "Value"], ["Label", "Payments needing attention", "Icon", "fa-solid fa-hand-holding-dollar", 3, "Tone", "Value", "Detail"], ["Variant", "error", "Icon", "fa-solid fa-triangle-exclamation", 1, "mjo-xq__note"], ["Icon", "fa-solid fa-circle-info", 1, "mjo-xq__note", 3, "Variant"], ["Variant", "warning", "Icon", "fa-solid fa-triangle-exclamation", 1, "mjo-xq__note"], ["role", "tablist", 1, "mjo-xq__tabs"], ["type", "button", "role", "tab", 3, "click"], [1, "mjo-xq__count"], ["data-testid", "poll-payments-bar", 1, "row", "mjo-xq__actions", "mjo-xq__poll-bar"], ["type", "button", "mjButton", "", "variant", "outline", 3, "click", "disabled"], ["aria-hidden", "true", 1, "fa-solid", "fa-rotate"], [1, "small", "muted"], [1, "row", "mjo-xq__actions"], ["aria-hidden", "true", 1, "fa-solid", "fa-arrow-up-right-from-square"], ["type", "button", "mjButton", "", "variant", "primary", 3, "click", "disabled"], ["aria-hidden", "true", 1, "fa-solid", "fa-paper-plane"], ["RowKey", "DocumentNumber", "EmptyTitle", "Nothing waiting", "EmptyHint", "Every confirmed order on a rail has been invoiced.", "EmptyIcon", "fa-solid fa-paper-plane", 3, "PresetChanged", "RowClicked", "Columns", "Rows", "Presets", "ActivePreset", "Searchable", "SelectedKey"], [1, "row", "wrap", "mjo-xq__actions"], [1, "mjo-xq__field"], ["type", "date", "aria-label", "Show payments dated before this day", 3, "change", "value"], [1, "mjo-xq__field", "mjo-xq__field--grow"], ["type", "text", "maxlength", "400", "placeholder", "e.g. Pre-go-live payment against AR not converted", 3, "input", "value"], ["aria-hidden", "true", 1, "fa-solid", "fa-box-archive"], ["RowKey", "ID", "EmptyTitle", "Nothing needs attention", "EmptyHint", "Every payment the rail reported has been recorded or set aside.", "EmptyIcon", "fa-solid fa-hand-holding-dollar", 3, "SelectionChanged", "Columns", "Rows", "Presets", "Searchable", "Selectable", "SelectedKeys", "FootNote"]], template: function MJOExternalInvoicingQueuePageComponent_Template(rf, ctx) { if (rf & 1) {
507
- i0.ɵɵelementStart(0, "div", 0);
508
- i0.ɵɵelement(1, "mjo-stat-tile", 1)(2, "mjo-stat-tile", 2)(3, "mjo-stat-tile", 3);
1218
+ static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: MJOExternalInvoicingQueuePageComponent, selectors: [["mjo-external-invoicing-queue-page"]], outputs: { OrderOpened: "OrderOpened", AddressChanged: "AddressChanged" }, decls: 34, vars: 38, consts: [["SearchPlaceholder", "Search customer, document or order number", 3, "Companies", "CompanyPicks", "Search", "ActiveFilter", "Summary", "Loading", "BuildExport", "CanExport"], ["SearchPlaceholder", "Search payment reference, customer or what happened", 3, "Companies", "CompanyPicks", "Search", "Summary", "Loading", "BuildExport", "CanExport"], [1, "mj-stat-grid", "mjo-xq__tiles"], ["Hint", "Show invoices not yet sent", "Label", "Waiting to send", "Icon", "fa-solid fa-paper-plane", 1, "mjo-xq__tile", 3, "Clicked", "Pressed", "Tone", "Value", "Detail"], ["Hint", "Show invoices whose send failed", "Label", "Sends that failed", "Icon", "fa-solid fa-triangle-exclamation", 1, "mjo-xq__tile", 3, "Clicked", "Pressed", "Tone", "Value", "Detail"], ["Hint", "Open Payment exceptions", "Label", "Payments needing attention", "Icon", "fa-solid fa-hand-holding-dollar", 1, "mjo-xq__tile", 3, "Clicked", "Pressed", "Tone", "Value", "Detail"], ["Variant", "error", "Icon", "fa-solid fa-triangle-exclamation", 1, "mjo-xq__note"], ["Icon", "fa-solid fa-circle-info", 1, "mjo-xq__note", 3, "Variant"], ["Variant", "warning", "Icon", "fa-solid fa-triangle-exclamation", 1, "mjo-xq__note"], ["role", "tablist", 1, "mjo-xq__tabs"], ["type", "button", "role", "tab", 3, "click"], [1, "mjo-xq__count"], [1, "mjo-split"], ["Size", "md", 3, "Close", "Visible", "Title"], [1, "mjo-xq__dialog-lede"], [1, "mjo-xq__field"], [1, "small", "muted"], ["type", "text", "maxlength", "400", "placeholder", "For example: paid before go-live, invoice not converted", "aria-label", "Reason for setting aside", 1, "mjo-xq__select", 3, "input", "value"], ["role", "status", 1, "mjo-xq__plan"], ["type", "button", "mjButton", "", "variant", "outline", 3, "click"], ["type", "button", "mjButton", "", "variant", "primary", 3, "click", "disabled"], ["SearchPlaceholder", "Search customer, document or order number", 3, "CompanyPicksChange", "SearchChange", "ActiveFilterCleared", "RefreshRequested", "Companies", "CompanyPicks", "Search", "ActiveFilter", "Summary", "Loading", "BuildExport", "CanExport"], [1, "mjo-xq__window"], ["aria-label", "Which due dates to list", 1, "mjo-xq__select", 3, "change", "value"], [3, "value", "selected"], ["type", "date", "aria-label", "Earliest due date", 1, "mjo-xq__select", 3, "change", "value"], ["type", "date", "aria-label", "Latest due date", 1, "mjo-xq__select", 3, "change", "value"], ["SearchPlaceholder", "Search payment reference, customer or what happened", 3, "CompanyPicksChange", "SearchChange", "RefreshRequested", "Companies", "CompanyPicks", "Search", "Summary", "Loading", "BuildExport", "CanExport"], [1, "mjo-split__main"], [1, "row", "mjo-xq__actions"], ["type", "button", "mjButton", "", "variant", "primary", "title", "Send the invoices that are waiting, for the companies chosen", 3, "click", "disabled"], ["aria-hidden", "true", 1, "fa-solid", "fa-paper-plane"], ["MaxHeight", "calc(100vh - 380px)", "RowKey", "DocumentNumber", "EmptyIcon", "fa-solid fa-paper-plane", 3, "SortChanged", "LinkClicked", "RowClicked", "Columns", "Rows", "Searchable", "Loading", "Totals", "SortKey", "SortDescending", "SelectedKey", "EmptyTitle", "EmptyHint"], [1, "mjo-split__side"], ["Icon", "fa-solid fa-paper-plane", 3, "Closed", "Title", "Chip", "ChipClass"], [1, "mjo-side-panel__amount"], [1, "mjo-side-panel__facts"], ["type", "button", "title", "Open the order", 1, "mjo-side-panel__link", 3, "click"], [1, "mjo-side-panel__actions"], ["aria-hidden", "true", 1, "fa-solid", "fa-arrow-up-right-from-square"], ["data-testid", "poll-payments-bar", 1, "row", "wrap", "mjo-xq__actions"], ["type", "button", "mjButton", "", "variant", "primary", "title", "Set the ticked payments aside", 3, "click", "disabled"], ["aria-hidden", "true", 1, "fa-solid", "fa-box-archive"], ["type", "button", "mjButton", "", "variant", "outline", 3, "click", "disabled"], ["aria-hidden", "true", 1, "fa-solid", "fa-rotate"], ["MaxHeight", "calc(100vh - 380px)", "RowKey", "ID", "EmptyIcon", "fa-solid fa-hand-holding-dollar", 3, "SelectionChanged", "SortChanged", "RowClicked", "Columns", "Rows", "Searchable", "Loading", "Totals", "SortKey", "SortDescending", "SelectedKey", "Selectable", "SelectedKeys", "RowLabel", "EmptyTitle", "EmptyHint"], ["Icon", "fa-solid fa-hand-holding-dollar", 3, "Closed", "Title", "Chip", "ChipClass"], ["type", "date", "aria-label", "Include unmatched payments dated before this day", 1, "mjo-xq__select", "mjo-xq__day", 3, "change", "value"], [1, "mjo-xq__left-out", "small"], [1, "mjo-xq__plan-rows", "small"], [1, "mono"], [1, "mjo-xq__plan-amount"]], template: function MJOExternalInvoicingQueuePageComponent_Template(rf, ctx) { if (rf & 1) {
1219
+ i0.ɵɵconditionalCreate(0, MJOExternalInvoicingQueuePageComponent_Conditional_0_Template, 8, 10, "mjo-worklist-bar", 0)(1, MJOExternalInvoicingQueuePageComponent_Conditional_1_Template, 1, 7, "mjo-worklist-bar", 1);
1220
+ i0.ɵɵelementStart(2, "div", 2)(3, "mjo-stat-tile", 3);
1221
+ i0.ɵɵlistener("Clicked", function MJOExternalInvoicingQueuePageComponent_Template_mjo_stat_tile_Clicked_3_listener() { return ctx.OnTile("unsent"); });
1222
+ i0.ɵɵelementEnd();
1223
+ i0.ɵɵelementStart(4, "mjo-stat-tile", 4);
1224
+ i0.ɵɵlistener("Clicked", function MJOExternalInvoicingQueuePageComponent_Template_mjo_stat_tile_Clicked_4_listener() { return ctx.OnTile("failed"); });
509
1225
  i0.ɵɵelementEnd();
510
- i0.ɵɵconditionalCreate(4, MJOExternalInvoicingQueuePageComponent_Conditional_4_Template, 4, 1, "mj-alert", 4);
511
- i0.ɵɵconditionalCreate(5, MJOExternalInvoicingQueuePageComponent_Conditional_5_Template, 2, 2, "mj-alert", 5);
512
- i0.ɵɵconditionalCreate(6, MJOExternalInvoicingQueuePageComponent_Conditional_6_Template, 4, 0, "mj-alert", 6);
513
- i0.ɵɵelementStart(7, "div", 7)(8, "button", 8);
514
- i0.ɵɵlistener("click", function MJOExternalInvoicingQueuePageComponent_Template_button_click_8_listener() { return ctx.Tab = "invoices"; });
515
- i0.ɵɵtext(9, " Invoices out ");
516
- i0.ɵɵelementStart(10, "span", 9);
517
- i0.ɵɵtext(11);
1226
+ i0.ɵɵelementStart(5, "mjo-stat-tile", 5);
1227
+ i0.ɵɵlistener("Clicked", function MJOExternalInvoicingQueuePageComponent_Template_mjo_stat_tile_Clicked_5_listener() { return ctx.OnTab("payments"); });
518
1228
  i0.ɵɵelementEnd()();
519
- i0.ɵɵelementStart(12, "button", 8);
520
- i0.ɵɵlistener("click", function MJOExternalInvoicingQueuePageComponent_Template_button_click_12_listener() { return ctx.Tab = "payments"; });
521
- i0.ɵɵtext(13, " Payment exceptions ");
522
- i0.ɵɵelementStart(14, "span", 9);
523
- i0.ɵɵtext(15);
1229
+ i0.ɵɵconditionalCreate(6, MJOExternalInvoicingQueuePageComponent_Conditional_6_Template, 4, 1, "mj-alert", 6);
1230
+ i0.ɵɵconditionalCreate(7, MJOExternalInvoicingQueuePageComponent_Conditional_7_Template, 2, 2, "mj-alert", 7);
1231
+ i0.ɵɵconditionalCreate(8, MJOExternalInvoicingQueuePageComponent_Conditional_8_Template, 4, 0, "mj-alert", 8);
1232
+ i0.ɵɵelementStart(9, "div", 9)(10, "button", 10);
1233
+ i0.ɵɵlistener("click", function MJOExternalInvoicingQueuePageComponent_Template_button_click_10_listener() { return ctx.OnTab("invoices"); });
1234
+ i0.ɵɵtext(11, " Invoices to send ");
1235
+ i0.ɵɵelementStart(12, "span", 11);
1236
+ i0.ɵɵtext(13);
1237
+ i0.ɵɵelementEnd()();
1238
+ i0.ɵɵelementStart(14, "button", 10);
1239
+ i0.ɵɵlistener("click", function MJOExternalInvoicingQueuePageComponent_Template_button_click_14_listener() { return ctx.OnTab("payments"); });
1240
+ i0.ɵɵtext(15, " Payment exceptions ");
1241
+ i0.ɵɵelementStart(16, "span", 11);
1242
+ i0.ɵɵtext(17);
524
1243
  i0.ɵɵelementEnd()()();
525
- i0.ɵɵelementStart(16, "div", 10)(17, "button", 11);
526
- i0.ɵɵlistener("click", function MJOExternalInvoicingQueuePageComponent_Template_button_click_17_listener() { return ctx.RunPoll(); });
527
- i0.ɵɵelement(18, "i", 12);
528
- i0.ɵɵtext(19);
1244
+ i0.ɵɵconditionalCreate(18, MJOExternalInvoicingQueuePageComponent_Conditional_18_Template, 10, 13, "div", 12)(19, MJOExternalInvoicingQueuePageComponent_Conditional_19_Template, 13, 19, "div", 12);
1245
+ i0.ɵɵelementStart(20, "mj-dialog", 13);
1246
+ i0.ɵɵlistener("Close", function MJOExternalInvoicingQueuePageComponent_Template_mj_dialog_Close_20_listener() { return ctx.CloseSetAside(); });
1247
+ i0.ɵɵelementStart(21, "p", 14);
1248
+ i0.ɵɵtext(22, " A payment set aside leaves this list and is never recorded as cash, even if its invoice is loaded later. This cannot be undone here. ");
1249
+ i0.ɵɵelementEnd();
1250
+ i0.ɵɵelementStart(23, "label", 15)(24, "span", 16);
1251
+ i0.ɵɵtext(25, "Reason");
529
1252
  i0.ɵɵelementEnd();
530
- i0.ɵɵelementStart(20, "span", 13);
531
- i0.ɵɵtext(21);
1253
+ i0.ɵɵelementStart(26, "input", 17);
1254
+ i0.ɵɵlistener("input", function MJOExternalInvoicingQueuePageComponent_Template_input_input_26_listener($event) { return ctx.SetAsideReason = $event.target.value; });
532
1255
  i0.ɵɵelementEnd()();
533
- i0.ɵɵconditionalCreate(22, MJOExternalInvoicingQueuePageComponent_Conditional_22_Template, 12, 11)(23, MJOExternalInvoicingQueuePageComponent_Conditional_23_Template, 13, 12);
1256
+ i0.ɵɵconditionalCreate(27, MJOExternalInvoicingQueuePageComponent_Conditional_27_Template, 6, 1, "label", 15);
1257
+ i0.ɵɵconditionalCreate(28, MJOExternalInvoicingQueuePageComponent_Conditional_28_Template, 5, 5, "div", 18);
1258
+ i0.ɵɵelementStart(29, "mj-dialog-actions")(30, "button", 19);
1259
+ i0.ɵɵlistener("click", function MJOExternalInvoicingQueuePageComponent_Template_button_click_30_listener() { return ctx.CloseSetAside(); });
1260
+ i0.ɵɵtext(31, "Cancel");
1261
+ i0.ɵɵelementEnd();
1262
+ i0.ɵɵelementStart(32, "button", 20);
1263
+ i0.ɵɵlistener("click", function MJOExternalInvoicingQueuePageComponent_Template_button_click_32_listener() { return ctx.ApplySetAside(); });
1264
+ i0.ɵɵtext(33);
1265
+ i0.ɵɵelementEnd()()();
534
1266
  } if (rf & 2) {
1267
+ let tmp_30_0;
1268
+ i0.ɵɵconditional(ctx.Tab === "invoices" ? 0 : 1);
1269
+ i0.ɵɵadvance(3);
1270
+ i0.ɵɵclassProp("is-on", ctx.Tab === "invoices" && ctx.Preset === "unsent");
1271
+ i0.ɵɵproperty("Pressed", ctx.Tab === "invoices" && ctx.Preset === "unsent")("Tone", ctx.UnsentCount ? "alert" : "default")("Value", ctx.String(ctx.UnsentCount))("Detail", ctx.UnsentDetail);
535
1272
  i0.ɵɵadvance();
536
- i0.ɵɵproperty("Tone", ctx.UnsentCount ? "alert" : "default")("Value", ctx.String(ctx.UnsentCount))("Detail", ctx.UnsentDetail);
537
- i0.ɵɵadvance();
538
- i0.ɵɵproperty("Tone", ctx.FailedCount ? "alert" : "default")("Value", ctx.String(ctx.FailedCount));
1273
+ i0.ɵɵclassProp("is-on", ctx.Tab === "invoices" && ctx.Preset === "failed");
1274
+ i0.ɵɵproperty("Pressed", ctx.Tab === "invoices" && ctx.Preset === "failed")("Tone", ctx.FailedCount ? "alert" : "default")("Value", ctx.String(ctx.FailedCount))("Detail", ctx.FailedCount ? "Review each before resending" : "No failed sends");
539
1275
  i0.ɵɵadvance();
540
- i0.ɵɵproperty("Tone", ctx.Exceptions.length ? "alert" : "default")("Value", ctx.String(ctx.Exceptions.length))("Detail", ctx.ExceptionDetail);
1276
+ i0.ɵɵclassProp("is-on", ctx.Tab === "payments");
1277
+ i0.ɵɵproperty("Pressed", ctx.Tab === "payments")("Tone", ctx.Exceptions.length ? "alert" : "default")("Value", ctx.String(ctx.Exceptions.length))("Detail", ctx.ExceptionDetail);
541
1278
  i0.ɵɵadvance();
542
- i0.ɵɵconditional(ctx.LoadError ? 4 : -1);
1279
+ i0.ɵɵconditional(ctx.LoadError ? 6 : -1);
543
1280
  i0.ɵɵadvance();
544
- i0.ɵɵconditional(ctx.Notice ? 5 : -1);
1281
+ i0.ɵɵconditional(ctx.Notice ? 7 : -1);
545
1282
  i0.ɵɵadvance();
546
- i0.ɵɵconditional(ctx.Truncated ? 6 : -1);
1283
+ i0.ɵɵconditional(ctx.Truncated ? 8 : -1);
547
1284
  i0.ɵɵadvance(2);
548
1285
  i0.ɵɵclassProp("is-active", ctx.Tab === "invoices");
549
1286
  i0.ɵɵattribute("aria-selected", ctx.Tab === "invoices");
550
1287
  i0.ɵɵadvance(3);
551
- i0.ɵɵtextInterpolate(ctx.Rows.length);
1288
+ i0.ɵɵtextInterpolate(ctx.InScope.length);
552
1289
  i0.ɵɵadvance();
553
1290
  i0.ɵɵclassProp("is-active", ctx.Tab === "payments");
554
1291
  i0.ɵɵattribute("aria-selected", ctx.Tab === "payments");
555
1292
  i0.ɵɵadvance(3);
556
1293
  i0.ɵɵtextInterpolate(ctx.Exceptions.length);
1294
+ i0.ɵɵadvance();
1295
+ i0.ɵɵconditional(ctx.Tab === "invoices" ? 18 : 19);
557
1296
  i0.ɵɵadvance(2);
558
- i0.ɵɵproperty("disabled", ctx.Busy || ctx.PollBlocked);
559
- i0.ɵɵadvance(2);
560
- i0.ɵɵtextInterpolate1(" ", ctx.Busy ? "Working\u2026" : (ctx.PollJob == null ? null : ctx.PollJob.State) === "Preview" ? "Preview payment check" : "Check for payments now", " ");
561
- i0.ɵɵadvance(2);
562
- i0.ɵɵtextInterpolate(ctx.PollHint);
1297
+ i0.ɵɵproperty("Visible", ctx.SetAsideOpen)("Title", ctx.SetAsideTargets.length === 1 ? "Set aside this payment" : "Set aside " + ctx.SetAsideTargets.length + " payments");
1298
+ i0.ɵɵadvance(6);
1299
+ i0.ɵɵproperty("value", ctx.SetAsideReason);
1300
+ i0.ɵɵadvance();
1301
+ i0.ɵɵconditional(ctx.SetAsideTargets.length > 1 ? 27 : -1);
563
1302
  i0.ɵɵadvance();
564
- i0.ɵɵconditional(ctx.Tab === "invoices" ? 22 : 23);
565
- } }, dependencies: [CommonModule, MJButtonDirective, MJAlertComponent, MJOStatTileComponent, MJOWorklistTableComponent], styles: ["[_nghost-%COMP%] {\n display: block;\n height: 100%;\n overflow: auto;\n padding: var(--mj-space-6);\n }\n .mjo-xq__tiles[_ngcontent-%COMP%] { margin-bottom: var(--mj-space-4); }\n .mjo-xq__note[_ngcontent-%COMP%] { margin-bottom: var(--mj-space-4); }\n .mjo-xq__actions[_ngcontent-%COMP%] {\n align-items: center;\n gap: var(--mj-space-3);\n margin-bottom: var(--mj-space-4);\n }\n .mjo-xq__field[_ngcontent-%COMP%] {\n display: flex;\n flex-direction: column;\n gap: var(--mj-space-1);\n }\n .mjo-xq__field--grow[_ngcontent-%COMP%] {\n flex: 1 1 260px;\n }\n .mjo-xq__tabs[_ngcontent-%COMP%] {\n display: flex;\n gap: var(--mj-space-2);\n border-bottom: 1px solid var(--mj-border-default);\n margin-bottom: var(--mj-space-4);\n }\n .mjo-xq__tabs[_ngcontent-%COMP%] button[_ngcontent-%COMP%] {\n appearance: none;\n background: none;\n border: none;\n border-bottom: 2px solid transparent;\n padding: var(--mj-space-3) var(--mj-space-4);\n cursor: pointer;\n font: inherit;\n color: var(--mj-text-muted);\n }\n .mjo-xq__tabs[_ngcontent-%COMP%] button.is-active[_ngcontent-%COMP%] {\n color: var(--mj-text-primary);\n border-bottom-color: var(--mj-brand-primary);\n font-weight: 600;\n }\n .mjo-xq__count[_ngcontent-%COMP%] {\n display: inline-block;\n margin-left: var(--mj-space-2);\n padding: 0 var(--mj-space-2);\n border-radius: 999px;\n background: var(--mj-bg-surface-card);\n font-size: 0.8em;\n }\n @media (max-width: 760px) {\n [_nghost-%COMP%] { padding: var(--mj-space-4); }\n }"] });
1303
+ i0.ɵɵconditional((tmp_30_0 = ctx.SetAsidePlan) ? 28 : -1, tmp_30_0);
1304
+ i0.ɵɵadvance(4);
1305
+ i0.ɵɵproperty("disabled", ctx.Busy || !ctx.SetAsideReason.trim() || !(ctx.SetAsidePlan == null ? null : ctx.SetAsidePlan.Eligible == null ? null : ctx.SetAsidePlan.Eligible.length));
1306
+ i0.ɵɵadvance();
1307
+ i0.ɵɵtextInterpolate1(" ", ctx.Busy ? "Working\u2026" : "Set aside" + ((ctx.SetAsidePlan == null ? null : ctx.SetAsidePlan.Eligible == null ? null : ctx.SetAsidePlan.Eligible.length) ? " " + ctx.SetAsidePlan.Eligible.length : ""), " ");
1308
+ } }, dependencies: [CommonModule,
1309
+ MJButtonDirective,
1310
+ MJAlertComponent,
1311
+ MJDialogComponent,
1312
+ MJDialogActionsComponent,
1313
+ MJOSidePanelComponent,
1314
+ MJOStatTileComponent,
1315
+ MJOWorklistBarComponent,
1316
+ MJOWorklistTableComponent], styles: ["[_nghost-%COMP%] {\n display: block;\n height: 100%;\n overflow: auto;\n padding: var(--mj-space-6);\n }\n .mjo-xq__tiles[_ngcontent-%COMP%] { margin-bottom: var(--mj-space-4); }\n .mjo-xq__tile[_ngcontent-%COMP%] { display: block; border-radius: var(--mj-radius-md); transition: box-shadow 140ms ease; }\n .mjo-xq__tile.is-on[_ngcontent-%COMP%] { box-shadow: 0 0 0 2px color-mix(in srgb, var(--mj-brand-primary) 55%, transparent); }\n .mjo-xq__note[_ngcontent-%COMP%] { display: block; margin-bottom: var(--mj-space-4); }\n .mjo-xq__actions[_ngcontent-%COMP%] {\n align-items: center;\n gap: var(--mj-space-3);\n margin-bottom: var(--mj-space-3);\n }\n .mjo-xq__field[_ngcontent-%COMP%] {\n display: flex;\n flex-direction: column;\n gap: var(--mj-space-1);\n margin-bottom: var(--mj-space-4);\n }\n .mjo-xq__day[_ngcontent-%COMP%] { width: 180px; }\n .mjo-xq__dialog-lede[_ngcontent-%COMP%] { margin: 0 0 var(--mj-space-4); }\n .mjo-xq__plan[_ngcontent-%COMP%] {\n padding: var(--mj-space-3);\n background: var(--mj-bg-surface-sunken);\n border-radius: var(--mj-radius-md);\n }\n .mjo-xq__plan-rows[_ngcontent-%COMP%] { width: 100%; margin-top: var(--mj-space-2); border-collapse: collapse; }\n .mjo-xq__plan-rows[_ngcontent-%COMP%] td[_ngcontent-%COMP%] { padding: 2px var(--mj-space-3) 2px 0; }\n .mjo-xq__plan-amount[_ngcontent-%COMP%] { text-align: right; font-variant-numeric: tabular-nums; }\n .mjo-xq__left-out[_ngcontent-%COMP%] { margin: var(--mj-space-2) 0 0; padding-left: var(--mj-space-5); }\n .mjo-xq__left-out[_ngcontent-%COMP%] li[_ngcontent-%COMP%] { margin-bottom: 4px; }\n .mjo-xq__window[_ngcontent-%COMP%] {\n display: inline-flex;\n align-items: center;\n gap: var(--mj-space-2);\n }\n .mjo-xq__select[_ngcontent-%COMP%] {\n font: inherit;\n font-size: 13px;\n padding: 4px 8px;\n border: 1px solid var(--mj-border-default);\n border-radius: var(--mj-radius-md);\n background: var(--mj-bg-surface);\n color: inherit;\n }\n .mjo-xq__tabs[_ngcontent-%COMP%] {\n display: flex;\n gap: var(--mj-space-2);\n border-bottom: 1px solid var(--mj-border-default);\n margin-bottom: var(--mj-space-4);\n }\n .mjo-xq__tabs[_ngcontent-%COMP%] button[_ngcontent-%COMP%] {\n appearance: none;\n background: none;\n border: none;\n border-bottom: 2px solid transparent;\n padding: var(--mj-space-3) var(--mj-space-4);\n cursor: pointer;\n font: inherit;\n color: var(--mj-text-muted);\n }\n .mjo-xq__tabs[_ngcontent-%COMP%] button.is-active[_ngcontent-%COMP%] {\n color: var(--mj-text-primary);\n border-bottom-color: var(--mj-brand-primary);\n font-weight: 600;\n }\n .mjo-xq__count[_ngcontent-%COMP%] {\n display: inline-block;\n margin-left: var(--mj-space-2);\n padding: 0 var(--mj-space-2);\n border-radius: 999px;\n background: var(--mj-bg-surface-card);\n font-size: 0.8em;\n }\n @media (max-width: 760px) {\n [_nghost-%COMP%] { padding: var(--mj-space-4); }\n }\n @media (prefers-reduced-motion: reduce) {\n .mjo-xq__tile[_ngcontent-%COMP%] { transition: none; }\n }"] });
566
1317
  }
567
1318
  (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(MJOExternalInvoicingQueuePageComponent, [{
568
1319
  type: Component,
569
- args: [{ selector: 'mjo-external-invoicing-queue-page', standalone: true, imports: [CommonModule, MJButtonDirective, MJAlertComponent, MJOStatTileComponent, MJOWorklistTableComponent], template: `
1320
+ args: [{ selector: 'mjo-external-invoicing-queue-page', standalone: true, imports: [
1321
+ CommonModule,
1322
+ MJButtonDirective,
1323
+ MJAlertComponent,
1324
+ MJDialogComponent,
1325
+ MJDialogActionsComponent,
1326
+ MJOSidePanelComponent,
1327
+ MJOStatTileComponent,
1328
+ MJOWorklistBarComponent,
1329
+ MJOWorklistTableComponent,
1330
+ ], template: `
1331
+ <!-- The filter row sits at the top, as on every Receivables page. It belongs to the open tab: each tab has its own search and export. -->
1332
+ @if (Tab === 'invoices') {
1333
+ <mjo-worklist-bar
1334
+ [Companies]="Companies"
1335
+ [CompanyPicks]="CompanyPicks"
1336
+ [Search]="Search"
1337
+ SearchPlaceholder="Search customer, document or order number"
1338
+ [ActiveFilter]="Preset === 'all' ? null : PresetLabel"
1339
+ [Summary]="InvoiceSummary"
1340
+ [Loading]="Loading"
1341
+ [BuildExport]="BuildInvoiceExport"
1342
+ [CanExport]="Rows.length > 0"
1343
+ (CompanyPicksChange)="OnCompanies($event)"
1344
+ (SearchChange)="OnSearch($event)"
1345
+ (ActiveFilterCleared)="OnPreset('all')"
1346
+ (RefreshRequested)="Refresh()">
1347
+ <label class="mjo-xq__window">
1348
+ <span class="small muted">Due</span>
1349
+ <select class="mjo-xq__select" [value]="Window.Key" (change)="OnWindow($any($event.target).value)" aria-label="Which due dates to list">
1350
+ @for (option of Windows; track option.Key) {
1351
+ <option [value]="option.Key" [selected]="option.Key === Window.Key">{{ option.Label }}</option>
1352
+ }
1353
+ </select>
1354
+ </label>
1355
+ @if (IsCustomWindow) {
1356
+ <label class="mjo-xq__window">
1357
+ <span class="small muted">From</span>
1358
+ <input class="mjo-xq__select" type="date" [value]="Window.From ?? ''" (change)="OnCustomDay('From', $any($event.target).value)" aria-label="Earliest due date">
1359
+ </label>
1360
+ <label class="mjo-xq__window">
1361
+ <span class="small muted">To</span>
1362
+ <input class="mjo-xq__select" type="date" [value]="Window.To ?? ''" (change)="OnCustomDay('To', $any($event.target).value)" aria-label="Latest due date">
1363
+ </label>
1364
+ }
1365
+ </mjo-worklist-bar>
1366
+ } @else {
1367
+ <mjo-worklist-bar
1368
+ [Companies]="PaymentCompanies"
1369
+ [CompanyPicks]="PaymentCompanyPicks"
1370
+ (CompanyPicksChange)="OnCompanies($event)"
1371
+ [Search]="PaymentSearch"
1372
+ SearchPlaceholder="Search payment reference, customer or what happened"
1373
+ [Summary]="PaymentSummary"
1374
+ [Loading]="Loading"
1375
+ [BuildExport]="BuildPaymentExport"
1376
+ [CanExport]="ShownExceptions.length > 0"
1377
+ (SearchChange)="OnPaymentSearch($event)"
1378
+ (RefreshRequested)="Refresh()" />
1379
+ }
1380
+
1381
+ <!-- The tiles count the chosen companies' invoices, and every payment exception. Each is also a way in: the first two filter Invoices to send, the third opens Payment exceptions. -->
570
1382
  <div class="mj-stat-grid mjo-xq__tiles">
571
1383
  <mjo-stat-tile
1384
+ class="mjo-xq__tile"
1385
+ [class.is-on]="Tab === 'invoices' && Preset === 'unsent'"
1386
+ [Pressed]="Tab === 'invoices' && Preset === 'unsent'"
1387
+ Hint="Show invoices not yet sent"
572
1388
  Label="Waiting to send"
573
1389
  Icon="fa-solid fa-paper-plane"
574
1390
  [Tone]="UnsentCount ? 'alert' : 'default'"
575
1391
  [Value]="String(UnsentCount)"
576
- [Detail]="UnsentDetail" />
1392
+ [Detail]="UnsentDetail"
1393
+ (Clicked)="OnTile('unsent')" />
577
1394
 
578
1395
  <mjo-stat-tile
1396
+ class="mjo-xq__tile"
1397
+ [class.is-on]="Tab === 'invoices' && Preset === 'failed'"
1398
+ [Pressed]="Tab === 'invoices' && Preset === 'failed'"
1399
+ Hint="Show invoices whose send failed"
579
1400
  Label="Sends that failed"
580
1401
  Icon="fa-solid fa-triangle-exclamation"
581
1402
  [Tone]="FailedCount ? 'alert' : 'default'"
582
1403
  [Value]="String(FailedCount)"
583
- Detail="A person has to look at these" />
1404
+ [Detail]="FailedCount ? 'Review each before resending' : 'No failed sends'"
1405
+ (Clicked)="OnTile('failed')" />
584
1406
 
585
1407
  <mjo-stat-tile
1408
+ class="mjo-xq__tile"
1409
+ [class.is-on]="Tab === 'payments'"
1410
+ [Pressed]="Tab === 'payments'"
1411
+ Hint="Open Payment exceptions"
586
1412
  Label="Payments needing attention"
587
1413
  Icon="fa-solid fa-hand-holding-dollar"
588
1414
  [Tone]="Exceptions.length ? 'alert' : 'default'"
589
1415
  [Value]="String(Exceptions.length)"
590
- [Detail]="ExceptionDetail" />
1416
+ [Detail]="ExceptionDetail"
1417
+ (Clicked)="OnTab('payments')" />
591
1418
  </div>
592
1419
 
593
1420
  @if (LoadError) {
@@ -602,94 +1429,229 @@ export class MJOExternalInvoicingQueuePageComponent {
602
1429
  @if (Truncated) {
603
1430
  <mj-alert Variant="warning" Icon="fa-solid fa-triangle-exclamation" class="mjo-xq__note">
604
1431
  <strong>List truncated.</strong>
605
- Not every waiting unit is shown.
1432
+ Not every waiting invoice is shown.
606
1433
  </mj-alert>
607
1434
  }
608
1435
 
609
1436
  <div class="mjo-xq__tabs" role="tablist">
610
- <button type="button" role="tab" [attr.aria-selected]="Tab === 'invoices'" [class.is-active]="Tab === 'invoices'" (click)="Tab = 'invoices'">
611
- Invoices out
612
- <span class="mjo-xq__count">{{ Rows.length }}</span>
1437
+ <button type="button" role="tab" [attr.aria-selected]="Tab === 'invoices'" [class.is-active]="Tab === 'invoices'" (click)="OnTab('invoices')">
1438
+ Invoices to send
1439
+ <span class="mjo-xq__count">{{ InScope.length }}</span>
613
1440
  </button>
614
- <button type="button" role="tab" [attr.aria-selected]="Tab === 'payments'" [class.is-active]="Tab === 'payments'" (click)="Tab = 'payments'">
1441
+ <button type="button" role="tab" [attr.aria-selected]="Tab === 'payments'" [class.is-active]="Tab === 'payments'" (click)="OnTab('payments')">
615
1442
  Payment exceptions
616
1443
  <span class="mjo-xq__count">{{ Exceptions.length }}</span>
617
1444
  </button>
618
1445
  </div>
619
1446
 
620
- <div class="row mjo-xq__actions mjo-xq__poll-bar" data-testid="poll-payments-bar">
621
- <button type="button" mjButton variant="outline" [disabled]="Busy || PollBlocked" (click)="RunPoll()">
622
- <i class="fa-solid fa-rotate" aria-hidden="true"></i> {{ Busy ? 'Working…' : PollJob?.State === 'Preview' ? 'Preview payment check' : 'Check for payments now' }}
623
- </button>
624
- <span class="small muted">{{ PollHint }}</span>
625
- </div>
626
-
627
1447
  @if (Tab === 'invoices') {
628
- <div class="row mjo-xq__actions">
629
- <button type="button" mjButton variant="outline" [disabled]="!SelectedInvoice" (click)="OpenSelected()">
630
- <i class="fa-solid fa-arrow-up-right-from-square" aria-hidden="true"></i> Open order
631
- </button>
632
- <button type="button" mjButton variant="primary" [disabled]="!SelectedInvoice || Busy" (click)="SendSelected()">
633
- <i class="fa-solid fa-paper-plane" aria-hidden="true"></i> Send this one
634
- </button>
635
- <button type="button" mjButton variant="outline" [disabled]="Busy || !Rows.length" (click)="RunSweep()">
636
- <i class="fa-solid fa-rotate" aria-hidden="true"></i> {{ Busy ? 'Working…' : 'Send all waiting' }}
637
- </button>
1448
+ <div class="mjo-split">
1449
+ <div class="mjo-split__main">
1450
+ <div class="row mjo-xq__actions">
1451
+ <button type="button" mjButton variant="primary" [disabled]="Busy || !InScope.length" (click)="RunSweep()" title="Send the invoices that are waiting, for the companies chosen">
1452
+ <i class="fa-solid fa-paper-plane" aria-hidden="true"></i> {{ Busy ? 'Working…' : 'Send all waiting' }}
1453
+ </button>
1454
+ <span class="small muted">Select an invoice to see its detail or send it on its own.</span>
1455
+ </div>
1456
+
1457
+ <mjo-worklist-table
1458
+ [Columns]="InvoiceColumns"
1459
+ [Rows]="Rows"
1460
+ [Searchable]="false"
1461
+ [Loading]="Loading"
1462
+ [Totals]="InvoiceTotals"
1463
+ MaxHeight="calc(100vh - 380px)"
1464
+ [SortKey]="InvoiceSort.Key"
1465
+ [SortDescending]="InvoiceSort.Descending"
1466
+ RowKey="DocumentNumber"
1467
+ [SelectedKey]="SelectedInvoice?.DocumentNumber ?? null"
1468
+ [EmptyTitle]="AllRows.length ? 'Nothing matches' : 'Nothing waiting'"
1469
+ [EmptyHint]="AllRows.length ? 'No waiting invoice matches these filters. Clear one to see more.' : 'Every invoice has been sent.'"
1470
+ EmptyIcon="fa-solid fa-paper-plane"
1471
+ (SortChanged)="OnInvoiceSort($event)"
1472
+ (LinkClicked)="OpenOrder($event.Row)"
1473
+ (RowClicked)="OnInvoiceRow($event)" />
1474
+ </div>
1475
+
638
1476
  @if (SelectedInvoice; as row) {
639
- <span class="small muted">{{ row.DocumentNumber }} · {{ money(row.Amount) }} · {{ row.CompanyName }}</span>
1477
+ <div class="mjo-split__side">
1478
+ <mjo-side-panel
1479
+ Icon="fa-solid fa-paper-plane"
1480
+ [Title]="row.DocumentNumber"
1481
+ [Chip]="stateLabel(row.State)"
1482
+ [ChipClass]="stateChip(row)"
1483
+ (Closed)="SelectedInvoice = null">
1484
+ <div class="mjo-side-panel__amount">{{ money(row.Amount) }}</div>
1485
+ <dl class="mjo-side-panel__facts">
1486
+ <dt>Customer</dt>
1487
+ <dd>{{ row.CustomerName }}</dd>
1488
+ <dt>Order</dt>
1489
+ <dd>
1490
+ <button type="button" class="mjo-side-panel__link" (click)="OpenOrder(row)" title="Open the order">{{ row.OrderNumber }}</button>
1491
+ · {{ row.InstallmentNumber ? 'installment ' + row.InstallmentNumber : 'whole order' }}
1492
+ </dd>
1493
+ <dt>Billed by</dt>
1494
+ <dd>{{ row.CompanyName || '—' }}</dd>
1495
+ <dt>Due</dt>
1496
+ <dd>{{ date(row.DueDate) }}</dd>
1497
+ @if (row.SinceAt) {
1498
+ <dt>{{ row.State === 'Unsent' ? 'Waiting since' : 'Last attempt' }}</dt>
1499
+ <dd>{{ instant(row.SinceAt) }}</dd>
1500
+ }
1501
+ @if (row.LastError) {
1502
+ <dt>Last error</dt>
1503
+ <dd>{{ row.LastError }}</dd>
1504
+ }
1505
+ </dl>
1506
+ <div class="mjo-side-panel__actions">
1507
+ <button type="button" mjButton variant="primary" [disabled]="Busy" (click)="SendSelected()">
1508
+ <i class="fa-solid fa-paper-plane" aria-hidden="true"></i> {{ row.State === 'Unsent' ? 'Send this invoice' : 'Send again' }}
1509
+ </button>
1510
+ <button type="button" mjButton variant="outline" (click)="OpenOrder(row)">
1511
+ <i class="fa-solid fa-arrow-up-right-from-square" aria-hidden="true"></i> Open order
1512
+ </button>
1513
+ </div>
1514
+ </mjo-side-panel>
1515
+ </div>
640
1516
  }
641
1517
  </div>
642
-
643
- <mjo-worklist-table
644
- [Columns]="InvoiceColumns"
645
- [Rows]="Rows"
646
- [Presets]="Presets"
647
- [ActivePreset]="Preset"
648
- [Searchable]="false"
649
- RowKey="DocumentNumber"
650
- [SelectedKey]="SelectedInvoice?.DocumentNumber ?? null"
651
- EmptyTitle="Nothing waiting"
652
- EmptyHint="Every confirmed order on a rail has been invoiced."
653
- EmptyIcon="fa-solid fa-paper-plane"
654
- (PresetChanged)="OnPreset($event)"
655
- (RowClicked)="SelectedInvoice = $event" />
656
1518
  } @else {
657
- <div class="row wrap mjo-xq__actions">
1519
+ <div class="mjo-split">
1520
+ <div class="mjo-split__main">
1521
+ <div class="row wrap mjo-xq__actions" data-testid="poll-payments-bar">
1522
+ <button type="button" mjButton variant="primary" [disabled]="Busy || !CheckedIDs.length" (click)="OpenSetAside(CheckedIDs)" title="Set the ticked payments aside">
1523
+ <i class="fa-solid fa-box-archive" aria-hidden="true"></i> Set aside{{ CheckedIDs.length ? ' (' + CheckedIDs.length + ')' : '' }}
1524
+ </button>
1525
+ <button type="button" mjButton variant="outline" [disabled]="Busy || PollBlocked" (click)="RunPoll()">
1526
+ <i class="fa-solid fa-rotate" aria-hidden="true"></i> {{ Busy ? 'Working…' : PollJob?.State === 'Preview' ? 'Preview payment check' : 'Check for payments now' }}
1527
+ </button>
1528
+ <span class="small muted">{{ PollHint }}</span>
1529
+ </div>
1530
+
1531
+ <mjo-worklist-table
1532
+ [Columns]="PaymentColumns"
1533
+ [Rows]="ShownExceptions"
1534
+ [Searchable]="false"
1535
+ [Loading]="Loading"
1536
+ [Totals]="PaymentTotals"
1537
+ MaxHeight="calc(100vh - 380px)"
1538
+ [SortKey]="PaymentSort.Key"
1539
+ [SortDescending]="PaymentSort.Descending"
1540
+ RowKey="ID"
1541
+ [SelectedKey]="SelectedPayment?.ID ?? null"
1542
+ [Selectable]="true"
1543
+ [SelectedKeys]="CheckedIDs"
1544
+ [RowLabel]="PaymentTickLabel"
1545
+ [EmptyTitle]="Exceptions.length ? 'Nothing matches' : 'Nothing needs attention'"
1546
+ [EmptyHint]="Exceptions.length ? 'No payment matches these filters. Clear one to see more.' : 'Every payment reported has been recorded or set aside.'"
1547
+ EmptyIcon="fa-solid fa-hand-holding-dollar"
1548
+ (SelectionChanged)="CheckedIDs = $event"
1549
+ (SortChanged)="OnPaymentSort($event)"
1550
+ (RowClicked)="OnPaymentRow($event)" />
1551
+ </div>
1552
+
1553
+ @if (SelectedPayment; as row) {
1554
+ <div class="mjo-split__side">
1555
+ <mjo-side-panel
1556
+ Icon="fa-solid fa-hand-holding-dollar"
1557
+ [Title]="row.ExternalPaymentRef"
1558
+ [Chip]="dispositionLabel(row)"
1559
+ [ChipClass]="dispositionChip(row)"
1560
+ (Closed)="SelectedPayment = null">
1561
+ <div class="mjo-side-panel__amount">{{ money(row.Amount) }}</div>
1562
+ <dl class="mjo-side-panel__facts">
1563
+ <dt>Dated</dt>
1564
+ <dd>{{ date(row.PaymentDate) }}</dd>
1565
+ <dt>Received through</dt>
1566
+ <dd>{{ providerText(row) }}</dd>
1567
+ <dt>Customer</dt>
1568
+ <dd>{{ customerOf(row) || 'Not matched to a customer' }}</dd>
1569
+ <dt>Customer reference</dt>
1570
+ <dd>{{ row.ExternalCustomerRef || '—' }}</dd>
1571
+ <dt>Provider status</dt>
1572
+ <dd>{{ row.ExternalStatus || '—' }}</dd>
1573
+ <dt>What happened</dt>
1574
+ <dd>{{ row.DispositionReason || '—' }}</dd>
1575
+ <dt>First seen</dt>
1576
+ <dd>{{ instant(row.FirstSeenAt) }}</dd>
1577
+ <dt>Last seen</dt>
1578
+ <dd>{{ instant(row.LastSeenAt) }}</dd>
1579
+ </dl>
1580
+ <div class="mjo-side-panel__actions">
1581
+ <button type="button" mjButton variant="primary" [disabled]="Busy" (click)="OpenSetAside([row.ID])">
1582
+ <i class="fa-solid fa-box-archive" aria-hidden="true"></i> Set aside
1583
+ </button>
1584
+ </div>
1585
+ </mjo-side-panel>
1586
+ </div>
1587
+ }
1588
+ </div>
1589
+ }
1590
+
1591
+ <mj-dialog [Visible]="SetAsideOpen" [Title]="SetAsideTargets.length === 1 ? 'Set aside this payment' : 'Set aside ' + SetAsideTargets.length + ' payments'" Size="md" (Close)="CloseSetAside()">
1592
+ <p class="mjo-xq__dialog-lede">
1593
+ A payment set aside leaves this list and is never recorded as cash, even if its invoice is loaded later. This cannot be undone here.
1594
+ </p>
1595
+ <label class="mjo-xq__field">
1596
+ <span class="small muted">Reason</span>
1597
+ <input
1598
+ type="text"
1599
+ class="mjo-xq__select"
1600
+ maxlength="400"
1601
+ [value]="SetAsideReason"
1602
+ (input)="SetAsideReason = $any($event.target).value"
1603
+ placeholder="For example: paid before go-live, invoice not converted"
1604
+ aria-label="Reason for setting aside">
1605
+ </label>
1606
+ @if (SetAsideTargets.length > 1) {
658
1607
  <label class="mjo-xq__field">
659
- <span class="small muted">Paid before</span>
660
- <input type="date" [value]="PaidBefore ?? ''" (change)="OnPaidBefore($any($event.target).value)" aria-label="Show payments dated before this day">
661
- </label>
662
- <label class="mjo-xq__field mjo-xq__field--grow">
663
- <span class="small muted">Reason for setting aside</span>
664
- <input
665
- type="text"
666
- maxlength="400"
667
- [value]="SetAsideReason"
668
- (input)="SetAsideReason = $any($event.target).value"
669
- placeholder="e.g. Pre-go-live payment against AR not converted">
1608
+ <span class="small muted">Include unmatched payments dated before</span>
1609
+ <input type="date" class="mjo-xq__select mjo-xq__day" [value]="SetAsideBefore ?? ''" (change)="OnSetAsideBefore($any($event.target).value)" aria-label="Include unmatched payments dated before this day">
1610
+ <span class="small muted">An unmatched payment may be waiting for an invoice still to be loaded, so in a batch only those dated before this day are set aside. Held and refused payments are set aside whatever their date.</span>
670
1611
  </label>
671
- <button type="button" mjButton variant="outline" [disabled]="Busy || !CheckedIDs.length || !SetAsideReason.trim()" (click)="SetAsideChecked()">
672
- <i class="fa-solid fa-box-archive" aria-hidden="true"></i> Set aside{{ CheckedIDs.length ? ' (' + CheckedIDs.length + ')' : '' }}
1612
+ }
1613
+ @if (SetAsidePlan; as plan) {
1614
+ <div class="mjo-xq__plan" role="status">
1615
+ <strong>{{ plan.Eligible.length }} of {{ SetAsideTargets.length }} will be set aside · {{ money(setAsideTotal) }}</strong>
1616
+ @if (plan.Eligible.length) {
1617
+ <!-- Named, not only counted: this cannot be undone, so what is about to be written is read first. -->
1618
+ <table class="mjo-xq__plan-rows small">
1619
+ <tbody>
1620
+ @for (row of setAsideListed; track row.ID) {
1621
+ <tr>
1622
+ <td class="mono">{{ row.ExternalPaymentRef }}</td>
1623
+ <td>{{ date(row.PaymentDate) }}</td>
1624
+ <td>{{ dispositionLabel(row) }}</td>
1625
+ <td class="mjo-xq__plan-amount">{{ money(row.Amount) }}</td>
1626
+ </tr>
1627
+ }
1628
+ </tbody>
1629
+ </table>
1630
+ @if (plan.Eligible.length > setAsideListed.length) {
1631
+ <div class="small muted">and {{ plan.Eligible.length - setAsideListed.length }} more</div>
1632
+ }
1633
+ }
1634
+ @if (plan.Excluded.length) {
1635
+ <ul class="mjo-xq__left-out small">
1636
+ @for (item of plan.Excluded; track item.Row.ID) {
1637
+ <li><span class="mono">{{ item.Row.ExternalPaymentRef }}</span> is left out. {{ item.Why }}</li>
1638
+ }
1639
+ </ul>
1640
+ }
1641
+ </div>
1642
+ }
1643
+ <mj-dialog-actions>
1644
+ <button type="button" mjButton variant="outline" (click)="CloseSetAside()">Cancel</button>
1645
+ <button type="button" mjButton variant="primary" [disabled]="Busy || !SetAsideReason.trim() || !SetAsidePlan?.Eligible?.length" (click)="ApplySetAside()">
1646
+ {{ Busy ? 'Working…' : 'Set aside' + (SetAsidePlan?.Eligible?.length ? ' ' + SetAsidePlan!.Eligible.length : '') }}
673
1647
  </button>
674
- </div>
675
-
676
- <mjo-worklist-table
677
- [Columns]="PaymentColumns"
678
- [Rows]="ShownExceptions"
679
- [Presets]="[]"
680
- [Searchable]="false"
681
- RowKey="ID"
682
- [Selectable]="true"
683
- [SelectedKeys]="CheckedIDs"
684
- (SelectionChanged)="CheckedIDs = $event"
685
- [FootNote]="ExceptionFootNote"
686
- EmptyTitle="Nothing needs attention"
687
- EmptyHint="Every payment the rail reported has been recorded or set aside."
688
- EmptyIcon="fa-solid fa-hand-holding-dollar" />
689
- }
690
- `, styles: ["\n :host {\n display: block;\n height: 100%;\n overflow: auto;\n padding: var(--mj-space-6);\n }\n .mjo-xq__tiles { margin-bottom: var(--mj-space-4); }\n .mjo-xq__note { margin-bottom: var(--mj-space-4); }\n .mjo-xq__actions {\n align-items: center;\n gap: var(--mj-space-3);\n margin-bottom: var(--mj-space-4);\n }\n .mjo-xq__field {\n display: flex;\n flex-direction: column;\n gap: var(--mj-space-1);\n }\n .mjo-xq__field--grow {\n flex: 1 1 260px;\n }\n .mjo-xq__tabs {\n display: flex;\n gap: var(--mj-space-2);\n border-bottom: 1px solid var(--mj-border-default);\n margin-bottom: var(--mj-space-4);\n }\n .mjo-xq__tabs button {\n appearance: none;\n background: none;\n border: none;\n border-bottom: 2px solid transparent;\n padding: var(--mj-space-3) var(--mj-space-4);\n cursor: pointer;\n font: inherit;\n color: var(--mj-text-muted);\n }\n .mjo-xq__tabs button.is-active {\n color: var(--mj-text-primary);\n border-bottom-color: var(--mj-brand-primary);\n font-weight: 600;\n }\n .mjo-xq__count {\n display: inline-block;\n margin-left: var(--mj-space-2);\n padding: 0 var(--mj-space-2);\n border-radius: 999px;\n background: var(--mj-bg-surface-card);\n font-size: 0.8em;\n }\n @media (max-width: 760px) {\n :host { padding: var(--mj-space-4); }\n }\n "] }]
1648
+ </mj-dialog-actions>
1649
+ </mj-dialog>
1650
+ `, styles: ["\n :host {\n display: block;\n height: 100%;\n overflow: auto;\n padding: var(--mj-space-6);\n }\n .mjo-xq__tiles { margin-bottom: var(--mj-space-4); }\n .mjo-xq__tile { display: block; border-radius: var(--mj-radius-md); transition: box-shadow 140ms ease; }\n .mjo-xq__tile.is-on { box-shadow: 0 0 0 2px color-mix(in srgb, var(--mj-brand-primary) 55%, transparent); }\n .mjo-xq__note { display: block; margin-bottom: var(--mj-space-4); }\n .mjo-xq__actions {\n align-items: center;\n gap: var(--mj-space-3);\n margin-bottom: var(--mj-space-3);\n }\n .mjo-xq__field {\n display: flex;\n flex-direction: column;\n gap: var(--mj-space-1);\n margin-bottom: var(--mj-space-4);\n }\n .mjo-xq__day { width: 180px; }\n .mjo-xq__dialog-lede { margin: 0 0 var(--mj-space-4); }\n .mjo-xq__plan {\n padding: var(--mj-space-3);\n background: var(--mj-bg-surface-sunken);\n border-radius: var(--mj-radius-md);\n }\n .mjo-xq__plan-rows { width: 100%; margin-top: var(--mj-space-2); border-collapse: collapse; }\n .mjo-xq__plan-rows td { padding: 2px var(--mj-space-3) 2px 0; }\n .mjo-xq__plan-amount { text-align: right; font-variant-numeric: tabular-nums; }\n .mjo-xq__left-out { margin: var(--mj-space-2) 0 0; padding-left: var(--mj-space-5); }\n .mjo-xq__left-out li { margin-bottom: 4px; }\n .mjo-xq__window {\n display: inline-flex;\n align-items: center;\n gap: var(--mj-space-2);\n }\n .mjo-xq__select {\n font: inherit;\n font-size: 13px;\n padding: 4px 8px;\n border: 1px solid var(--mj-border-default);\n border-radius: var(--mj-radius-md);\n background: var(--mj-bg-surface);\n color: inherit;\n }\n .mjo-xq__tabs {\n display: flex;\n gap: var(--mj-space-2);\n border-bottom: 1px solid var(--mj-border-default);\n margin-bottom: var(--mj-space-4);\n }\n .mjo-xq__tabs button {\n appearance: none;\n background: none;\n border: none;\n border-bottom: 2px solid transparent;\n padding: var(--mj-space-3) var(--mj-space-4);\n cursor: pointer;\n font: inherit;\n color: var(--mj-text-muted);\n }\n .mjo-xq__tabs button.is-active {\n color: var(--mj-text-primary);\n border-bottom-color: var(--mj-brand-primary);\n font-weight: 600;\n }\n .mjo-xq__count {\n display: inline-block;\n margin-left: var(--mj-space-2);\n padding: 0 var(--mj-space-2);\n border-radius: 999px;\n background: var(--mj-bg-surface-card);\n font-size: 0.8em;\n }\n @media (max-width: 760px) {\n :host { padding: var(--mj-space-4); }\n }\n @media (prefers-reduced-motion: reduce) {\n .mjo-xq__tile { transition: none; }\n }\n "] }]
691
1651
  }], null, { OrderOpened: [{
692
1652
  type: Output
1653
+ }], AddressChanged: [{
1654
+ type: Output
693
1655
  }] }); })();
694
- (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(MJOExternalInvoicingQueuePageComponent, { className: "MJOExternalInvoicingQueuePageComponent", filePath: "lib/pages/receivables/external-invoicing-queue.page.ts", lineNumber: 248 }); })();
1656
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(MJOExternalInvoicingQueuePageComponent, { className: "MJOExternalInvoicingQueuePageComponent", filePath: "lib/pages/receivables/external-invoicing-queue.page.ts", lineNumber: 570 }); })();
695
1657
  //# sourceMappingURL=external-invoicing-queue.page.js.map