@sfinges/sf-solicitud 0.0.0-stage → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +100 -2
- package/fesm2022/sfinges-sf-solicitud.mjs +689 -0
- package/fesm2022/sfinges-sf-solicitud.mjs.map +1 -0
- package/index.d.ts +5 -0
- package/lib/components/application-person/application-person.component.d.ts +48 -0
- package/lib/components/debt-buyouts/debt-buyouts.component.d.ts +60 -0
- package/lib/components/line-simulator/line-simulator.component.d.ts +147 -0
- package/lib/gateways/application-person.port.d.ts +20 -0
- package/lib/models/application.models.d.ts +162 -0
- package/lib/utils/format.util.d.ts +17 -0
- package/package.json +28 -3
- package/public-api.d.ts +5 -0
|
@@ -0,0 +1,689 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { InjectionToken, inject, DestroyRef, input, computed, signal, effect, untracked, Component, output } from '@angular/core';
|
|
3
|
+
import * as i1 from '@angular/common';
|
|
4
|
+
import { registerLocaleData, CommonModule } from '@angular/common';
|
|
5
|
+
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
6
|
+
import * as i2 from 'primeng/button';
|
|
7
|
+
import { ButtonModule } from 'primeng/button';
|
|
8
|
+
import * as i3 from 'primeng/card';
|
|
9
|
+
import { CardModule } from 'primeng/card';
|
|
10
|
+
import * as i4 from 'primeng/message';
|
|
11
|
+
import { MessageModule } from 'primeng/message';
|
|
12
|
+
import * as i5 from 'primeng/skeleton';
|
|
13
|
+
import { SkeletonModule } from 'primeng/skeleton';
|
|
14
|
+
import * as i6 from 'primeng/table';
|
|
15
|
+
import { TableModule } from 'primeng/table';
|
|
16
|
+
import * as i7 from 'primeng/tag';
|
|
17
|
+
import { TagModule } from 'primeng/tag';
|
|
18
|
+
import localeEsCO from '@angular/common/locales/es-CO';
|
|
19
|
+
import * as i2$1 from '@angular/forms';
|
|
20
|
+
import { FormsModule } from '@angular/forms';
|
|
21
|
+
import * as i4$1 from 'primeng/checkbox';
|
|
22
|
+
import { CheckboxModule } from 'primeng/checkbox';
|
|
23
|
+
import * as i5$1 from 'primeng/dialog';
|
|
24
|
+
import { DialogModule } from 'primeng/dialog';
|
|
25
|
+
import * as i6$1 from 'primeng/inputnumber';
|
|
26
|
+
import { InputNumberModule } from 'primeng/inputnumber';
|
|
27
|
+
import * as i8 from 'primeng/select';
|
|
28
|
+
import { SelectModule } from 'primeng/select';
|
|
29
|
+
import * as i12 from 'primeng/tooltip';
|
|
30
|
+
import { TooltipModule } from 'primeng/tooltip';
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Modelos de una solicitud de crédito como los pintan los componentes de sf-solicitud. Los hosts los arman con lo que
|
|
34
|
+
* traen de su API (TFB, del detalle de LoanService por TFAServices; forms-ui, de los datos del formulario).
|
|
35
|
+
*/
|
|
36
|
+
|
|
37
|
+
const APPLICATION_PERSON_SERVICE = new InjectionToken('APPLICATION_PERSON_SERVICE');
|
|
38
|
+
|
|
39
|
+
/** Locale de moneda y números de los componentes: `| currency: 'COP' : 'symbol-narrow' : '1.0-0' : 'es-CO'`. */
|
|
40
|
+
const LOCALE = 'es-CO';
|
|
41
|
+
let localeRegistered = false;
|
|
42
|
+
/**
|
|
43
|
+
* Los hosts no registran ningún locale: cada componente registra es-CO al crearse. Va en el constructor y no en la raíz
|
|
44
|
+
* del módulo para no depender de que el bundler conserve un efecto de módulo con `sideEffects: false`.
|
|
45
|
+
*/
|
|
46
|
+
function ensureLocale() {
|
|
47
|
+
if (localeRegistered)
|
|
48
|
+
return;
|
|
49
|
+
registerLocaleData(localeEsCO);
|
|
50
|
+
localeRegistered = true;
|
|
51
|
+
}
|
|
52
|
+
/** Un texto apto para un id del DOM (sin espacios ni caracteres raros). */
|
|
53
|
+
function safeId(value) {
|
|
54
|
+
return value.replace(/[^A-Za-z0-9_-]/g, '-');
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Una fecha de texto en el formato de los fronts (yyyy-MM-dd). Entiende dd/MM/yyyy (compras de cartera), yyyy/MM/dd y
|
|
58
|
+
* yyyy-MM-dd con o sin hora; lo que no reconoce lo devuelve tal cual, y vacío es null.
|
|
59
|
+
*/
|
|
60
|
+
function toIsoDate(value) {
|
|
61
|
+
const text = (value ?? '').toString().trim();
|
|
62
|
+
if (!text)
|
|
63
|
+
return null;
|
|
64
|
+
let match = /^(\d{1,2})\/(\d{1,2})\/(\d{4})/.exec(text);
|
|
65
|
+
if (match)
|
|
66
|
+
return `${match[3]}-${pad(match[2])}-${pad(match[1])}`;
|
|
67
|
+
match = /^(\d{4})[-/](\d{1,2})[-/](\d{1,2})/.exec(text);
|
|
68
|
+
if (match)
|
|
69
|
+
return `${match[1]}-${pad(match[2])}-${pad(match[3])}`;
|
|
70
|
+
return text;
|
|
71
|
+
}
|
|
72
|
+
function round(value, decimals) {
|
|
73
|
+
const factor = 10 ** decimals;
|
|
74
|
+
return Math.round(value * factor) / factor;
|
|
75
|
+
}
|
|
76
|
+
/** Dos valores de la pantalla son el mismo: números con tolerancia de medio centavo, textos sin mayúsculas. */
|
|
77
|
+
function sameValue(a, b) {
|
|
78
|
+
if (typeof a === 'number' && typeof b === 'number')
|
|
79
|
+
return Math.abs(a - b) < 0.005;
|
|
80
|
+
return a.toString().trim().toUpperCase() === b.toString().trim().toUpperCase();
|
|
81
|
+
}
|
|
82
|
+
function pad(value) {
|
|
83
|
+
return (value ?? '').padStart(2, '0');
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const GENDERS = { F: 'Femenino', M: 'Masculino' };
|
|
87
|
+
let nextId$1 = 0;
|
|
88
|
+
/**
|
|
89
|
+
* Titular de la solicitud: arriba lo básico (lo que trae la solicitud) y, al expandir, la persona completa, sus
|
|
90
|
+
* cuentas y las demás personas. La persona y las cuentas se piden por el puerto `APPLICATION_PERSON_SERVICE` solo al
|
|
91
|
+
* expandir, una vez por titular.
|
|
92
|
+
*/
|
|
93
|
+
class ApplicationPersonComponent {
|
|
94
|
+
gateway = inject(APPLICATION_PERSON_SERVICE);
|
|
95
|
+
destroyRef = inject(DestroyRef);
|
|
96
|
+
/** Las personas de la solicitud; el titular es la de rol "Titular" o, si no hay, la primera. */
|
|
97
|
+
parties = input.required();
|
|
98
|
+
locale = LOCALE;
|
|
99
|
+
ids = { more: `sfs-person-more-${++nextId$1}`, prefix: `sfs-person-${nextId$1}` };
|
|
100
|
+
hasAccounts = typeof this.gateway.getAccounts === 'function';
|
|
101
|
+
holder = computed(() => {
|
|
102
|
+
const parties = this.parties() ?? [];
|
|
103
|
+
return parties.find((p) => p.role?.toLowerCase() === 'titular') ?? parties[0] ?? null;
|
|
104
|
+
});
|
|
105
|
+
others = computed(() => (this.parties() ?? []).filter((p) => p !== this.holder()));
|
|
106
|
+
expanded = signal(false);
|
|
107
|
+
person = signal(null);
|
|
108
|
+
personState = signal('idle');
|
|
109
|
+
accounts = signal([]);
|
|
110
|
+
accountsState = signal('idle');
|
|
111
|
+
initials = computed(() => {
|
|
112
|
+
const words = (this.holder()?.name ?? '').split(/\s+/).filter(Boolean);
|
|
113
|
+
return ((words[0]?.[0] ?? '') + (words[1]?.[0] ?? '')).toUpperCase() || '?';
|
|
114
|
+
});
|
|
115
|
+
generalFields = computed(() => {
|
|
116
|
+
const p = this.person();
|
|
117
|
+
if (!p)
|
|
118
|
+
return [];
|
|
119
|
+
return [
|
|
120
|
+
{ label: 'Nombres', value: p.firstNames },
|
|
121
|
+
{ label: 'Apellidos', value: p.lastNames },
|
|
122
|
+
{ label: 'Sexo', value: GENDERS[(p.gender ?? '').trim().toUpperCase()] ?? p.gender },
|
|
123
|
+
{ label: 'Estado civil', value: p.maritalStatus },
|
|
124
|
+
{ label: 'Lugar de nacimiento', value: p.birthPlace },
|
|
125
|
+
{ label: 'Fecha de nacimiento', value: toIsoDate(p.birthDate) },
|
|
126
|
+
{ label: 'Lugar de expedición', value: p.documentIssuePlace },
|
|
127
|
+
{ label: 'Fecha de expedición', value: toIsoDate(p.documentIssueDate) }
|
|
128
|
+
].map((field) => ({ label: field.label, value: field.value?.toString().trim() || '—' }));
|
|
129
|
+
});
|
|
130
|
+
contacts = computed(() => this.person()?.contacts ?? []);
|
|
131
|
+
addresses = computed(() => this.person()?.addresses ?? []);
|
|
132
|
+
personRequest;
|
|
133
|
+
accountsRequest;
|
|
134
|
+
loadedFor = null;
|
|
135
|
+
constructor() {
|
|
136
|
+
ensureLocale();
|
|
137
|
+
// Otro titular (el host recargó la solicitud con otras personas): lo cargado ya no es suyo.
|
|
138
|
+
effect(() => {
|
|
139
|
+
const key = this.holderKey();
|
|
140
|
+
untracked(() => {
|
|
141
|
+
if (key === this.loadedFor)
|
|
142
|
+
return;
|
|
143
|
+
this.personRequest?.unsubscribe();
|
|
144
|
+
this.accountsRequest?.unsubscribe();
|
|
145
|
+
this.person.set(null);
|
|
146
|
+
this.accounts.set([]);
|
|
147
|
+
this.personState.set('idle');
|
|
148
|
+
this.accountsState.set('idle');
|
|
149
|
+
this.loadedFor = null;
|
|
150
|
+
if (this.expanded())
|
|
151
|
+
this.load();
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
toggle() {
|
|
156
|
+
this.expanded.update((open) => !open);
|
|
157
|
+
// Lo ya cargado (o en camino) no se vuelve a pedir: solo lo que nunca se pidió o falló.
|
|
158
|
+
const state = this.personState();
|
|
159
|
+
if (this.expanded() && (state === 'idle' || state === 'error'))
|
|
160
|
+
this.load();
|
|
161
|
+
}
|
|
162
|
+
load() {
|
|
163
|
+
const holder = this.holder();
|
|
164
|
+
if (!holder?.documentNumber) {
|
|
165
|
+
this.personState.set('missing');
|
|
166
|
+
this.accountsState.set('missing');
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
this.loadedFor = this.holderKey();
|
|
170
|
+
this.loadPerson();
|
|
171
|
+
this.loadAccounts();
|
|
172
|
+
}
|
|
173
|
+
loadPerson() {
|
|
174
|
+
const holder = this.holder();
|
|
175
|
+
if (!holder?.documentNumber)
|
|
176
|
+
return;
|
|
177
|
+
this.personRequest?.unsubscribe();
|
|
178
|
+
this.personState.set('loading');
|
|
179
|
+
this.personRequest = this.gateway
|
|
180
|
+
.getPerson(holder.documentType || null, holder.documentNumber)
|
|
181
|
+
.pipe(takeUntilDestroyed(this.destroyRef))
|
|
182
|
+
.subscribe({
|
|
183
|
+
next: (person) => {
|
|
184
|
+
this.person.set(person);
|
|
185
|
+
this.personState.set(person ? 'ready' : 'empty');
|
|
186
|
+
},
|
|
187
|
+
error: () => this.personState.set('error')
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
loadAccounts() {
|
|
191
|
+
const holder = this.holder();
|
|
192
|
+
if (!holder?.documentNumber || !this.gateway.getAccounts)
|
|
193
|
+
return;
|
|
194
|
+
this.accountsRequest?.unsubscribe();
|
|
195
|
+
this.accountsState.set('loading');
|
|
196
|
+
this.accountsRequest = this.gateway
|
|
197
|
+
.getAccounts(holder.documentType || null, holder.documentNumber)
|
|
198
|
+
.pipe(takeUntilDestroyed(this.destroyRef))
|
|
199
|
+
.subscribe({
|
|
200
|
+
next: (accounts) => {
|
|
201
|
+
this.accounts.set(accounts ?? []);
|
|
202
|
+
this.accountsState.set('ready');
|
|
203
|
+
},
|
|
204
|
+
error: () => this.accountsState.set('error')
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
holderKey() {
|
|
208
|
+
const holder = this.holder();
|
|
209
|
+
return holder ? `${holder.documentType ?? ''}|${holder.documentNumber}` : null;
|
|
210
|
+
}
|
|
211
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.17", ngImport: i0, type: ApplicationPersonComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
212
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.17", type: ApplicationPersonComponent, isStandalone: true, selector: "lib-application-person", inputs: { parties: { classPropertyName: "parties", publicName: "parties", isSignal: true, isRequired: true, transformFunction: null } }, ngImport: i0, template: "<p-card>\n @if (holder(); as titular) {\n <div class=\"sfs-person-head\">\n <div class=\"sfs-person-avatar\" aria-hidden=\"true\">{{ initials() }}</div>\n <div class=\"sfs-person-main\">\n <h2 class=\"sfs-title\">{{ titular.name || '\u2014' }}</h2>\n <div class=\"sfs-person-facts\">\n <span>Documento {{ titular.documentNumber || '\u2014' }}</span>\n <span>{{ titular.age != null ? (titular.age | number: '1.0-0' : locale) + ' a\u00F1os' : 'Edad: \u2014' }}</span>\n <span><i class=\"pi pi-mobile\" aria-hidden=\"true\"></i><span class=\"sfs-sr-only\">Celular: </span> {{ titular.phone || '\u2014' }}</span>\n <span class=\"sfs-break\"><i class=\"pi pi-envelope\" aria-hidden=\"true\"></i><span class=\"sfs-sr-only\">Correo: </span> {{ titular.email || '\u2014' }}</span>\n @if (others().length) {\n <span>{{ others().length }} {{ others().length === 1 ? 'persona m\u00E1s' : 'personas m\u00E1s' }} en la solicitud</span>\n }\n </div>\n </div>\n <!-- pButton y no p-button: el componente no deja poner aria-expanded en su <button>. -->\n <button pButton type=\"button\" severity=\"secondary\" [text]=\"true\" label=\"Datos de la persona\" aria-label=\"Datos de la persona\"\n [icon]=\"expanded() ? 'pi pi-chevron-up' : 'pi pi-chevron-down'\" iconPos=\"right\"\n [attr.aria-expanded]=\"expanded()\" [attr.aria-controls]=\"ids.more\"\n (click)=\"toggle()\"></button>\n </div>\n\n @if (expanded()) {\n <div [id]=\"ids.more\" class=\"sfs-person-more\">\n <section [attr.aria-labelledby]=\"ids.prefix + '-general'\">\n <h3 [id]=\"ids.prefix + '-general'\" class=\"sfs-section-title\"><i class=\"pi pi-id-card\" aria-hidden=\"true\"></i> Informaci\u00F3n general</h3>\n @switch (personState()) {\n @case ('loading') {\n <div class=\"sfs-person-grid\" aria-busy=\"true\">\n @for (i of [1, 2, 3, 4, 5, 6, 7, 8]; track i) { <p-skeleton height=\"2.5rem\"></p-skeleton> }\n </div>\n }\n @case ('empty') {\n <p-message severity=\"info\" text=\"La persona no est\u00E1 registrada: se muestran solo los datos de la solicitud.\"></p-message>\n }\n @case ('missing') {\n <p-message severity=\"warn\" text=\"El titular no tiene documento en la solicitud: no se pueden consultar sus datos.\"></p-message>\n }\n @case ('error') {\n <p-message severity=\"error\">\n <div class=\"sfs-inline\">\n <span>No se pudieron cargar los datos de la persona.</span>\n <p-button label=\"Reintentar\" icon=\"pi pi-refresh\" [text]=\"true\" (onClick)=\"loadPerson()\"></p-button>\n </div>\n </p-message>\n }\n @case ('ready') {\n <dl class=\"sfs-person-grid sfs-dl\">\n @for (field of generalFields(); track field.label) {\n <div class=\"sfs-field\">\n <dt>{{ field.label }}</dt>\n <dd>{{ field.value }}</dd>\n </div>\n }\n </dl>\n }\n }\n </section>\n\n @if (personState() === 'ready') {\n <section [attr.aria-labelledby]=\"ids.prefix + '-contact'\">\n <h3 [id]=\"ids.prefix + '-contact'\" class=\"sfs-section-title\"><i class=\"pi pi-phone\" aria-hidden=\"true\"></i> Informaci\u00F3n de contacto</h3>\n <p-table [value]=\"contacts()\" styleClass=\"p-datatable-sm\" [scrollable]=\"true\">\n <ng-template #header>\n <tr><th>Tipo</th><th>Descripci\u00F3n</th><th>Valor</th></tr>\n </ng-template>\n <ng-template #body let-c>\n <tr>\n <td>{{ c.type || '\u2014' }}</td>\n <td>{{ c.description || '\u2014' }}</td>\n <td class=\"sfs-break\">\n {{ c.value || '\u2014' }}\n @if (c.primary) { <span class=\"sfs-tag-gap\"><p-tag value=\"Principal\" severity=\"info\"></p-tag></span> }\n </td>\n </tr>\n </ng-template>\n <ng-template #emptymessage>\n <tr><td colspan=\"3\">La persona no tiene medios de contacto registrados.</td></tr>\n </ng-template>\n </p-table>\n </section>\n\n <section [attr.aria-labelledby]=\"ids.prefix + '-address'\">\n <h3 [id]=\"ids.prefix + '-address'\" class=\"sfs-section-title\"><i class=\"pi pi-home\" aria-hidden=\"true\"></i> Direcciones</h3>\n <p-table [value]=\"addresses()\" styleClass=\"p-datatable-sm\" [scrollable]=\"true\">\n <ng-template #header>\n <tr><th>Direcci\u00F3n</th><th>Pa\u00EDs</th><th>Ciudad</th><th>Barrio</th><th>Tel\u00E9fono</th></tr>\n </ng-template>\n <ng-template #body let-a>\n <tr>\n <td>{{ a.address || '\u2014' }}</td>\n <td>{{ a.country || '\u2014' }}</td>\n <td>{{ a.city || '\u2014' }}</td>\n <td>{{ a.neighborhood || '\u2014' }}</td>\n <td>{{ a.phone || '\u2014' }}</td>\n </tr>\n </ng-template>\n <ng-template #emptymessage>\n <tr><td colspan=\"5\">La persona no tiene direcciones registradas.</td></tr>\n </ng-template>\n </p-table>\n </section>\n }\n\n @if (hasAccounts && accountsState() !== 'missing') {\n <section [attr.aria-labelledby]=\"ids.prefix + '-accounts'\">\n <h3 [id]=\"ids.prefix + '-accounts'\" class=\"sfs-section-title\"><i class=\"pi pi-wallet\" aria-hidden=\"true\"></i> Cuentas</h3>\n @switch (accountsState()) {\n @case ('loading') { <p-skeleton height=\"5rem\" aria-busy=\"true\"></p-skeleton> }\n @case ('error') {\n <p-message severity=\"error\">\n <div class=\"sfs-inline\">\n <span>No se pudieron cargar las cuentas.</span>\n <p-button label=\"Reintentar\" icon=\"pi pi-refresh\" [text]=\"true\" (onClick)=\"loadAccounts()\"></p-button>\n </div>\n </p-message>\n }\n @case ('ready') {\n <p-table [value]=\"accounts()\" styleClass=\"p-datatable-sm\" [scrollable]=\"true\">\n <ng-template #header>\n <tr><th>Banco</th><th>Tipo de cuenta</th><th>N\u00FAmero</th></tr>\n </ng-template>\n <ng-template #body let-a>\n <tr>\n <td>{{ a.bank || '\u2014' }}</td>\n <td>{{ a.accountType || '\u2014' }}</td>\n <td>{{ a.number || '\u2014' }}</td>\n </tr>\n </ng-template>\n <ng-template #emptymessage>\n <tr><td colspan=\"3\">La persona no tiene cuentas registradas.</td></tr>\n </ng-template>\n </p-table>\n }\n }\n </section>\n }\n\n @if (others().length) {\n <section [attr.aria-labelledby]=\"ids.prefix + '-others'\">\n <h3 [id]=\"ids.prefix + '-others'\" class=\"sfs-section-title\"><i class=\"pi pi-users\" aria-hidden=\"true\"></i> Otras personas de la solicitud</h3>\n <p-table [value]=\"others()\" styleClass=\"p-datatable-sm\" [scrollable]=\"true\" dataKey=\"documentNumber\">\n <ng-template #header>\n <tr><th>Rol</th><th>Documento</th><th>Nombre</th><th>Edad</th><th>Celular</th><th>Correo</th></tr>\n </ng-template>\n <ng-template #body let-p>\n <tr>\n <td>{{ p.role || '\u2014' }}</td>\n <td>{{ p.documentNumber || '\u2014' }}</td>\n <td>{{ p.name || '\u2014' }}</td>\n <td>{{ p.age != null ? (p.age | number: '1.0-0' : locale) : '\u2014' }}</td>\n <td>{{ p.phone || '\u2014' }}</td>\n <td class=\"sfs-break\">{{ p.email || '\u2014' }}</td>\n </tr>\n </ng-template>\n </p-table>\n </section>\n }\n </div>\n }\n } @else {\n <p-message severity=\"info\" text=\"La solicitud no tiene titular registrado.\"></p-message>\n }\n</p-card>\n", styles: [".sfs-title{margin:0;font-size:1.125rem;font-weight:600}.sfs-subtitle{margin:0;font-size:1rem;font-weight:600}.sfs-muted{color:var(--p-text-muted-color)}.sfs-section-title{display:flex;align-items:center;gap:.5rem;margin:0 0 .75rem;font-size:1rem;font-weight:600}.sfs-section-title i{color:var(--primary-color, var(--p-primary-color))}.sfs-inline{display:flex;flex-wrap:wrap;align-items:center;gap:.75rem}.sfs-head{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:.5rem;margin-bottom:.75rem}.sfs-break{overflow-wrap:anywhere}.sfs-nowrap{white-space:nowrap}.sfs-right{text-align:right}.sfs-strong{font-weight:600}.sfs-tag-gap{margin-left:.5rem}.sfs-stack{display:flex;flex-direction:column;gap:1rem}.sfs-sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}.sfs-summary{display:grid;grid-template-columns:minmax(8rem,max-content) 1fr;gap:.25rem 1rem;margin:0}.sfs-summary dt{color:var(--p-text-muted-color)}.sfs-summary dd{margin:0;text-align:right;font-variant-numeric:tabular-nums}\n", ".sfs-person-head{display:flex;flex-wrap:wrap;align-items:center;gap:.75rem}.sfs-person-avatar{display:flex;align-items:center;justify-content:center;width:3.5rem;height:3.5rem;flex-shrink:0;border-radius:50%;font-size:1.25rem;font-weight:700;color:var(--primary-color, var(--p-primary-color));background:var(--p-highlight-background)}.sfs-person-main{display:flex;flex-direction:column;gap:.25rem;flex:1;min-width:0}.sfs-person-facts{display:flex;flex-wrap:wrap;gap:.25rem 1rem;font-size:.875rem;color:var(--p-text-muted-color)}.sfs-person-facts i{font-size:.8rem}.sfs-person-more{display:flex;flex-direction:column;gap:1.25rem;margin-top:1rem;padding-top:1rem;border-top:1px solid var(--p-content-border-color)}.sfs-person-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:.75rem 1rem}@media (min-width: 768px){.sfs-person-grid{grid-template-columns:repeat(4,minmax(0,1fr))}}.sfs-dl{margin:0}.sfs-field{display:flex;flex-direction:column;min-width:0}.sfs-field dt{font-size:.8rem;color:var(--p-text-muted-color)}.sfs-field dd{margin:0;overflow-wrap:anywhere}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "pipe", type: i1.DecimalPipe, name: "number" }, { kind: "ngmodule", type: ButtonModule }, { kind: "directive", type: i2.ButtonDirective, selector: "[pButton]", inputs: ["iconPos", "loadingIcon", "loading", "severity", "raised", "rounded", "text", "outlined", "size", "plain", "fluid", "label", "icon", "buttonProps"] }, { kind: "component", type: i2.Button, selector: "p-button", inputs: ["type", "iconPos", "icon", "badge", "label", "disabled", "loading", "loadingIcon", "raised", "rounded", "text", "plain", "severity", "outlined", "link", "tabindex", "size", "variant", "style", "styleClass", "badgeClass", "badgeSeverity", "ariaLabel", "autofocus", "fluid", "buttonProps"], outputs: ["onClick", "onFocus", "onBlur"] }, { kind: "ngmodule", type: CardModule }, { kind: "component", type: i3.Card, selector: "p-card", inputs: ["header", "subheader", "style", "styleClass"] }, { kind: "ngmodule", type: MessageModule }, { kind: "component", type: i4.Message, selector: "p-message", inputs: ["severity", "text", "escape", "style", "styleClass", "closable", "icon", "closeIcon", "life", "showTransitionOptions", "hideTransitionOptions", "size", "variant"], outputs: ["onClose"] }, { kind: "ngmodule", type: SkeletonModule }, { kind: "component", type: i5.Skeleton, selector: "p-skeleton", inputs: ["styleClass", "style", "shape", "animation", "borderRadius", "size", "width", "height"] }, { kind: "ngmodule", type: TableModule }, { kind: "component", type: i6.Table, selector: "p-table", inputs: ["frozenColumns", "frozenValue", "style", "styleClass", "tableStyle", "tableStyleClass", "paginator", "pageLinks", "rowsPerPageOptions", "alwaysShowPaginator", "paginatorPosition", "paginatorStyleClass", "paginatorDropdownAppendTo", "paginatorDropdownScrollHeight", "currentPageReportTemplate", "showCurrentPageReport", "showJumpToPageDropdown", "showJumpToPageInput", "showFirstLastIcon", "showPageLinks", "defaultSortOrder", "sortMode", "resetPageOnSort", "selectionMode", "selectionPageOnly", "contextMenuSelection", "contextMenuSelectionMode", "dataKey", "metaKeySelection", "rowSelectable", "rowTrackBy", "lazy", "lazyLoadOnInit", "compareSelectionBy", "csvSeparator", "exportFilename", "filters", "globalFilterFields", "filterDelay", "filterLocale", "expandedRowKeys", "editingRowKeys", "rowExpandMode", "scrollable", "scrollDirection", "rowGroupMode", "scrollHeight", "virtualScroll", "virtualScrollItemSize", "virtualScrollOptions", "virtualScrollDelay", "frozenWidth", "responsive", "contextMenu", "resizableColumns", "columnResizeMode", "reorderableColumns", "loading", "loadingIcon", "showLoader", "rowHover", "customSort", "showInitialSortBadge", "autoLayout", "exportFunction", "exportHeader", "stateKey", "stateStorage", "editMode", "groupRowsBy", "size", "showGridlines", "stripedRows", "groupRowsByOrder", "responsiveLayout", "breakpoint", "paginatorLocale", "value", "columns", "first", "rows", "totalRecords", "sortField", "sortOrder", "multiSortMeta", "selection", "virtualRowHeight", "selectAll"], outputs: ["contextMenuSelectionChange", "selectAllChange", "selectionChange", "onRowSelect", "onRowUnselect", "onPage", "onSort", "onFilter", "onLazyLoad", "onRowExpand", "onRowCollapse", "onContextMenuSelect", "onColResize", "onColReorder", "onRowReorder", "onEditInit", "onEditComplete", "onEditCancel", "onHeaderCheckboxToggle", "sortFunction", "firstChange", "rowsChange", "onStateSave", "onStateRestore"] }, { kind: "ngmodule", type: TagModule }, { kind: "component", type: i7.Tag, selector: "p-tag", inputs: ["style", "styleClass", "severity", "value", "icon", "rounded"] }] });
|
|
213
|
+
}
|
|
214
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.17", ngImport: i0, type: ApplicationPersonComponent, decorators: [{
|
|
215
|
+
type: Component,
|
|
216
|
+
args: [{ selector: 'lib-application-person', imports: [CommonModule, ButtonModule, CardModule, MessageModule, SkeletonModule, TableModule, TagModule], template: "<p-card>\n @if (holder(); as titular) {\n <div class=\"sfs-person-head\">\n <div class=\"sfs-person-avatar\" aria-hidden=\"true\">{{ initials() }}</div>\n <div class=\"sfs-person-main\">\n <h2 class=\"sfs-title\">{{ titular.name || '\u2014' }}</h2>\n <div class=\"sfs-person-facts\">\n <span>Documento {{ titular.documentNumber || '\u2014' }}</span>\n <span>{{ titular.age != null ? (titular.age | number: '1.0-0' : locale) + ' a\u00F1os' : 'Edad: \u2014' }}</span>\n <span><i class=\"pi pi-mobile\" aria-hidden=\"true\"></i><span class=\"sfs-sr-only\">Celular: </span> {{ titular.phone || '\u2014' }}</span>\n <span class=\"sfs-break\"><i class=\"pi pi-envelope\" aria-hidden=\"true\"></i><span class=\"sfs-sr-only\">Correo: </span> {{ titular.email || '\u2014' }}</span>\n @if (others().length) {\n <span>{{ others().length }} {{ others().length === 1 ? 'persona m\u00E1s' : 'personas m\u00E1s' }} en la solicitud</span>\n }\n </div>\n </div>\n <!-- pButton y no p-button: el componente no deja poner aria-expanded en su <button>. -->\n <button pButton type=\"button\" severity=\"secondary\" [text]=\"true\" label=\"Datos de la persona\" aria-label=\"Datos de la persona\"\n [icon]=\"expanded() ? 'pi pi-chevron-up' : 'pi pi-chevron-down'\" iconPos=\"right\"\n [attr.aria-expanded]=\"expanded()\" [attr.aria-controls]=\"ids.more\"\n (click)=\"toggle()\"></button>\n </div>\n\n @if (expanded()) {\n <div [id]=\"ids.more\" class=\"sfs-person-more\">\n <section [attr.aria-labelledby]=\"ids.prefix + '-general'\">\n <h3 [id]=\"ids.prefix + '-general'\" class=\"sfs-section-title\"><i class=\"pi pi-id-card\" aria-hidden=\"true\"></i> Informaci\u00F3n general</h3>\n @switch (personState()) {\n @case ('loading') {\n <div class=\"sfs-person-grid\" aria-busy=\"true\">\n @for (i of [1, 2, 3, 4, 5, 6, 7, 8]; track i) { <p-skeleton height=\"2.5rem\"></p-skeleton> }\n </div>\n }\n @case ('empty') {\n <p-message severity=\"info\" text=\"La persona no est\u00E1 registrada: se muestran solo los datos de la solicitud.\"></p-message>\n }\n @case ('missing') {\n <p-message severity=\"warn\" text=\"El titular no tiene documento en la solicitud: no se pueden consultar sus datos.\"></p-message>\n }\n @case ('error') {\n <p-message severity=\"error\">\n <div class=\"sfs-inline\">\n <span>No se pudieron cargar los datos de la persona.</span>\n <p-button label=\"Reintentar\" icon=\"pi pi-refresh\" [text]=\"true\" (onClick)=\"loadPerson()\"></p-button>\n </div>\n </p-message>\n }\n @case ('ready') {\n <dl class=\"sfs-person-grid sfs-dl\">\n @for (field of generalFields(); track field.label) {\n <div class=\"sfs-field\">\n <dt>{{ field.label }}</dt>\n <dd>{{ field.value }}</dd>\n </div>\n }\n </dl>\n }\n }\n </section>\n\n @if (personState() === 'ready') {\n <section [attr.aria-labelledby]=\"ids.prefix + '-contact'\">\n <h3 [id]=\"ids.prefix + '-contact'\" class=\"sfs-section-title\"><i class=\"pi pi-phone\" aria-hidden=\"true\"></i> Informaci\u00F3n de contacto</h3>\n <p-table [value]=\"contacts()\" styleClass=\"p-datatable-sm\" [scrollable]=\"true\">\n <ng-template #header>\n <tr><th>Tipo</th><th>Descripci\u00F3n</th><th>Valor</th></tr>\n </ng-template>\n <ng-template #body let-c>\n <tr>\n <td>{{ c.type || '\u2014' }}</td>\n <td>{{ c.description || '\u2014' }}</td>\n <td class=\"sfs-break\">\n {{ c.value || '\u2014' }}\n @if (c.primary) { <span class=\"sfs-tag-gap\"><p-tag value=\"Principal\" severity=\"info\"></p-tag></span> }\n </td>\n </tr>\n </ng-template>\n <ng-template #emptymessage>\n <tr><td colspan=\"3\">La persona no tiene medios de contacto registrados.</td></tr>\n </ng-template>\n </p-table>\n </section>\n\n <section [attr.aria-labelledby]=\"ids.prefix + '-address'\">\n <h3 [id]=\"ids.prefix + '-address'\" class=\"sfs-section-title\"><i class=\"pi pi-home\" aria-hidden=\"true\"></i> Direcciones</h3>\n <p-table [value]=\"addresses()\" styleClass=\"p-datatable-sm\" [scrollable]=\"true\">\n <ng-template #header>\n <tr><th>Direcci\u00F3n</th><th>Pa\u00EDs</th><th>Ciudad</th><th>Barrio</th><th>Tel\u00E9fono</th></tr>\n </ng-template>\n <ng-template #body let-a>\n <tr>\n <td>{{ a.address || '\u2014' }}</td>\n <td>{{ a.country || '\u2014' }}</td>\n <td>{{ a.city || '\u2014' }}</td>\n <td>{{ a.neighborhood || '\u2014' }}</td>\n <td>{{ a.phone || '\u2014' }}</td>\n </tr>\n </ng-template>\n <ng-template #emptymessage>\n <tr><td colspan=\"5\">La persona no tiene direcciones registradas.</td></tr>\n </ng-template>\n </p-table>\n </section>\n }\n\n @if (hasAccounts && accountsState() !== 'missing') {\n <section [attr.aria-labelledby]=\"ids.prefix + '-accounts'\">\n <h3 [id]=\"ids.prefix + '-accounts'\" class=\"sfs-section-title\"><i class=\"pi pi-wallet\" aria-hidden=\"true\"></i> Cuentas</h3>\n @switch (accountsState()) {\n @case ('loading') { <p-skeleton height=\"5rem\" aria-busy=\"true\"></p-skeleton> }\n @case ('error') {\n <p-message severity=\"error\">\n <div class=\"sfs-inline\">\n <span>No se pudieron cargar las cuentas.</span>\n <p-button label=\"Reintentar\" icon=\"pi pi-refresh\" [text]=\"true\" (onClick)=\"loadAccounts()\"></p-button>\n </div>\n </p-message>\n }\n @case ('ready') {\n <p-table [value]=\"accounts()\" styleClass=\"p-datatable-sm\" [scrollable]=\"true\">\n <ng-template #header>\n <tr><th>Banco</th><th>Tipo de cuenta</th><th>N\u00FAmero</th></tr>\n </ng-template>\n <ng-template #body let-a>\n <tr>\n <td>{{ a.bank || '\u2014' }}</td>\n <td>{{ a.accountType || '\u2014' }}</td>\n <td>{{ a.number || '\u2014' }}</td>\n </tr>\n </ng-template>\n <ng-template #emptymessage>\n <tr><td colspan=\"3\">La persona no tiene cuentas registradas.</td></tr>\n </ng-template>\n </p-table>\n }\n }\n </section>\n }\n\n @if (others().length) {\n <section [attr.aria-labelledby]=\"ids.prefix + '-others'\">\n <h3 [id]=\"ids.prefix + '-others'\" class=\"sfs-section-title\"><i class=\"pi pi-users\" aria-hidden=\"true\"></i> Otras personas de la solicitud</h3>\n <p-table [value]=\"others()\" styleClass=\"p-datatable-sm\" [scrollable]=\"true\" dataKey=\"documentNumber\">\n <ng-template #header>\n <tr><th>Rol</th><th>Documento</th><th>Nombre</th><th>Edad</th><th>Celular</th><th>Correo</th></tr>\n </ng-template>\n <ng-template #body let-p>\n <tr>\n <td>{{ p.role || '\u2014' }}</td>\n <td>{{ p.documentNumber || '\u2014' }}</td>\n <td>{{ p.name || '\u2014' }}</td>\n <td>{{ p.age != null ? (p.age | number: '1.0-0' : locale) : '\u2014' }}</td>\n <td>{{ p.phone || '\u2014' }}</td>\n <td class=\"sfs-break\">{{ p.email || '\u2014' }}</td>\n </tr>\n </ng-template>\n </p-table>\n </section>\n }\n </div>\n }\n } @else {\n <p-message severity=\"info\" text=\"La solicitud no tiene titular registrado.\"></p-message>\n }\n</p-card>\n", styles: [".sfs-title{margin:0;font-size:1.125rem;font-weight:600}.sfs-subtitle{margin:0;font-size:1rem;font-weight:600}.sfs-muted{color:var(--p-text-muted-color)}.sfs-section-title{display:flex;align-items:center;gap:.5rem;margin:0 0 .75rem;font-size:1rem;font-weight:600}.sfs-section-title i{color:var(--primary-color, var(--p-primary-color))}.sfs-inline{display:flex;flex-wrap:wrap;align-items:center;gap:.75rem}.sfs-head{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:.5rem;margin-bottom:.75rem}.sfs-break{overflow-wrap:anywhere}.sfs-nowrap{white-space:nowrap}.sfs-right{text-align:right}.sfs-strong{font-weight:600}.sfs-tag-gap{margin-left:.5rem}.sfs-stack{display:flex;flex-direction:column;gap:1rem}.sfs-sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}.sfs-summary{display:grid;grid-template-columns:minmax(8rem,max-content) 1fr;gap:.25rem 1rem;margin:0}.sfs-summary dt{color:var(--p-text-muted-color)}.sfs-summary dd{margin:0;text-align:right;font-variant-numeric:tabular-nums}\n", ".sfs-person-head{display:flex;flex-wrap:wrap;align-items:center;gap:.75rem}.sfs-person-avatar{display:flex;align-items:center;justify-content:center;width:3.5rem;height:3.5rem;flex-shrink:0;border-radius:50%;font-size:1.25rem;font-weight:700;color:var(--primary-color, var(--p-primary-color));background:var(--p-highlight-background)}.sfs-person-main{display:flex;flex-direction:column;gap:.25rem;flex:1;min-width:0}.sfs-person-facts{display:flex;flex-wrap:wrap;gap:.25rem 1rem;font-size:.875rem;color:var(--p-text-muted-color)}.sfs-person-facts i{font-size:.8rem}.sfs-person-more{display:flex;flex-direction:column;gap:1.25rem;margin-top:1rem;padding-top:1rem;border-top:1px solid var(--p-content-border-color)}.sfs-person-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:.75rem 1rem}@media (min-width: 768px){.sfs-person-grid{grid-template-columns:repeat(4,minmax(0,1fr))}}.sfs-dl{margin:0}.sfs-field{display:flex;flex-direction:column;min-width:0}.sfs-field dt{font-size:.8rem;color:var(--p-text-muted-color)}.sfs-field dd{margin:0;overflow-wrap:anywhere}\n"] }]
|
|
217
|
+
}], ctorParameters: () => [] });
|
|
218
|
+
|
|
219
|
+
/** Métodos de cargo que se configuran en pesos; el resto es un porcentaje (fracción en el core). */
|
|
220
|
+
const FIXED_METHODS = new Set(['FIJO', 'DESCUENTOSGIRO']);
|
|
221
|
+
const CAPACITY_FIELDS = [
|
|
222
|
+
{ key: 'income', label: 'Ingresos' },
|
|
223
|
+
{ key: 'legalDeductions', label: 'Descuentos de ley' },
|
|
224
|
+
{ key: 'otherAffiliations', label: 'Otras afiliaciones' },
|
|
225
|
+
{ key: 'otherDeductions', label: 'Otros descuentos' },
|
|
226
|
+
{ key: 'purchasesValue', label: 'Compras de cartera' }
|
|
227
|
+
];
|
|
228
|
+
let nextId = 0;
|
|
229
|
+
/**
|
|
230
|
+
* Simulador comercial por línea de una solicitud. Solo pinta: el host simula y guarda con su API cuando el componente
|
|
231
|
+
* se lo pide (`simulate`, `save`, `retry`) y le devuelve el resultado por `simulation`, `state` y `saving`.
|
|
232
|
+
*
|
|
233
|
+
* Al elegir otra línea se ven su tasa y sus porcentajes. Quien puede editar cambia plazo, monto y los cargos
|
|
234
|
+
* permitidos; con `capacityEditable`, también la capacidad de pago (como en el formulario de radicación). Cualquier
|
|
235
|
+
* cambio exige recalcular antes de guardar, y guardar pide confirmación con el resumen.
|
|
236
|
+
*/
|
|
237
|
+
class LineSimulatorComponent {
|
|
238
|
+
/** Capacidad de pago con que se simula. */
|
|
239
|
+
capacity = input.required();
|
|
240
|
+
/** La persona puede editar la capacidad de pago (formulario de radicación); si no, es de solo lectura. */
|
|
241
|
+
capacityEditable = input(false);
|
|
242
|
+
simulation = input(null);
|
|
243
|
+
state = input('idle');
|
|
244
|
+
/** Mensaje para la persona cuando `state` es `error`. */
|
|
245
|
+
errorMessage = input(null);
|
|
246
|
+
/** Lo que la solicitud tiene guardado, para compararlo; null si no hay nada guardado. */
|
|
247
|
+
saved = input(null);
|
|
248
|
+
/** Puede cambiar plazo, monto y los cargos de `editableCharges`. */
|
|
249
|
+
canEdit = input(false);
|
|
250
|
+
/** Cargos cuyo valor configurado puede cambiar (por nombre, sin importar mayúsculas). */
|
|
251
|
+
editableCharges = input([]);
|
|
252
|
+
/**
|
|
253
|
+
* Muestra "Guardar condiciones". Va en false si el perfil nunca puede guardar (se oculta, no se deshabilita) o si
|
|
254
|
+
* el formulario guarda por su cuenta y escucha `lineChange`.
|
|
255
|
+
*/
|
|
256
|
+
showSave = input(true);
|
|
257
|
+
/** Por qué el host no deja guardar ahora (estado, crédito ya creado); null si por su lado se puede. */
|
|
258
|
+
saveBlockedReason = input(null);
|
|
259
|
+
/** El host está guardando. Póngalo en true al recibir `save` y en false al terminar, bien o mal. */
|
|
260
|
+
saving = input(false);
|
|
261
|
+
/** Simular otra vez con lo que la persona cambió. */
|
|
262
|
+
simulate = output();
|
|
263
|
+
/** Guardar, ya confirmado. Al terminar el host (`saving` vuelve a false) se cierra la confirmación. */
|
|
264
|
+
save = output();
|
|
265
|
+
/** Reintentar la simulación que falló: lleva la última que se pidió, o null si fue la inicial del host. */
|
|
266
|
+
retry = output();
|
|
267
|
+
/** La línea elegida y su resultado, cada vez que cambia (null mientras no hay ninguna). */
|
|
268
|
+
lineChange = output();
|
|
269
|
+
/** Lo que se ve no es lo guardado y la persona trabajó en ello (para avisar antes de salir o cambiar de estado). */
|
|
270
|
+
unsavedChange = output();
|
|
271
|
+
locale = LOCALE;
|
|
272
|
+
capacityFields = CAPACITY_FIELDS;
|
|
273
|
+
ids = (() => {
|
|
274
|
+
const n = ++nextId;
|
|
275
|
+
return {
|
|
276
|
+
line: `sfs-sim-line-${n}`,
|
|
277
|
+
lineLabel: `sfs-sim-line-label-${n}`,
|
|
278
|
+
term: `sfs-sim-term-${n}`,
|
|
279
|
+
amount: `sfs-sim-amount-${n}`,
|
|
280
|
+
charge: `sfs-sim-charge-${n}-`,
|
|
281
|
+
capacity: `sfs-sim-capacity-${n}-`,
|
|
282
|
+
garnishment: `sfs-sim-garnishment-${n}`,
|
|
283
|
+
capacityTitle: `sfs-sim-capacity-title-${n}`,
|
|
284
|
+
resultTitle: `sfs-sim-result-title-${n}`,
|
|
285
|
+
saveReason: `sfs-sim-save-reason-${n}`
|
|
286
|
+
};
|
|
287
|
+
})();
|
|
288
|
+
selectedLine = signal(null);
|
|
289
|
+
termInput = signal(null);
|
|
290
|
+
amountInput = signal(null);
|
|
291
|
+
chargeInputs = signal({});
|
|
292
|
+
/** La capacidad editada; null mientras no se toque. */
|
|
293
|
+
capacityInput = signal(null);
|
|
294
|
+
confirmVisible = signal(false);
|
|
295
|
+
/** La capacidad con que se simuló lo que se ve; null si fue la que trajo el host. */
|
|
296
|
+
simulatedCapacity = signal(null);
|
|
297
|
+
/** La última simulación pedida, mientras no llega su resultado. */
|
|
298
|
+
pendingRequest = null;
|
|
299
|
+
lastRequest = null;
|
|
300
|
+
/** La persona cambió algo (línea, plazo, monto, cargos o capacidad) desde lo que se cargó. */
|
|
301
|
+
touched = signal(false);
|
|
302
|
+
confirmOpener = null;
|
|
303
|
+
/** Contra qué se mide si la capacidad cambió: la que se simuló. */
|
|
304
|
+
referenceCapacity = computed(() => this.simulatedCapacity() ?? this.capacity());
|
|
305
|
+
currentCapacity = computed(() => this.capacityInput() ?? this.referenceCapacity());
|
|
306
|
+
lineOptions = computed(() => (this.simulation()?.lines ?? []).map((line) => ({
|
|
307
|
+
value: line.line,
|
|
308
|
+
label: line.lineName || `Línea ${line.line}`,
|
|
309
|
+
disabled: !!line.error
|
|
310
|
+
})));
|
|
311
|
+
line = computed(() => {
|
|
312
|
+
const code = this.selectedLine();
|
|
313
|
+
return this.simulation()?.lines.find((l) => l.line === code) ?? null;
|
|
314
|
+
});
|
|
315
|
+
savedLineName = computed(() => {
|
|
316
|
+
const code = this.saved()?.line;
|
|
317
|
+
if (!code)
|
|
318
|
+
return null;
|
|
319
|
+
return this.simulation()?.lines.find((l) => l.line === code)?.lineName || `Línea ${code}`;
|
|
320
|
+
});
|
|
321
|
+
chargeRows = computed(() => {
|
|
322
|
+
const line = this.line();
|
|
323
|
+
if (!line)
|
|
324
|
+
return [];
|
|
325
|
+
const editable = new Set(this.editableCharges().map((c) => c.toUpperCase()));
|
|
326
|
+
const canEdit = this.canEdit();
|
|
327
|
+
const saved = new Map((this.saved()?.charges ?? []).map((c) => [c.name.toUpperCase(), c.configuredValue]));
|
|
328
|
+
const toRow = (charge, type) => {
|
|
329
|
+
const percentage = !FIXED_METHODS.has((charge.method ?? '').toUpperCase());
|
|
330
|
+
const savedValue = saved.get(charge.name.toUpperCase());
|
|
331
|
+
return {
|
|
332
|
+
name: charge.name,
|
|
333
|
+
id: this.ids.charge + safeId(charge.name),
|
|
334
|
+
label: (charge.description || charge.name).replace(/_/g, ' '),
|
|
335
|
+
type,
|
|
336
|
+
percentage,
|
|
337
|
+
simulatedInput: toScreenUnit(charge.configuredValue, percentage),
|
|
338
|
+
savedInput: savedValue === undefined ? null : toScreenUnit(savedValue, percentage),
|
|
339
|
+
value: charge.value,
|
|
340
|
+
editable: canEdit && editable.has(charge.name.toUpperCase())
|
|
341
|
+
};
|
|
342
|
+
};
|
|
343
|
+
return [...line.charges.map((c) => toRow(c, 'ADMIN')), ...line.installmentCharges.map((c) => toRow(c, 'CUOTA'))];
|
|
344
|
+
});
|
|
345
|
+
/** Cargos editados que difieren de lo que calculó el simulador, en la unidad del core (fracción o pesos). */
|
|
346
|
+
editedCharges = computed(() => {
|
|
347
|
+
const inputs = this.chargeInputs();
|
|
348
|
+
const edited = {};
|
|
349
|
+
for (const row of this.chargeRows()) {
|
|
350
|
+
const input = inputs[row.name];
|
|
351
|
+
if (!row.editable || input === null || input === undefined || input === row.simulatedInput)
|
|
352
|
+
continue;
|
|
353
|
+
edited[row.name] = row.percentage ? round(input / 100, 8) : input;
|
|
354
|
+
}
|
|
355
|
+
return edited;
|
|
356
|
+
});
|
|
357
|
+
capacityChanged = computed(() => {
|
|
358
|
+
const edited = this.capacityInput();
|
|
359
|
+
return !!edited && !sameCapacity(edited, this.referenceCapacity());
|
|
360
|
+
});
|
|
361
|
+
/** Hay cambios sin recalcular: guardar exige ver primero lo que va a quedar. */
|
|
362
|
+
pendingChanges = computed(() => {
|
|
363
|
+
if (this.capacityChanged())
|
|
364
|
+
return true;
|
|
365
|
+
const line = this.line();
|
|
366
|
+
if (!line)
|
|
367
|
+
return false;
|
|
368
|
+
return ((this.termInput() ?? line.term) !== line.term ||
|
|
369
|
+
(this.amountInput() ?? line.amount) !== line.amount ||
|
|
370
|
+
Object.keys(this.editedCharges()).length > 0);
|
|
371
|
+
});
|
|
372
|
+
hasNegativeInput = computed(() => (this.amountInput() ?? 0) < 0 ||
|
|
373
|
+
Object.values(this.chargeInputs()).some((v) => v !== null && v !== undefined && v < 0) ||
|
|
374
|
+
CAPACITY_FIELDS.some((f) => this.currentCapacity()[f.key] < 0));
|
|
375
|
+
/** Por qué no se puede guardar ahora, para mostrarlo junto al botón; null si se puede. */
|
|
376
|
+
saveUnavailableReason = computed(() => {
|
|
377
|
+
const blocked = this.saveBlockedReason();
|
|
378
|
+
if (blocked)
|
|
379
|
+
return blocked;
|
|
380
|
+
if (!this.canEdit())
|
|
381
|
+
return 'No puede guardar las condiciones de esta solicitud.';
|
|
382
|
+
const line = this.line();
|
|
383
|
+
if (!line)
|
|
384
|
+
return 'Seleccione una línea.';
|
|
385
|
+
if (line.error)
|
|
386
|
+
return 'La línea no se pudo simular.';
|
|
387
|
+
if (line.amount <= 0)
|
|
388
|
+
return 'Con estas condiciones no hay capacidad de pago.';
|
|
389
|
+
if (this.pendingChanges())
|
|
390
|
+
return 'Recalcule para ver las condiciones antes de guardar.';
|
|
391
|
+
return null;
|
|
392
|
+
});
|
|
393
|
+
/** Lo guardado frente a lo que muestra el simulador para la línea elegida. */
|
|
394
|
+
comparison = computed(() => {
|
|
395
|
+
const l = this.line();
|
|
396
|
+
if (!l)
|
|
397
|
+
return [];
|
|
398
|
+
const s = this.saved();
|
|
399
|
+
const hasSaved = !!s && (!!s.line || s.amount > 0);
|
|
400
|
+
const row = (label, kind, saved, simulated) => ({
|
|
401
|
+
label,
|
|
402
|
+
kind,
|
|
403
|
+
saved,
|
|
404
|
+
simulated,
|
|
405
|
+
changed: hasSaved && saved !== null && simulated !== null && !sameValue(saved, simulated)
|
|
406
|
+
});
|
|
407
|
+
return [
|
|
408
|
+
row('Línea', 'text', this.savedLineName(), l.lineName || `Línea ${l.line}`),
|
|
409
|
+
row('Monto', 'money', hasSaved ? s.amount : null, l.amount),
|
|
410
|
+
row('Plazo', 'term', hasSaved ? s.term : null, l.term),
|
|
411
|
+
row('Tasa', 'rate', hasSaved ? s.rate : null, l.rate),
|
|
412
|
+
row('Cuota total', 'money', hasSaved ? s.totalInstallment : null, l.installment),
|
|
413
|
+
row('Seguro', 'money', null, l.insurance),
|
|
414
|
+
row('Cargos administrativos', 'money', null, l.administrativeCharges),
|
|
415
|
+
row('Desembolso', 'money', null, l.disbursement),
|
|
416
|
+
row('Giro al cliente', 'money', null, l.transfer)
|
|
417
|
+
];
|
|
418
|
+
});
|
|
419
|
+
/**
|
|
420
|
+
* La persona trabajó en el simulador y lo que ve no es lo guardado: hay cambios sin recalcular, o recalculó otra
|
|
421
|
+
* línea, plazo, monto o cargos y no guardó. Cuando el host actualiza `saved` tras guardar, vuelve sola a false.
|
|
422
|
+
*/
|
|
423
|
+
unsavedChanges = computed(() => {
|
|
424
|
+
if (this.pendingChanges())
|
|
425
|
+
return true;
|
|
426
|
+
const s = this.saved();
|
|
427
|
+
const l = this.line();
|
|
428
|
+
if (!this.touched() || !l || l.error)
|
|
429
|
+
return false;
|
|
430
|
+
if (!s?.line)
|
|
431
|
+
return true;
|
|
432
|
+
return (l.line !== s.line ||
|
|
433
|
+
l.term !== s.term ||
|
|
434
|
+
!sameValue(l.amount, s.amount) ||
|
|
435
|
+
this.chargeRows().some((row) => row.savedInput !== null && !sameValue(row.savedInput, row.simulatedInput)));
|
|
436
|
+
});
|
|
437
|
+
/** Lo que se anuncia al lector de pantalla cuando cambia la simulación (región siempre montada). */
|
|
438
|
+
liveMessage = computed(() => {
|
|
439
|
+
switch (this.state()) {
|
|
440
|
+
case 'loading':
|
|
441
|
+
return 'Simulando…';
|
|
442
|
+
case 'error':
|
|
443
|
+
return this.errorMessage() || 'No se pudo simular la solicitud.';
|
|
444
|
+
case 'ready': {
|
|
445
|
+
const l = this.line();
|
|
446
|
+
if (!l)
|
|
447
|
+
return '';
|
|
448
|
+
return `${l.lineName || `Línea ${l.line}`}: ${l.viable ? 'viable' : 'no viable'}.`;
|
|
449
|
+
}
|
|
450
|
+
default:
|
|
451
|
+
return '';
|
|
452
|
+
}
|
|
453
|
+
});
|
|
454
|
+
constructor() {
|
|
455
|
+
ensureLocale();
|
|
456
|
+
// Llega otra simulación.
|
|
457
|
+
// - Si la pidió la persona (Recalcular o Reintentar), se conserva la línea elegida; si respondía a una capacidad
|
|
458
|
+
// editada, esa pasa a ser la de referencia.
|
|
459
|
+
// - Si no la pidió (la inicial, o una que el host volvió a pedir por su cuenta, por ejemplo al recargar tras un
|
|
460
|
+
// guardado en duda), se muestra lo guardado y se olvida lo que la persona trabajó: su línea, sus cambios, la
|
|
461
|
+
// capacidad editada y su último pedido.
|
|
462
|
+
effect(() => {
|
|
463
|
+
const simulation = this.simulation();
|
|
464
|
+
untracked(() => {
|
|
465
|
+
if (!simulation)
|
|
466
|
+
return;
|
|
467
|
+
const requested = this.pendingRequest;
|
|
468
|
+
this.pendingRequest = null;
|
|
469
|
+
if (requested) {
|
|
470
|
+
this.simulatedCapacity.set(requested.capacity);
|
|
471
|
+
if (this.capacityInput() && sameCapacity(this.capacityInput(), requested.capacity))
|
|
472
|
+
this.capacityInput.set(null);
|
|
473
|
+
}
|
|
474
|
+
else {
|
|
475
|
+
this.touched.set(false);
|
|
476
|
+
this.lastRequest = null;
|
|
477
|
+
this.capacityInput.set(null);
|
|
478
|
+
this.simulatedCapacity.set(null);
|
|
479
|
+
}
|
|
480
|
+
const keep = requested ? simulation.lines.find((l) => l.line === this.selectedLine()) : undefined;
|
|
481
|
+
const saved = simulation.lines.find((l) => l.line === this.saved()?.line);
|
|
482
|
+
const fallback = simulation.lines.find((l) => l.viable && !l.error) ?? simulation.lines[0];
|
|
483
|
+
this.selectLine((keep ?? saved ?? fallback)?.line ?? null);
|
|
484
|
+
});
|
|
485
|
+
});
|
|
486
|
+
// Si la simulación que pidió la persona falla, ya no se espera: la próxima que llegue sin pedirla es del host.
|
|
487
|
+
// Reintentar la vuelve a marcar como pedida.
|
|
488
|
+
effect(() => {
|
|
489
|
+
const state = this.state();
|
|
490
|
+
untracked(() => {
|
|
491
|
+
if (state === 'error')
|
|
492
|
+
this.pendingRequest = null;
|
|
493
|
+
});
|
|
494
|
+
});
|
|
495
|
+
// Llega otra capacidad con otros valores (el host recargó la solicitud o guardó la editada): se descarta lo
|
|
496
|
+
// editado. La misma capacidad en otro objeto no cuenta como cambio.
|
|
497
|
+
let lastCapacity = null;
|
|
498
|
+
effect(() => {
|
|
499
|
+
const capacity = this.capacity();
|
|
500
|
+
untracked(() => {
|
|
501
|
+
if (lastCapacity && sameCapacity(lastCapacity, capacity))
|
|
502
|
+
return;
|
|
503
|
+
lastCapacity = capacity;
|
|
504
|
+
this.capacityInput.set(null);
|
|
505
|
+
this.simulatedCapacity.set(null);
|
|
506
|
+
});
|
|
507
|
+
});
|
|
508
|
+
effect(() => {
|
|
509
|
+
const line = this.line();
|
|
510
|
+
untracked(() => this.lineChange.emit(line));
|
|
511
|
+
});
|
|
512
|
+
effect(() => {
|
|
513
|
+
const unsaved = this.unsavedChanges();
|
|
514
|
+
untracked(() => this.unsavedChange.emit(unsaved));
|
|
515
|
+
});
|
|
516
|
+
// El host terminó de guardar (bien o mal): se cierra la confirmación. Si falló, lo que se ve sigue sin
|
|
517
|
+
// guardar y `unsavedChanges` lo sigue diciendo, porque `saved` no cambió.
|
|
518
|
+
let wasSaving = false;
|
|
519
|
+
effect(() => {
|
|
520
|
+
const saving = this.saving();
|
|
521
|
+
untracked(() => {
|
|
522
|
+
if (wasSaving && !saving)
|
|
523
|
+
this.confirmVisible.set(false);
|
|
524
|
+
wasSaving = saving;
|
|
525
|
+
});
|
|
526
|
+
});
|
|
527
|
+
}
|
|
528
|
+
/** La persona eligió otra línea en el selector. */
|
|
529
|
+
chooseLine(code) {
|
|
530
|
+
this.touched.set(true);
|
|
531
|
+
this.selectLine(code);
|
|
532
|
+
}
|
|
533
|
+
selectLine(code) {
|
|
534
|
+
this.selectedLine.set(code);
|
|
535
|
+
const line = this.simulation()?.lines.find((l) => l.line === code);
|
|
536
|
+
this.termInput.set(line?.term ?? null);
|
|
537
|
+
this.amountInput.set(line?.amount ?? null);
|
|
538
|
+
const inputs = {};
|
|
539
|
+
for (const row of this.chargeRows())
|
|
540
|
+
inputs[row.name] = row.simulatedInput;
|
|
541
|
+
this.chargeInputs.set(inputs);
|
|
542
|
+
}
|
|
543
|
+
setChargeInput(name, value) {
|
|
544
|
+
this.chargeInputs.update((current) => ({ ...current, [name]: value }));
|
|
545
|
+
}
|
|
546
|
+
setCapacity(field, value) {
|
|
547
|
+
this.capacityInput.set({ ...this.currentCapacity(), [field]: value ?? 0 });
|
|
548
|
+
}
|
|
549
|
+
setGarnishment(value) {
|
|
550
|
+
this.capacityInput.set({ ...this.currentCapacity(), hasGarnishment: value });
|
|
551
|
+
}
|
|
552
|
+
/** Pide simular otra vez con lo que la persona cambió. */
|
|
553
|
+
recalculate() {
|
|
554
|
+
if (this.hasNegativeInput())
|
|
555
|
+
return;
|
|
556
|
+
const line = this.line();
|
|
557
|
+
this.touched.set(true);
|
|
558
|
+
const edited = this.editedCharges();
|
|
559
|
+
const lines = line
|
|
560
|
+
? [
|
|
561
|
+
{
|
|
562
|
+
line: line.line,
|
|
563
|
+
term: this.termInput() ?? line.term,
|
|
564
|
+
amount: this.amountInput() ?? line.amount,
|
|
565
|
+
defaultTerm: line.defaultTerm ?? null,
|
|
566
|
+
defaultAmount: line.defaultAmount,
|
|
567
|
+
editedCharges: Object.keys(edited).length ? edited : null
|
|
568
|
+
}
|
|
569
|
+
]
|
|
570
|
+
: [];
|
|
571
|
+
const request = { capacity: this.currentCapacity(), lines };
|
|
572
|
+
this.pendingRequest = request;
|
|
573
|
+
this.lastRequest = request;
|
|
574
|
+
this.simulate.emit(request);
|
|
575
|
+
}
|
|
576
|
+
retrySimulation() {
|
|
577
|
+
if (this.lastRequest)
|
|
578
|
+
this.pendingRequest = this.lastRequest;
|
|
579
|
+
this.retry.emit(this.lastRequest);
|
|
580
|
+
}
|
|
581
|
+
openConfirm() {
|
|
582
|
+
if (this.saveUnavailableReason())
|
|
583
|
+
return;
|
|
584
|
+
this.confirmOpener = document.activeElement instanceof HTMLElement ? document.activeElement : null;
|
|
585
|
+
this.confirmVisible.set(true);
|
|
586
|
+
}
|
|
587
|
+
/** Al cerrar la confirmación, el foco vuelve al botón que la abrió. */
|
|
588
|
+
restoreConfirmFocus() {
|
|
589
|
+
const opener = this.confirmOpener;
|
|
590
|
+
this.confirmOpener = null;
|
|
591
|
+
if (opener?.isConnected)
|
|
592
|
+
opener.focus();
|
|
593
|
+
}
|
|
594
|
+
confirmSave() {
|
|
595
|
+
const line = this.line();
|
|
596
|
+
if (!line || this.saving() || this.saveUnavailableReason())
|
|
597
|
+
return;
|
|
598
|
+
// Lo que se ve, ya recalculado: los cargos editables van con su valor configurado para que el host los
|
|
599
|
+
// guarde tal cual (el back los vuelve a simular antes de guardar).
|
|
600
|
+
const editedCharges = {};
|
|
601
|
+
for (const row of this.chargeRows().filter((r) => r.editable)) {
|
|
602
|
+
const original = line.charges.concat(line.installmentCharges).find((c) => c.name === row.name);
|
|
603
|
+
if (original)
|
|
604
|
+
editedCharges[row.name] = original.configuredValue;
|
|
605
|
+
}
|
|
606
|
+
this.save.emit({
|
|
607
|
+
line: line.line,
|
|
608
|
+
term: line.term,
|
|
609
|
+
amount: line.amount,
|
|
610
|
+
editedCharges: Object.keys(editedCharges).length ? editedCharges : null,
|
|
611
|
+
...(this.capacityEditable() ? { capacity: this.referenceCapacity() } : {})
|
|
612
|
+
});
|
|
613
|
+
}
|
|
614
|
+
chargeTypeLabel(type) {
|
|
615
|
+
return type === 'ADMIN' ? 'Crédito' : 'Cuota';
|
|
616
|
+
}
|
|
617
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.17", ngImport: i0, type: LineSimulatorComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
618
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.17", type: LineSimulatorComponent, isStandalone: true, selector: "lib-line-simulator", inputs: { capacity: { classPropertyName: "capacity", publicName: "capacity", isSignal: true, isRequired: true, transformFunction: null }, capacityEditable: { classPropertyName: "capacityEditable", publicName: "capacityEditable", isSignal: true, isRequired: false, transformFunction: null }, simulation: { classPropertyName: "simulation", publicName: "simulation", isSignal: true, isRequired: false, transformFunction: null }, state: { classPropertyName: "state", publicName: "state", isSignal: true, isRequired: false, transformFunction: null }, errorMessage: { classPropertyName: "errorMessage", publicName: "errorMessage", isSignal: true, isRequired: false, transformFunction: null }, saved: { classPropertyName: "saved", publicName: "saved", isSignal: true, isRequired: false, transformFunction: null }, canEdit: { classPropertyName: "canEdit", publicName: "canEdit", isSignal: true, isRequired: false, transformFunction: null }, editableCharges: { classPropertyName: "editableCharges", publicName: "editableCharges", isSignal: true, isRequired: false, transformFunction: null }, showSave: { classPropertyName: "showSave", publicName: "showSave", isSignal: true, isRequired: false, transformFunction: null }, saveBlockedReason: { classPropertyName: "saveBlockedReason", publicName: "saveBlockedReason", isSignal: true, isRequired: false, transformFunction: null }, saving: { classPropertyName: "saving", publicName: "saving", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { simulate: "simulate", save: "save", retry: "retry", lineChange: "lineChange", unsavedChange: "unsavedChange" }, ngImport: i0, template: "<div class=\"sfs-stack\">\n <!-- Capacidad de pago -->\n <section [attr.aria-labelledby]=\"ids.capacityTitle\">\n <h3 [id]=\"ids.capacityTitle\" class=\"sfs-subtitle sfs-gap-bottom\">Capacidad de pago</h3>\n @if (capacityEditable()) {\n <div class=\"sfs-capacity-grid\">\n @for (field of capacityFields; track field.key) {\n <div class=\"sfs-control\">\n <label [for]=\"ids.capacity + field.key\">{{ field.label }}</label>\n <p-inputnumber [inputId]=\"ids.capacity + field.key\" [ngModel]=\"currentCapacity()[field.key]\" (ngModelChange)=\"setCapacity(field.key, $event)\"\n mode=\"currency\" currency=\"COP\" [locale]=\"locale\" [minFractionDigits]=\"0\" [maxFractionDigits]=\"0\" [min]=\"0\" [fluid]=\"true\"></p-inputnumber>\n </div>\n }\n <div class=\"sfs-control sfs-control--check\">\n <p-checkbox [inputId]=\"ids.garnishment\" [binary]=\"true\" [ngModel]=\"currentCapacity().hasGarnishment\" (ngModelChange)=\"setGarnishment($event)\"></p-checkbox>\n <label [for]=\"ids.garnishment\">Tiene embargo</label>\n </div>\n </div>\n } @else {\n <dl class=\"sfs-summary\">\n <dt>Ingresos</dt><dd>{{ capacity().income | currency: 'COP' : 'symbol-narrow' : '1.0-0' : locale }}</dd>\n <dt>Descuentos de ley</dt><dd>{{ capacity().legalDeductions | currency: 'COP' : 'symbol-narrow' : '1.0-0' : locale }}</dd>\n <dt>Otras afiliaciones</dt><dd>{{ capacity().otherAffiliations | currency: 'COP' : 'symbol-narrow' : '1.0-0' : locale }}</dd>\n <dt>Otros descuentos</dt><dd>{{ capacity().otherDeductions | currency: 'COP' : 'symbol-narrow' : '1.0-0' : locale }}</dd>\n <dt>Compras de cartera</dt><dd>{{ capacity().purchasesValue | currency: 'COP' : 'symbol-narrow' : '1.0-0' : locale }}</dd>\n <dt>Embargo</dt><dd>{{ capacity().hasGarnishment ? 'S\u00ED' : 'No' }}</dd>\n </dl>\n }\n @if (simulation(); as s) {\n <dl class=\"sfs-summary sfs-gap-top\">\n <dt>Cuota disponible</dt><dd>{{ s.capacity.availableInstallment | currency: 'COP' : 'symbol-narrow' : '1.0-0' : locale }}</dd>\n <dt>Monto m\u00E1ximo</dt><dd>{{ s.capacity.maxAmount != null ? (s.capacity.maxAmount | currency: 'COP' : 'symbol-narrow' : '1.0-0' : locale) : '\u2014' }}</dd>\n </dl>\n }\n </section>\n\n @switch (state()) {\n @case ('loading') {\n <div class=\"sfs-stack\" aria-busy=\"true\">\n <p-skeleton height=\"2.5rem\"></p-skeleton>\n <p-skeleton height=\"12rem\"></p-skeleton>\n </div>\n }\n @case ('error') {\n <p-message severity=\"error\">\n <div class=\"sfs-inline\">\n <span>{{ errorMessage() || 'No se pudo simular la solicitud.' }}</span>\n <p-button label=\"Reintentar\" icon=\"pi pi-refresh\" [text]=\"true\" (onClick)=\"retrySimulation()\"></p-button>\n </div>\n </p-message>\n @if (capacityEditable() && pendingChanges()) {\n <div class=\"sfs-actions\">\n <p-button label=\"Recalcular\" icon=\"pi pi-calculator\" severity=\"secondary\" [text]=\"true\" [disabled]=\"hasNegativeInput()\" (onClick)=\"recalculate()\"></p-button>\n </div>\n }\n }\n @case ('idle') {\n @if (capacityEditable()) {\n <div class=\"sfs-actions\">\n <p-button label=\"Simular\" icon=\"pi pi-calculator\" [disabled]=\"hasNegativeInput()\" (onClick)=\"recalculate()\"></p-button>\n </div>\n } @else {\n <p class=\"sfs-muted sfs-no-top\">Todav\u00EDa no hay una simulaci\u00F3n para esta solicitud.</p>\n }\n }\n @case ('ready') {\n @if (simulation()?.warnings?.length) {\n <p-message severity=\"warn\">\n <ul class=\"sfs-list\">\n @for (w of simulation()?.warnings ?? []; track $index) { <li>{{ w }}</li> }\n </ul>\n </p-message>\n }\n\n @if (!lineOptions().length) {\n <p-message severity=\"info\" text=\"El simulador no devolvi\u00F3 l\u00EDneas para esta solicitud. Revise la pagadur\u00EDa, el producto y la capacidad de pago.\"></p-message>\n }\n\n <!-- L\u00EDnea. p-select pone el inputId en un span: el nombre accesible va por ariaLabelledBy. -->\n <div class=\"sfs-control\">\n <label [id]=\"ids.lineLabel\" [for]=\"ids.line\" class=\"sfs-strong\">L\u00EDnea</label>\n <p-select [inputId]=\"ids.line\" [ariaLabelledBy]=\"ids.lineLabel\" [options]=\"lineOptions()\" optionLabel=\"label\" optionValue=\"value\" optionDisabled=\"disabled\"\n [ngModel]=\"selectedLine()\" (ngModelChange)=\"chooseLine($event)\" placeholder=\"Seleccione una l\u00EDnea\" [fluid]=\"true\"></p-select>\n @if (saved()?.line && saved()?.line !== selectedLine()) {\n <small class=\"sfs-muted\">La l\u00EDnea guardada es {{ savedLineName() }}. Al guardar se cambia por la elegida.</small>\n }\n </div>\n\n @if (line(); as l) {\n @if (l.error) {\n <p-message severity=\"error\" text=\"Esta l\u00EDnea no se pudo simular. Elija otra o intente m\u00E1s tarde.\"></p-message>\n } @else {\n <!-- Condiciones -->\n <div class=\"sfs-conditions\">\n <div class=\"sfs-control\">\n <label [for]=\"ids.term\">Plazo (cuotas)</label>\n <p-inputnumber [inputId]=\"ids.term\" [ngModel]=\"termInput()\" (ngModelChange)=\"termInput.set($event)\"\n [min]=\"simulation()?.minTerm ?? 1\" [max]=\"simulation()?.maxTerm ?? 600\" [useGrouping]=\"false\"\n [disabled]=\"!canEdit()\" [fluid]=\"true\"></p-inputnumber>\n </div>\n <div class=\"sfs-control\">\n <label [for]=\"ids.amount\">Monto</label>\n <p-inputnumber [inputId]=\"ids.amount\" [ngModel]=\"amountInput()\" (ngModelChange)=\"amountInput.set($event)\"\n mode=\"currency\" currency=\"COP\" [locale]=\"locale\" [minFractionDigits]=\"0\" [maxFractionDigits]=\"0\" [min]=\"0\"\n [disabled]=\"!canEdit()\" [fluid]=\"true\"></p-inputnumber>\n </div>\n <div class=\"sfs-control\">\n <span>Tasa</span>\n <span class=\"sfs-strong\">{{ l.rate | number: '1.0-4' : locale }} % M.V.</span>\n </div>\n </div>\n\n <!-- Cargos de la l\u00EDnea, con lo guardado al lado -->\n <p-table [value]=\"chargeRows()\" styleClass=\"p-datatable-sm\" [scrollable]=\"true\" dataKey=\"name\">\n <ng-template #header>\n <tr>\n <th>Cargo</th>\n <th>Tipo</th>\n <th class=\"sfs-right\">Guardado</th>\n <th class=\"sfs-right\">Configurado</th>\n <th class=\"sfs-right\">Valor</th>\n </tr>\n </ng-template>\n <ng-template #body let-row>\n <tr>\n <td>{{ row.label }}</td>\n <td>{{ chargeTypeLabel(row.type) }}</td>\n <td class=\"sfs-right sfs-nowrap\">\n @if (row.savedInput === null) { \u2014 }\n @else { {{ row.percentage ? (row.savedInput | number: '1.0-4' : locale) + ' %' : (row.savedInput | currency: 'COP' : 'symbol-narrow' : '1.0-0' : locale) }} }\n </td>\n <td class=\"sfs-right\">\n @if (row.editable) {\n <label [for]=\"row.id\" class=\"sfs-sr-only\">{{ row.label }}</label>\n <p-inputnumber [inputId]=\"row.id\" [ngModel]=\"chargeInputs()[row.name]\" (ngModelChange)=\"setChargeInput(row.name, $event)\"\n [min]=\"0\" [minFractionDigits]=\"0\" [maxFractionDigits]=\"row.percentage ? 4 : 0\" [locale]=\"locale\"\n [suffix]=\"row.percentage ? ' %' : ''\" [prefix]=\"row.percentage ? '' : '$ '\" inputStyleClass=\"sfs-charge-input\"></p-inputnumber>\n } @else {\n {{ row.percentage ? (row.simulatedInput | number: '1.0-4' : locale) + ' %' : (row.simulatedInput | currency: 'COP' : 'symbol-narrow' : '1.0-0' : locale) }}\n }\n </td>\n <td class=\"sfs-right sfs-nowrap\">{{ row.value | currency: 'COP' : 'symbol-narrow' : '1.0-0' : locale }}</td>\n </tr>\n </ng-template>\n <ng-template #emptymessage>\n <tr><td colspan=\"5\">La l\u00EDnea no tiene cargos.</td></tr>\n </ng-template>\n </p-table>\n\n <!-- Resultado frente a lo guardado -->\n <section [attr.aria-labelledby]=\"ids.resultTitle\">\n <div class=\"sfs-head\">\n <h3 [id]=\"ids.resultTitle\" class=\"sfs-subtitle\">Resultado</h3>\n <p-tag [value]=\"l.viable ? 'Viable' : 'No viable'\" [severity]=\"l.viable ? 'success' : 'warn'\"></p-tag>\n </div>\n <p-table [value]=\"comparison()\" styleClass=\"p-datatable-sm\" [scrollable]=\"true\" dataKey=\"label\">\n <ng-template #header>\n <tr><th>Concepto</th><th class=\"sfs-right\">Guardado</th><th class=\"sfs-right\">Simulaci\u00F3n</th></tr>\n </ng-template>\n <ng-template #body let-row>\n <tr>\n <td>{{ row.label }}</td>\n <td class=\"sfs-right sfs-nowrap\">\n <ng-container *ngTemplateOutlet=\"valueTpl; context: { $implicit: row.saved, kind: row.kind }\"></ng-container>\n </td>\n <td class=\"sfs-right sfs-nowrap\">\n @if (row.changed) { <span class=\"sfs-tag-before\"><p-tag value=\"Cambia\" severity=\"warn\"></p-tag></span> }\n <span [class.sfs-strong]=\"row.changed\">\n <ng-container *ngTemplateOutlet=\"valueTpl; context: { $implicit: row.simulated, kind: row.kind }\"></ng-container>\n </span>\n </td>\n </tr>\n </ng-template>\n </p-table>\n @if (!l.viable && l.viabilityReasons.length) {\n <ul class=\"sfs-list sfs-gap-top\">\n @for (reason of l.viabilityReasons; track $index) { <li>{{ reason }}</li> }\n </ul>\n }\n </section>\n\n <!-- Acciones -->\n <div class=\"sfs-actions\">\n @if (canEdit() || capacityEditable()) {\n <p-button label=\"Recalcular\" icon=\"pi pi-calculator\" severity=\"secondary\" [text]=\"true\"\n [disabled]=\"!pendingChanges() || hasNegativeInput()\" (onClick)=\"recalculate()\"></p-button>\n }\n @if (showSave()) {\n <!-- pButton y no p-button: sin poder guardar el bot\u00F3n queda aria-disabled (no disabled) para que el\n motivo se vea con Tab y con el mouse; openConfirm() corta el clic cuando hay motivo. -->\n <button pButton type=\"button\" label=\"Guardar condiciones\" aria-label=\"Guardar condiciones\"\n [icon]=\"saveUnavailableReason() ? 'pi pi-lock' : 'pi pi-save'\"\n [class.sfs-unavailable]=\"!!saveUnavailableReason()\"\n [attr.aria-disabled]=\"saveUnavailableReason() ? 'true' : null\"\n [attr.aria-describedby]=\"saveUnavailableReason() ? ids.saveReason : null\"\n [pTooltip]=\"saveUnavailableReason() ?? ''\" [tooltipDisabled]=\"!saveUnavailableReason()\" tooltipPosition=\"top\" tooltipEvent=\"both\"\n (click)=\"openConfirm()\"></button>\n @if (saveUnavailableReason()) {\n <span [id]=\"ids.saveReason\" class=\"sfs-sr-only\">{{ saveUnavailableReason() }}</span>\n }\n }\n </div>\n }\n }\n }\n }\n</div>\n\n<!-- Siempre montada: anuncia el resultado de cada simulaci\u00F3n (la de arriba se destruye mientras carga). -->\n<div class=\"sfs-sr-only\" role=\"status\" aria-live=\"polite\">{{ liveMessage() }}</div>\n\n<!-- Un valor de la comparaci\u00F3n, en su formato -->\n<ng-template #valueTpl let-value let-kind=\"kind\">\n @if (value === null || value === undefined || value === '') { \u2014 }\n @else {\n @switch (kind) {\n @case ('money') { {{ value | currency: 'COP' : 'symbol-narrow' : '1.0-0' : locale }} }\n @case ('rate') { {{ value | number: '1.0-4' : locale }} % M.V. }\n @case ('term') { {{ value }} cuotas }\n @default { {{ value }} }\n }\n }\n</ng-template>\n\n<!-- Confirmaci\u00F3n: cambia l\u00EDnea, monto, plazo y cargos de la solicitud -->\n<p-dialog header=\"Guardar condiciones\" [visible]=\"confirmVisible()\" (visibleChange)=\"confirmVisible.set($event)\" (onHide)=\"restoreConfirmFocus()\"\n [modal]=\"true\" [draggable]=\"false\" [closable]=\"!saving()\" [style]=\"{ width: '32rem', maxWidth: '95vw' }\">\n @if (confirmVisible() && line(); as l) {\n <p class=\"sfs-no-top\">\n Se guardar\u00E1n la l\u00EDnea <strong>{{ l.lineName || l.line }}</strong>,\n un monto de <strong>{{ l.amount | currency: 'COP' : 'symbol-narrow' : '1.0-0' : locale }}</strong>\n a <strong>{{ l.term }} cuotas</strong> con una tasa de <strong>{{ l.rate | number: '1.0-4' : locale }} % M.V.</strong> y una cuota de <strong>{{ l.installment | currency: 'COP' : 'symbol-narrow' : '1.0-0' : locale }}</strong>,\n con un giro al cliente de <strong>{{ l.transfer | currency: 'COP' : 'symbol-narrow' : '1.0-0' : locale }}</strong>.\n </p>\n @if (!l.viable) {\n <p-message severity=\"warn\" text=\"La l\u00EDnea no es viable con la capacidad de pago de la solicitud.\"></p-message>\n }\n }\n <ng-template #footer>\n <p-button label=\"Cancelar\" severity=\"secondary\" [text]=\"true\" [disabled]=\"saving()\" (onClick)=\"confirmVisible.set(false)\"></p-button>\n <p-button label=\"Guardar condiciones\" icon=\"pi pi-save\" [loading]=\"saving()\" (onClick)=\"confirmSave()\"></p-button>\n </ng-template>\n</p-dialog>\n", styles: [".sfs-title{margin:0;font-size:1.125rem;font-weight:600}.sfs-subtitle{margin:0;font-size:1rem;font-weight:600}.sfs-muted{color:var(--p-text-muted-color)}.sfs-section-title{display:flex;align-items:center;gap:.5rem;margin:0 0 .75rem;font-size:1rem;font-weight:600}.sfs-section-title i{color:var(--primary-color, var(--p-primary-color))}.sfs-inline{display:flex;flex-wrap:wrap;align-items:center;gap:.75rem}.sfs-head{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:.5rem;margin-bottom:.75rem}.sfs-break{overflow-wrap:anywhere}.sfs-nowrap{white-space:nowrap}.sfs-right{text-align:right}.sfs-strong{font-weight:600}.sfs-tag-gap{margin-left:.5rem}.sfs-stack{display:flex;flex-direction:column;gap:1rem}.sfs-sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}.sfs-summary{display:grid;grid-template-columns:minmax(8rem,max-content) 1fr;gap:.25rem 1rem;margin:0}.sfs-summary dt{color:var(--p-text-muted-color)}.sfs-summary dd{margin:0;text-align:right;font-variant-numeric:tabular-nums}\n", ".sfs-control{display:flex;flex-direction:column;gap:.25rem;min-width:0}.sfs-control--check{flex-direction:row;align-items:center;gap:.5rem;align-self:end;min-height:2.75rem}.sfs-capacity-grid{display:grid;grid-template-columns:minmax(0,1fr);gap:.75rem}@media (min-width: 576px){.sfs-capacity-grid{grid-template-columns:repeat(3,minmax(0,1fr))}}.sfs-conditions{display:grid;grid-template-columns:minmax(0,1fr);gap:.75rem}@media (min-width: 576px){.sfs-conditions{grid-template-columns:repeat(3,minmax(0,1fr))}}.sfs-actions{display:flex;flex-wrap:wrap;justify-content:flex-end;gap:.5rem}.sfs-list{margin:0;padding-left:1rem}.sfs-gap-top{margin-top:.5rem}.sfs-gap-bottom{margin-bottom:.5rem}.sfs-no-top{margin-top:0}.sfs-tag-before{margin-right:.5rem}:host ::ng-deep .sfs-charge-input{width:7rem;text-align:right}:host ::ng-deep .sfs-unavailable.p-button{opacity:var(--p-disabled-opacity);cursor:default}:host ::ng-deep .sfs-unavailable.p-button:hover,:host ::ng-deep .sfs-unavailable.p-button:active{background:var(--button-color, var(--p-button-primary-background));border-color:var(--button-color, var(--p-button-primary-border-color))}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "pipe", type: i1.DecimalPipe, name: "number" }, { kind: "pipe", type: i1.CurrencyPipe, name: "currency" }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i2$1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2$1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "ngmodule", type: ButtonModule }, { kind: "directive", type: i2.ButtonDirective, selector: "[pButton]", inputs: ["iconPos", "loadingIcon", "loading", "severity", "raised", "rounded", "text", "outlined", "size", "plain", "fluid", "label", "icon", "buttonProps"] }, { kind: "component", type: i2.Button, selector: "p-button", inputs: ["type", "iconPos", "icon", "badge", "label", "disabled", "loading", "loadingIcon", "raised", "rounded", "text", "plain", "severity", "outlined", "link", "tabindex", "size", "variant", "style", "styleClass", "badgeClass", "badgeSeverity", "ariaLabel", "autofocus", "fluid", "buttonProps"], outputs: ["onClick", "onFocus", "onBlur"] }, { kind: "ngmodule", type: CheckboxModule }, { kind: "component", type: i4$1.Checkbox, selector: "p-checkbox, p-checkBox, p-check-box", inputs: ["value", "name", "disabled", "binary", "ariaLabelledBy", "ariaLabel", "tabindex", "inputId", "style", "inputStyle", "styleClass", "inputClass", "indeterminate", "size", "formControl", "checkboxIcon", "readonly", "required", "autofocus", "trueValue", "falseValue", "variant"], outputs: ["onChange", "onFocus", "onBlur"] }, { kind: "ngmodule", type: DialogModule }, { kind: "component", type: i5$1.Dialog, selector: "p-dialog", inputs: ["header", "draggable", "resizable", "positionLeft", "positionTop", "contentStyle", "contentStyleClass", "modal", "closeOnEscape", "dismissableMask", "rtl", "closable", "responsive", "appendTo", "breakpoints", "styleClass", "maskStyleClass", "maskStyle", "showHeader", "breakpoint", "blockScroll", "autoZIndex", "baseZIndex", "minX", "minY", "focusOnShow", "maximizable", "keepInViewport", "focusTrap", "transitionOptions", "closeIcon", "closeAriaLabel", "closeTabindex", "minimizeIcon", "maximizeIcon", "closeButtonProps", "maximizeButtonProps", "visible", "style", "position", "role", "content", "contentTemplate", "footerTemplate", "closeIconTemplate", "maximizeIconTemplate", "minimizeIconTemplate", "headlessTemplate"], outputs: ["onShow", "onHide", "visibleChange", "onResizeInit", "onResizeEnd", "onDragEnd", "onMaximize"] }, { kind: "ngmodule", type: InputNumberModule }, { kind: "component", type: i6$1.InputNumber, selector: "p-inputNumber, p-inputnumber, p-input-number", inputs: ["showButtons", "format", "buttonLayout", "inputId", "styleClass", "style", "placeholder", "size", "maxlength", "tabindex", "title", "ariaLabelledBy", "ariaDescribedBy", "ariaLabel", "ariaRequired", "name", "required", "autocomplete", "min", "max", "incrementButtonClass", "decrementButtonClass", "incrementButtonIcon", "decrementButtonIcon", "readonly", "step", "allowEmpty", "locale", "localeMatcher", "mode", "currency", "currencyDisplay", "useGrouping", "variant", "minFractionDigits", "maxFractionDigits", "prefix", "suffix", "inputStyle", "inputStyleClass", "showClear", "autofocus", "disabled", "fluid"], outputs: ["onInput", "onFocus", "onBlur", "onKeyDown", "onClear"] }, { kind: "ngmodule", type: MessageModule }, { kind: "component", type: i4.Message, selector: "p-message", inputs: ["severity", "text", "escape", "style", "styleClass", "closable", "icon", "closeIcon", "life", "showTransitionOptions", "hideTransitionOptions", "size", "variant"], outputs: ["onClose"] }, { kind: "ngmodule", type: SelectModule }, { kind: "component", type: i8.Select, selector: "p-select", inputs: ["id", "scrollHeight", "filter", "name", "style", "panelStyle", "styleClass", "panelStyleClass", "readonly", "required", "editable", "appendTo", "tabindex", "placeholder", "loadingIcon", "filterPlaceholder", "filterLocale", "variant", "inputId", "dataKey", "filterBy", "filterFields", "autofocus", "resetFilterOnHide", "checkmark", "dropdownIcon", "loading", "optionLabel", "optionValue", "optionDisabled", "optionGroupLabel", "optionGroupChildren", "autoDisplayFirst", "group", "showClear", "emptyFilterMessage", "emptyMessage", "lazy", "virtualScroll", "virtualScrollItemSize", "virtualScrollOptions", "size", "overlayOptions", "ariaFilterLabel", "ariaLabel", "ariaLabelledBy", "filterMatchMode", "maxlength", "tooltip", "tooltipPosition", "tooltipPositionStyle", "tooltipStyleClass", "focusOnHover", "selectOnFocus", "autoOptionFocus", "autofocusFilter", "fluid", "disabled", "itemSize", "autoZIndex", "baseZIndex", "showTransitionOptions", "hideTransitionOptions", "filterValue", "options"], outputs: ["onChange", "onFilter", "onFocus", "onBlur", "onClick", "onShow", "onHide", "onClear", "onLazyLoad"] }, { kind: "ngmodule", type: SkeletonModule }, { kind: "component", type: i5.Skeleton, selector: "p-skeleton", inputs: ["styleClass", "style", "shape", "animation", "borderRadius", "size", "width", "height"] }, { kind: "ngmodule", type: TableModule }, { kind: "component", type: i6.Table, selector: "p-table", inputs: ["frozenColumns", "frozenValue", "style", "styleClass", "tableStyle", "tableStyleClass", "paginator", "pageLinks", "rowsPerPageOptions", "alwaysShowPaginator", "paginatorPosition", "paginatorStyleClass", "paginatorDropdownAppendTo", "paginatorDropdownScrollHeight", "currentPageReportTemplate", "showCurrentPageReport", "showJumpToPageDropdown", "showJumpToPageInput", "showFirstLastIcon", "showPageLinks", "defaultSortOrder", "sortMode", "resetPageOnSort", "selectionMode", "selectionPageOnly", "contextMenuSelection", "contextMenuSelectionMode", "dataKey", "metaKeySelection", "rowSelectable", "rowTrackBy", "lazy", "lazyLoadOnInit", "compareSelectionBy", "csvSeparator", "exportFilename", "filters", "globalFilterFields", "filterDelay", "filterLocale", "expandedRowKeys", "editingRowKeys", "rowExpandMode", "scrollable", "scrollDirection", "rowGroupMode", "scrollHeight", "virtualScroll", "virtualScrollItemSize", "virtualScrollOptions", "virtualScrollDelay", "frozenWidth", "responsive", "contextMenu", "resizableColumns", "columnResizeMode", "reorderableColumns", "loading", "loadingIcon", "showLoader", "rowHover", "customSort", "showInitialSortBadge", "autoLayout", "exportFunction", "exportHeader", "stateKey", "stateStorage", "editMode", "groupRowsBy", "size", "showGridlines", "stripedRows", "groupRowsByOrder", "responsiveLayout", "breakpoint", "paginatorLocale", "value", "columns", "first", "rows", "totalRecords", "sortField", "sortOrder", "multiSortMeta", "selection", "virtualRowHeight", "selectAll"], outputs: ["contextMenuSelectionChange", "selectAllChange", "selectionChange", "onRowSelect", "onRowUnselect", "onPage", "onSort", "onFilter", "onLazyLoad", "onRowExpand", "onRowCollapse", "onContextMenuSelect", "onColResize", "onColReorder", "onRowReorder", "onEditInit", "onEditComplete", "onEditCancel", "onHeaderCheckboxToggle", "sortFunction", "firstChange", "rowsChange", "onStateSave", "onStateRestore"] }, { kind: "ngmodule", type: TagModule }, { kind: "component", type: i7.Tag, selector: "p-tag", inputs: ["style", "styleClass", "severity", "value", "icon", "rounded"] }, { kind: "ngmodule", type: TooltipModule }, { kind: "directive", type: i12.Tooltip, selector: "[pTooltip]", inputs: ["tooltipPosition", "tooltipEvent", "appendTo", "positionStyle", "tooltipStyleClass", "tooltipZIndex", "escape", "showDelay", "hideDelay", "life", "positionTop", "positionLeft", "autoHide", "fitContent", "hideOnEscape", "pTooltip", "tooltipDisabled", "tooltipOptions"] }] });
|
|
619
|
+
}
|
|
620
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.17", ngImport: i0, type: LineSimulatorComponent, decorators: [{
|
|
621
|
+
type: Component,
|
|
622
|
+
args: [{ selector: 'lib-line-simulator', imports: [
|
|
623
|
+
CommonModule,
|
|
624
|
+
FormsModule,
|
|
625
|
+
ButtonModule,
|
|
626
|
+
CheckboxModule,
|
|
627
|
+
DialogModule,
|
|
628
|
+
InputNumberModule,
|
|
629
|
+
MessageModule,
|
|
630
|
+
SelectModule,
|
|
631
|
+
SkeletonModule,
|
|
632
|
+
TableModule,
|
|
633
|
+
TagModule,
|
|
634
|
+
TooltipModule
|
|
635
|
+
], template: "<div class=\"sfs-stack\">\n <!-- Capacidad de pago -->\n <section [attr.aria-labelledby]=\"ids.capacityTitle\">\n <h3 [id]=\"ids.capacityTitle\" class=\"sfs-subtitle sfs-gap-bottom\">Capacidad de pago</h3>\n @if (capacityEditable()) {\n <div class=\"sfs-capacity-grid\">\n @for (field of capacityFields; track field.key) {\n <div class=\"sfs-control\">\n <label [for]=\"ids.capacity + field.key\">{{ field.label }}</label>\n <p-inputnumber [inputId]=\"ids.capacity + field.key\" [ngModel]=\"currentCapacity()[field.key]\" (ngModelChange)=\"setCapacity(field.key, $event)\"\n mode=\"currency\" currency=\"COP\" [locale]=\"locale\" [minFractionDigits]=\"0\" [maxFractionDigits]=\"0\" [min]=\"0\" [fluid]=\"true\"></p-inputnumber>\n </div>\n }\n <div class=\"sfs-control sfs-control--check\">\n <p-checkbox [inputId]=\"ids.garnishment\" [binary]=\"true\" [ngModel]=\"currentCapacity().hasGarnishment\" (ngModelChange)=\"setGarnishment($event)\"></p-checkbox>\n <label [for]=\"ids.garnishment\">Tiene embargo</label>\n </div>\n </div>\n } @else {\n <dl class=\"sfs-summary\">\n <dt>Ingresos</dt><dd>{{ capacity().income | currency: 'COP' : 'symbol-narrow' : '1.0-0' : locale }}</dd>\n <dt>Descuentos de ley</dt><dd>{{ capacity().legalDeductions | currency: 'COP' : 'symbol-narrow' : '1.0-0' : locale }}</dd>\n <dt>Otras afiliaciones</dt><dd>{{ capacity().otherAffiliations | currency: 'COP' : 'symbol-narrow' : '1.0-0' : locale }}</dd>\n <dt>Otros descuentos</dt><dd>{{ capacity().otherDeductions | currency: 'COP' : 'symbol-narrow' : '1.0-0' : locale }}</dd>\n <dt>Compras de cartera</dt><dd>{{ capacity().purchasesValue | currency: 'COP' : 'symbol-narrow' : '1.0-0' : locale }}</dd>\n <dt>Embargo</dt><dd>{{ capacity().hasGarnishment ? 'S\u00ED' : 'No' }}</dd>\n </dl>\n }\n @if (simulation(); as s) {\n <dl class=\"sfs-summary sfs-gap-top\">\n <dt>Cuota disponible</dt><dd>{{ s.capacity.availableInstallment | currency: 'COP' : 'symbol-narrow' : '1.0-0' : locale }}</dd>\n <dt>Monto m\u00E1ximo</dt><dd>{{ s.capacity.maxAmount != null ? (s.capacity.maxAmount | currency: 'COP' : 'symbol-narrow' : '1.0-0' : locale) : '\u2014' }}</dd>\n </dl>\n }\n </section>\n\n @switch (state()) {\n @case ('loading') {\n <div class=\"sfs-stack\" aria-busy=\"true\">\n <p-skeleton height=\"2.5rem\"></p-skeleton>\n <p-skeleton height=\"12rem\"></p-skeleton>\n </div>\n }\n @case ('error') {\n <p-message severity=\"error\">\n <div class=\"sfs-inline\">\n <span>{{ errorMessage() || 'No se pudo simular la solicitud.' }}</span>\n <p-button label=\"Reintentar\" icon=\"pi pi-refresh\" [text]=\"true\" (onClick)=\"retrySimulation()\"></p-button>\n </div>\n </p-message>\n @if (capacityEditable() && pendingChanges()) {\n <div class=\"sfs-actions\">\n <p-button label=\"Recalcular\" icon=\"pi pi-calculator\" severity=\"secondary\" [text]=\"true\" [disabled]=\"hasNegativeInput()\" (onClick)=\"recalculate()\"></p-button>\n </div>\n }\n }\n @case ('idle') {\n @if (capacityEditable()) {\n <div class=\"sfs-actions\">\n <p-button label=\"Simular\" icon=\"pi pi-calculator\" [disabled]=\"hasNegativeInput()\" (onClick)=\"recalculate()\"></p-button>\n </div>\n } @else {\n <p class=\"sfs-muted sfs-no-top\">Todav\u00EDa no hay una simulaci\u00F3n para esta solicitud.</p>\n }\n }\n @case ('ready') {\n @if (simulation()?.warnings?.length) {\n <p-message severity=\"warn\">\n <ul class=\"sfs-list\">\n @for (w of simulation()?.warnings ?? []; track $index) { <li>{{ w }}</li> }\n </ul>\n </p-message>\n }\n\n @if (!lineOptions().length) {\n <p-message severity=\"info\" text=\"El simulador no devolvi\u00F3 l\u00EDneas para esta solicitud. Revise la pagadur\u00EDa, el producto y la capacidad de pago.\"></p-message>\n }\n\n <!-- L\u00EDnea. p-select pone el inputId en un span: el nombre accesible va por ariaLabelledBy. -->\n <div class=\"sfs-control\">\n <label [id]=\"ids.lineLabel\" [for]=\"ids.line\" class=\"sfs-strong\">L\u00EDnea</label>\n <p-select [inputId]=\"ids.line\" [ariaLabelledBy]=\"ids.lineLabel\" [options]=\"lineOptions()\" optionLabel=\"label\" optionValue=\"value\" optionDisabled=\"disabled\"\n [ngModel]=\"selectedLine()\" (ngModelChange)=\"chooseLine($event)\" placeholder=\"Seleccione una l\u00EDnea\" [fluid]=\"true\"></p-select>\n @if (saved()?.line && saved()?.line !== selectedLine()) {\n <small class=\"sfs-muted\">La l\u00EDnea guardada es {{ savedLineName() }}. Al guardar se cambia por la elegida.</small>\n }\n </div>\n\n @if (line(); as l) {\n @if (l.error) {\n <p-message severity=\"error\" text=\"Esta l\u00EDnea no se pudo simular. Elija otra o intente m\u00E1s tarde.\"></p-message>\n } @else {\n <!-- Condiciones -->\n <div class=\"sfs-conditions\">\n <div class=\"sfs-control\">\n <label [for]=\"ids.term\">Plazo (cuotas)</label>\n <p-inputnumber [inputId]=\"ids.term\" [ngModel]=\"termInput()\" (ngModelChange)=\"termInput.set($event)\"\n [min]=\"simulation()?.minTerm ?? 1\" [max]=\"simulation()?.maxTerm ?? 600\" [useGrouping]=\"false\"\n [disabled]=\"!canEdit()\" [fluid]=\"true\"></p-inputnumber>\n </div>\n <div class=\"sfs-control\">\n <label [for]=\"ids.amount\">Monto</label>\n <p-inputnumber [inputId]=\"ids.amount\" [ngModel]=\"amountInput()\" (ngModelChange)=\"amountInput.set($event)\"\n mode=\"currency\" currency=\"COP\" [locale]=\"locale\" [minFractionDigits]=\"0\" [maxFractionDigits]=\"0\" [min]=\"0\"\n [disabled]=\"!canEdit()\" [fluid]=\"true\"></p-inputnumber>\n </div>\n <div class=\"sfs-control\">\n <span>Tasa</span>\n <span class=\"sfs-strong\">{{ l.rate | number: '1.0-4' : locale }} % M.V.</span>\n </div>\n </div>\n\n <!-- Cargos de la l\u00EDnea, con lo guardado al lado -->\n <p-table [value]=\"chargeRows()\" styleClass=\"p-datatable-sm\" [scrollable]=\"true\" dataKey=\"name\">\n <ng-template #header>\n <tr>\n <th>Cargo</th>\n <th>Tipo</th>\n <th class=\"sfs-right\">Guardado</th>\n <th class=\"sfs-right\">Configurado</th>\n <th class=\"sfs-right\">Valor</th>\n </tr>\n </ng-template>\n <ng-template #body let-row>\n <tr>\n <td>{{ row.label }}</td>\n <td>{{ chargeTypeLabel(row.type) }}</td>\n <td class=\"sfs-right sfs-nowrap\">\n @if (row.savedInput === null) { \u2014 }\n @else { {{ row.percentage ? (row.savedInput | number: '1.0-4' : locale) + ' %' : (row.savedInput | currency: 'COP' : 'symbol-narrow' : '1.0-0' : locale) }} }\n </td>\n <td class=\"sfs-right\">\n @if (row.editable) {\n <label [for]=\"row.id\" class=\"sfs-sr-only\">{{ row.label }}</label>\n <p-inputnumber [inputId]=\"row.id\" [ngModel]=\"chargeInputs()[row.name]\" (ngModelChange)=\"setChargeInput(row.name, $event)\"\n [min]=\"0\" [minFractionDigits]=\"0\" [maxFractionDigits]=\"row.percentage ? 4 : 0\" [locale]=\"locale\"\n [suffix]=\"row.percentage ? ' %' : ''\" [prefix]=\"row.percentage ? '' : '$ '\" inputStyleClass=\"sfs-charge-input\"></p-inputnumber>\n } @else {\n {{ row.percentage ? (row.simulatedInput | number: '1.0-4' : locale) + ' %' : (row.simulatedInput | currency: 'COP' : 'symbol-narrow' : '1.0-0' : locale) }}\n }\n </td>\n <td class=\"sfs-right sfs-nowrap\">{{ row.value | currency: 'COP' : 'symbol-narrow' : '1.0-0' : locale }}</td>\n </tr>\n </ng-template>\n <ng-template #emptymessage>\n <tr><td colspan=\"5\">La l\u00EDnea no tiene cargos.</td></tr>\n </ng-template>\n </p-table>\n\n <!-- Resultado frente a lo guardado -->\n <section [attr.aria-labelledby]=\"ids.resultTitle\">\n <div class=\"sfs-head\">\n <h3 [id]=\"ids.resultTitle\" class=\"sfs-subtitle\">Resultado</h3>\n <p-tag [value]=\"l.viable ? 'Viable' : 'No viable'\" [severity]=\"l.viable ? 'success' : 'warn'\"></p-tag>\n </div>\n <p-table [value]=\"comparison()\" styleClass=\"p-datatable-sm\" [scrollable]=\"true\" dataKey=\"label\">\n <ng-template #header>\n <tr><th>Concepto</th><th class=\"sfs-right\">Guardado</th><th class=\"sfs-right\">Simulaci\u00F3n</th></tr>\n </ng-template>\n <ng-template #body let-row>\n <tr>\n <td>{{ row.label }}</td>\n <td class=\"sfs-right sfs-nowrap\">\n <ng-container *ngTemplateOutlet=\"valueTpl; context: { $implicit: row.saved, kind: row.kind }\"></ng-container>\n </td>\n <td class=\"sfs-right sfs-nowrap\">\n @if (row.changed) { <span class=\"sfs-tag-before\"><p-tag value=\"Cambia\" severity=\"warn\"></p-tag></span> }\n <span [class.sfs-strong]=\"row.changed\">\n <ng-container *ngTemplateOutlet=\"valueTpl; context: { $implicit: row.simulated, kind: row.kind }\"></ng-container>\n </span>\n </td>\n </tr>\n </ng-template>\n </p-table>\n @if (!l.viable && l.viabilityReasons.length) {\n <ul class=\"sfs-list sfs-gap-top\">\n @for (reason of l.viabilityReasons; track $index) { <li>{{ reason }}</li> }\n </ul>\n }\n </section>\n\n <!-- Acciones -->\n <div class=\"sfs-actions\">\n @if (canEdit() || capacityEditable()) {\n <p-button label=\"Recalcular\" icon=\"pi pi-calculator\" severity=\"secondary\" [text]=\"true\"\n [disabled]=\"!pendingChanges() || hasNegativeInput()\" (onClick)=\"recalculate()\"></p-button>\n }\n @if (showSave()) {\n <!-- pButton y no p-button: sin poder guardar el bot\u00F3n queda aria-disabled (no disabled) para que el\n motivo se vea con Tab y con el mouse; openConfirm() corta el clic cuando hay motivo. -->\n <button pButton type=\"button\" label=\"Guardar condiciones\" aria-label=\"Guardar condiciones\"\n [icon]=\"saveUnavailableReason() ? 'pi pi-lock' : 'pi pi-save'\"\n [class.sfs-unavailable]=\"!!saveUnavailableReason()\"\n [attr.aria-disabled]=\"saveUnavailableReason() ? 'true' : null\"\n [attr.aria-describedby]=\"saveUnavailableReason() ? ids.saveReason : null\"\n [pTooltip]=\"saveUnavailableReason() ?? ''\" [tooltipDisabled]=\"!saveUnavailableReason()\" tooltipPosition=\"top\" tooltipEvent=\"both\"\n (click)=\"openConfirm()\"></button>\n @if (saveUnavailableReason()) {\n <span [id]=\"ids.saveReason\" class=\"sfs-sr-only\">{{ saveUnavailableReason() }}</span>\n }\n }\n </div>\n }\n }\n }\n }\n</div>\n\n<!-- Siempre montada: anuncia el resultado de cada simulaci\u00F3n (la de arriba se destruye mientras carga). -->\n<div class=\"sfs-sr-only\" role=\"status\" aria-live=\"polite\">{{ liveMessage() }}</div>\n\n<!-- Un valor de la comparaci\u00F3n, en su formato -->\n<ng-template #valueTpl let-value let-kind=\"kind\">\n @if (value === null || value === undefined || value === '') { \u2014 }\n @else {\n @switch (kind) {\n @case ('money') { {{ value | currency: 'COP' : 'symbol-narrow' : '1.0-0' : locale }} }\n @case ('rate') { {{ value | number: '1.0-4' : locale }} % M.V. }\n @case ('term') { {{ value }} cuotas }\n @default { {{ value }} }\n }\n }\n</ng-template>\n\n<!-- Confirmaci\u00F3n: cambia l\u00EDnea, monto, plazo y cargos de la solicitud -->\n<p-dialog header=\"Guardar condiciones\" [visible]=\"confirmVisible()\" (visibleChange)=\"confirmVisible.set($event)\" (onHide)=\"restoreConfirmFocus()\"\n [modal]=\"true\" [draggable]=\"false\" [closable]=\"!saving()\" [style]=\"{ width: '32rem', maxWidth: '95vw' }\">\n @if (confirmVisible() && line(); as l) {\n <p class=\"sfs-no-top\">\n Se guardar\u00E1n la l\u00EDnea <strong>{{ l.lineName || l.line }}</strong>,\n un monto de <strong>{{ l.amount | currency: 'COP' : 'symbol-narrow' : '1.0-0' : locale }}</strong>\n a <strong>{{ l.term }} cuotas</strong> con una tasa de <strong>{{ l.rate | number: '1.0-4' : locale }} % M.V.</strong> y una cuota de <strong>{{ l.installment | currency: 'COP' : 'symbol-narrow' : '1.0-0' : locale }}</strong>,\n con un giro al cliente de <strong>{{ l.transfer | currency: 'COP' : 'symbol-narrow' : '1.0-0' : locale }}</strong>.\n </p>\n @if (!l.viable) {\n <p-message severity=\"warn\" text=\"La l\u00EDnea no es viable con la capacidad de pago de la solicitud.\"></p-message>\n }\n }\n <ng-template #footer>\n <p-button label=\"Cancelar\" severity=\"secondary\" [text]=\"true\" [disabled]=\"saving()\" (onClick)=\"confirmVisible.set(false)\"></p-button>\n <p-button label=\"Guardar condiciones\" icon=\"pi pi-save\" [loading]=\"saving()\" (onClick)=\"confirmSave()\"></p-button>\n </ng-template>\n</p-dialog>\n", styles: [".sfs-title{margin:0;font-size:1.125rem;font-weight:600}.sfs-subtitle{margin:0;font-size:1rem;font-weight:600}.sfs-muted{color:var(--p-text-muted-color)}.sfs-section-title{display:flex;align-items:center;gap:.5rem;margin:0 0 .75rem;font-size:1rem;font-weight:600}.sfs-section-title i{color:var(--primary-color, var(--p-primary-color))}.sfs-inline{display:flex;flex-wrap:wrap;align-items:center;gap:.75rem}.sfs-head{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:.5rem;margin-bottom:.75rem}.sfs-break{overflow-wrap:anywhere}.sfs-nowrap{white-space:nowrap}.sfs-right{text-align:right}.sfs-strong{font-weight:600}.sfs-tag-gap{margin-left:.5rem}.sfs-stack{display:flex;flex-direction:column;gap:1rem}.sfs-sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}.sfs-summary{display:grid;grid-template-columns:minmax(8rem,max-content) 1fr;gap:.25rem 1rem;margin:0}.sfs-summary dt{color:var(--p-text-muted-color)}.sfs-summary dd{margin:0;text-align:right;font-variant-numeric:tabular-nums}\n", ".sfs-control{display:flex;flex-direction:column;gap:.25rem;min-width:0}.sfs-control--check{flex-direction:row;align-items:center;gap:.5rem;align-self:end;min-height:2.75rem}.sfs-capacity-grid{display:grid;grid-template-columns:minmax(0,1fr);gap:.75rem}@media (min-width: 576px){.sfs-capacity-grid{grid-template-columns:repeat(3,minmax(0,1fr))}}.sfs-conditions{display:grid;grid-template-columns:minmax(0,1fr);gap:.75rem}@media (min-width: 576px){.sfs-conditions{grid-template-columns:repeat(3,minmax(0,1fr))}}.sfs-actions{display:flex;flex-wrap:wrap;justify-content:flex-end;gap:.5rem}.sfs-list{margin:0;padding-left:1rem}.sfs-gap-top{margin-top:.5rem}.sfs-gap-bottom{margin-bottom:.5rem}.sfs-no-top{margin-top:0}.sfs-tag-before{margin-right:.5rem}:host ::ng-deep .sfs-charge-input{width:7rem;text-align:right}:host ::ng-deep .sfs-unavailable.p-button{opacity:var(--p-disabled-opacity);cursor:default}:host ::ng-deep .sfs-unavailable.p-button:hover,:host ::ng-deep .sfs-unavailable.p-button:active{background:var(--button-color, var(--p-button-primary-background));border-color:var(--button-color, var(--p-button-primary-border-color))}\n"] }]
|
|
636
|
+
}], ctorParameters: () => [] });
|
|
637
|
+
/** Un valor configurado del core (fracción o pesos) en la unidad de la pantalla (% o pesos). */
|
|
638
|
+
function toScreenUnit(value, percentage) {
|
|
639
|
+
return percentage ? round(value * 100, 4) : value;
|
|
640
|
+
}
|
|
641
|
+
function sameCapacity(a, b) {
|
|
642
|
+
return a.age === b.age && a.hasGarnishment === b.hasGarnishment && CAPACITY_FIELDS.every((f) => a[f.key] === b[f.key]);
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
/**
|
|
646
|
+
* Compras de cartera de la solicitud (buró, digitadas y retanqueos), de solo lectura. Las totaliza y avisa si lo
|
|
647
|
+
* marcado para comprar no cuadra con el valor con que se simula.
|
|
648
|
+
*/
|
|
649
|
+
class DebtBuyoutsComponent {
|
|
650
|
+
/** El host todavía las está leyendo. Mientras tanto `buyouts` no se mira. */
|
|
651
|
+
loading = input(false);
|
|
652
|
+
/** `null` o `undefined`: no se pudieron leer (no es lo mismo que una lista vacía). */
|
|
653
|
+
buyouts = input(null);
|
|
654
|
+
/** Valor de compras de cartera con que se simula. */
|
|
655
|
+
simulatedValue = input(0);
|
|
656
|
+
/** Pide al host volver a leer las compras. */
|
|
657
|
+
retry = output();
|
|
658
|
+
locale = LOCALE;
|
|
659
|
+
rows = computed(() => (this.buyouts() ?? []).map((row) => ({ ...row, FechaVencimiento: toIsoDate(row.FechaVencimiento) })));
|
|
660
|
+
failed = computed(() => !Array.isArray(this.buyouts()));
|
|
661
|
+
toBuy = computed(() => this.rows().filter((row) => row.Comprar));
|
|
662
|
+
totalToBuy = computed(() => this.toBuy().reduce((sum, row) => sum + (Number(row.SaldoActual) || 0), 0));
|
|
663
|
+
installmentsToBuy = computed(() => this.toBuy().reduce((sum, row) => sum + (Number(row.ValorCuota) || 0), 0));
|
|
664
|
+
/**
|
|
665
|
+
* Lo marcado para comprar no es lo que se simula (diferencia de al menos un peso), incluido el caso de no tener
|
|
666
|
+
* nada marcado y simular con compras.
|
|
667
|
+
*/
|
|
668
|
+
mismatch = computed(() => this.rows().length > 0 && Math.abs(this.totalToBuy() - (this.simulatedValue() || 0)) >= 1);
|
|
669
|
+
constructor() {
|
|
670
|
+
ensureLocale();
|
|
671
|
+
}
|
|
672
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.17", ngImport: i0, type: DebtBuyoutsComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
673
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.17", type: DebtBuyoutsComponent, isStandalone: true, selector: "lib-debt-buyouts", inputs: { loading: { classPropertyName: "loading", publicName: "loading", isSignal: true, isRequired: false, transformFunction: null }, buyouts: { classPropertyName: "buyouts", publicName: "buyouts", isSignal: true, isRequired: false, transformFunction: null }, simulatedValue: { classPropertyName: "simulatedValue", publicName: "simulatedValue", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { retry: "retry" }, ngImport: i0, template: "<p-card>\n <div class=\"sfs-head\">\n <h2 class=\"sfs-title\">Compras de cartera</h2>\n @if (!loading() && !failed() && rows().length) {\n <span class=\"sfs-muted\">\n {{ toBuy().length }} de {{ rows().length }} {{ rows().length === 1 ? 'obligaci\u00F3n' : 'obligaciones' }} para comprar\n </span>\n }\n </div>\n\n @if (loading()) {\n <div class=\"sfs-stack\" aria-busy=\"true\">\n <p-skeleton height=\"2.5rem\"></p-skeleton>\n <p-skeleton height=\"8rem\"></p-skeleton>\n </div>\n } @else if (failed()) {\n <p-message severity=\"error\">\n <div class=\"sfs-inline\">\n <span>No se pudieron leer las compras de cartera de la solicitud.</span>\n <p-button label=\"Reintentar\" icon=\"pi pi-refresh\" [text]=\"true\" (onClick)=\"retry.emit()\"></p-button>\n </div>\n </p-message>\n } @else {\n <div class=\"sfs-stack\">\n @if (mismatch()) {\n <p-message severity=\"warn\">\n Las obligaciones marcadas para comprar suman {{ totalToBuy() | currency: 'COP' : 'symbol-narrow' : '1.0-0' : locale }},\n pero la solicitud se simula con compras de cartera por {{ simulatedValue() | currency: 'COP' : 'symbol-narrow' : '1.0-0' : locale }}.\n </p-message>\n }\n\n <p-table [value]=\"rows()\" styleClass=\"p-datatable-sm\" [scrollable]=\"true\" dataKey=\"IdPrstmsCC\">\n <ng-template #header>\n <tr>\n <th>Entidad</th>\n <th>Obligaci\u00F3n</th>\n <th>Origen</th>\n <th>Estado</th>\n <th>Vence</th>\n <th class=\"sfs-right\">Cuota</th>\n <th class=\"sfs-right\">Saldo</th>\n <th class=\"sfs-right\">Mora</th>\n <th>Desprendible</th>\n <th>Comprar</th>\n </tr>\n </ng-template>\n <ng-template #body let-row>\n <tr>\n <td>\n {{ row.Entidad || '\u2014' }}\n @if (row.NitEntidad) { <br /><small class=\"sfs-muted\">NIT {{ row.NitEntidad }}</small> }\n </td>\n <td>{{ row.NumeroObligacion || '\u2014' }}</td>\n <td>\n {{ row.Buro || '\u2014' }}\n @if (row.Sector) { <br /><small class=\"sfs-muted\">{{ row.Sector }}</small> }\n </td>\n <td>{{ row.EstadoObligacion || '\u2014' }}</td>\n <td class=\"sfs-nowrap\">{{ row.FechaVencimiento || '\u2014' }}</td>\n <td class=\"sfs-right sfs-nowrap\">{{ row.ValorCuota | currency: 'COP' : 'symbol-narrow' : '1.0-0' : locale }}</td>\n <td class=\"sfs-right sfs-nowrap\">{{ row.SaldoActual | currency: 'COP' : 'symbol-narrow' : '1.0-0' : locale }}</td>\n <td class=\"sfs-right sfs-nowrap\">{{ row.SaldoMora | currency: 'COP' : 'symbol-narrow' : '1.0-0' : locale }}</td>\n <td>{{ row.Desprendible ? 'S\u00ED' : 'No' }}</td>\n <td><p-tag [value]=\"row.Comprar ? 'Comprar' : 'No comprar'\" [severity]=\"row.Comprar ? 'success' : 'secondary'\"></p-tag></td>\n </tr>\n </ng-template>\n <ng-template #footer>\n @if (rows().length) {\n <tr>\n <td colspan=\"5\" class=\"sfs-strong\">Total para comprar</td>\n <td class=\"sfs-right sfs-nowrap sfs-strong\">{{ installmentsToBuy() | currency: 'COP' : 'symbol-narrow' : '1.0-0' : locale }}</td>\n <td class=\"sfs-right sfs-nowrap sfs-strong\">{{ totalToBuy() | currency: 'COP' : 'symbol-narrow' : '1.0-0' : locale }}</td>\n <td colspan=\"3\"></td>\n </tr>\n }\n </ng-template>\n <ng-template #emptymessage>\n <tr><td colspan=\"10\">La solicitud no tiene compras de cartera registradas.</td></tr>\n </ng-template>\n </p-table>\n </div>\n }\n</p-card>\n", styles: [".sfs-title{margin:0;font-size:1.125rem;font-weight:600}.sfs-subtitle{margin:0;font-size:1rem;font-weight:600}.sfs-muted{color:var(--p-text-muted-color)}.sfs-section-title{display:flex;align-items:center;gap:.5rem;margin:0 0 .75rem;font-size:1rem;font-weight:600}.sfs-section-title i{color:var(--primary-color, var(--p-primary-color))}.sfs-inline{display:flex;flex-wrap:wrap;align-items:center;gap:.75rem}.sfs-head{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:.5rem;margin-bottom:.75rem}.sfs-break{overflow-wrap:anywhere}.sfs-nowrap{white-space:nowrap}.sfs-right{text-align:right}.sfs-strong{font-weight:600}.sfs-tag-gap{margin-left:.5rem}.sfs-stack{display:flex;flex-direction:column;gap:1rem}.sfs-sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}.sfs-summary{display:grid;grid-template-columns:minmax(8rem,max-content) 1fr;gap:.25rem 1rem;margin:0}.sfs-summary dt{color:var(--p-text-muted-color)}.sfs-summary dd{margin:0;text-align:right;font-variant-numeric:tabular-nums}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "pipe", type: i1.CurrencyPipe, name: "currency" }, { kind: "ngmodule", type: ButtonModule }, { kind: "component", type: i2.Button, selector: "p-button", inputs: ["type", "iconPos", "icon", "badge", "label", "disabled", "loading", "loadingIcon", "raised", "rounded", "text", "plain", "severity", "outlined", "link", "tabindex", "size", "variant", "style", "styleClass", "badgeClass", "badgeSeverity", "ariaLabel", "autofocus", "fluid", "buttonProps"], outputs: ["onClick", "onFocus", "onBlur"] }, { kind: "ngmodule", type: CardModule }, { kind: "component", type: i3.Card, selector: "p-card", inputs: ["header", "subheader", "style", "styleClass"] }, { kind: "ngmodule", type: MessageModule }, { kind: "component", type: i4.Message, selector: "p-message", inputs: ["severity", "text", "escape", "style", "styleClass", "closable", "icon", "closeIcon", "life", "showTransitionOptions", "hideTransitionOptions", "size", "variant"], outputs: ["onClose"] }, { kind: "ngmodule", type: SkeletonModule }, { kind: "component", type: i5.Skeleton, selector: "p-skeleton", inputs: ["styleClass", "style", "shape", "animation", "borderRadius", "size", "width", "height"] }, { kind: "ngmodule", type: TableModule }, { kind: "component", type: i6.Table, selector: "p-table", inputs: ["frozenColumns", "frozenValue", "style", "styleClass", "tableStyle", "tableStyleClass", "paginator", "pageLinks", "rowsPerPageOptions", "alwaysShowPaginator", "paginatorPosition", "paginatorStyleClass", "paginatorDropdownAppendTo", "paginatorDropdownScrollHeight", "currentPageReportTemplate", "showCurrentPageReport", "showJumpToPageDropdown", "showJumpToPageInput", "showFirstLastIcon", "showPageLinks", "defaultSortOrder", "sortMode", "resetPageOnSort", "selectionMode", "selectionPageOnly", "contextMenuSelection", "contextMenuSelectionMode", "dataKey", "metaKeySelection", "rowSelectable", "rowTrackBy", "lazy", "lazyLoadOnInit", "compareSelectionBy", "csvSeparator", "exportFilename", "filters", "globalFilterFields", "filterDelay", "filterLocale", "expandedRowKeys", "editingRowKeys", "rowExpandMode", "scrollable", "scrollDirection", "rowGroupMode", "scrollHeight", "virtualScroll", "virtualScrollItemSize", "virtualScrollOptions", "virtualScrollDelay", "frozenWidth", "responsive", "contextMenu", "resizableColumns", "columnResizeMode", "reorderableColumns", "loading", "loadingIcon", "showLoader", "rowHover", "customSort", "showInitialSortBadge", "autoLayout", "exportFunction", "exportHeader", "stateKey", "stateStorage", "editMode", "groupRowsBy", "size", "showGridlines", "stripedRows", "groupRowsByOrder", "responsiveLayout", "breakpoint", "paginatorLocale", "value", "columns", "first", "rows", "totalRecords", "sortField", "sortOrder", "multiSortMeta", "selection", "virtualRowHeight", "selectAll"], outputs: ["contextMenuSelectionChange", "selectAllChange", "selectionChange", "onRowSelect", "onRowUnselect", "onPage", "onSort", "onFilter", "onLazyLoad", "onRowExpand", "onRowCollapse", "onContextMenuSelect", "onColResize", "onColReorder", "onRowReorder", "onEditInit", "onEditComplete", "onEditCancel", "onHeaderCheckboxToggle", "sortFunction", "firstChange", "rowsChange", "onStateSave", "onStateRestore"] }, { kind: "ngmodule", type: TagModule }, { kind: "component", type: i7.Tag, selector: "p-tag", inputs: ["style", "styleClass", "severity", "value", "icon", "rounded"] }] });
|
|
674
|
+
}
|
|
675
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.17", ngImport: i0, type: DebtBuyoutsComponent, decorators: [{
|
|
676
|
+
type: Component,
|
|
677
|
+
args: [{ selector: 'lib-debt-buyouts', imports: [CommonModule, ButtonModule, CardModule, MessageModule, SkeletonModule, TableModule, TagModule], template: "<p-card>\n <div class=\"sfs-head\">\n <h2 class=\"sfs-title\">Compras de cartera</h2>\n @if (!loading() && !failed() && rows().length) {\n <span class=\"sfs-muted\">\n {{ toBuy().length }} de {{ rows().length }} {{ rows().length === 1 ? 'obligaci\u00F3n' : 'obligaciones' }} para comprar\n </span>\n }\n </div>\n\n @if (loading()) {\n <div class=\"sfs-stack\" aria-busy=\"true\">\n <p-skeleton height=\"2.5rem\"></p-skeleton>\n <p-skeleton height=\"8rem\"></p-skeleton>\n </div>\n } @else if (failed()) {\n <p-message severity=\"error\">\n <div class=\"sfs-inline\">\n <span>No se pudieron leer las compras de cartera de la solicitud.</span>\n <p-button label=\"Reintentar\" icon=\"pi pi-refresh\" [text]=\"true\" (onClick)=\"retry.emit()\"></p-button>\n </div>\n </p-message>\n } @else {\n <div class=\"sfs-stack\">\n @if (mismatch()) {\n <p-message severity=\"warn\">\n Las obligaciones marcadas para comprar suman {{ totalToBuy() | currency: 'COP' : 'symbol-narrow' : '1.0-0' : locale }},\n pero la solicitud se simula con compras de cartera por {{ simulatedValue() | currency: 'COP' : 'symbol-narrow' : '1.0-0' : locale }}.\n </p-message>\n }\n\n <p-table [value]=\"rows()\" styleClass=\"p-datatable-sm\" [scrollable]=\"true\" dataKey=\"IdPrstmsCC\">\n <ng-template #header>\n <tr>\n <th>Entidad</th>\n <th>Obligaci\u00F3n</th>\n <th>Origen</th>\n <th>Estado</th>\n <th>Vence</th>\n <th class=\"sfs-right\">Cuota</th>\n <th class=\"sfs-right\">Saldo</th>\n <th class=\"sfs-right\">Mora</th>\n <th>Desprendible</th>\n <th>Comprar</th>\n </tr>\n </ng-template>\n <ng-template #body let-row>\n <tr>\n <td>\n {{ row.Entidad || '\u2014' }}\n @if (row.NitEntidad) { <br /><small class=\"sfs-muted\">NIT {{ row.NitEntidad }}</small> }\n </td>\n <td>{{ row.NumeroObligacion || '\u2014' }}</td>\n <td>\n {{ row.Buro || '\u2014' }}\n @if (row.Sector) { <br /><small class=\"sfs-muted\">{{ row.Sector }}</small> }\n </td>\n <td>{{ row.EstadoObligacion || '\u2014' }}</td>\n <td class=\"sfs-nowrap\">{{ row.FechaVencimiento || '\u2014' }}</td>\n <td class=\"sfs-right sfs-nowrap\">{{ row.ValorCuota | currency: 'COP' : 'symbol-narrow' : '1.0-0' : locale }}</td>\n <td class=\"sfs-right sfs-nowrap\">{{ row.SaldoActual | currency: 'COP' : 'symbol-narrow' : '1.0-0' : locale }}</td>\n <td class=\"sfs-right sfs-nowrap\">{{ row.SaldoMora | currency: 'COP' : 'symbol-narrow' : '1.0-0' : locale }}</td>\n <td>{{ row.Desprendible ? 'S\u00ED' : 'No' }}</td>\n <td><p-tag [value]=\"row.Comprar ? 'Comprar' : 'No comprar'\" [severity]=\"row.Comprar ? 'success' : 'secondary'\"></p-tag></td>\n </tr>\n </ng-template>\n <ng-template #footer>\n @if (rows().length) {\n <tr>\n <td colspan=\"5\" class=\"sfs-strong\">Total para comprar</td>\n <td class=\"sfs-right sfs-nowrap sfs-strong\">{{ installmentsToBuy() | currency: 'COP' : 'symbol-narrow' : '1.0-0' : locale }}</td>\n <td class=\"sfs-right sfs-nowrap sfs-strong\">{{ totalToBuy() | currency: 'COP' : 'symbol-narrow' : '1.0-0' : locale }}</td>\n <td colspan=\"3\"></td>\n </tr>\n }\n </ng-template>\n <ng-template #emptymessage>\n <tr><td colspan=\"10\">La solicitud no tiene compras de cartera registradas.</td></tr>\n </ng-template>\n </p-table>\n </div>\n }\n</p-card>\n", styles: [".sfs-title{margin:0;font-size:1.125rem;font-weight:600}.sfs-subtitle{margin:0;font-size:1rem;font-weight:600}.sfs-muted{color:var(--p-text-muted-color)}.sfs-section-title{display:flex;align-items:center;gap:.5rem;margin:0 0 .75rem;font-size:1rem;font-weight:600}.sfs-section-title i{color:var(--primary-color, var(--p-primary-color))}.sfs-inline{display:flex;flex-wrap:wrap;align-items:center;gap:.75rem}.sfs-head{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:.5rem;margin-bottom:.75rem}.sfs-break{overflow-wrap:anywhere}.sfs-nowrap{white-space:nowrap}.sfs-right{text-align:right}.sfs-strong{font-weight:600}.sfs-tag-gap{margin-left:.5rem}.sfs-stack{display:flex;flex-direction:column;gap:1rem}.sfs-sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}.sfs-summary{display:grid;grid-template-columns:minmax(8rem,max-content) 1fr;gap:.25rem 1rem;margin:0}.sfs-summary dt{color:var(--p-text-muted-color)}.sfs-summary dd{margin:0;text-align:right;font-variant-numeric:tabular-nums}\n"] }]
|
|
678
|
+
}], ctorParameters: () => [] });
|
|
679
|
+
|
|
680
|
+
/*
|
|
681
|
+
* API pública de @sfinges/sf-solicitud
|
|
682
|
+
*/
|
|
683
|
+
|
|
684
|
+
/**
|
|
685
|
+
* Generated bundle index. Do not edit.
|
|
686
|
+
*/
|
|
687
|
+
|
|
688
|
+
export { APPLICATION_PERSON_SERVICE, ApplicationPersonComponent, DebtBuyoutsComponent, LineSimulatorComponent };
|
|
689
|
+
//# sourceMappingURL=sfinges-sf-solicitud.mjs.map
|