feat(web): el indicador del documento se elige de su ventana de selección (FactoringIndicators)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
02c231a662
commit
d1cafcd721
6 files changed
+56
-4
No files matched your search
@@ -18,7 +18,7 @@ describe('recursos del Service Layer', () => {
|
||||
});
|
||||
|
||||
it('dimensiones, proyectos y cuentas son catálogos de solo lectura', () => {
|
||||
for (const name of ['DistributionRules', 'Projects', 'ChartOfAccounts', 'AdditionalExpenses', 'ItemGroups', 'BusinessPartnerGroups']) {
|
||||
for (const name of ['FactoringIndicators', 'DistributionRules', 'Projects', 'ChartOfAccounts', 'AdditionalExpenses', 'ItemGroups', 'BusinessPartnerGroups']) {
|
||||
const r = SL_RESOURCE_MAP.get(name)!;
|
||||
expect(r.methods, name).toEqual(['GET']);
|
||||
expect(r.read, name).toBeNull();
|
||||
|
||||
@@ -85,6 +85,8 @@ export const SL_RESOURCES: readonly SlResource[] = [
|
||||
catalog('BusinessPartnerGroups', 'number'),
|
||||
catalog('ItemGroups', 'number'),
|
||||
// Dimensiones, proyectos y cuentas de los documentos (para elegirlos en cabecera y líneas).
|
||||
// Indicadores de los documentos (tabla OIDC; en la localización chilena, el tipo de documento: 33 factura, 39 boleta).
|
||||
catalog('FactoringIndicators', 'string'),
|
||||
catalog('DistributionRules', 'string'),
|
||||
catalog('Projects', 'string'),
|
||||
catalog('ChartOfAccounts', 'string'),
|
||||
|
||||
@@ -12,6 +12,17 @@ export const dimensionLookup = (n: 1 | 2 | 3 | 4 | 5): VhLookup => ({
|
||||
],
|
||||
});
|
||||
|
||||
/** Indicadores del documento (`Indicator`): en la localización chilena, el tipo de documento (33 factura, 39 boleta). */
|
||||
export const INDICATOR_LOOKUP: VhLookup = {
|
||||
title: 'Indicadores',
|
||||
resource: 'FactoringIndicators',
|
||||
orderby: 'IndicatorCode',
|
||||
columns: [
|
||||
{ key: 'IndicatorCode', title: 'Código', width: '100px', mono: true },
|
||||
{ key: 'IndicatorName', title: 'Nombre' },
|
||||
],
|
||||
};
|
||||
|
||||
/** Proyectos activos. */
|
||||
export const PROJECT_LOOKUP: VhLookup = {
|
||||
title: 'Proyectos',
|
||||
|
||||
@@ -245,3 +245,42 @@ describe('el proyecto de la cabecera se elige de su ventana modal', () => {
|
||||
expect(fixture.componentInstance['header']()['Project']).toBe('PE001');
|
||||
});
|
||||
});
|
||||
|
||||
describe('el indicador de la cabecera se elige de su ventana modal', () => {
|
||||
it('es un campo con lista de valores sobre FactoringIndicators, con código y nombre', () => {
|
||||
const f = DOCUMENT_SCREENS.find((s) => s.path === '/ventas/facturas')!.layout.header.left.find((x) => x.type === 'lookup' && x.key === 'Indicator');
|
||||
expect(f && f.type === 'lookup' && f.lookup.resource).toBe('FactoringIndicators');
|
||||
expect(f && f.type === 'lookup' && f.lookup.columns.map((c) => c.key)).toEqual(['IndicatorCode', 'IndicatorName']);
|
||||
});
|
||||
|
||||
it('abre su ventana de selección y escribe el código elegido', async () => {
|
||||
TestBed.resetTestingModule();
|
||||
const screen = DOCUMENT_SCREENS.find((s) => s.path === '/ventas/facturas')!;
|
||||
const route = {
|
||||
snapshot: { data: { screen, title: 'Documento' }, paramMap: convertToParamMap({}) },
|
||||
paramMap: of(convertToParamMap({})),
|
||||
};
|
||||
await TestBed.configureTestingModule({
|
||||
imports: [DocumentFormPage],
|
||||
providers: [provideRouter([]), provideHttpClient(), provideHttpClientTesting(), { provide: ActivatedRoute, useValue: route }],
|
||||
}).compileComponents();
|
||||
const ctrl = TestBed.inject(HttpTestingController);
|
||||
const fixture = TestBed.createComponent(DocumentFormPage);
|
||||
const tick = async () => {
|
||||
fixture.detectChanges();
|
||||
await new Promise((r) => setTimeout(r));
|
||||
fixture.detectChanges();
|
||||
};
|
||||
await tick();
|
||||
const el = fixture.nativeElement as HTMLElement;
|
||||
const row = [...el.querySelectorAll('sbo-lookup-field')].find((f) => f.querySelector('label')?.textContent?.trim() === 'Indicador')!;
|
||||
expect(row, 'campo Indicador con lista').toBeDefined();
|
||||
(row.querySelector('button.sbo-btn') as HTMLElement).click();
|
||||
await tick();
|
||||
ctrl.expectOne((r) => r.url === '/api/sl/FactoringIndicators').flush({ value: [{ IndicatorCode: '33', IndicatorName: 'Factura' }, { IndicatorCode: '39', IndicatorName: 'Boleta' }], 'odata.count': '2' });
|
||||
await tick();
|
||||
(el.querySelectorAll('.dlg tbody tr')[1] as HTMLElement).click();
|
||||
await tick();
|
||||
expect(fixture.componentInstance['header']()['Indicator']).toBe('39');
|
||||
});
|
||||
});
|
||||
@@ -2,7 +2,7 @@ import type { GridColumn, GridLine } from '../../shared/grid/grid.types';
|
||||
import type { ListColumn } from '../../shared/list/list.types';
|
||||
import type { VhLookup } from '../../shared/value-help/value-help.types';
|
||||
import type { DocRecord, LinesSpec } from './document-model';
|
||||
import { PROJECT_LOOKUP } from './dimension-lookups';
|
||||
import { INDICATOR_LOOKUP, PROJECT_LOOKUP } from './dimension-lookups';
|
||||
import { SERIES_SUBTYPE } from './document-objects';
|
||||
import { ANALYTIC_COLUMNS, DOCUMENT_LINE_COLUMNS, lineColumnsFor, lineFieldsOf, newDocumentLine, recalcLine, uomEntryOf } from './line-columns';
|
||||
|
||||
@@ -95,7 +95,7 @@ export const FIELDS = {
|
||||
docNum: { type: 'computed', label: 'Número', source: 'docNum' },
|
||||
/** Número del documento con su serie. */
|
||||
docNumber: { type: 'series', key: 'Series', label: 'Número' },
|
||||
indicator: { type: 'text', key: 'Indicator', label: 'Indicador' },
|
||||
indicator: { type: 'lookup', key: 'Indicator', label: 'Indicador', lookup: INDICATOR_LOOKUP },
|
||||
project: { type: 'lookup', key: 'Project', label: 'Proyecto', lookup: PROJECT_LOOKUP },
|
||||
docDate: { type: 'date', key: 'DocDate', label: 'Fecha de contabilización', required: true, missing: 'la fecha de contabilización' },
|
||||
docDueDate: { type: 'date', key: 'DocDueDate', label: 'Fecha de vencimiento' },
|
||||
|
||||
Reference in new issue
Block a user