@extends('layouts.master') @section('title') @lang('Escritorio') @endsection @php # Obtener los pedidos de venta más recientes utilizando Carbon para filtrar por fecha. $startOfDay = Carbon\Carbon::now('America/Caracas')->startOfDay(); $endOfDay = Carbon\Carbon::now('America/Caracas')->endOfDay(); # Obtener los pedidos de venta que fueron creados dentro del rango de tiempo del día actual. $recentOrders = App\Models\Sale::with('client', 'currency', 'condition', 'shipping', 'saleDetails', 'seller') ->whereBetween('created_at', [$startOfDay, $endOfDay]) ->get(); if (!$recentOrders->isEmpty()) { $recentOrders = $recentOrders->map(function ($order) { return [ 'id' => $order->id, 'serial' => $order->serial, 'description' => $order->description, 'delivery_address' => $order->delivery_address, 'client_name' => $order->client ? $order->client->description : null, 'client_rif' => $order->client ? $order->client->rif : null, 'region_description' => $order->client->region ? $order->client->region->region_description : null, 'currency_code' => $order->currency ? $order->currency->currency_code : null, 'condition_description' => $order->condition ? $order->condition->condition_description : null, 'seller_name' => $order->seller ? $order->seller->users()->first()->name : null, 'shipping_description' => $order->shipping ? $order->shipping->description : null, 'subtotal_amount' => $order->subtotal, 'tax_amount' => $order->tax_amount, 'discount_amount' => $order->discount_amount, 'total_amount' => $order->total, 'issue_date' => Carbon\Carbon::parse($order->issue_date)->format('d-m-Y'), 'due_date' => Carbon\Carbon::parse($order->due_date)->format('d-m-Y'), 'status' => $order->status, 'products' => $order->saleDetails->map(function ($detail) { return [ 'product_code' => $detail->product_code, 'product_description' => $detail->product ? $detail->product->description : null, 'unit_code' => $detail->unit_code, 'quantity' => $detail->quantity, 'unit_price' => $detail->unit_price, 'tax_amount' => $detail->tax_amount, 'tax_type' => $detail->tax ? $detail->tax->description : null, 'tax_percent' => $detail->tax ? $detail->tax->rate : null, ]; }), ]; }); } // dd($recentOrders); # Obtener el inicio y el fin del mes actual utilizando Carbon. $startOfMonth = Carbon\Carbon::now('America/Caracas')->startOfMonth(); $endOfMonth = Carbon\Carbon::now('America/Caracas')->endOfMonth(); # Contar los pedidos de ventas que fueron creados dentro del rango de tiempo del mes actual. $monthlyOrdersCount = App\Models\Sale::whereBetween('created_at', [$startOfMonth, $endOfMonth])->count(); # Obtener la suma total de los montos de los pedidos de ventas que fueron creados dentro del rango de tiempo del mes actual. $monthlySalesTotal = App\Models\Sale::WhereIn('status', [2, 3])->whereBetween('created_at', [$startOfMonth, $endOfMonth])->sum('total'); // dd($monthlyOrdersCount, $monthlySalesTotal); @endphp @section('css') @endsection @section('content')

Total Facturado Mensual

$0

Monto facturado en el mes

Total Pedidos del Mes

Ventas Mensuales

0

Pedidos

$0k

Ganancias

0

Pedidos Rechazados

Pedidos Recientes

@if ($recentOrders->isEmpty()) @else @foreach ($recentOrders as $order) @endforeach @endif
ID de Pedido Cliente Zona de Pedido Tipo Moneda Subtotal Total Vendedor Estado
No hay pedidos recientes.
{{ $order['serial'] }}
{{ $order['client_name'] ?? 'N/A' }} {{ $order['client_rif'] ?? '' }}
{{ $order['region_description'] ?? 'N/A' }} {{ $order['currency_code'] ?? 'N/A' }} {{ number_format($order['subtotal_amount'], 2) }} {{ number_format($order['total_amount'], 2) }} {{ $order['seller_name'] ?? 'N/A' }} @if ($order['status'] == '1') Pendiente @elseif ($order['status'] == '2') Aprobado @elseif ($order['status'] == '3') Facturado @else Rechazado @endif
@endsection @section('script') @endsection