diff --git a/src/app/app.component.html b/src/app/app.component.html index d19c1c6..ca6f792 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -13,7 +13,7 @@

2024 Tax Estimator Calculator

Tax Year

- @@ -26,7 +26,7 @@

Filing Status

+ class="text-center w-75 m-auto form-control" [(ngModel)]="gross_income" (ngModelChange)="saveToSessionStorage()"/>
@@ -46,7 +46,7 @@

Gross Income

State

-
@@ -59,7 +59,7 @@

Self Employment Income

+ class="text-center w-75 m-auto form-control" [(ngModel)]="self_employment_income" (ngModelChange)="saveToSessionStorage()"/>
@@ -70,7 +70,7 @@

401K (Traditional)

+ class="text-center w-75 m-auto form-control" [(ngModel)]="traditional_retirement_contributions" (ngModelChange)="saveToSessionStorage()" />
@@ -81,7 +81,7 @@

401K (Roth)

+ class="text-center w-75 m-auto form-control" [(ngModel)]="roth_retirement_contributions" (ngModelChange)="saveToSessionStorage()"/>
@@ -92,7 +92,7 @@

HSA Contributions

+ class="text-center w-75 m-auto form-control" [(ngModel)]="hsa_contributions" (ngModelChange)="saveToSessionStorage()"/>
@@ -104,7 +104,7 @@

Insurance Premiums

+ class="text-center w-75 m-auto form-control" [(ngModel)]="insurance_premiums" (ngModelChange)="saveToSessionStorage()"/>
diff --git a/src/app/app.component.ts b/src/app/app.component.ts index e270e80..0bd4f07 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -38,10 +38,36 @@ export class AppComponent implements OnInit { constructor() { } ngOnInit(): void { - this.filing_state = 'WV'; - this.tax_year = 2024; + this.filing_state = sessionStorage.getItem('filing_state') || 'WV'; // default to 'WV' if not found + this.filing_status = sessionStorage.getItem('filing_status') || ''; + this.tax_year = +(sessionStorage.getItem('tax_year')??0) || 2024; // default to 2024 if not found + this.gross_income = +(sessionStorage.getItem('gross_income')??0) || undefined; + this.self_employment_income = +(sessionStorage.getItem('self_employment_income')??0) || undefined; + this.traditional_retirement_contributions = +(sessionStorage.getItem('traditional_retirement_contributions')??0) || undefined; + this.roth_retirement_contributions = +(sessionStorage.getItem('roth_retirement_contributions')??0) || undefined; + this.hsa_contributions = +(sessionStorage.getItem('hsa_contributions')??0) || undefined; + this.insurance_premiums = +(sessionStorage.getItem('insurance_premiums')??0) || undefined; } + saveToSessionStorage() { + // Save all relevant data to sessionStorage + sessionStorage.setItem('filing_state', this.filing_state || ''); + sessionStorage.setItem('filing_status', this.filing_status || ''); + sessionStorage.setItem('tax_year', this.tax_year?.toString() || ''); + sessionStorage.setItem('gross_income', this.gross_income?.toString() || ''); + sessionStorage.setItem('self_employment_income', this.self_employment_income?.toString() || ''); + sessionStorage.setItem('traditional_retirement_contributions', this.traditional_retirement_contributions?.toString() || ''); + sessionStorage.setItem('roth_retirement_contributions', this.roth_retirement_contributions?.toString() || ''); + sessionStorage.setItem('hsa_contributions', this.hsa_contributions?.toString() || ''); + sessionStorage.setItem('insurance_premiums', this.insurance_premiums?.toString() || ''); + } + + clearSessionStorage() { + // Clear all sessionStorage data + sessionStorage.clear(); + } + + updateStandardDeduction() { if (this.tax_year == 2024) { switch (this.filing_status) {