import 'package:domain/generated/json/base/json_convert_content.dart';
import 'package:domain/entity/response/labour_report_entity.dart';

LabourReportEntity $LabourReportEntityFromJson(Map<String, dynamic> json) {
  final LabourReportEntity labourReportEntity = LabourReportEntity();
  final List<LabourReportRows>? rows = (json['rows'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<LabourReportRows>(e) as LabourReportRows).toList();
  if (rows != null) {
    labourReportEntity.rows = rows;
  }
  final LabourReportTotal? total = jsonConvert.convert<LabourReportTotal>(json['total']);
  if (total != null) {
    labourReportEntity.total = total;
  }
  return labourReportEntity;
}

Map<String, dynamic> $LabourReportEntityToJson(LabourReportEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['rows'] = entity.rows.map((v) => v.toJson()).toList();
  data['total'] = entity.total?.toJson();
  return data;
}

extension LabourReportEntityExtension on LabourReportEntity {
  LabourReportEntity copyWith({
    List<LabourReportRows>? rows,
    LabourReportTotal? total,
  }) {
    return LabourReportEntity()
      ..rows = rows ?? this.rows
      ..total = total ?? this.total;
  }
}

LabourReportRows $LabourReportRowsFromJson(Map<String, dynamic> json) {
  final LabourReportRows labourReportRows = LabourReportRows();
  final int? outletId = jsonConvert.convert<int>(json['outlet_id']);
  if (outletId != null) {
    labourReportRows.outletId = outletId;
  }
  final String? outletName = jsonConvert.convert<String>(json['outlet_name']);
  if (outletName != null) {
    labourReportRows.outletName = outletName;
  }
  final String? hrs = jsonConvert.convert<String>(json['hrs']);
  if (hrs != null) {
    labourReportRows.hrs = hrs;
  }
  final String? agAmt = jsonConvert.convert<String>(json['ag_amt']);
  if (agAmt != null) {
    labourReportRows.agAmt = agAmt;
  }
  final String? inHrs = jsonConvert.convert<String>(json['in_hrs']);
  if (inHrs != null) {
    labourReportRows.inHrs = inHrs;
  }
  final String? inAgAmt = jsonConvert.convert<String>(json['in_ag_amt']);
  if (inAgAmt != null) {
    labourReportRows.inAgAmt = inAgAmt;
  }
  final String? totHrs = jsonConvert.convert<String>(json['tot_hrs']);
  if (totHrs != null) {
    labourReportRows.totHrs = totHrs;
  }
  final String? totAgAmt = jsonConvert.convert<String>(json['tot_ag_amt']);
  if (totAgAmt != null) {
    labourReportRows.totAgAmt = totAgAmt;
  }
  return labourReportRows;
}

Map<String, dynamic> $LabourReportRowsToJson(LabourReportRows entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['outlet_id'] = entity.outletId;
  data['outlet_name'] = entity.outletName;
  data['hrs'] = entity.hrs;
  data['ag_amt'] = entity.agAmt;
  data['in_hrs'] = entity.inHrs;
  data['in_ag_amt'] = entity.inAgAmt;
  data['tot_hrs'] = entity.totHrs;
  data['tot_ag_amt'] = entity.totAgAmt;
  return data;
}

extension LabourReportRowsExtension on LabourReportRows {
  LabourReportRows copyWith({
    int? outletId,
    String? outletName,
    String? hrs,
    String? agAmt,
    String? inHrs,
    String? inAgAmt,
    String? totHrs,
    String? totAgAmt,
  }) {
    return LabourReportRows()
      ..outletId = outletId ?? this.outletId
      ..outletName = outletName ?? this.outletName
      ..hrs = hrs ?? this.hrs
      ..agAmt = agAmt ?? this.agAmt
      ..inHrs = inHrs ?? this.inHrs
      ..inAgAmt = inAgAmt ?? this.inAgAmt
      ..totHrs = totHrs ?? this.totHrs
      ..totAgAmt = totAgAmt ?? this.totAgAmt;
  }
}

LabourReportTotal $LabourReportTotalFromJson(Map<String, dynamic> json) {
  final LabourReportTotal labourReportTotal = LabourReportTotal();
  final String? hrs = jsonConvert.convert<String>(json['hrs']);
  if (hrs != null) {
    labourReportTotal.hrs = hrs;
  }
  final String? agAmt = jsonConvert.convert<String>(json['ag_amt']);
  if (agAmt != null) {
    labourReportTotal.agAmt = agAmt;
  }
  final String? inHrs = jsonConvert.convert<String>(json['in_hrs']);
  if (inHrs != null) {
    labourReportTotal.inHrs = inHrs;
  }
  final String? inAgAmt = jsonConvert.convert<String>(json['in_ag_amt']);
  if (inAgAmt != null) {
    labourReportTotal.inAgAmt = inAgAmt;
  }
  final String? totHrs = jsonConvert.convert<String>(json['tot_hrs']);
  if (totHrs != null) {
    labourReportTotal.totHrs = totHrs;
  }
  final String? totAgAmt = jsonConvert.convert<String>(json['tot_ag_amt']);
  if (totAgAmt != null) {
    labourReportTotal.totAgAmt = totAgAmt;
  }
  return labourReportTotal;
}

Map<String, dynamic> $LabourReportTotalToJson(LabourReportTotal entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['hrs'] = entity.hrs;
  data['ag_amt'] = entity.agAmt;
  data['in_hrs'] = entity.inHrs;
  data['in_ag_amt'] = entity.inAgAmt;
  data['tot_hrs'] = entity.totHrs;
  data['tot_ag_amt'] = entity.totAgAmt;
  return data;
}

extension LabourReportTotalExtension on LabourReportTotal {
  LabourReportTotal copyWith({
    String? hrs,
    String? agAmt,
    String? inHrs,
    String? inAgAmt,
    String? totHrs,
    String? totAgAmt,
  }) {
    return LabourReportTotal()
      ..hrs = hrs ?? this.hrs
      ..agAmt = agAmt ?? this.agAmt
      ..inHrs = inHrs ?? this.inHrs
      ..inAgAmt = inAgAmt ?? this.inAgAmt
      ..totHrs = totHrs ?? this.totHrs
      ..totAgAmt = totAgAmt ?? this.totAgAmt;
  }
}