feat: implement I-9 and W-4 tax form handling with dedicated use cases and mappers
This commit is contained in:
@@ -15,18 +15,36 @@ class TaxFormAdapter {
|
||||
DateTime? createdAt,
|
||||
DateTime? updatedAt,
|
||||
}) {
|
||||
return TaxForm(
|
||||
id: id,
|
||||
type: _stringToType(type),
|
||||
title: title,
|
||||
subtitle: subtitle,
|
||||
description: description,
|
||||
status: _stringToStatus(status),
|
||||
staffId: staffId,
|
||||
formData: formData is Map ? Map<String, dynamic>.from(formData) : null,
|
||||
createdAt: createdAt,
|
||||
updatedAt: updatedAt,
|
||||
);
|
||||
final TaxFormType formType = _stringToType(type);
|
||||
final TaxFormStatus formStatus = _stringToStatus(status);
|
||||
final Map<String, dynamic> formDetails =
|
||||
formData is Map ? Map<String, dynamic>.from(formData as Map) : <String, dynamic>{};
|
||||
|
||||
if (formType == TaxFormType.i9) {
|
||||
return I9TaxForm(
|
||||
id: id,
|
||||
title: title,
|
||||
subtitle: subtitle,
|
||||
description: description,
|
||||
status: formStatus,
|
||||
staffId: staffId,
|
||||
formData: formDetails,
|
||||
createdAt: createdAt,
|
||||
updatedAt: updatedAt,
|
||||
);
|
||||
} else {
|
||||
return W4TaxForm(
|
||||
id: id,
|
||||
title: title,
|
||||
subtitle: subtitle,
|
||||
description: description,
|
||||
status: formStatus,
|
||||
staffId: staffId,
|
||||
formData: formDetails,
|
||||
createdAt: createdAt,
|
||||
updatedAt: updatedAt,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
static TaxFormType _stringToType(String? value) {
|
||||
|
||||
@@ -4,27 +4,26 @@ enum TaxFormType { i9, w4 }
|
||||
|
||||
enum TaxFormStatus { notStarted, inProgress, submitted, approved, rejected }
|
||||
|
||||
class TaxForm extends Equatable {
|
||||
abstract class TaxForm extends Equatable {
|
||||
final String id;
|
||||
final TaxFormType type;
|
||||
TaxFormType get type;
|
||||
final String title;
|
||||
final String? subtitle;
|
||||
final String? description;
|
||||
final TaxFormStatus status;
|
||||
final String? staffId;
|
||||
final Map<String, dynamic>? formData;
|
||||
final Map<String, dynamic> formData;
|
||||
final DateTime? createdAt;
|
||||
final DateTime? updatedAt;
|
||||
|
||||
const TaxForm({
|
||||
required this.id,
|
||||
required this.type,
|
||||
required this.title,
|
||||
this.subtitle,
|
||||
this.description,
|
||||
this.status = TaxFormStatus.notStarted,
|
||||
this.staffId,
|
||||
this.formData,
|
||||
this.formData = const {},
|
||||
this.createdAt,
|
||||
this.updatedAt,
|
||||
});
|
||||
@@ -43,3 +42,37 @@ class TaxForm extends Equatable {
|
||||
updatedAt,
|
||||
];
|
||||
}
|
||||
|
||||
class I9TaxForm extends TaxForm {
|
||||
const I9TaxForm({
|
||||
required super.id,
|
||||
required super.title,
|
||||
super.subtitle,
|
||||
super.description,
|
||||
super.status,
|
||||
super.staffId,
|
||||
super.formData,
|
||||
super.createdAt,
|
||||
super.updatedAt,
|
||||
});
|
||||
|
||||
@override
|
||||
TaxFormType get type => TaxFormType.i9;
|
||||
}
|
||||
|
||||
class W4TaxForm extends TaxForm {
|
||||
const W4TaxForm({
|
||||
required super.id,
|
||||
required super.title,
|
||||
super.subtitle,
|
||||
super.description,
|
||||
super.status,
|
||||
super.staffId,
|
||||
super.formData,
|
||||
super.createdAt,
|
||||
super.updatedAt,
|
||||
});
|
||||
|
||||
@override
|
||||
TaxFormType get type => TaxFormType.w4;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user