diff --git a/apps/edr-freight-api/src/contracts/contract-dynamic-template.spec.ts b/apps/edr-freight-api/src/contracts/contract-dynamic-template.spec.ts index b0e0e4d3d..b840cb032 100644 --- a/apps/edr-freight-api/src/contracts/contract-dynamic-template.spec.ts +++ b/apps/edr-freight-api/src/contracts/contract-dynamic-template.spec.ts @@ -90,6 +90,8 @@ describe('dynamic template rendering (edr-dynamic.hbs)', () => { template: { ...meta, title: 'Bulk Import Contract', templateFile: 'edr-dynamic.hbs' }, contractDate: '1 January 2026', contractYear: 2026, + contractStartDate: '1 January 2026', + contractEndDate: '31 December 2026', client: { companyName: 'Abyssinia Trading PLC', companyAddress: 'Bole Sub-city, Addis Ababa', @@ -195,6 +197,24 @@ describe('dynamic template rendering (edr-dynamic.hbs)', () => { expect(html).toContain('#1b9e7a'); }); + it('shows the contract validity window in the commercial schedule annex', () => { + const html = renderer.render(dynamicView()); + expect(html).toContain('Valid from'); + expect(html).toContain('Valid until'); + expect(html).toContain('1 January 2026'); + expect(html).toContain('31 December 2026'); + }); + + it('interpolates the start/end date placeholders inside article text', () => { + const view = dynamicView(); + expect( + interpolateTemplateText( + 'In force {{contractStartDate}} to {{contractEndDate}}.', + view, + ), + ).toBe('In force 1 January 2026 to 31 December 2026.'); + }); + it('shows cargo type and container type in the commercial schedule annex', () => { const html = renderer.render(dynamicView()); expect(html).toContain('Cargo type'); diff --git a/apps/edr-freight-api/src/contracts/contract-renderer.service.spec.ts b/apps/edr-freight-api/src/contracts/contract-renderer.service.spec.ts index 79f5e2f73..fc7e66e5b 100644 --- a/apps/edr-freight-api/src/contracts/contract-renderer.service.spec.ts +++ b/apps/edr-freight-api/src/contracts/contract-renderer.service.spec.ts @@ -16,6 +16,8 @@ describe('ContractRendererService', () => { template, contractDate: '1 January 2026', contractYear: 2026, + contractStartDate: '1 January 2026', + contractEndDate: '31 December 2026', client: { companyName: 'Test Co', companyAddress: 'Addis Ababa', diff --git a/apps/edr-freight-api/src/contracts/contract-view-model.builder.ts b/apps/edr-freight-api/src/contracts/contract-view-model.builder.ts index d874fb792..d1158d035 100644 --- a/apps/edr-freight-api/src/contracts/contract-view-model.builder.ts +++ b/apps/edr-freight-api/src/contracts/contract-view-model.builder.ts @@ -150,6 +150,8 @@ export class ContractViewModelBuilder { year: 'numeric', }), contractYear: new Date().getFullYear(), + contractStartDate: this.formatDate(booking.contractValidFrom), + contractEndDate: this.formatDate(booking.contractValidUntil), client: { companyName: booking.company?.name ?? 'Client', companyAddress: this.valueOrDash(booking.company?.address), diff --git a/apps/edr-freight-api/src/contracts/templates/edr-dynamic.hbs b/apps/edr-freight-api/src/contracts/templates/edr-dynamic.hbs index 5c4c4052b..6ba7c1610 100644 --- a/apps/edr-freight-api/src/contracts/templates/edr-dynamic.hbs +++ b/apps/edr-freight-api/src/contracts/templates/edr-dynamic.hbs @@ -143,6 +143,12 @@