Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | 76x 76x 76x 76x 76x 76x 76x 76x 76x 76x 28x 28x 4x 4x 4x 1x 1x 2x | import type { CostIndexSeriesRead } from "@/api/apiStore.gen";
import { ManualAnnualHeatBasisUnitEnum } from "@/api/apiStore.gen";
import type { UnitSelectOption } from "../../shared/ui/EconomicsFormFields";
export const NONE_SELECT_VALUE = "__none__";
export const AUTOSAVE_DELAY_MS = 250;
export const DEFAULT_CURRENCY = "NZD";
export const DEFAULT_DISCOUNT_RATE = "10.0000";
export const DEFAULT_PROJECT_LIFETIME = "25";
export const DEFAULT_INDEX_METHOD = "stats_nz_cpi_all_groups";
export const DEFAULT_HEAT_BASIS_UNIT = ManualAnnualHeatBasisUnitEnum.GjYear;
export const DEFAULT_AVERAGE_POWER_UNIT = "GJ/hr";
export const NUMERIC_DRAFT_PAYLOAD_KEYS = new Set([
"annual_operating_hours",
"average_power_input",
"boiler_efficiency_percent",
"contingency_percent",
"default_lang_factor",
"default_depreciation_life_years",
"default_depreciation_salvage_percent",
"discount_rate_percent",
"electrical_upgrade_rate_amount",
"manual_annual_heat_basis",
"manual_annual_opex",
"manual_capex",
"project_lifetime_years",
"residual_value",
"tax_rate_percent",
"steam_energy_gj_per_t",
"value",
]);
export const INDEX_METHOD_OPTIONS = [
{
value: DEFAULT_INDEX_METHOD,
label: "Stats NZ CPI all groups",
badge: "NZ default",
},
{
value: "none",
label: "No escalation",
},
] as const;
export function unitOptionsOrCurrent<TUnit extends string>(
options: readonly UnitSelectOption<TUnit>[] | undefined,
currentUnit: TUnit,
): readonly UnitSelectOption<TUnit>[] {
const current = currentUnit.trim() as TUnit;
if (options?.length) {
if (!current || options.some((option) => option.value === current)) {
return options;
}
return [{ value: current, label: current }, ...options];
}
return current ? [{ value: current, label: current }] : [];
}
export function fixedUnitFromOptions(
options: readonly UnitSelectOption[] | undefined,
currentUnit: string,
): string {
const current = currentUnit.trim();
if (current) return current;
return options?.[0]?.value ?? "";
}
export function inflationMethodOptions(currentValue: string) {
const options: { value: string; label: string; badge?: string }[] = [
...INDEX_METHOD_OPTIONS,
];
if (
currentValue &&
!options.some((option) => option.value === currentValue)
) {
options.push({
value: currentValue,
label: `Current: ${currentValue}`,
});
}
return options;
}
export function indexMethodLabel(value: string) {
return (
inflationMethodOptions(value).find((option) => option.value === value)
?.label ?? value
);
}
export function indexSeriesLabel(
series: CostIndexSeriesRead[],
id?: number | null,
) {
if (id == null) return "Not set";
return series.find((item) => item.id === id)?.name ?? `Series ${id}`;
}
|