@extends('template.template') @section('content') @php $user_id = auth()->id(); $user = auth()->user(); use App\Models\Venda; use Carbon\Carbon; $mesAtual = ucfirst(Carbon::now()->locale('pt_BR')->monthName); $mesNumber = ucfirst(Carbon::now()->locale('pt_BR')->month); $vendas = Venda::where('user_id', $user_id)->whereRaw("month(date) = $mesNumber")->orderBy('id', 'desc')->get(); $valorTotal = $vendas->sum(function ($venda) { return $venda->product_value + $venda->frame_value; }); $valorTotalComissoes = $vendas->sum('commission'); $valorTotalComissoesPagas = $vendas->sum('commission_paid'); // Filtrado por mês $vendasMesAtual = Venda::where('user_id', $user_id) ->whereBetween('date', [Carbon::now()->startOfMonth(), Carbon::now()->endOfMonth()]) ->orderBy('id', 'desc') ->get(); $valorTotalMes = $vendasMesAtual->sum(function ($venda) { return $venda->product_value + $venda->frame_value; }); $valorTotalComissoesMes = $vendasMesAtual->sum('commission'); @endphp
| Data de venda | Nota Fiscal | Cliente | Valor de venda | Valor de comissão | Forma de pagamento | Condição | Empresa | Tipo de material | Cliente quitou? | ||
|---|---|---|---|---|---|---|---|---|---|---|---|
| {{ Carbon::parse($venda->date)->format('d/m/Y') }} | {{ $venda->invoice }} | {{ $venda->client_name }} | {{ 'R$ ' . number_format($venda->product_value + $venda->frame_value, 2, ',', '.') }} | {{ 'R$ ' . number_format($venda->commission, 2, ',', '.') }} | {{--{{ 'R$ ' . number_format($venda->commission_paid, 2, ',', '.') }} | --}}{{ $venda->payment_method }} | {{ $venda->condition }} | {{ $venda->company }} | {{ $venda->product_type == 'PRODUCT' ? 'Produto' : ($venda->product_type == 'FRAME' ? 'Quadro' : 'Produto e Quadro') }} | @if ($venda->settled) Quitado | (desfazer) @else Quitar @endif |
| # | Vendedor | Valor total | Valor de comissão | Recebido | Pendente | |
|---|---|---|---|---|---|---|
| {{ $user->id }} | {{ $user->name }} | {{ 'R$ ' . number_format($valorTotal, 2, ',', '.') }} | {{ 'R$ ' . number_format($valorTotalComissoes, 2, ',', '.') }} | {{ 'R$ ' . number_format($valorTotalComissoesPagas, 2, ',', '.') }} | {{ 'R$ ' . number_format($valorTotalComissoes - $valorTotalComissoesPagas, 2, ',', '.') }} | Visualizar |