Skip to content

Commit

Permalink
Merge pull request #2041 from bharateshwq/undefined-vars-marginalTaxR…
Browse files Browse the repository at this point in the history
…ates

solves undefined variable employment_income error in Marginal tax Rates
  • Loading branch information
anth-volk authored Oct 15, 2024
2 parents 1a491ff + 96527fc commit 7f49e72
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/api/variables.js
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ export function getValueFromHousehold(
}
if (!timePeriodValues) {
console.error("Error getting variable value", variable);
return null;
return 0;
}
if (!timePeriod) {
const possibleTimePeriods = Object.keys(timePeriodValues);
Expand Down
6 changes: 6 additions & 0 deletions src/pages/household/output/MarginalTaxRates.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export default function MarginalTaxRates(props) {
householdInput,
metadata,
);

const currentMtr = getValueFromHousehold(
"marginal_tax_rate",
year,
Expand All @@ -61,7 +62,12 @@ export default function MarginalTaxRates(props) {

useEffect(() => {
let householdData = JSON.parse(JSON.stringify(householdInput));
// Ensure 'employment_income' exists for the current user and initialize if necessary
householdData.people.you = householdData.people.you || {};
householdData.people.you.employment_income =
householdData.people.you.employment_income || {};
householdData.people.you.employment_income[year] = null;

householdData.axes = [
[
{
Expand Down

0 comments on commit 7f49e72

Please sign in to comment.