report_model.dart 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /// 报表汇总数据
  2. class ReportSummary {
  3. final double totalAmount;
  4. final int totalCount;
  5. final int transferredCount; // 已转报销笔数
  6. final double transferredAmount; // 已转报销金额
  7. final double approvedAmount; // 核准金额
  8. const ReportSummary({
  9. this.totalAmount = 0,
  10. this.totalCount = 0,
  11. this.transferredCount = 0,
  12. this.transferredAmount = 0,
  13. this.approvedAmount = 0,
  14. });
  15. factory ReportSummary.fromJson(Map<String, dynamic> json) {
  16. return ReportSummary(
  17. totalAmount: (json['totalAmount'] as num?)?.toDouble() ?? 0,
  18. totalCount: json['totalCount'] as int? ?? 0,
  19. transferredCount: json['transferredCount'] as int? ?? 0,
  20. transferredAmount: (json['transferredAmount'] as num?)?.toDouble() ?? 0,
  21. approvedAmount: (json['approvedAmount'] as num?)?.toDouble() ?? 0,
  22. );
  23. }
  24. }
  25. /// 月度报表数据
  26. class ReportMonthlyItem {
  27. final int month;
  28. final double amount;
  29. final double transferredAmount; // 当月已转报销金额
  30. final double approvedAmount; // 当月核准金额
  31. final int count;
  32. const ReportMonthlyItem({
  33. this.month = 0,
  34. this.amount = 0,
  35. this.transferredAmount = 0,
  36. this.approvedAmount = 0,
  37. this.count = 0,
  38. });
  39. factory ReportMonthlyItem.fromJson(Map<String, dynamic> json) {
  40. return ReportMonthlyItem(
  41. month: json['month'] as int? ?? 0,
  42. amount: (json['amount'] as num?)?.toDouble() ?? 0,
  43. transferredAmount: (json['transferredAmount'] as num?)?.toDouble() ?? 0,
  44. approvedAmount: (json['approvedAmount'] as num?)?.toDouble() ?? 0,
  45. count: json['count'] as int? ?? 0,
  46. );
  47. }
  48. }
  49. /// 报表明细项
  50. class ReportDetailItem {
  51. final String billNo;
  52. final String? billDate;
  53. final double amount;
  54. final double approvedAmount; // 核准金额
  55. final bool isTransferred;
  56. final String reason;
  57. const ReportDetailItem({
  58. this.billNo = '',
  59. this.billDate,
  60. this.amount = 0,
  61. this.approvedAmount = 0,
  62. this.isTransferred = false,
  63. this.reason = '',
  64. });
  65. factory ReportDetailItem.fromJson(Map<String, dynamic> json) {
  66. return ReportDetailItem(
  67. billNo: json['billNo'] as String? ?? '',
  68. billDate: json['billDate'] as String?,
  69. amount: (json['amount'] as num?)?.toDouble() ?? 0,
  70. approvedAmount: (json['approvedAmount'] as num?)?.toDouble() ?? 0,
  71. isTransferred: json['isTransferred'] as bool? ?? false,
  72. reason: json['reason'] as String? ?? '',
  73. );
  74. }
  75. }
  76. /// 报表完整数据
  77. class ReportData {
  78. final ReportSummary summary;
  79. final List<ReportMonthlyItem> monthly;
  80. final List<ReportDetailItem> details;
  81. const ReportData({
  82. this.summary = const ReportSummary(),
  83. this.monthly = const [],
  84. this.details = const [],
  85. });
  86. factory ReportData.fromJson(Map<String, dynamic> json) {
  87. return ReportData(
  88. summary: json['summary'] != null
  89. ? ReportSummary.fromJson(json['summary'] as Map<String, dynamic>)
  90. : const ReportSummary(),
  91. monthly: (json['monthly'] as List<dynamic>?)
  92. ?.map((e) => ReportMonthlyItem.fromJson(e as Map<String, dynamic>))
  93. .toList() ??
  94. [],
  95. details: (json['details'] as List<dynamic>?)
  96. ?.map((e) => ReportDetailItem.fromJson(e as Map<String, dynamic>))
  97. .toList() ??
  98. [],
  99. );
  100. }
  101. }