feat: enhance tax form handling by adding fields and initializing forms in cubits
This commit is contained in:
@@ -173,6 +173,7 @@ class TaxFormsRepositoryImpl implements TaxFormsRepository {
|
||||
'lastName': form.lastName,
|
||||
'middleInitial': form.mInitial,
|
||||
'otherLastNames': form.oLastName,
|
||||
'dob': form.dob.toString(),
|
||||
'ssn': form.socialSN.toString(),
|
||||
'email': form.email,
|
||||
'phone': form.phone,
|
||||
@@ -181,7 +182,24 @@ class TaxFormsRepositoryImpl implements TaxFormsRepository {
|
||||
'city': form.city,
|
||||
'state': form.state,
|
||||
'zipCode': form.zipCode,
|
||||
// Add other fields as they become available in the UI
|
||||
|
||||
// I-9 Fields
|
||||
'citizenshipStatus': form.citizen,
|
||||
'uscisNumber': form.uscis,
|
||||
'passportNumber': form.passportNumber,
|
||||
'countryIssuance': form.countryIssue,
|
||||
'preparerUsed': form.prepartorOrTranslator,
|
||||
|
||||
// W-4 Fields
|
||||
'filingStatus': form.marital,
|
||||
'multipleJobs': form.multipleJob,
|
||||
'qualifyingChildren': form.childrens,
|
||||
'otherDependents': form.otherDeps,
|
||||
'otherIncome': form.otherInconme.toString(), // Note backend typo
|
||||
'deductions': form.deductions.toString(),
|
||||
'extraWithholding': form.extraWithholding.toString(),
|
||||
|
||||
'signature': form.signature,
|
||||
};
|
||||
|
||||
String title = '';
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
enum TaxFormType { i9, w4 }
|
||||
|
||||
enum TaxFormStatus { notStarted, inProgress, submitted, approved, rejected }
|
||||
|
||||
class TaxFormEntity extends Equatable {
|
||||
final TaxFormType type;
|
||||
final String title;
|
||||
final String subtitle;
|
||||
final String description;
|
||||
final TaxFormStatus status;
|
||||
final DateTime? lastUpdated;
|
||||
|
||||
const TaxFormEntity({
|
||||
required this.type,
|
||||
required this.title,
|
||||
required this.subtitle,
|
||||
required this.description,
|
||||
this.status = TaxFormStatus.notStarted,
|
||||
this.lastUpdated,
|
||||
});
|
||||
|
||||
@override
|
||||
List<Object?> get props => [type, title, subtitle, description, status, lastUpdated];
|
||||
}
|
||||
@@ -9,6 +9,37 @@ class FormI9Cubit extends Cubit<FormI9State> {
|
||||
|
||||
FormI9Cubit(this._submitTaxFormUseCase) : super(const FormI9State());
|
||||
|
||||
void initialize(TaxForm? form) {
|
||||
if (form == null || form.formData.isEmpty) {
|
||||
emit(const FormI9State()); // Reset to empty if no form
|
||||
return;
|
||||
}
|
||||
|
||||
final Map<String, dynamic> data = form.formData;
|
||||
emit(FormI9State(
|
||||
firstName: data['firstName'] as String? ?? '',
|
||||
lastName: data['lastName'] as String? ?? '',
|
||||
middleInitial: data['middleInitial'] as String? ?? '',
|
||||
otherLastNames: data['otherLastNames'] as String? ?? '',
|
||||
dob: data['dob'] as String? ?? '',
|
||||
ssn: data['ssn'] as String? ?? '',
|
||||
email: data['email'] as String? ?? '',
|
||||
phone: data['phone'] as String? ?? '',
|
||||
address: data['address'] as String? ?? '',
|
||||
aptNumber: data['aptNumber'] as String? ?? '',
|
||||
city: data['city'] as String? ?? '',
|
||||
state: data['state'] as String? ?? '',
|
||||
zipCode: data['zipCode'] as String? ?? '',
|
||||
citizenshipStatus: data['citizenshipStatus'] as String? ?? '',
|
||||
uscisNumber: data['uscisNumber'] as String? ?? '',
|
||||
admissionNumber: data['admissionNumber'] as String? ?? '',
|
||||
passportNumber: data['passportNumber'] as String? ?? '',
|
||||
countryIssuance: data['countryIssuance'] as String? ?? '',
|
||||
preparerUsed: data['preparerUsed'] as bool? ?? false,
|
||||
signature: data['signature'] as String? ?? '',
|
||||
));
|
||||
}
|
||||
|
||||
void nextStep(int totalSteps) {
|
||||
if (state.currentStep < totalSteps - 1) {
|
||||
emit(state.copyWith(currentStep: state.currentStep + 1));
|
||||
|
||||
@@ -9,6 +9,37 @@ class FormW4Cubit extends Cubit<FormW4State> {
|
||||
|
||||
FormW4Cubit(this._submitTaxFormUseCase) : super(const FormW4State());
|
||||
|
||||
void initialize(TaxForm? form) {
|
||||
if (form == null || form.formData.isEmpty) {
|
||||
emit(const FormW4State()); // Reset
|
||||
return;
|
||||
}
|
||||
|
||||
final Map<String, dynamic> data = form.formData;
|
||||
|
||||
// Combine address parts if needed, or take existing
|
||||
final String city = data['city'] as String? ?? '';
|
||||
final String stateVal = data['state'] as String? ?? '';
|
||||
final String zip = data['zipCode'] as String? ?? '';
|
||||
final String cityStateZip = '$city, $stateVal $zip'.trim();
|
||||
|
||||
emit(FormW4State(
|
||||
firstName: data['firstName'] as String? ?? '',
|
||||
lastName: data['lastName'] as String? ?? '',
|
||||
ssn: data['ssn'] as String? ?? '',
|
||||
address: data['address'] as String? ?? '',
|
||||
cityStateZip: cityStateZip.contains(',') ? cityStateZip : '',
|
||||
filingStatus: data['filingStatus'] as String? ?? '',
|
||||
multipleJobs: data['multipleJobs'] as bool? ?? false,
|
||||
qualifyingChildren: data['qualifyingChildren'] as int? ?? 0,
|
||||
otherDependents: data['otherDependents'] as int? ?? 0,
|
||||
otherIncome: data['otherIncome'] as String? ?? '',
|
||||
deductions: data['deductions'] as String? ?? '',
|
||||
extraWithholding: data['extraWithholding'] as String? ?? '',
|
||||
signature: data['signature'] as String? ?? '',
|
||||
));
|
||||
}
|
||||
|
||||
void nextStep(int totalSteps) {
|
||||
if (state.currentStep < totalSteps - 1) {
|
||||
emit(state.copyWith(currentStep: state.currentStep + 1));
|
||||
|
||||
@@ -2,12 +2,14 @@ import 'package:design_system/design_system.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_modular/flutter_modular.dart' hide ModularWatchExtension;
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:krow_domain/krow_domain.dart';
|
||||
|
||||
import '../blocs/i9/form_i9_cubit.dart';
|
||||
import '../blocs/i9/form_i9_state.dart';
|
||||
|
||||
class FormI9Page extends StatefulWidget {
|
||||
const FormI9Page({super.key});
|
||||
final TaxForm? form;
|
||||
const FormI9Page({super.key, this.form});
|
||||
|
||||
@override
|
||||
State<FormI9Page> createState() => _FormI9PageState();
|
||||
@@ -22,6 +24,16 @@ class _FormI9PageState extends State<FormI9Page> {
|
||||
'SD', 'TN', 'TX', 'UT', 'VT', 'VA', 'WA', 'WV', 'WI', 'WY'
|
||||
];
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
if (widget.form != null) {
|
||||
// Use post-frame callback or simple direct call since we are using Modular.get in build
|
||||
// But better helper:
|
||||
Modular.get<FormI9Cubit>().initialize(widget.form);
|
||||
}
|
||||
}
|
||||
|
||||
final List<Map<String, String>> _steps = <Map<String, String>>[
|
||||
<String, String>{'title': 'Personal Information', 'subtitle': 'Name and contact details'},
|
||||
<String, String>{'title': 'Address', 'subtitle': 'Your current address'},
|
||||
|
||||
@@ -2,18 +2,81 @@ import 'package:design_system/design_system.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_modular/flutter_modular.dart' hide ModularWatchExtension;
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:krow_domain/krow_domain.dart';
|
||||
|
||||
import '../blocs/w4/form_w4_cubit.dart';
|
||||
import '../blocs/w4/form_w4_state.dart';
|
||||
|
||||
class FormW4Page extends StatefulWidget {
|
||||
const FormW4Page({super.key});
|
||||
final TaxForm? form;
|
||||
const FormW4Page({super.key, this.form});
|
||||
|
||||
@override
|
||||
State<FormW4Page> createState() => _FormW4PageState();
|
||||
}
|
||||
|
||||
class _FormW4PageState extends State<FormW4Page> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
if (widget.form != null) {
|
||||
Modular.get<FormW4Cubit>().initialize(widget.form);
|
||||
}
|
||||
}
|
||||
|
||||
final List<String> _usStates = <String>[
|
||||
'Alabama',
|
||||
'Alaska',
|
||||
'Arizona',
|
||||
'Arkansas',
|
||||
'California',
|
||||
'Colorado',
|
||||
'Connecticut',
|
||||
'Delaware',
|
||||
'Florida',
|
||||
'Georgia',
|
||||
'Hawaii',
|
||||
'Idaho',
|
||||
'Illinois',
|
||||
'Indiana',
|
||||
'Iowa',
|
||||
'Kansas',
|
||||
'Kentucky',
|
||||
'Louisiana',
|
||||
'Maine',
|
||||
'Maryland',
|
||||
'Massachusetts',
|
||||
'Michigan',
|
||||
'Minnesota',
|
||||
'Mississippi',
|
||||
'Missouri',
|
||||
'Montana',
|
||||
'Nebraska',
|
||||
'Nevada',
|
||||
'New Hampshire',
|
||||
'New Jersey',
|
||||
'New Mexico',
|
||||
'New York',
|
||||
'North Carolina',
|
||||
'North Dakota',
|
||||
'Ohio',
|
||||
'Oklahoma',
|
||||
'Oregon',
|
||||
'Pennsylvania',
|
||||
'Rhode Island',
|
||||
'South Carolina',
|
||||
'South Dakota',
|
||||
'Tennessee',
|
||||
'Texas',
|
||||
'Utah',
|
||||
'Vermont',
|
||||
'Virginia',
|
||||
'Washington',
|
||||
'West Virginia',
|
||||
'Wisconsin',
|
||||
'Wyoming',
|
||||
];
|
||||
|
||||
final List<Map<String, String>> _steps = <Map<String, String>>[
|
||||
<String, String>{'title': 'Personal Information', 'subtitle': 'Step 1'},
|
||||
<String, String>{'title': 'Filing Status', 'subtitle': 'Step 1c'},
|
||||
|
||||
@@ -145,9 +145,9 @@ class TaxFormsPage extends StatelessWidget {
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
if (form.type == TaxFormType.i9) {
|
||||
Modular.to.pushNamed('i9');
|
||||
Modular.to.pushNamed('i9', arguments: form);
|
||||
} else if (form.type == TaxFormType.w4) {
|
||||
Modular.to.pushNamed('w4');
|
||||
Modular.to.pushNamed('w4', arguments: form);
|
||||
}
|
||||
},
|
||||
child: Container(
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'package:firebase_auth/firebase_auth.dart';
|
||||
import 'package:flutter_modular/flutter_modular.dart';
|
||||
import 'package:krow_data_connect/krow_data_connect.dart';
|
||||
import 'package:krow_domain/krow_domain.dart';
|
||||
import 'data/repositories/tax_forms_repository_impl.dart';
|
||||
import 'domain/repositories/tax_forms_repository.dart';
|
||||
import 'domain/usecases/get_tax_forms_usecase.dart';
|
||||
@@ -35,7 +36,13 @@ class StaffTaxFormsModule extends Module {
|
||||
@override
|
||||
void routes(RouteManager r) {
|
||||
r.child('/', child: (_) => const TaxFormsPage());
|
||||
r.child('/i9', child: (_) => const FormI9Page());
|
||||
r.child('/w4', child: (_) => const FormW4Page());
|
||||
r.child(
|
||||
'/i9',
|
||||
child: (_) => FormI9Page(form: r.args.data as TaxForm?),
|
||||
);
|
||||
r.child(
|
||||
'/w4',
|
||||
child: (_) => FormW4Page(form: r.args.data as TaxForm?),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user