PayrollDetailModel.fromJson constructor
Creates a new instance of the PayrollDetailModel
class from a JSON map.
The json
parameter is a JSON map representing the payroll detail.
Implementation
factory PayrollDetailModel.fromJson(Map<String, dynamic> json) {
return PayrollDetailModel(
name: json["name"] ?? '',
image: json["image"] ?? '',
designation: json["designation"] ?? '',
status: PayrollStatusConverter.fromString(json["status"]) ??
PayrollStatus.generated,
paidOn: json["paid_on"] != null
? DateTime.parse(json["paid_on"]).toLocal()
: null,
totalEarning: double.parse('${json["total_earning"] ?? 0}'),
totalDeduction: double.parse('${json["total_deduction"] ?? 0}'),
totalAmount: double.parse('${json["total_amount"] ?? 0}'),
resignPinaltyAmount:
double.parse('${json['resign_pinalty_amount'] ?? 0}'),
totalAmountAfterPinalty:
double.parse('${json['total_amount_after_pinalty'] ?? 0}'),
earnings: json["earnings"] != null
? List<PayrollComponentModel>.from(
json["earnings"].map((x) => PayrollComponentModel.fromJson(x)))
: [],
deductions: json["deductions"] != null
? List<PayrollComponentModel>.from(
json["deductions"].map((x) => PayrollComponentModel.fromJson(x)))
: [],
publicUrl: json['public_url'] ?? '',
);
}