|
@@ -21,6 +21,24 @@ class EstimateOverview extends EnhancedStatsOverviewWidget
|
21
|
21
|
|
22
|
22
|
protected function getStats(): array
|
23
|
23
|
{
|
|
24
|
+ $activeTab = $this->activeTab;
|
|
25
|
+
|
|
26
|
+ if ($activeTab === 'draft') {
|
|
27
|
+ return [
|
|
28
|
+ EnhancedStatsOverviewWidget\EnhancedStat::make('Active Estimates', '-')
|
|
29
|
+ ->suffix('')
|
|
30
|
+ ->description(''),
|
|
31
|
+ EnhancedStatsOverviewWidget\EnhancedStat::make('Accepted Estimates', '-')
|
|
32
|
+ ->suffix('')
|
|
33
|
+ ->description(''),
|
|
34
|
+ EnhancedStatsOverviewWidget\EnhancedStat::make('Converted Estimates', '-')
|
|
35
|
+ ->suffix('')
|
|
36
|
+ ->description(''),
|
|
37
|
+ EnhancedStatsOverviewWidget\EnhancedStat::make('Average Estimate Total', '-')
|
|
38
|
+ ->suffix(''),
|
|
39
|
+ ];
|
|
40
|
+ }
|
|
41
|
+
|
24
|
42
|
$activeEstimates = $this->getPageTableQuery()->active();
|
25
|
43
|
|
26
|
44
|
$totalActiveCount = $activeEstimates->count();
|
|
@@ -36,18 +54,21 @@ class EstimateOverview extends EnhancedStatsOverviewWidget
|
36
|
54
|
->where('status', EstimateStatus::Converted);
|
37
|
55
|
|
38
|
56
|
$totalConvertedCount = $convertedEstimates->count();
|
39
|
|
- $totalEstimatesCount = $this->getPageTableQuery()->count();
|
40
|
57
|
|
41
|
|
- $percentConverted = $totalEstimatesCount > 0
|
42
|
|
- ? Number::percentage(($totalConvertedCount / $totalEstimatesCount) * 100, maxPrecision: 1)
|
43
|
|
- : Number::percentage(0, maxPrecision: 1);
|
|
58
|
+ $validEstimates = $this->getPageTableQuery()
|
|
59
|
+ ->whereNotIn('status', [
|
|
60
|
+ EstimateStatus::Draft,
|
|
61
|
+ ]);
|
44
|
62
|
|
45
|
|
- $totalEstimateAmount = $this->getPageTableQuery()
|
46
|
|
- ->get()
|
47
|
|
- ->sumMoneyInDefaultCurrency('total');
|
|
63
|
+ $totalValidEstimatesCount = $validEstimates->count();
|
|
64
|
+ $totalValidEstimateAmount = $validEstimates->get()->sumMoneyInDefaultCurrency('total');
|
|
65
|
+
|
|
66
|
+ $percentConverted = $totalValidEstimatesCount > 0
|
|
67
|
+ ? Number::percentage(($totalConvertedCount / $totalValidEstimatesCount) * 100, maxPrecision: 1)
|
|
68
|
+ : Number::percentage(0, maxPrecision: 1);
|
48
|
69
|
|
49
|
|
- $averageEstimateTotal = $totalEstimatesCount > 0
|
50
|
|
- ? (int) round($totalEstimateAmount / $totalEstimatesCount)
|
|
70
|
+ $averageEstimateTotal = $totalValidEstimatesCount > 0
|
|
71
|
+ ? (int) round($totalValidEstimateAmount / $totalValidEstimatesCount)
|
51
|
72
|
: 0;
|
52
|
73
|
|
53
|
74
|
return [
|