$invoiceNumberTemp = Sale::where('shop_id', shopConnect()->id)
->where('status', 'Pendiente')
->first();
if (empty($invoiceNumberTemp)) {
if (empty($newInvoice)) {
$invoiceNumeber = 1;
$sumProduct = 0;
$sumTotal = 0;
} else {
$newInvoice = Sale::where('shop_id', shopConnect()->id)
->orderBy('id', 'DESC')
->first();
$invoiceNumeber = $newInvoice->invoice + 1;
}
} else {
$newInvoice = Sale::where('shop_id', shopConnect()->id)
->orderBy('id', 'DESC')
->first();
$sumProduct = Sale::where('shop_id', shopConnect()->id)
->where('status', 'Pendiente')
->sum('quantity');
$sumTotal = Sale::where('shop_id', shopConnect()->id)
->where('status', 'Pendiente')
->sum('discount');
$invoiceNumeber = $newInvoice->invoice;
}