|
@@ -24,11 +24,20 @@ class EstimateOverview extends EnhancedStatsOverviewWidget
|
24
|
24
|
$activeTab = $this->activeTab;
|
25
|
25
|
|
26
|
26
|
if ($activeTab === 'draft') {
|
|
27
|
+ $draftEstimates = $this->getPageTableQuery();
|
|
28
|
+ $totalDraftCount = $draftEstimates->count();
|
|
29
|
+ $totalDraftAmount = $draftEstimates->get()->sumMoneyInDefaultCurrency('total');
|
|
30
|
+
|
|
31
|
+ $averageDraftTotal = $totalDraftCount > 0
|
|
32
|
+ ? (int) round($totalDraftAmount / $totalDraftCount)
|
|
33
|
+ : 0;
|
|
34
|
+
|
27
|
35
|
return [
|
28
|
36
|
EnhancedStatsOverviewWidget\EnhancedStat::make('Active Estimates', '-'),
|
29
|
37
|
EnhancedStatsOverviewWidget\EnhancedStat::make('Accepted Estimates', '-'),
|
30
|
38
|
EnhancedStatsOverviewWidget\EnhancedStat::make('Converted Estimates', '-'),
|
31
|
|
- EnhancedStatsOverviewWidget\EnhancedStat::make('Average Estimate Total', '-'),
|
|
39
|
+ EnhancedStatsOverviewWidget\EnhancedStat::make('Average Estimate Total', CurrencyConverter::formatCentsToMoney($averageDraftTotal))
|
|
40
|
+ ->suffix(CurrencyAccessor::getDefaultCurrency()),
|
32
|
41
|
];
|
33
|
42
|
}
|
34
|
43
|
|
|
@@ -56,14 +65,23 @@ class EstimateOverview extends EnhancedStatsOverviewWidget
|
56
|
65
|
$totalValidEstimatesCount = $validEstimates->count();
|
57
|
66
|
$totalValidEstimateAmount = $validEstimates->get()->sumMoneyInDefaultCurrency('total');
|
58
|
67
|
|
59
|
|
- $percentConverted = $totalValidEstimatesCount > 0
|
60
|
|
- ? Number::percentage(($totalConvertedCount / $totalValidEstimatesCount) * 100, maxPrecision: 1)
|
61
|
|
- : Number::percentage(0, maxPrecision: 1);
|
62
|
|
-
|
63
|
68
|
$averageEstimateTotal = $totalValidEstimatesCount > 0
|
64
|
69
|
? (int) round($totalValidEstimateAmount / $totalValidEstimatesCount)
|
65
|
70
|
: 0;
|
66
|
71
|
|
|
72
|
+ $percentConverted = '-';
|
|
73
|
+ $percentConvertedSuffix = null;
|
|
74
|
+ $percentConvertedDescription = null;
|
|
75
|
+
|
|
76
|
+ if ($activeTab !== 'active') {
|
|
77
|
+ $percentConverted = $totalValidEstimatesCount > 0
|
|
78
|
+ ? Number::percentage(($totalConvertedCount / $totalValidEstimatesCount) * 100, maxPrecision: 1)
|
|
79
|
+ : Number::percentage(0, maxPrecision: 1);
|
|
80
|
+
|
|
81
|
+ $percentConvertedSuffix = 'converted';
|
|
82
|
+ $percentConvertedDescription = $totalConvertedCount . ' converted';
|
|
83
|
+ }
|
|
84
|
+
|
67
|
85
|
return [
|
68
|
86
|
EnhancedStatsOverviewWidget\EnhancedStat::make('Active Estimates', CurrencyConverter::formatCentsToMoney($totalActiveAmount))
|
69
|
87
|
->suffix(CurrencyAccessor::getDefaultCurrency())
|
|
@@ -74,11 +92,12 @@ class EstimateOverview extends EnhancedStatsOverviewWidget
|
74
|
92
|
->description($totalAcceptedCount . ' accepted'),
|
75
|
93
|
|
76
|
94
|
EnhancedStatsOverviewWidget\EnhancedStat::make('Converted Estimates', $percentConverted)
|
77
|
|
- ->suffix('converted')
|
78
|
|
- ->description($totalConvertedCount . ' converted'),
|
|
95
|
+ ->suffix($percentConvertedSuffix)
|
|
96
|
+ ->description($percentConvertedDescription),
|
79
|
97
|
|
80
|
98
|
EnhancedStatsOverviewWidget\EnhancedStat::make('Average Estimate Total', CurrencyConverter::formatCentsToMoney($averageEstimateTotal))
|
81
|
|
- ->suffix(CurrencyAccessor::getDefaultCurrency()),
|
|
99
|
+ ->suffix(CurrencyAccessor::getDefaultCurrency())
|
|
100
|
+ ->description($activeTab === 'all' ? 'Excludes draft estimates' : null),
|
82
|
101
|
];
|
83
|
102
|
}
|
84
|
103
|
}
|