mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-09-01 15:53:27 +00:00
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:
@@ -5,6 +5,7 @@ import { Contract } from '../../contracts/entities/contract.entity';
|
||||
import { ServiceType } from '../../rule-engine/entities/service-type.entity';
|
||||
import { applyDirectionScope } from '../../user-trade-access/trade-scope.util';
|
||||
import { ExportDataset } from '../export.types';
|
||||
import { PAYMENT_CURRENCIES } from '@edr/types';
|
||||
|
||||
export const contractsDataset: ExportDataset = {
|
||||
key: 'contracts',
|
||||
@@ -109,10 +110,7 @@ export const contractsDataset: ExportDataset = {
|
||||
{ key: 'contractKind', label: 'Kind', type: 'text' },
|
||||
{ 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: 'paymentCurrency', label: 'Currency', type: 'select', options: [
|
||||
{ value: 'ETB', label: 'ETB' },
|
||||
{ value: 'USD', label: 'USD' },
|
||||
] },
|
||||
{ key: 'paymentCurrency', label: 'Currency', type: 'select', options: PAYMENT_CURRENCIES.map((v) => ({ value: v, label: v })) },
|
||||
{ key: 'serviceTypeId', label: 'Service type', type: 'text' },
|
||||
// Routes are one-to-many on contract_routes, so these filter via EXISTS
|
||||
// rather than a column comparison.
|
||||
|
||||
@@ -9,6 +9,7 @@ import { CargoType } from '../rule-engine/entities/cargo-type.entity';
|
||||
import { Yard } from '../rule-engine/entities/yard.entity';
|
||||
import { applyBookingRefDirectionScope } from '../user-trade-access/trade-scope.util';
|
||||
import { ReportContext, ReportFilterDef, ReportFilterOption } from './report.types';
|
||||
import { PAYMENT_CURRENCIES } from '@edr/types';
|
||||
|
||||
/**
|
||||
* The shared vocabulary and SQL behind every revenue report.
|
||||
@@ -463,10 +464,10 @@ export const CURRENCY_FILTER: ReportFilterDef = {
|
||||
key: 'currency',
|
||||
label: 'Currency',
|
||||
type: 'select',
|
||||
options: [
|
||||
{ value: 'ETB', label: 'ETB' },
|
||||
{ value: 'USD', label: 'USD' },
|
||||
],
|
||||
// Driven by the shared list: a revenue report that cannot be filtered to a currency
|
||||
// simply never shows that currency's revenue, which is a silent hole rather than an
|
||||
// error. `currencyOf` still defaults to ETB when the caller picks nothing.
|
||||
options: PAYMENT_CURRENCIES.map((code) => ({ value: code, label: code })),
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user