Files
autocrm/app/Filament/Tenant/Widgets/FinanceOverview.php
T
Vasyka 2d447e6294 feat(i18n): fix widgets, pipeline & mechanic boards + missing translations
Follow-up to previous i18n pass — user reported many visible RO strings on
EN/RU locales because auto-wrap missed:
  - Stat::make() first-arg labels in StatsOverview, FinanceOverview, PlatformStats
  - $heading static in LowStockTable (converted to getHeading() method)
  - Pipeline board Blade view: 40+ literal strings wrapped with {{ __() }}
  - Mechanic board Blade view: statuses, buttons, block modal
  - PipelineBoard.php hardcoded tag labels, stage labels, notify strings
  - MechanicBoard.php confirmBlock notification

Added human RU + EN translations for the visible strings shown in the
screenshots (dashboard widgets, Client/Vehicle list breadcrumbs & columns,
pipeline board topbar/stats/filters/cards/detail panel/quick actions,
mechanic board stats/statuses/block modal). All 306 tests pass.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-07-15 05:31:26 +00:00

52 lines
1.9 KiB
PHP

<?php
namespace App\Filament\Tenant\Widgets;
use App\Models\Tenant\Expense;
use App\Models\Tenant\Payment;
use App\Models\Tenant\WorkOrder;
use Filament\Widgets\StatsOverviewWidget as BaseWidget;
use Filament\Widgets\StatsOverviewWidget\Stat;
class FinanceOverview extends BaseWidget
{
protected static ?int $sort = 2;
protected function getStats(): array
{
$start = now()->startOfMonth();
$end = now()->endOfMonth();
$income = (float) Payment::whereBetween('paid_at', [$start, $end])->sum('amount');
$expenses = (float) Expense::whereBetween('paid_at', [$start, $end])->sum('amount');
$profit = $income - $expenses;
$debtTotal = (float) WorkOrder::where('pay_status', '!=', 'paid')
->whereNotIn('status', ['cancelled'])
->sum('total');
$paidOnDebt = (float) Payment::whereIn('work_order_id',
WorkOrder::where('pay_status', '!=', 'paid')->pluck('id')
)->sum('amount');
$debt = max(0, $debtTotal - $paidOnDebt);
return [
Stat::make(__('Încasări (luna)'), number_format($income, 2, '.', ' ') . ' MDL')
->icon('heroicon-o-arrow-trending-up')
->color('success')
->description(now()->translatedFormat('F Y')),
Stat::make(__('Cheltuieli (luna)'), number_format($expenses, 2, '.', ' ') . ' MDL')
->icon('heroicon-o-arrow-trending-down')
->color('danger'),
Stat::make(__('Profit (luna)'), number_format($profit, 2, '.', ' ') . ' MDL')
->icon('heroicon-o-banknotes')
->color($profit >= 0 ? 'success' : 'danger'),
Stat::make(__('Datorii clienți'), number_format($debt, 2, '.', ' ') . ' MDL')
->icon('heroicon-o-exclamation-circle')
->color($debt > 0 ? 'warning' : 'success'),
];
}
}