/*
 * @Author: ChenYaJin
 * @Date: 2021-11-24 17:57:17
 * @LastEditors: ChenYaJin
 * @LastEditTime: 2021-11-30 10:41:42
 * @Description:  费用详情-模型
 */
class ServiceFeeDetailModel {
  String? id;
  String? houseId;
  String? houseNo;
  String? buildName;
  String? unitName;
  String? residentName;
  String? mobile;
  String? communityId;
  String? serviceType; // 服务类型(repair 报修;report 报事)
  String? relationId;
  String? paymentStatus; //付款状态(cleared 已结清；unCleared 未结清)
  num? serviceFee; //总服务费用
  num? receivableFee; // 应收金额
  num? receivedFee; //已收金额
  num? arrearsFee; //欠费金额
  num? discountFee; //减免金额
  String? paymentCode;
  List<FeeDetail>? serviceFeeDetails;

  ServiceFeeDetailModel({
    this.id,
    this.houseId,
    this.houseNo,
    this.buildName,
    this.unitName,
    this.residentName,
    this.mobile,
    this.communityId,
    this.serviceType,
    this.relationId,
    this.paymentStatus,
    this.serviceFee,
    this.receivableFee,
    this.receivedFee,
    this.arrearsFee,
    this.discountFee,
    this.paymentCode,
    this.serviceFeeDetails,
  });

  ServiceFeeDetailModel.fromJson(json) {
    Map<String, dynamic> map = Map.from(json ?? {});
    id = map['id'];
    houseId = map['houseId'];
    houseNo = map['houseNo'];
    buildName = map['buildName'];
    residentName = map['residentName'];
    mobile = map['mobile'];
    communityId = map['communityId'];
    serviceType = map['serviceType'];
    relationId = map['relationId'];
    paymentStatus = map['paymentStatus'];
    serviceFee = map['serviceFee'];
    receivableFee = map['receivableFee'];
    receivedFee = map['receivedFee'];
    arrearsFee = map['arrearsFee'];
    discountFee = map['discountFee'];
    paymentCode = map['paymentCode'];
    serviceFeeDetails = List<FeeDetail>.from((map['serviceFeeDetails'] ?? [])
        .map((item) => FeeDetail.fromJson(item)));
  }

  Map<String, dynamic> toJson() {
    Map<String, dynamic> json = Map<String, dynamic>();

    json['id'] = this.id.toString();
    json['houseId'] = this.houseId;
    json['houseNo'] = this.houseNo;
    json['buildName'] = this.buildName;
    json['unitName'] = this.unitName;
    json['residentName'] = this.residentName;
    json['mobile'] = this.mobile;
    json['communityId'] = this.communityId;
    json['serviceType'] = this.serviceType;
    json['relationId'] = this.relationId;
    json['paymentStatus'] = this.paymentStatus;
    json['serviceFee'] = this.serviceFee;
    json['receivableFee'] = this.receivableFee;
    json['receivedFee'] = this.receivedFee;
    json['serviceFeeDetails'] =
        List<dynamic>.from((serviceFeeDetails ?? []).map((x) => x.toJson()));
    json['arrearsFee'] = this.arrearsFee;
    json['discountFee'] = this.discountFee;
    json['paymentCode'] = this.paymentCode;

    return json;
  }
}

class FeeDetail {
  String? id;
  String? serviceFeeId;
  String? billId;
  String? identification; // 收费标准唯一标示
  String? name;
  dynamic price; //单价
  dynamic unit;
  dynamic quantity;
  double? fee; // 金额
  bool? isCreateBy;
  bool? check;
  String? payServiceProjectId; // 服务项目

  FeeDetail({
    this.id,
    this.name,
    this.serviceFeeId,
    this.billId,
    this.identification,
    this.price,
    this.unit,
    this.quantity,
    this.fee,
    this.isCreateBy,
    this.check,
    this.payServiceProjectId,
  });

  FeeDetail.fromJson(json) {
    Map<String, dynamic> map = Map.from(json ?? {});
    id = map['id'].toString();
    name = map['name'];
    serviceFeeId = map['serviceFeeId'];
    billId = map['billId'];
    identification = map['identification'];
    price = map['price'];
    unit = map['unit'];
    quantity = map['quantity'];
    fee = map['fee'];
    isCreateBy = map['isCreateBy'];
    check = false;
    payServiceProjectId = map['payServiceProjectId'];
  }

  Map<String, dynamic> toJson() {
    Map<String, dynamic> json = Map<String, dynamic>();

    json['id'] = this.id;
    json['name'] = this.name;
    json['serviceFeeId'] = this.serviceFeeId;
    json['billId'] = this.billId;
    json['identification'] = this.identification;
    json['price'] = this.price;
    json['quantity'] = this.quantity;
    json['unit'] = this.unit;
    json['fee'] = this.fee;
    json['isCreateBy'] = this.isCreateBy;
    json['check'] = this.check;
    json['payServiceProjectId'] = this.payServiceProjectId;

    return json;
  }
}
