// ============================ // PurchaseInvoiceOverviewModel.dart // ============================ class PurchaseInvoiceOverviewResponse { final bool? success; final String? message; final PurchaseInvoiceOverviewData? data; final dynamic errors; final int? statusCode; final DateTime? timestamp; PurchaseInvoiceOverviewResponse({ this.success, this.message, this.data, this.errors, this.statusCode, this.timestamp, }); factory PurchaseInvoiceOverviewResponse.fromJson(Map json) { return PurchaseInvoiceOverviewResponse( success: json['success'] as bool?, message: json['message'] as String?, data: json['data'] != null ? PurchaseInvoiceOverviewData.fromJson(json['data']) : null, errors: json['errors'], statusCode: json['statusCode'] as int?, timestamp: json['timestamp'] != null ? DateTime.tryParse(json['timestamp']) : null, ); } Map toJson() { return { 'success': success, 'message': message, 'data': data?.toJson(), 'errors': errors, 'statusCode': statusCode, 'timestamp': timestamp?.toIso8601String(), }; } } class PurchaseInvoiceOverviewData { final int? totalInvoices; final double? totalValue; final double? averageValue; final List? statusBreakdown; final List? projectBreakdown; final TopSupplier? topSupplier; PurchaseInvoiceOverviewData({ this.totalInvoices, this.totalValue, this.averageValue, this.statusBreakdown, this.projectBreakdown, this.topSupplier, }); factory PurchaseInvoiceOverviewData.fromJson(Map json) { return PurchaseInvoiceOverviewData( totalInvoices: json['totalInvoices'] as int?, totalValue: (json['totalValue'] != null) ? (json['totalValue'] as num).toDouble() : null, averageValue: (json['averageValue'] != null) ? (json['averageValue'] as num).toDouble() : null, statusBreakdown: json['statusBreakdown'] != null ? (json['statusBreakdown'] as List) .map((e) => StatusBreakdown.fromJson(e)) .toList() : null, projectBreakdown: json['projectBreakdown'] != null ? (json['projectBreakdown'] as List) .map((e) => ProjectBreakdown.fromJson(e)) .toList() : null, topSupplier: json['topSupplier'] != null ? TopSupplier.fromJson(json['topSupplier']) : null, ); } Map toJson() { return { 'totalInvoices': totalInvoices, 'totalValue': totalValue, 'averageValue': averageValue, 'statusBreakdown': statusBreakdown?.map((e) => e.toJson()).toList(), 'projectBreakdown': projectBreakdown?.map((e) => e.toJson()).toList(), 'topSupplier': topSupplier?.toJson(), }; } } class StatusBreakdown { final String? id; final String? name; final int? count; final double? totalValue; final double? percentage; StatusBreakdown({ this.id, this.name, this.count, this.totalValue, this.percentage, }); factory StatusBreakdown.fromJson(Map json) { return StatusBreakdown( id: json['id'] as String?, name: json['name'] as String?, count: json['count'] as int?, totalValue: (json['totalValue'] != null) ? (json['totalValue'] as num).toDouble() : null, percentage: (json['percentage'] != null) ? (json['percentage'] as num).toDouble() : null, ); } Map toJson() { return { 'id': id, 'name': name, 'count': count, 'totalValue': totalValue, 'percentage': percentage, }; } } class ProjectBreakdown { final String? id; final String? name; final int? count; final double? totalValue; final double? percentage; ProjectBreakdown({ this.id, this.name, this.count, this.totalValue, this.percentage, }); factory ProjectBreakdown.fromJson(Map json) { return ProjectBreakdown( id: json['id'] as String?, name: json['name'] as String?, count: json['count'] as int?, totalValue: (json['totalValue'] != null) ? (json['totalValue'] as num).toDouble() : null, percentage: (json['percentage'] != null) ? (json['percentage'] as num).toDouble() : null, ); } Map toJson() { return { 'id': id, 'name': name, 'count': count, 'totalValue': totalValue, 'percentage': percentage, }; } } class TopSupplier { final String? id; final String? name; final int? count; final double? totalValue; final double? percentage; TopSupplier({ this.id, this.name, this.count, this.totalValue, this.percentage, }); factory TopSupplier.fromJson(Map json) { return TopSupplier( id: json['id'] as String?, name: json['name'] as String?, count: json['count'] as int?, totalValue: (json['totalValue'] != null) ? (json['totalValue'] as num).toDouble() : null, percentage: (json['percentage'] != null) ? (json['percentage'] as num).toDouble() : null, ); } Map toJson() { return { 'id': id, 'name': name, 'count': count, 'totalValue': totalValue, 'percentage': percentage, }; } }