@sneat/extension-debtus-ui 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,196 @@
1
+ import * as i0 from '@angular/core';
2
+ import { inject, signal, Component } from '@angular/core';
3
+ import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
4
+ import * as i1 from '@angular/forms';
5
+ import { FormControl, Validators, FormGroup, ReactiveFormsModule } from '@angular/forms';
6
+ import { ToastController, IonHeader, IonToolbar, IonButtons, IonBackButton, IonTitle, IonContent, IonCard, IonCardContent, IonItem, IonLabel, IonInput, IonTextarea, IonSelect, IonSelectOption, IonSegment, IonSegmentButton, IonButton, IonNote, IonSpinner } from '@ionic/angular';
7
+ import { ContactInputComponent } from '@sneat/extension-contactus-ui';
8
+ import { DEBTUS_SERVICE } from '@sneat/extension-debtus-contract';
9
+ import { SpacePageBaseComponent, SpaceComponentBaseParams } from '@sneat/space-components';
10
+ import { ClassName } from '@sneat/ui';
11
+ import { first } from 'rxjs';
12
+
13
+ // Create transfer — the primary write flow. Mirrors the bot's lend/borrow
14
+ // wizard: direction, counterparty (a contactus space contact), amount +
15
+ // currency, optional note. Reuses the contactus `sneat-contact-input` picker
16
+ // so the counterparty is a real space contact, not a debtus-private person.
17
+ class NewTransferPageComponent extends SpacePageBaseComponent {
18
+ debtusService = inject(DEBTUS_SERVICE);
19
+ toastController = inject(ToastController);
20
+ $submitting = signal(false, /* @ts-ignore */
21
+ ...(ngDevMode ? [{ debugName: "$submitting" }] : /* istanbul ignore next */ []));
22
+ $pickedContact = signal(undefined, /* @ts-ignore */
23
+ ...(ngDevMode ? [{ debugName: "$pickedContact" }] : /* istanbul ignore next */ []));
24
+ /** Set when arriving from a contact detail page (?contactID=…). */
25
+ prefilledContactID;
26
+ direction = new FormControl('lend', {
27
+ nonNullable: true,
28
+ });
29
+ currency = new FormControl('EUR', {
30
+ nonNullable: true,
31
+ });
32
+ amount = new FormControl(null, [
33
+ Validators.required,
34
+ Validators.min(0.01),
35
+ ]);
36
+ counterpartyName = new FormControl('', {
37
+ nonNullable: true,
38
+ });
39
+ note = new FormControl('', { nonNullable: true });
40
+ form = new FormGroup({
41
+ direction: this.direction,
42
+ currency: this.currency,
43
+ amount: this.amount,
44
+ counterpartyName: this.counterpartyName,
45
+ note: this.note,
46
+ });
47
+ currencies = ['EUR', 'USD'];
48
+ constructor() {
49
+ super();
50
+ this.$defaultBackUrlSpacePath.set('debts');
51
+ this.route.queryParamMap.pipe(first(), takeUntilDestroyed()).subscribe({
52
+ next: (params) => {
53
+ const dir = params.get('direction');
54
+ if (dir === 'lend' || dir === 'borrow') {
55
+ this.direction.setValue(dir);
56
+ }
57
+ const contactID = params.get('contactID');
58
+ if (contactID) {
59
+ this.prefilledContactID = contactID;
60
+ // Prefill the name field from the known balance so the user sees who
61
+ // they're recording against even before the contactus picker loads.
62
+ this.spaceIDChanged$.pipe(first()).subscribe((spaceID) => {
63
+ this.debtusService
64
+ .getContactBalance(spaceID ?? '', contactID)
65
+ .pipe(first())
66
+ .subscribe((c) => this.counterpartyName.setValue(c.title));
67
+ });
68
+ }
69
+ },
70
+ });
71
+ }
72
+ onContactChanged(contact) {
73
+ this.$pickedContact.set(contact);
74
+ if (contact) {
75
+ // A picked contact supersedes a typed name / prefilled id.
76
+ this.prefilledContactID = undefined;
77
+ this.counterpartyName.setValue(contact.brief?.title ?? '');
78
+ }
79
+ }
80
+ resolveCounterparty() {
81
+ const picked = this.$pickedContact();
82
+ if (picked) {
83
+ return { contactID: picked.id, title: picked.brief?.title ?? picked.id };
84
+ }
85
+ if (this.prefilledContactID) {
86
+ return {
87
+ contactID: this.prefilledContactID,
88
+ title: this.counterpartyName.value,
89
+ };
90
+ }
91
+ // Fable refactoring: the "new counterparty by name" path is disabled —
92
+ // the assumption that "the backend create flow resolves/creates it" was
93
+ // wrong: POST create-transfer validation requires toContactID/fromContactID
94
+ // (facade4debtus CreateTransferRequest.Validate), so an empty contactID
95
+ // always 400s. Until a create-contact-then-transfer flow is wired, users
96
+ // must pick an existing space contact (the picker above supports adding
97
+ // one). Original branch kept per the no-delete policy:
98
+ // const name = this.counterpartyName.value.trim();
99
+ // if (name) {
100
+ // // New counterparty by name (mirrors the bot's "new counterparty"
101
+ // // step). No contactID yet — the backend create flow
102
+ // // resolves/creates it.
103
+ // return { contactID: '', title: name };
104
+ // }
105
+ return null;
106
+ }
107
+ submit() {
108
+ this.form.markAllAsTouched();
109
+ const amount = this.amount.value;
110
+ if (!amount || amount <= 0) {
111
+ return;
112
+ }
113
+ const counterparty = this.resolveCounterparty();
114
+ if (!counterparty) {
115
+ this.showToast('Pick a counterparty contact. To record against someone new, add them as a space contact first.', 'danger');
116
+ return;
117
+ }
118
+ const spaceID = this.$spaceID();
119
+ if (!spaceID) {
120
+ return;
121
+ }
122
+ const request = {
123
+ spaceID,
124
+ direction: this.direction.value,
125
+ amount: { currency: this.currency.value, value: amount },
126
+ contactID: counterparty.contactID,
127
+ contactTitle: counterparty.title,
128
+ note: this.note.value.trim() || undefined,
129
+ counterpartySpaceID: this.$pickedContact()?.space?.id,
130
+ };
131
+ this.$submitting.set(true);
132
+ this.debtusService.createTransfer(request).subscribe({
133
+ next: (resp) => {
134
+ this.$submitting.set(false);
135
+ // Navigation default: go to the created transfer's detail, replaceUrl
136
+ // so Back doesn't reopen the filled form. The created transfer is
137
+ // handed over via router state — transfer reads are not wired to the
138
+ // live backend yet, so the details page must not fabricate a receipt
139
+ // from fixtures.
140
+ this.spaceNav.navigateForwardToSpacePage(this.space, `transfer/${resp.transfer.id}`, { replaceUrl: true, state: { transfer: resp.transfer } });
141
+ },
142
+ error: (err) => {
143
+ this.$submitting.set(false);
144
+ this.errorLogger.logError(err, 'Failed to create transfer', {
145
+ show: false,
146
+ });
147
+ this.showToast('Failed to record transfer. Please try again.', 'danger');
148
+ },
149
+ });
150
+ }
151
+ async showToast(message, color) {
152
+ const toast = await this.toastController.create({
153
+ message,
154
+ duration: 3000,
155
+ color,
156
+ });
157
+ await toast.present();
158
+ }
159
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: NewTransferPageComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
160
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.3", type: NewTransferPageComponent, isStandalone: true, selector: "sneat-debtus-new-transfer-page", providers: [
161
+ { provide: ClassName, useValue: 'NewTransferPageComponent' },
162
+ SpaceComponentBaseParams,
163
+ ], usesInheritance: true, ngImport: i0, template: "<ion-header>\n <ion-toolbar color=\"light\">\n <ion-buttons slot=\"start\">\n <ion-back-button [defaultHref]=\"$defaultBackUrl()\" />\n </ion-buttons>\n <ion-title>New transfer</ion-title>\n </ion-toolbar>\n</ion-header>\n\n<ion-content class=\"cardy\">\n <form [formGroup]=\"form\" (ngSubmit)=\"submit()\">\n <ion-card>\n <ion-card-content>\n <ion-segment [formControl]=\"direction\">\n <ion-segment-button value=\"lend\">\n <ion-label>I lent</ion-label>\n </ion-segment-button>\n <ion-segment-button value=\"borrow\">\n <ion-label>I borrowed</ion-label>\n </ion-segment-button>\n </ion-segment>\n <ion-note class=\"ion-padding-start\" color=\"medium\">\n {{\n direction.value === 'lend'\n ? 'You gave money \u2014 they owe you.'\n : 'You got money \u2014 you owe them.'\n }}\n </ion-note>\n </ion-card-content>\n </ion-card>\n\n <ion-card>\n <ion-card-content>\n <!-- Reuse the contactus space-contact picker. The counterparty is a\n real contactus contact, not a debtus-private person. -->\n <sneat-contact-input\n [space]=\"space\"\n label=\"Counterparty\"\n [canChangeContact]=\"true\"\n (contactChange)=\"onContactChanged($event)\"\n />\n @if (prefilledContactID) {\n <ion-note class=\"ion-padding-start\" color=\"medium\">\n Recording against\n {{ counterpartyName.value || prefilledContactID }}\n </ion-note>\n }\n <!-- Fable refactoring: the \"Or new counterparty name\" free-text input\n is disabled \u2014 a name-only counterparty always 400s server-side\n (POST create-transfer requires a real contact id; see\n resolveCounterparty() in the component). Re-enable once a\n create-contact-then-transfer flow exists. Kept per the no-delete\n policy:\n <ion-item>\n <ion-label position=\"stacked\">\n Or new counterparty name\n </ion-label>\n <ion-input\n [formControl]=\"counterpartyName\"\n placeholder=\"e.g. Alex\"\n autocapitalize=\"words\"\n />\n </ion-item>\n -->\n </ion-card-content>\n </ion-card>\n\n <ion-card>\n <ion-card-content>\n <ion-item>\n <ion-label>Currency</ion-label>\n <ion-select [formControl]=\"currency\" interface=\"popover\">\n @for (c of currencies; track c) {\n <ion-select-option [value]=\"c\">{{ c }}</ion-select-option>\n }\n </ion-select>\n </ion-item>\n <ion-item>\n <ion-label position=\"stacked\">Amount</ion-label>\n <ion-input\n type=\"number\"\n inputmode=\"decimal\"\n [formControl]=\"amount\"\n placeholder=\"0.00\"\n />\n </ion-item>\n @if (amount.touched && amount.invalid) {\n <ion-note color=\"danger\" class=\"ion-padding-start\">\n Enter an amount greater than zero.\n </ion-note>\n }\n <ion-item>\n <ion-label position=\"stacked\">Note (optional)</ion-label>\n <ion-textarea\n [formControl]=\"note\"\n placeholder=\"What is it for?\"\n [autoGrow]=\"true\"\n />\n </ion-item>\n </ion-card-content>\n </ion-card>\n\n <div class=\"ion-padding\">\n <ion-button\n expand=\"block\"\n type=\"submit\"\n [disabled]=\"$submitting() || form.invalid\"\n >\n @if ($submitting()) {\n <ion-spinner name=\"dots\" slot=\"start\" />\n Saving\u2026\n } @else {\n Record transfer\n }\n </ion-button>\n </div>\n </form>\n</ion-content>\n", dependencies: [{ kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i1.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],[formArray],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i1.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "directive", type: i1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "component", type: IonHeader, selector: "ion-header", inputs: ["collapse", "mode", "translucent"] }, { kind: "component", type: IonToolbar, selector: "ion-toolbar", inputs: ["color", "mode"] }, { kind: "component", type: IonButtons, selector: "ion-buttons", inputs: ["collapse"] }, { kind: "component", type: IonBackButton, selector: "ion-back-button" }, { kind: "component", type: IonTitle, selector: "ion-title", inputs: ["color", "size"] }, { kind: "component", type: IonContent, selector: "ion-content", inputs: ["color", "fixedSlotPlacement", "forceOverscroll", "fullscreen", "scrollEvents", "scrollX", "scrollY"], outputs: ["ionScrollStart", "ionScroll", "ionScrollEnd"] }, { kind: "component", type: IonCard, selector: "ion-card", inputs: ["button", "color", "disabled", "download", "href", "mode", "rel", "routerAnimation", "routerDirection", "target", "type"] }, { kind: "component", type: IonCardContent, selector: "ion-card-content", inputs: ["mode"] }, { kind: "component", type: IonItem, selector: "ion-item", inputs: ["button", "color", "detail", "detailIcon", "disabled", "download", "href", "lines", "mode", "rel", "routerAnimation", "routerDirection", "target", "type"] }, { kind: "component", type: IonLabel, selector: "ion-label", inputs: ["color", "mode", "position"] }, { kind: "component", type: IonInput, selector: "ion-input", inputs: ["accept", "autocapitalize", "autocomplete", "autocorrect", "autofocus", "clearInput", "clearOnEdit", "color", "counter", "counterFormatter", "debounce", "disabled", "enterkeyhint", "errorText", "fill", "helperText", "inputmode", "label", "labelPlacement", "max", "maxlength", "min", "minlength", "mode", "multiple", "name", "pattern", "placeholder", "readonly", "required", "shape", "size", "spellcheck", "step", "type", "value"] }, { kind: "component", type: IonTextarea, selector: "ion-textarea", inputs: ["autoGrow", "autocapitalize", "autofocus", "clearOnEdit", "color", "cols", "counter", "counterFormatter", "debounce", "disabled", "enterkeyhint", "errorText", "fill", "helperText", "inputmode", "label", "labelPlacement", "maxlength", "minlength", "mode", "name", "placeholder", "readonly", "required", "rows", "shape", "spellcheck", "value", "wrap"] }, { kind: "component", type: IonSelect, selector: "ion-select", inputs: ["cancelText", "color", "compareWith", "disabled", "errorText", "expandedIcon", "fill", "helperText", "interface", "interfaceOptions", "justify", "label", "labelPlacement", "mode", "multiple", "name", "okText", "placeholder", "selectedText", "shape", "toggleIcon", "value"] }, { kind: "component", type: IonSelectOption, selector: "ion-select-option", inputs: ["description", "disabled", "justify", "labelPlacement", "mode", "value"] }, { kind: "component", type: IonSegment, selector: "ion-segment", inputs: ["color", "disabled", "mode", "scrollable", "selectOnFocus", "swipeGesture", "value"] }, { kind: "component", type: IonSegmentButton, selector: "ion-segment-button", inputs: ["contentId", "disabled", "layout", "mode", "type", "value"] }, { kind: "component", type: IonButton, selector: "ion-button", inputs: ["buttonType", "color", "disabled", "download", "expand", "fill", "form", "href", "mode", "rel", "routerAnimation", "routerDirection", "shape", "size", "strong", "target", "type"], outputs: ["ionFocus", "ionBlur"] }, { kind: "component", type: IonNote, selector: "ion-note", inputs: ["color", "mode"] }, { kind: "component", type: IonSpinner, selector: "ion-spinner", inputs: ["color", "duration", "name", "paused"] }, { kind: "component", type: ContactInputComponent, selector: "sneat-contact-input", inputs: ["space", "disabled", "canChangeContact", "canReset", "readonly", "label", "labelPosition", "contactRole", "contactType", "subLabel", "parentType", "parentRole", "parentContact", "deleting", "contact"], outputs: ["contactChange"] }] });
164
+ }
165
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: NewTransferPageComponent, decorators: [{
166
+ type: Component,
167
+ args: [{ selector: 'sneat-debtus-new-transfer-page', imports: [
168
+ ReactiveFormsModule,
169
+ IonHeader,
170
+ IonToolbar,
171
+ IonButtons,
172
+ IonBackButton,
173
+ IonTitle,
174
+ IonContent,
175
+ IonCard,
176
+ IonCardContent,
177
+ IonItem,
178
+ IonLabel,
179
+ IonInput,
180
+ IonTextarea,
181
+ IonSelect,
182
+ IonSelectOption,
183
+ IonSegment,
184
+ IonSegmentButton,
185
+ IonButton,
186
+ IonNote,
187
+ IonSpinner,
188
+ ContactInputComponent,
189
+ ], providers: [
190
+ { provide: ClassName, useValue: 'NewTransferPageComponent' },
191
+ SpaceComponentBaseParams,
192
+ ], template: "<ion-header>\n <ion-toolbar color=\"light\">\n <ion-buttons slot=\"start\">\n <ion-back-button [defaultHref]=\"$defaultBackUrl()\" />\n </ion-buttons>\n <ion-title>New transfer</ion-title>\n </ion-toolbar>\n</ion-header>\n\n<ion-content class=\"cardy\">\n <form [formGroup]=\"form\" (ngSubmit)=\"submit()\">\n <ion-card>\n <ion-card-content>\n <ion-segment [formControl]=\"direction\">\n <ion-segment-button value=\"lend\">\n <ion-label>I lent</ion-label>\n </ion-segment-button>\n <ion-segment-button value=\"borrow\">\n <ion-label>I borrowed</ion-label>\n </ion-segment-button>\n </ion-segment>\n <ion-note class=\"ion-padding-start\" color=\"medium\">\n {{\n direction.value === 'lend'\n ? 'You gave money \u2014 they owe you.'\n : 'You got money \u2014 you owe them.'\n }}\n </ion-note>\n </ion-card-content>\n </ion-card>\n\n <ion-card>\n <ion-card-content>\n <!-- Reuse the contactus space-contact picker. The counterparty is a\n real contactus contact, not a debtus-private person. -->\n <sneat-contact-input\n [space]=\"space\"\n label=\"Counterparty\"\n [canChangeContact]=\"true\"\n (contactChange)=\"onContactChanged($event)\"\n />\n @if (prefilledContactID) {\n <ion-note class=\"ion-padding-start\" color=\"medium\">\n Recording against\n {{ counterpartyName.value || prefilledContactID }}\n </ion-note>\n }\n <!-- Fable refactoring: the \"Or new counterparty name\" free-text input\n is disabled \u2014 a name-only counterparty always 400s server-side\n (POST create-transfer requires a real contact id; see\n resolveCounterparty() in the component). Re-enable once a\n create-contact-then-transfer flow exists. Kept per the no-delete\n policy:\n <ion-item>\n <ion-label position=\"stacked\">\n Or new counterparty name\n </ion-label>\n <ion-input\n [formControl]=\"counterpartyName\"\n placeholder=\"e.g. Alex\"\n autocapitalize=\"words\"\n />\n </ion-item>\n -->\n </ion-card-content>\n </ion-card>\n\n <ion-card>\n <ion-card-content>\n <ion-item>\n <ion-label>Currency</ion-label>\n <ion-select [formControl]=\"currency\" interface=\"popover\">\n @for (c of currencies; track c) {\n <ion-select-option [value]=\"c\">{{ c }}</ion-select-option>\n }\n </ion-select>\n </ion-item>\n <ion-item>\n <ion-label position=\"stacked\">Amount</ion-label>\n <ion-input\n type=\"number\"\n inputmode=\"decimal\"\n [formControl]=\"amount\"\n placeholder=\"0.00\"\n />\n </ion-item>\n @if (amount.touched && amount.invalid) {\n <ion-note color=\"danger\" class=\"ion-padding-start\">\n Enter an amount greater than zero.\n </ion-note>\n }\n <ion-item>\n <ion-label position=\"stacked\">Note (optional)</ion-label>\n <ion-textarea\n [formControl]=\"note\"\n placeholder=\"What is it for?\"\n [autoGrow]=\"true\"\n />\n </ion-item>\n </ion-card-content>\n </ion-card>\n\n <div class=\"ion-padding\">\n <ion-button\n expand=\"block\"\n type=\"submit\"\n [disabled]=\"$submitting() || form.invalid\"\n >\n @if ($submitting()) {\n <ion-spinner name=\"dots\" slot=\"start\" />\n Saving\u2026\n } @else {\n Record transfer\n }\n </ion-button>\n </div>\n </form>\n</ion-content>\n" }]
193
+ }], ctorParameters: () => [] });
194
+
195
+ export { NewTransferPageComponent };
196
+ //# sourceMappingURL=sneat-extension-debtus-ui-new-transfer-page.component-CT-6X_0e.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sneat-extension-debtus-ui-new-transfer-page.component-CT-6X_0e.mjs","sources":["../../../../../../libs/extensions/debtus/ui/src/lib/pages/new-transfer/new-transfer-page.component.ts","../../../../../../libs/extensions/debtus/ui/src/lib/pages/new-transfer/new-transfer-page.component.html"],"sourcesContent":["import { Component, inject, signal } from '@angular/core';\nimport { takeUntilDestroyed } from '@angular/core/rxjs-interop';\nimport {\n FormControl,\n FormGroup,\n ReactiveFormsModule,\n Validators,\n} from '@angular/forms';\nimport {\n IonBackButton,\n IonButton,\n IonButtons,\n IonCard,\n IonCardContent,\n IonContent,\n IonHeader,\n IonInput,\n IonItem,\n IonLabel,\n IonNote,\n IonSegment,\n IonSegmentButton,\n IonSelect,\n IonSelectOption,\n IonSpinner,\n IonTextarea,\n IonTitle,\n IonToolbar,\n ToastController,\n} from '@ionic/angular';\nimport { IContactContext } from '@sneat/extension-contactus-contract';\nimport { ContactInputComponent } from '@sneat/extension-contactus-ui';\nimport {\n CurrencyCode,\n DEBTUS_SERVICE,\n DebtDirection,\n ICreateTransferRequest,\n} from '@sneat/extension-debtus-contract';\nimport {\n SpaceComponentBaseParams,\n SpacePageBaseComponent,\n} from '@sneat/space-components';\nimport { ClassName } from '@sneat/ui';\nimport { first } from 'rxjs';\n\n// Create transfer — the primary write flow. Mirrors the bot's lend/borrow\n// wizard: direction, counterparty (a contactus space contact), amount +\n// currency, optional note. Reuses the contactus `sneat-contact-input` picker\n// so the counterparty is a real space contact, not a debtus-private person.\n@Component({\n selector: 'sneat-debtus-new-transfer-page',\n templateUrl: './new-transfer-page.component.html',\n imports: [\n ReactiveFormsModule,\n IonHeader,\n IonToolbar,\n IonButtons,\n IonBackButton,\n IonTitle,\n IonContent,\n IonCard,\n IonCardContent,\n IonItem,\n IonLabel,\n IonInput,\n IonTextarea,\n IonSelect,\n IonSelectOption,\n IonSegment,\n IonSegmentButton,\n IonButton,\n IonNote,\n IonSpinner,\n ContactInputComponent,\n ],\n providers: [\n { provide: ClassName, useValue: 'NewTransferPageComponent' },\n SpaceComponentBaseParams,\n ],\n})\nexport class NewTransferPageComponent extends SpacePageBaseComponent {\n private readonly debtusService = inject(DEBTUS_SERVICE);\n private readonly toastController = inject(ToastController);\n\n protected readonly $submitting = signal(false);\n protected readonly $pickedContact = signal<IContactContext | undefined>(\n undefined,\n );\n /** Set when arriving from a contact detail page (?contactID=…). */\n protected prefilledContactID?: string;\n\n protected readonly direction = new FormControl<DebtDirection>('lend', {\n nonNullable: true,\n });\n protected readonly currency = new FormControl<CurrencyCode>('EUR', {\n nonNullable: true,\n });\n protected readonly amount = new FormControl<number | null>(null, [\n Validators.required,\n Validators.min(0.01),\n ]);\n protected readonly counterpartyName = new FormControl<string>('', {\n nonNullable: true,\n });\n protected readonly note = new FormControl<string>('', { nonNullable: true });\n\n protected readonly form = new FormGroup({\n direction: this.direction,\n currency: this.currency,\n amount: this.amount,\n counterpartyName: this.counterpartyName,\n note: this.note,\n });\n\n protected readonly currencies: CurrencyCode[] = ['EUR', 'USD'];\n\n constructor() {\n super();\n this.$defaultBackUrlSpacePath.set('debts');\n this.route.queryParamMap.pipe(first(), takeUntilDestroyed()).subscribe({\n next: (params) => {\n const dir = params.get('direction');\n if (dir === 'lend' || dir === 'borrow') {\n this.direction.setValue(dir);\n }\n const contactID = params.get('contactID');\n if (contactID) {\n this.prefilledContactID = contactID;\n // Prefill the name field from the known balance so the user sees who\n // they're recording against even before the contactus picker loads.\n this.spaceIDChanged$.pipe(first()).subscribe((spaceID) => {\n this.debtusService\n .getContactBalance(spaceID ?? '', contactID)\n .pipe(first())\n .subscribe((c) => this.counterpartyName.setValue(c.title));\n });\n }\n },\n });\n }\n\n protected onContactChanged(contact: IContactContext | undefined): void {\n this.$pickedContact.set(contact);\n if (contact) {\n // A picked contact supersedes a typed name / prefilled id.\n this.prefilledContactID = undefined;\n this.counterpartyName.setValue(contact.brief?.title ?? '');\n }\n }\n\n private resolveCounterparty(): { contactID: string; title: string } | null {\n const picked = this.$pickedContact();\n if (picked) {\n return { contactID: picked.id, title: picked.brief?.title ?? picked.id };\n }\n if (this.prefilledContactID) {\n return {\n contactID: this.prefilledContactID,\n title: this.counterpartyName.value,\n };\n }\n // Fable refactoring: the \"new counterparty by name\" path is disabled —\n // the assumption that \"the backend create flow resolves/creates it\" was\n // wrong: POST create-transfer validation requires toContactID/fromContactID\n // (facade4debtus CreateTransferRequest.Validate), so an empty contactID\n // always 400s. Until a create-contact-then-transfer flow is wired, users\n // must pick an existing space contact (the picker above supports adding\n // one). Original branch kept per the no-delete policy:\n // const name = this.counterpartyName.value.trim();\n // if (name) {\n // // New counterparty by name (mirrors the bot's \"new counterparty\"\n // // step). No contactID yet — the backend create flow\n // // resolves/creates it.\n // return { contactID: '', title: name };\n // }\n return null;\n }\n\n protected submit(): void {\n this.form.markAllAsTouched();\n const amount = this.amount.value;\n if (!amount || amount <= 0) {\n return;\n }\n const counterparty = this.resolveCounterparty();\n if (!counterparty) {\n this.showToast(\n 'Pick a counterparty contact. To record against someone new, add them as a space contact first.',\n 'danger',\n );\n return;\n }\n const spaceID = this.$spaceID();\n if (!spaceID) {\n return;\n }\n const request: ICreateTransferRequest = {\n spaceID,\n direction: this.direction.value,\n amount: { currency: this.currency.value, value: amount },\n contactID: counterparty.contactID,\n contactTitle: counterparty.title,\n note: this.note.value.trim() || undefined,\n counterpartySpaceID: this.$pickedContact()?.space?.id,\n };\n\n this.$submitting.set(true);\n this.debtusService.createTransfer(request).subscribe({\n next: (resp) => {\n this.$submitting.set(false);\n // Navigation default: go to the created transfer's detail, replaceUrl\n // so Back doesn't reopen the filled form. The created transfer is\n // handed over via router state — transfer reads are not wired to the\n // live backend yet, so the details page must not fabricate a receipt\n // from fixtures.\n this.spaceNav.navigateForwardToSpacePage(\n this.space,\n `transfer/${resp.transfer.id}`,\n { replaceUrl: true, state: { transfer: resp.transfer } },\n );\n },\n error: (err) => {\n this.$submitting.set(false);\n this.errorLogger.logError(err, 'Failed to create transfer', {\n show: false,\n });\n this.showToast('Failed to record transfer. Please try again.', 'danger');\n },\n });\n }\n\n private async showToast(message: string, color: string): Promise<void> {\n const toast = await this.toastController.create({\n message,\n duration: 3000,\n color,\n });\n await toast.present();\n }\n}\n","<ion-header>\n <ion-toolbar color=\"light\">\n <ion-buttons slot=\"start\">\n <ion-back-button [defaultHref]=\"$defaultBackUrl()\" />\n </ion-buttons>\n <ion-title>New transfer</ion-title>\n </ion-toolbar>\n</ion-header>\n\n<ion-content class=\"cardy\">\n <form [formGroup]=\"form\" (ngSubmit)=\"submit()\">\n <ion-card>\n <ion-card-content>\n <ion-segment [formControl]=\"direction\">\n <ion-segment-button value=\"lend\">\n <ion-label>I lent</ion-label>\n </ion-segment-button>\n <ion-segment-button value=\"borrow\">\n <ion-label>I borrowed</ion-label>\n </ion-segment-button>\n </ion-segment>\n <ion-note class=\"ion-padding-start\" color=\"medium\">\n {{\n direction.value === 'lend'\n ? 'You gave money — they owe you.'\n : 'You got money — you owe them.'\n }}\n </ion-note>\n </ion-card-content>\n </ion-card>\n\n <ion-card>\n <ion-card-content>\n <!-- Reuse the contactus space-contact picker. The counterparty is a\n real contactus contact, not a debtus-private person. -->\n <sneat-contact-input\n [space]=\"space\"\n label=\"Counterparty\"\n [canChangeContact]=\"true\"\n (contactChange)=\"onContactChanged($event)\"\n />\n @if (prefilledContactID) {\n <ion-note class=\"ion-padding-start\" color=\"medium\">\n Recording against\n {{ counterpartyName.value || prefilledContactID }}\n </ion-note>\n }\n <!-- Fable refactoring: the \"Or new counterparty name\" free-text input\n is disabled — a name-only counterparty always 400s server-side\n (POST create-transfer requires a real contact id; see\n resolveCounterparty() in the component). Re-enable once a\n create-contact-then-transfer flow exists. Kept per the no-delete\n policy:\n <ion-item>\n <ion-label position=\"stacked\">\n Or new counterparty name\n </ion-label>\n <ion-input\n [formControl]=\"counterpartyName\"\n placeholder=\"e.g. Alex\"\n autocapitalize=\"words\"\n />\n </ion-item>\n -->\n </ion-card-content>\n </ion-card>\n\n <ion-card>\n <ion-card-content>\n <ion-item>\n <ion-label>Currency</ion-label>\n <ion-select [formControl]=\"currency\" interface=\"popover\">\n @for (c of currencies; track c) {\n <ion-select-option [value]=\"c\">{{ c }}</ion-select-option>\n }\n </ion-select>\n </ion-item>\n <ion-item>\n <ion-label position=\"stacked\">Amount</ion-label>\n <ion-input\n type=\"number\"\n inputmode=\"decimal\"\n [formControl]=\"amount\"\n placeholder=\"0.00\"\n />\n </ion-item>\n @if (amount.touched && amount.invalid) {\n <ion-note color=\"danger\" class=\"ion-padding-start\">\n Enter an amount greater than zero.\n </ion-note>\n }\n <ion-item>\n <ion-label position=\"stacked\">Note (optional)</ion-label>\n <ion-textarea\n [formControl]=\"note\"\n placeholder=\"What is it for?\"\n [autoGrow]=\"true\"\n />\n </ion-item>\n </ion-card-content>\n </ion-card>\n\n <div class=\"ion-padding\">\n <ion-button\n expand=\"block\"\n type=\"submit\"\n [disabled]=\"$submitting() || form.invalid\"\n >\n @if ($submitting()) {\n <ion-spinner name=\"dots\" slot=\"start\" />\n Saving…\n } @else {\n Record transfer\n }\n </ion-button>\n </div>\n </form>\n</ion-content>\n"],"names":[],"mappings":";;;;;;;;;;;;AA6CA;AACA;AACA;AACA;AAgCM,MAAO,wBAAyB,SAAQ,sBAAsB,CAAA;AACjD,IAAA,aAAa,GAAG,MAAM,CAAC,cAAc,CAAC;AACtC,IAAA,eAAe,GAAG,MAAM,CAAC,eAAe,CAAC;IAEvC,WAAW,GAAG,MAAM,CAAC,KAAK;oFAAC;IAC3B,cAAc,GAAG,MAAM,CACxC,SAAS;uFACV;;AAES,IAAA,kBAAkB;AAET,IAAA,SAAS,GAAG,IAAI,WAAW,CAAgB,MAAM,EAAE;AACpE,QAAA,WAAW,EAAE,IAAI;AAClB,KAAA,CAAC;AACiB,IAAA,QAAQ,GAAG,IAAI,WAAW,CAAe,KAAK,EAAE;AACjE,QAAA,WAAW,EAAE,IAAI;AAClB,KAAA,CAAC;AACiB,IAAA,MAAM,GAAG,IAAI,WAAW,CAAgB,IAAI,EAAE;AAC/D,QAAA,UAAU,CAAC,QAAQ;AACnB,QAAA,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC;AACrB,KAAA,CAAC;AACiB,IAAA,gBAAgB,GAAG,IAAI,WAAW,CAAS,EAAE,EAAE;AAChE,QAAA,WAAW,EAAE,IAAI;AAClB,KAAA,CAAC;AACiB,IAAA,IAAI,GAAG,IAAI,WAAW,CAAS,EAAE,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;IAEzD,IAAI,G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EAAA,EAAA,EAAA,IAAA,EAAA,WAAA,EAAA,IAAA,EACT,OAAO,EAAA,QAAA,EAAA,UAAA,EAAA,MAAA,EAAA,CAAA,OAAA,EAAA,MAAA,CAAA,EAAA,EAAA,EAAA,IAAA,EAAA,WAAA,EAAA,IAAA,EACP,UAAU,yGACV,qBAAqB,EAAA,QAAA,EAAA,qBAAA,EAAA,MAAA,EAAA,CAAA,OAAA,EAAA,UAAA,EAAA,kBAAA,EAAA,UAAA,EAAA,UAAA,EAAA,OAAA,EAAA,eAAA,EAAA,aAAA,EAAA,aAAA,EAAA,UAAA,EAAA,YAAA,EAAA,YAAA,EAAA,eAAA,EAAA,UAAA,EAAA,SAAA,CAAA,EAAA,OAAA,EAAA,CAAA,eAAA,CAAA,EAAA,CAAA,EAAA,CAAA;;2FAOZ,wBAAwB,EAAA,UAAA,EAAA,CAAA;kBA/BpC,SAAS;AACE,YAAA,IAAA,EAAA,CAAA,EAAA,QAAA,EAAA,gCAAgC,EAAA,OAAA,EAEjC;wBACP,mBAAmB;wBACnB,SAAS;wBACT,UAAU;wBACV,UAAU;wBACV,aAAa;wBACb,QAAQ;wBACR,UAAU;wBACV,OAAO;wBACP,cAAc;wBACd,OAAO;wBACP,QAAQ;wBACR,QAAQ;wBACR,WAAW;wBACX,SAAS;wBACT,eAAe;wBACf,UAAU;wBACV,gBAAgB;wBAChB,SAAS;wBACT,OAAO;wBACP,UAAU;wBACV,qBAAqB;qBACtB,EAAA,SAAA,EACU;AACT,wBAAA,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,0BAA0B,EAAE;wBAC5D,wBAAwB;AACzB,qBAAA,EAAA,QAAA,EAAA,s2HAAA,EAAA;;;;;"}
@@ -0,0 +1,163 @@
1
+ import * as i0 from '@angular/core';
2
+ import { inject, signal, Component } from '@angular/core';
3
+ import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
4
+ import * as i1 from '@angular/forms';
5
+ import { FormControl, Validators, FormGroup, ReactiveFormsModule } from '@angular/forms';
6
+ import { ToastController, IonHeader, IonToolbar, IonButtons, IonBackButton, IonTitle, IonContent, IonCard, IonCardHeader, IonCardTitle, IonCardContent, IonItem, IonLabel, IonInput, IonSelect, IonSelectOption, IonButton, IonNote, IonSpinner } from '@ionic/angular';
7
+ import { DemoDataBannerComponent } from './sneat-extension-debtus-ui.mjs';
8
+ import { DEBTUS_SERVICE, formatSignedBalance, round2, settleDirectionForBalance } from '@sneat/extension-debtus-contract';
9
+ import { SpacePageBaseComponent, SpaceComponentBaseParams } from '@sneat/space-components';
10
+ import { ClassName } from '@sneat/ui';
11
+ import { combineLatest, switchMap } from 'rxjs';
12
+
13
+ // Settle up — records a settling (return) transfer against a counterparty
14
+ // balance. Mirrors the bot's "Returned fully/partially" flow: the backend nets
15
+ // the return against outstanding transfers.
16
+ class SettleUpPageComponent extends SpacePageBaseComponent {
17
+ debtusService = inject(DEBTUS_SERVICE);
18
+ toastController = inject(ToastController);
19
+ $loading = signal(true, /* @ts-ignore */
20
+ ...(ngDevMode ? [{ debugName: "$loading" }] : /* istanbul ignore next */ []));
21
+ $submitting = signal(false, /* @ts-ignore */
22
+ ...(ngDevMode ? [{ debugName: "$submitting" }] : /* istanbul ignore next */ []));
23
+ $error = signal(undefined, /* @ts-ignore */
24
+ ...(ngDevMode ? [{ debugName: "$error" }] : /* istanbul ignore next */ []));
25
+ $contact = signal(undefined, /* @ts-ignore */
26
+ ...(ngDevMode ? [{ debugName: "$contact" }] : /* istanbul ignore next */ []));
27
+ contactID = '';
28
+ formatSignedBalance = formatSignedBalance;
29
+ currency = new FormControl('EUR', {
30
+ nonNullable: true,
31
+ });
32
+ amount = new FormControl(null, [
33
+ Validators.required,
34
+ Validators.min(0.01),
35
+ ]);
36
+ form = new FormGroup({
37
+ currency: this.currency,
38
+ amount: this.amount,
39
+ });
40
+ currencies = ['EUR', 'USD'];
41
+ constructor() {
42
+ super();
43
+ combineLatest([this.spaceIDChanged$, this.route.queryParamMap])
44
+ .pipe(switchMap(([spaceID, params]) => {
45
+ this.contactID = params.get('contactID') ?? '';
46
+ // Back should return to the contact detail this settle-up was
47
+ // opened from, not a fixed page.
48
+ this.$defaultBackUrlSpacePath.set(`debtus-contact/${this.contactID}`);
49
+ this.$loading.set(true);
50
+ this.$error.set(undefined);
51
+ return this.debtusService.getContactBalance(spaceID ?? '', this.contactID);
52
+ }), takeUntilDestroyed())
53
+ .subscribe({
54
+ next: (contact) => {
55
+ this.$contact.set(contact);
56
+ // Default the settle amount/currency to the outstanding balance.
57
+ const entries = Object.entries(contact.balance).filter(([, v]) => v && round2(v) !== 0);
58
+ if (entries.length) {
59
+ const [cur, val] = entries[0];
60
+ this.currency.setValue(cur);
61
+ this.amount.setValue(Math.abs(round2(val)));
62
+ }
63
+ this.$loading.set(false);
64
+ },
65
+ error: (err) => {
66
+ this.$loading.set(false);
67
+ this.$error.set('Failed to load contact');
68
+ this.errorLogger.logError(err, 'Failed to load contact for settle');
69
+ },
70
+ });
71
+ }
72
+ submit() {
73
+ this.form.markAllAsTouched();
74
+ const amount = this.amount.value;
75
+ if (!amount || amount <= 0) {
76
+ return;
77
+ }
78
+ const spaceID = this.$spaceID();
79
+ if (!spaceID || !this.contactID) {
80
+ return;
81
+ }
82
+ // Mirrors the bot's "Is it returned in full?" confirmation step
83
+ // (askIfReturnedInFull in transfer_return.go) before recording the
84
+ // settling transfer — this is a financial record, not a reversible
85
+ // toggle, so it needs an explicit yes.
86
+ const title = this.$contact()?.title ?? 'this contact';
87
+ if (!confirm(`Record settlement of ${this.currency.value} ${amount.toFixed(2)} with ${title}?`)) {
88
+ return;
89
+ }
90
+ // This page shows the signed balance, so it (not the service) derives the
91
+ // direction that moves that balance toward zero for the chosen currency.
92
+ // Deriving it downstream from demo fixtures recorded the wrong direction
93
+ // for contacts the fixtures don't know about.
94
+ const balanceValue = this.$contact()?.balance[this.currency.value] ?? 0;
95
+ const request = {
96
+ spaceID,
97
+ contactID: this.contactID,
98
+ contactTitle: this.$contact()?.title,
99
+ amount: { currency: this.currency.value, value: amount },
100
+ counterpartySpaceID: this.$contact()?.counterpartySpaceID,
101
+ direction: settleDirectionForBalance(balanceValue),
102
+ };
103
+ this.$submitting.set(true);
104
+ this.debtusService.settleUp(request).subscribe({
105
+ next: (resp) => {
106
+ this.$submitting.set(false);
107
+ // Hand the created transfer to the details page via router state —
108
+ // transfer reads are not wired to the live backend yet, so the details
109
+ // page must not fabricate a receipt from fixtures.
110
+ this.spaceNav.navigateForwardToSpacePage(this.space, `transfer/${resp.transfer.id}`, { replaceUrl: true, state: { transfer: resp.transfer } });
111
+ },
112
+ error: (err) => {
113
+ this.$submitting.set(false);
114
+ this.errorLogger.logError(err, 'Failed to settle up');
115
+ this.showToast('Failed to settle up. Please try again.');
116
+ },
117
+ });
118
+ }
119
+ async showToast(message) {
120
+ const toast = await this.toastController.create({
121
+ message,
122
+ duration: 3000,
123
+ color: 'danger',
124
+ });
125
+ await toast.present();
126
+ }
127
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: SettleUpPageComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
128
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.3", type: SettleUpPageComponent, isStandalone: true, selector: "sneat-debtus-settle-up-page", providers: [
129
+ { provide: ClassName, useValue: 'SettleUpPageComponent' },
130
+ SpaceComponentBaseParams,
131
+ ], usesInheritance: true, ngImport: i0, template: "<ion-header>\n <ion-toolbar color=\"light\">\n <ion-buttons slot=\"start\">\n <ion-back-button [defaultHref]=\"$defaultBackUrl()\" />\n </ion-buttons>\n <ion-title>Settle up</ion-title>\n </ion-toolbar>\n</ion-header>\n\n<ion-content class=\"cardy\">\n <!-- Reads on this page are still demo fixtures (see DebtusService). -->\n <sneat-debtus-demo-data-banner />\n\n @if ($loading()) {\n <div class=\"ion-padding ion-text-center\">\n <ion-spinner name=\"dots\" />\n </div>\n } @else if ($error()) {\n <div class=\"ion-padding\">\n <ion-note color=\"danger\">{{ $error() }}</ion-note>\n </div>\n } @else {\n <ion-card>\n <ion-card-header>\n <ion-card-title>{{ $contact()?.title ?? 'Contact' }}</ion-card-title>\n </ion-card-header>\n <ion-card-content>\n Current balance: {{ formatSignedBalance($contact()?.balance ?? {}) }}\n </ion-card-content>\n </ion-card>\n\n <form [formGroup]=\"form\" (ngSubmit)=\"submit()\">\n <ion-card>\n <ion-card-content>\n <ion-item>\n <ion-label>Currency</ion-label>\n <ion-select [formControl]=\"currency\" interface=\"popover\">\n @for (c of currencies; track c) {\n <ion-select-option [value]=\"c\">{{ c }}</ion-select-option>\n }\n </ion-select>\n </ion-item>\n <ion-item>\n <ion-label position=\"stacked\">Amount to settle</ion-label>\n <ion-input\n type=\"number\"\n inputmode=\"decimal\"\n [formControl]=\"amount\"\n placeholder=\"0.00\"\n />\n </ion-item>\n @if (amount.touched && amount.invalid) {\n <ion-note color=\"danger\" class=\"ion-padding-start\">\n Enter an amount greater than zero.\n </ion-note>\n }\n <ion-note class=\"ion-padding\" color=\"medium\">\n Records a settling (return) transfer. The balance is netted against\n outstanding transfers.\n </ion-note>\n </ion-card-content>\n </ion-card>\n\n <div class=\"ion-padding\">\n <ion-button\n expand=\"block\"\n color=\"success\"\n type=\"submit\"\n [disabled]=\"$submitting() || form.invalid\"\n >\n @if ($submitting()) {\n <ion-spinner name=\"dots\" slot=\"start\" />\n Settling\u2026\n } @else {\n Record settlement\n }\n </ion-button>\n </div>\n </form>\n }\n</ion-content>\n", dependencies: [{ kind: "component", type: DemoDataBannerComponent, selector: "sneat-debtus-demo-data-banner" }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i1.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],[formArray],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i1.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "directive", type: i1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "component", type: IonHeader, selector: "ion-header", inputs: ["collapse", "mode", "translucent"] }, { kind: "component", type: IonToolbar, selector: "ion-toolbar", inputs: ["color", "mode"] }, { kind: "component", type: IonButtons, selector: "ion-buttons", inputs: ["collapse"] }, { kind: "component", type: IonBackButton, selector: "ion-back-button" }, { kind: "component", type: IonTitle, selector: "ion-title", inputs: ["color", "size"] }, { kind: "component", type: IonContent, selector: "ion-content", inputs: ["color", "fixedSlotPlacement", "forceOverscroll", "fullscreen", "scrollEvents", "scrollX", "scrollY"], outputs: ["ionScrollStart", "ionScroll", "ionScrollEnd"] }, { kind: "component", type: IonCard, selector: "ion-card", inputs: ["button", "color", "disabled", "download", "href", "mode", "rel", "routerAnimation", "routerDirection", "target", "type"] }, { kind: "component", type: IonCardHeader, selector: "ion-card-header", inputs: ["color", "mode", "translucent"] }, { kind: "component", type: IonCardTitle, selector: "ion-card-title", inputs: ["color", "mode"] }, { kind: "component", type: IonCardContent, selector: "ion-card-content", inputs: ["mode"] }, { kind: "component", type: IonItem, selector: "ion-item", inputs: ["button", "color", "detail", "detailIcon", "disabled", "download", "href", "lines", "mode", "rel", "routerAnimation", "routerDirection", "target", "type"] }, { kind: "component", type: IonLabel, selector: "ion-label", inputs: ["color", "mode", "position"] }, { kind: "component", type: IonInput, selector: "ion-input", inputs: ["accept", "autocapitalize", "autocomplete", "autocorrect", "autofocus", "clearInput", "clearOnEdit", "color", "counter", "counterFormatter", "debounce", "disabled", "enterkeyhint", "errorText", "fill", "helperText", "inputmode", "label", "labelPlacement", "max", "maxlength", "min", "minlength", "mode", "multiple", "name", "pattern", "placeholder", "readonly", "required", "shape", "size", "spellcheck", "step", "type", "value"] }, { kind: "component", type: IonSelect, selector: "ion-select", inputs: ["cancelText", "color", "compareWith", "disabled", "errorText", "expandedIcon", "fill", "helperText", "interface", "interfaceOptions", "justify", "label", "labelPlacement", "mode", "multiple", "name", "okText", "placeholder", "selectedText", "shape", "toggleIcon", "value"] }, { kind: "component", type: IonSelectOption, selector: "ion-select-option", inputs: ["description", "disabled", "justify", "labelPlacement", "mode", "value"] }, { kind: "component", type: IonButton, selector: "ion-button", inputs: ["buttonType", "color", "disabled", "download", "expand", "fill", "form", "href", "mode", "rel", "routerAnimation", "routerDirection", "shape", "size", "strong", "target", "type"], outputs: ["ionFocus", "ionBlur"] }, { kind: "component", type: IonNote, selector: "ion-note", inputs: ["color", "mode"] }, { kind: "component", type: IonSpinner, selector: "ion-spinner", inputs: ["color", "duration", "name", "paused"] }] });
132
+ }
133
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: SettleUpPageComponent, decorators: [{
134
+ type: Component,
135
+ args: [{ selector: 'sneat-debtus-settle-up-page', imports: [
136
+ DemoDataBannerComponent,
137
+ ReactiveFormsModule,
138
+ IonHeader,
139
+ IonToolbar,
140
+ IonButtons,
141
+ IonBackButton,
142
+ IonTitle,
143
+ IonContent,
144
+ IonCard,
145
+ IonCardHeader,
146
+ IonCardTitle,
147
+ IonCardContent,
148
+ IonItem,
149
+ IonLabel,
150
+ IonInput,
151
+ IonSelect,
152
+ IonSelectOption,
153
+ IonButton,
154
+ IonNote,
155
+ IonSpinner,
156
+ ], providers: [
157
+ { provide: ClassName, useValue: 'SettleUpPageComponent' },
158
+ SpaceComponentBaseParams,
159
+ ], template: "<ion-header>\n <ion-toolbar color=\"light\">\n <ion-buttons slot=\"start\">\n <ion-back-button [defaultHref]=\"$defaultBackUrl()\" />\n </ion-buttons>\n <ion-title>Settle up</ion-title>\n </ion-toolbar>\n</ion-header>\n\n<ion-content class=\"cardy\">\n <!-- Reads on this page are still demo fixtures (see DebtusService). -->\n <sneat-debtus-demo-data-banner />\n\n @if ($loading()) {\n <div class=\"ion-padding ion-text-center\">\n <ion-spinner name=\"dots\" />\n </div>\n } @else if ($error()) {\n <div class=\"ion-padding\">\n <ion-note color=\"danger\">{{ $error() }}</ion-note>\n </div>\n } @else {\n <ion-card>\n <ion-card-header>\n <ion-card-title>{{ $contact()?.title ?? 'Contact' }}</ion-card-title>\n </ion-card-header>\n <ion-card-content>\n Current balance: {{ formatSignedBalance($contact()?.balance ?? {}) }}\n </ion-card-content>\n </ion-card>\n\n <form [formGroup]=\"form\" (ngSubmit)=\"submit()\">\n <ion-card>\n <ion-card-content>\n <ion-item>\n <ion-label>Currency</ion-label>\n <ion-select [formControl]=\"currency\" interface=\"popover\">\n @for (c of currencies; track c) {\n <ion-select-option [value]=\"c\">{{ c }}</ion-select-option>\n }\n </ion-select>\n </ion-item>\n <ion-item>\n <ion-label position=\"stacked\">Amount to settle</ion-label>\n <ion-input\n type=\"number\"\n inputmode=\"decimal\"\n [formControl]=\"amount\"\n placeholder=\"0.00\"\n />\n </ion-item>\n @if (amount.touched && amount.invalid) {\n <ion-note color=\"danger\" class=\"ion-padding-start\">\n Enter an amount greater than zero.\n </ion-note>\n }\n <ion-note class=\"ion-padding\" color=\"medium\">\n Records a settling (return) transfer. The balance is netted against\n outstanding transfers.\n </ion-note>\n </ion-card-content>\n </ion-card>\n\n <div class=\"ion-padding\">\n <ion-button\n expand=\"block\"\n color=\"success\"\n type=\"submit\"\n [disabled]=\"$submitting() || form.invalid\"\n >\n @if ($submitting()) {\n <ion-spinner name=\"dots\" slot=\"start\" />\n Settling\u2026\n } @else {\n Record settlement\n }\n </ion-button>\n </div>\n </form>\n }\n</ion-content>\n" }]
160
+ }], ctorParameters: () => [] });
161
+
162
+ export { SettleUpPageComponent };
163
+ //# sourceMappingURL=sneat-extension-debtus-ui-settle-up-page.component-CUoNSuAE.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sneat-extension-debtus-ui-settle-up-page.component-CUoNSuAE.mjs","sources":["../../../../../../libs/extensions/debtus/ui/src/lib/pages/settle-up/settle-up-page.component.ts","../../../../../../libs/extensions/debtus/ui/src/lib/pages/settle-up/settle-up-page.component.html"],"sourcesContent":["import { Component, inject, signal } from '@angular/core';\nimport { takeUntilDestroyed } from '@angular/core/rxjs-interop';\nimport {\n FormControl,\n FormGroup,\n ReactiveFormsModule,\n Validators,\n} from '@angular/forms';\nimport {\n IonBackButton,\n IonButton,\n IonButtons,\n IonCard,\n IonCardContent,\n IonCardHeader,\n IonCardTitle,\n IonContent,\n IonHeader,\n IonInput,\n IonItem,\n IonLabel,\n IonNote,\n IonSelect,\n IonSelectOption,\n IonSpinner,\n IonTitle,\n IonToolbar,\n ToastController,\n} from '@ionic/angular';\nimport { DemoDataBannerComponent } from '../../components/demo-data-banner/demo-data-banner.component';\nimport {\n CurrencyCode,\n DEBTUS_SERVICE,\n IContactBalance,\n ISettleUpRequest,\n formatSignedBalance,\n round2,\n settleDirectionForBalance,\n} from '@sneat/extension-debtus-contract';\nimport {\n SpaceComponentBaseParams,\n SpacePageBaseComponent,\n} from '@sneat/space-components';\nimport { ClassName } from '@sneat/ui';\nimport { combineLatest, switchMap } from 'rxjs';\n\n// Settle up — records a settling (return) transfer against a counterparty\n// balance. Mirrors the bot's \"Returned fully/partially\" flow: the backend nets\n// the return against outstanding transfers.\n@Component({\n selector: 'sneat-debtus-settle-up-page',\n templateUrl: './settle-up-page.component.html',\n imports: [\n DemoDataBannerComponent,\n ReactiveFormsModule,\n IonHeader,\n IonToolbar,\n IonButtons,\n IonBackButton,\n IonTitle,\n IonContent,\n IonCard,\n IonCardHeader,\n IonCardTitle,\n IonCardContent,\n IonItem,\n IonLabel,\n IonInput,\n IonSelect,\n IonSelectOption,\n IonButton,\n IonNote,\n IonSpinner,\n ],\n providers: [\n { provide: ClassName, useValue: 'SettleUpPageComponent' },\n SpaceComponentBaseParams,\n ],\n})\nexport class SettleUpPageComponent extends SpacePageBaseComponent {\n private readonly debtusService = inject(DEBTUS_SERVICE);\n private readonly toastController = inject(ToastController);\n\n protected readonly $loading = signal(true);\n protected readonly $submitting = signal(false);\n protected readonly $error = signal<string | undefined>(undefined);\n protected readonly $contact = signal<IContactBalance | undefined>(undefined);\n protected contactID = '';\n\n protected readonly formatSignedBalance = formatSignedBalance;\n\n protected readonly currency = new FormControl<CurrencyCode>('EUR', {\n nonNullable: true,\n });\n protected readonly amount = new FormControl<number | null>(null, [\n Validators.required,\n Validators.min(0.01),\n ]);\n protected readonly form = new FormGroup({\n currency: this.currency,\n amount: this.amount,\n });\n\n protected readonly currencies: CurrencyCode[] = ['EUR', 'USD'];\n\n constructor() {\n super();\n combineLatest([this.spaceIDChanged$, this.route.queryParamMap])\n .pipe(\n switchMap(([spaceID, params]) => {\n this.contactID = params.get('contactID') ?? '';\n // Back should return to the contact detail this settle-up was\n // opened from, not a fixed page.\n this.$defaultBackUrlSpacePath.set(\n `debtus-contact/${this.contactID}`,\n );\n this.$loading.set(true);\n this.$error.set(undefined);\n return this.debtusService.getContactBalance(\n spaceID ?? '',\n this.contactID,\n );\n }),\n takeUntilDestroyed(),\n )\n .subscribe({\n next: (contact) => {\n this.$contact.set(contact);\n // Default the settle amount/currency to the outstanding balance.\n const entries = Object.entries(contact.balance).filter(\n ([, v]) => v && round2(v) !== 0,\n );\n if (entries.length) {\n const [cur, val] = entries[0];\n this.currency.setValue(cur as CurrencyCode);\n this.amount.setValue(Math.abs(round2(val as number)));\n }\n this.$loading.set(false);\n },\n error: (err) => {\n this.$loading.set(false);\n this.$error.set('Failed to load contact');\n this.errorLogger.logError(err, 'Failed to load contact for settle');\n },\n });\n }\n\n protected submit(): void {\n this.form.markAllAsTouched();\n const amount = this.amount.value;\n if (!amount || amount <= 0) {\n return;\n }\n const spaceID = this.$spaceID();\n if (!spaceID || !this.contactID) {\n return;\n }\n // Mirrors the bot's \"Is it returned in full?\" confirmation step\n // (askIfReturnedInFull in transfer_return.go) before recording the\n // settling transfer — this is a financial record, not a reversible\n // toggle, so it needs an explicit yes.\n const title = this.$contact()?.title ?? 'this contact';\n if (\n !confirm(\n `Record settlement of ${this.currency.value} ${amount.toFixed(2)} with ${title}?`,\n )\n ) {\n return;\n }\n // This page shows the signed balance, so it (not the service) derives the\n // direction that moves that balance toward zero for the chosen currency.\n // Deriving it downstream from demo fixtures recorded the wrong direction\n // for contacts the fixtures don't know about.\n const balanceValue = this.$contact()?.balance[this.currency.value] ?? 0;\n const request: ISettleUpRequest = {\n spaceID,\n contactID: this.contactID,\n contactTitle: this.$contact()?.title,\n amount: { currency: this.currency.value, value: amount },\n counterpartySpaceID: this.$contact()?.counterpartySpaceID,\n direction: settleDirectionForBalance(balanceValue),\n };\n this.$submitting.set(true);\n this.debtusService.settleUp(request).subscribe({\n next: (resp) => {\n this.$submitting.set(false);\n // Hand the created transfer to the details page via router state —\n // transfer reads are not wired to the live backend yet, so the details\n // page must not fabricate a receipt from fixtures.\n this.spaceNav.navigateForwardToSpacePage(\n this.space,\n `transfer/${resp.transfer.id}`,\n { replaceUrl: true, state: { transfer: resp.transfer } },\n );\n },\n error: (err) => {\n this.$submitting.set(false);\n this.errorLogger.logError(err, 'Failed to settle up');\n this.showToast('Failed to settle up. Please try again.');\n },\n });\n }\n\n private async showToast(message: string): Promise<void> {\n const toast = await this.toastController.create({\n message,\n duration: 3000,\n color: 'danger',\n });\n await toast.present();\n }\n}\n","<ion-header>\n <ion-toolbar color=\"light\">\n <ion-buttons slot=\"start\">\n <ion-back-button [defaultHref]=\"$defaultBackUrl()\" />\n </ion-buttons>\n <ion-title>Settle up</ion-title>\n </ion-toolbar>\n</ion-header>\n\n<ion-content class=\"cardy\">\n <!-- Reads on this page are still demo fixtures (see DebtusService). -->\n <sneat-debtus-demo-data-banner />\n\n @if ($loading()) {\n <div class=\"ion-padding ion-text-center\">\n <ion-spinner name=\"dots\" />\n </div>\n } @else if ($error()) {\n <div class=\"ion-padding\">\n <ion-note color=\"danger\">{{ $error() }}</ion-note>\n </div>\n } @else {\n <ion-card>\n <ion-card-header>\n <ion-card-title>{{ $contact()?.title ?? 'Contact' }}</ion-card-title>\n </ion-card-header>\n <ion-card-content>\n Current balance: {{ formatSignedBalance($contact()?.balance ?? {}) }}\n </ion-card-content>\n </ion-card>\n\n <form [formGroup]=\"form\" (ngSubmit)=\"submit()\">\n <ion-card>\n <ion-card-content>\n <ion-item>\n <ion-label>Currency</ion-label>\n <ion-select [formControl]=\"currency\" interface=\"popover\">\n @for (c of currencies; track c) {\n <ion-select-option [value]=\"c\">{{ c }}</ion-select-option>\n }\n </ion-select>\n </ion-item>\n <ion-item>\n <ion-label position=\"stacked\">Amount to settle</ion-label>\n <ion-input\n type=\"number\"\n inputmode=\"decimal\"\n [formControl]=\"amount\"\n placeholder=\"0.00\"\n />\n </ion-item>\n @if (amount.touched && amount.invalid) {\n <ion-note color=\"danger\" class=\"ion-padding-start\">\n Enter an amount greater than zero.\n </ion-note>\n }\n <ion-note class=\"ion-padding\" color=\"medium\">\n Records a settling (return) transfer. The balance is netted against\n outstanding transfers.\n </ion-note>\n </ion-card-content>\n </ion-card>\n\n <div class=\"ion-padding\">\n <ion-button\n expand=\"block\"\n color=\"success\"\n type=\"submit\"\n [disabled]=\"$submitting() || form.invalid\"\n >\n @if ($submitting()) {\n <ion-spinner name=\"dots\" slot=\"start\" />\n Settling…\n } @else {\n Record settlement\n }\n </ion-button>\n </div>\n </form>\n }\n</ion-content>\n"],"names":[],"mappings":";;;;;;;;;;;;AA8CA;AACA;AACA;AA+BM,MAAO,qBAAsB,SAAQ,sBAAsB,CAAA;AAC9C,IAAA,aAAa,GAAG,MAAM,CAAC,cAAc,CAAC;AACtC,IAAA,eAAe,GAAG,MAAM,CAAC,eAAe,CAAC;IAEvC,QAAQ,GAAG,MAAM,CAAC,IAAI;iFAAC;IACvB,WAAW,GAAG,MAAM,CAAC,KAAK;oFAAC;IAC3B,MAAM,GAAG,MAAM,CAAqB,SAAS;+EAAC;IAC9C,QAAQ,GAAG,MAAM,C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