32 lines
920 B
Dart
32 lines
920 B
Dart
import '../models/invoice_models.dart';
|
|
|
|
class SalesCustomerStat {
|
|
SalesCustomerStat({required this.customerName, required this.totalAmount});
|
|
|
|
final String customerName;
|
|
final int totalAmount;
|
|
}
|
|
|
|
class SalesSummary {
|
|
SalesSummary({
|
|
required this.year,
|
|
required this.monthlyTotals,
|
|
required this.yearlyTotal,
|
|
required this.customerStats,
|
|
this.documentType,
|
|
});
|
|
|
|
final int year;
|
|
final Map<int, int> monthlyTotals;
|
|
final int yearlyTotal;
|
|
final List<SalesCustomerStat> customerStats;
|
|
final DocumentType? documentType;
|
|
|
|
int get bestMonth =>
|
|
monthlyTotals.entries.isEmpty ? 0 : monthlyTotals.entries.reduce((a, b) => a.value >= b.value ? a : b).key;
|
|
|
|
int get bestMonthTotal =>
|
|
monthlyTotals.entries.isEmpty ? 0 : monthlyTotals.entries.reduce((a, b) => a.value >= b.value ? a : b).value;
|
|
|
|
double get averageMonthly => yearlyTotal / (monthlyTotals.isEmpty ? 1 : 12);
|
|
}
|