Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions app/src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export const FOREVER = '2100-12-31';
export const BASE_URL = 'https://api.policyengine.org';
export const CURRENT_YEAR = '2025';
export const CURRENT_YEAR = '2026';

// App URLs for the split website/calculator architecture
// In dev mode, these are set via VITE_* env vars to localhost URLs
Expand All @@ -9,12 +9,6 @@ export const WEBSITE_URL = import.meta.env.VITE_WEBSITE_URL || 'https://policyen

export const CALCULATOR_URL = import.meta.env.VITE_CALCULATOR_URL || 'https://app.policyengine.org';

/**
* Temporary constant for report time calculations
* TODO: Replace with dynamic date selection from user input
*/
export const TEMP_REPORT_TIME = 2025;

/**
* Get parameter definition date for a given year
* Used for querying parameter values from metadata at a specific point in time
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import { useState } from 'react';
import { useSelector } from 'react-redux';
import { Button, Container, Divider, Group, Stack, Text } from '@mantine/core';
import { CURRENT_YEAR } from '@/constants';
import { getDateRange } from '@/libs/metadataUtils';
import { ParameterMetadata } from '@/types/metadata/parameterMetadata';
import { PolicyStateProps } from '@/types/pathwayState';
Expand All @@ -33,8 +34,8 @@ export default function PolicyParameterSelectorValueSetter({
const [intervals, setIntervals] = useState<ValueInterval[]>([]);

// Hoisted date state for all non-multi-year selectors
const [startDate, setStartDate] = useState<string>('2025-01-01');
const [endDate, setEndDate] = useState<string>('2025-12-31');
const [startDate, setStartDate] = useState<string>(`${CURRENT_YEAR}-01-01`);
const [endDate, setEndDate] = useState<string>(`${CURRENT_YEAR}-12-31`);

function resetValueSettingState() {
setIntervals([]);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useEffect, useMemo, useState } from 'react';
import { useSelector } from 'react-redux';
import { Box, Group, SimpleGrid, Stack, Text } from '@mantine/core';
import { CURRENT_YEAR } from '@/constants';
import { getTaxYears } from '@/libs/metadataUtils';
import { RootState } from '@/store';
import { ValueInterval } from '@/types/subIngredients/valueInterval';
Expand All @@ -22,8 +23,9 @@ export function MultiYearValueSelector(props: ValueSetterProps) {
};

// Generate years from metadata, starting from current year
// Uses CURRENT_YEAR constant for consistency with report year defaults
const generateYears = () => {
const currentYear = new Date().getFullYear();
const currentYear = parseInt(CURRENT_YEAR, 10);
const maxYears = MAX_YEARS_BY_COUNTRY[countryId || 'us'] || 10;

// Filter available years from metadata to only include current year onwards
Expand Down
6 changes: 3 additions & 3 deletions app/src/tests/fixtures/utils/householdQueriesMocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ export const QUERY_COUNTRIES = {
// Years
export const QUERY_YEARS = {
CURRENT: CURRENT_YEAR,
PAST: '2023',
FUTURE: '2026',
NON_EXISTENT: '2027',
PAST: '2024',
FUTURE: '2027',
NON_EXISTENT: '2028',
} as const;

// Entity names
Expand Down
6 changes: 3 additions & 3 deletions app/src/tests/fixtures/utils/householdValidationMocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ export const VALIDATION_COUNTRIES = {
// Years
export const VALIDATION_YEARS = {
DEFAULT: CURRENT_YEAR,
PAST: '2023',
FUTURE: '2026',
MISSING: '2027',
PAST: '2024',
FUTURE: '2027',
MISSING: '2028',
} as const;

// Entity names
Expand Down
15 changes: 8 additions & 7 deletions app/src/tests/fixtures/utils/householdValuesMocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,9 @@ export const MOCK_HOUSEHOLD_DATA_MULTI_PERIOD: Household = {
households: {
'your household': {
household_income: {
'2023': 48000,
'2024': 48000,
[CURRENT_YEAR]: 50000,
'2026': 52000,
'2027': 52000,
},
},
},
Expand All @@ -169,16 +169,17 @@ export const MOCK_PARAMETER = {
description: 'Standard deduction',
values: {
'2020-01-01': 12000,
'2023-01-01': 13850,
'2024-01-01': 13850,
[`${CURRENT_YEAR}-01-01`]: 14600,
'2026-01-01': 15000,
'2027-01-01': 15000,
},
};

export const TEST_TIME_PERIODS = {
YEAR_2023: '2023',
YEAR_2024: CURRENT_YEAR,
YEAR_2025: CURRENT_YEAR,
YEAR_2024: '2024',
YEAR_2025: '2025',
YEAR_2026: '2026',
CURRENT: CURRENT_YEAR,
} as const;

export const TEST_ENTITY_NAMES = {
Expand Down
2 changes: 1 addition & 1 deletion app/src/tests/unit/pages/Populations.page.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ vi.mock('react-router-dom', async () => {
vi.mock('@/constants', () => ({
MOCK_USER_ID: 'test-user-123',
BASE_URL: 'https://api.test.com',
CURRENT_YEAR: '2025',
CURRENT_YEAR: '2026',
}));

describe('PopulationsPage', () => {
Expand Down
24 changes: 12 additions & 12 deletions app/src/tests/unit/utils/householdValues.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ describe('getValueFromHousehold', () => {
test('given household variable with specific time period and entity then returns correct value', () => {
// Given
const variableName = TEST_VARIABLE_NAMES.HOUSEHOLD_INCOME;
const timePeriod = TEST_TIME_PERIODS.YEAR_2024;
const timePeriod = TEST_TIME_PERIODS.CURRENT;
const entityName = TEST_ENTITY_NAMES.YOUR_HOUSEHOLD;

// When
Expand All @@ -45,7 +45,7 @@ describe('getValueFromHousehold', () => {
test('given person variable with specific time period and entity then returns correct value', () => {
// Given
const variableName = TEST_VARIABLE_NAMES.AGE;
const timePeriod = TEST_TIME_PERIODS.YEAR_2024;
const timePeriod = TEST_TIME_PERIODS.CURRENT;
const entityName = TEST_ENTITY_NAMES.PERSON_1;

// When
Expand All @@ -64,7 +64,7 @@ describe('getValueFromHousehold', () => {
test('given null entity name then aggregates across all entities', () => {
// Given
const variableName = TEST_VARIABLE_NAMES.AGE;
const timePeriod = TEST_TIME_PERIODS.YEAR_2024;
const timePeriod = TEST_TIME_PERIODS.CURRENT;
const entityName = null;

// When
Expand Down Expand Up @@ -121,7 +121,7 @@ describe('getValueFromHousehold', () => {
test('given nonexistent variable then returns zero', () => {
// Given
const variableName = TEST_VARIABLE_NAMES.NONEXISTENT;
const timePeriod = TEST_TIME_PERIODS.YEAR_2024;
const timePeriod = TEST_TIME_PERIODS.CURRENT;
const entityName = TEST_ENTITY_NAMES.YOUR_HOUSEHOLD;

// When
Expand All @@ -140,7 +140,7 @@ describe('getValueFromHousehold', () => {
test('given valueFromFirstOnly true then returns value from first entity only', () => {
// Given
const variableName = TEST_VARIABLE_NAMES.BENEFITS;
const timePeriod = TEST_TIME_PERIODS.YEAR_2024;
const timePeriod = TEST_TIME_PERIODS.CURRENT;
const entityName = null;
const valueFromFirstOnly = true;

Expand Down Expand Up @@ -224,8 +224,8 @@ describe('formatVariableValue', () => {

describe('getParameterAtInstant', () => {
test('given instant matching exact date then returns value at that date', () => {
// Given
const instant = '2025-01-01';
// Given - MOCK_PARAMETER has '2026-01-01': 14600 (CURRENT_YEAR)
const instant = '2026-01-01';

// When
const result = getParameterAtInstant(MOCK_PARAMETER, instant);
Expand All @@ -235,8 +235,8 @@ describe('getParameterAtInstant', () => {
});

test('given instant between dates then returns most recent prior value', () => {
// Given
const instant = '2025-06-15';
// Given - instant is between '2026-01-01' and '2027-01-01'
const instant = '2026-06-15';

// When
const result = getParameterAtInstant(MOCK_PARAMETER, instant);
Expand All @@ -257,8 +257,8 @@ describe('getParameterAtInstant', () => {
});

test('given instant after all dates then returns latest value', () => {
// Given
const instant = '2026-01-01';
// Given - MOCK_PARAMETER has '2027-01-01': 15000 as the latest
const instant = '2028-01-01';

// When
const result = getParameterAtInstant(MOCK_PARAMETER, instant);
Expand All @@ -269,7 +269,7 @@ describe('getParameterAtInstant', () => {

test('given null parameter then returns empty array', () => {
// Given
const instant = '2025-01-01';
const instant = '2026-01-01';

// When
const result = getParameterAtInstant(null, instant);
Expand Down
Loading