feat(reports): drive the currency filters from the shared list

Two more hardcoded ETB/USD option lists, one on the shared revenue-report
filter and one on the contracts export dataset. A report that cannot be
filtered to a currency never shows that currency's revenue, which reads as
an empty result rather than an error. currencyOf() still defaults to ETB
when the caller picks nothing.
This commit is contained in:
Nathnael
2026-08-29 08:13:38 +00:00
parent a119b09322
commit 7e877bd6a0
2 changed files with 7 additions and 8 deletions

View File

@@ -5,6 +5,7 @@ import { Contract } from '../../contracts/entities/contract.entity';
import { ServiceType } from '../../rule-engine/entities/service-type.entity'; import { ServiceType } from '../../rule-engine/entities/service-type.entity';
import { applyDirectionScope } from '../../user-trade-access/trade-scope.util'; import { applyDirectionScope } from '../../user-trade-access/trade-scope.util';
import { ExportDataset } from '../export.types'; import { ExportDataset } from '../export.types';
import { PAYMENT_CURRENCIES } from '@edr/types';
export const contractsDataset: ExportDataset = { export const contractsDataset: ExportDataset = {
key: 'contracts', key: 'contracts',
@@ -109,10 +110,7 @@ export const contractsDataset: ExportDataset = {
{ key: 'contractKind', label: 'Kind', type: 'text' }, { key: 'contractKind', label: 'Kind', type: 'text' },
{ key: 'tradeDirection', label: 'Direction', type: 'select', options: ['IMPORT', 'EXPORT', 'DOMESTIC'].map((v) => ({ value: v, label: v })) }, { key: 'tradeDirection', label: 'Direction', type: 'select', options: ['IMPORT', 'EXPORT', 'DOMESTIC'].map((v) => ({ value: v, label: v })) },
{ key: 'freightType', label: 'Freight type', type: 'select', options: ['CONTAINER', 'BULK'].map((v) => ({ value: v, label: v })) }, { key: 'freightType', label: 'Freight type', type: 'select', options: ['CONTAINER', 'BULK'].map((v) => ({ value: v, label: v })) },
{ key: 'paymentCurrency', label: 'Currency', type: 'select', options: [ { key: 'paymentCurrency', label: 'Currency', type: 'select', options: PAYMENT_CURRENCIES.map((v) => ({ value: v, label: v })) },
{ value: 'ETB', label: 'ETB' },
{ value: 'USD', label: 'USD' },
] },
{ key: 'serviceTypeId', label: 'Service type', type: 'text' }, { key: 'serviceTypeId', label: 'Service type', type: 'text' },
// Routes are one-to-many on contract_routes, so these filter via EXISTS // Routes are one-to-many on contract_routes, so these filter via EXISTS
// rather than a column comparison. // rather than a column comparison.

View File

@@ -9,6 +9,7 @@ import { CargoType } from '../rule-engine/entities/cargo-type.entity';
import { Yard } from '../rule-engine/entities/yard.entity'; import { Yard } from '../rule-engine/entities/yard.entity';
import { applyBookingRefDirectionScope } from '../user-trade-access/trade-scope.util'; import { applyBookingRefDirectionScope } from '../user-trade-access/trade-scope.util';
import { ReportContext, ReportFilterDef, ReportFilterOption } from './report.types'; import { ReportContext, ReportFilterDef, ReportFilterOption } from './report.types';
import { PAYMENT_CURRENCIES } from '@edr/types';
/** /**
* The shared vocabulary and SQL behind every revenue report. * The shared vocabulary and SQL behind every revenue report.
@@ -463,10 +464,10 @@ export const CURRENCY_FILTER: ReportFilterDef = {
key: 'currency', key: 'currency',
label: 'Currency', label: 'Currency',
type: 'select', type: 'select',
options: [ // Driven by the shared list: a revenue report that cannot be filtered to a currency
{ value: 'ETB', label: 'ETB' }, // simply never shows that currency's revenue, which is a silent hole rather than an
{ value: 'USD', label: 'USD' }, // error. `currencyOf` still defaults to ETB when the caller picks nothing.
], options: PAYMENT_CURRENCIES.map((code) => ({ value: code, label: code })),
}; };
/** /**