Corte de caja correcciones
This commit is contained in:
parent
db49b127db
commit
cc20de761a
@ -35,7 +35,7 @@ public function index(Request $request)
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function CloseCashClose($id)
|
public function closeCashClose($id)
|
||||||
{
|
{
|
||||||
$today = now()->format('Y-m-d');
|
$today = now()->format('Y-m-d');
|
||||||
|
|
||||||
@ -50,7 +50,6 @@ public function CloseCashClose($id)
|
|||||||
$cashClose->update([
|
$cashClose->update([
|
||||||
'income' => $totalSales,
|
'income' => $totalSales,
|
||||||
'balance' => $totalSales - $cashClose->exit,
|
'balance' => $totalSales - $cashClose->exit,
|
||||||
'payment_methods' => $paymentMethods,
|
|
||||||
'status' => 'closed',
|
'status' => 'closed',
|
||||||
'close_date' => $today,
|
'close_date' => $today,
|
||||||
]);
|
]);
|
||||||
@ -94,28 +93,34 @@ public function report($id)
|
|||||||
->get();
|
->get();
|
||||||
|
|
||||||
// Reporte detallado de ventas
|
// Reporte detallado de ventas
|
||||||
$detailedSales = DB::table('sales')
|
$detailedSales = SaleItem::whereHas('sale', function($query) use ($id) {
|
||||||
->join('clients', 'sales.client_id', '=', 'clients.id')
|
$query->where('cash_close_id', $id);
|
||||||
->join('sale_items', 'sales.id', '=', 'sale_items.sale_id')
|
})
|
||||||
->join('packages', 'sale_items.package_id', '=', 'packages.id')
|
->with([
|
||||||
->join('sim_cards', 'sale_items.sim_card_id', '=', 'sim_cards.id')
|
'sale.client:id,name,paternal,maternal',
|
||||||
->where('sales.cash_close_id', $id)
|
'sale:id,client_id,payment_method',
|
||||||
->select(
|
'simCard:id,iccid,msisdn',
|
||||||
DB::raw("CONCAT(clients.name, ' ', clients.paternal, ' ', clients.maternal) as nombre_comprador"),
|
'package:id,name,price'
|
||||||
'sim_cards.iccid as id_sim',
|
])
|
||||||
'sim_cards.msisdn as numero_asignado',
|
->orderBy('id', 'asc')
|
||||||
'packages.name as paquete',
|
->paginate(config('app.pagination'))
|
||||||
'packages.price as costo',
|
->through(function($item) {
|
||||||
'sales.payment_method as medio_pago'
|
return [
|
||||||
)
|
'nombre_comprador' => $item->sale->client->full_name,
|
||||||
->orderBy('sales.id', 'desc')
|
'id_sim' => $item->simCard->iccid,
|
||||||
->get();
|
'numero_asignado' => $item->simCard->msisdn,
|
||||||
|
'paquete' => $item->package->name,
|
||||||
|
'costo' => $item->package->price,
|
||||||
|
'medio_pago' => $item->sale->payment_method
|
||||||
|
];
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
return ApiResponse::OK->response([
|
return ApiResponse::OK->response([
|
||||||
'cash_close' => $cashClose,
|
'cash_close' => $cashClose,
|
||||||
'ventas por paquete' => $packageStats,
|
'ventas_paquete' => $packageStats,
|
||||||
'ventas por duracion' => $durationStats,
|
'ventas_duracion' => $durationStats,
|
||||||
'ventas detalladas' => $detailedSales,
|
'ventas_detalladas' => $detailedSales,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,10 +12,7 @@ class CashClose extends Model
|
|||||||
'balance',
|
'balance',
|
||||||
'income',
|
'income',
|
||||||
'exit',
|
'exit',
|
||||||
'expected_balance',
|
|
||||||
'difference',
|
|
||||||
'close_date',
|
'close_date',
|
||||||
'notes',
|
|
||||||
'status',
|
'status',
|
||||||
'user_id',
|
'user_id',
|
||||||
];
|
];
|
||||||
@ -24,8 +21,6 @@ class CashClose extends Model
|
|||||||
'balance' => 'decimal:2',
|
'balance' => 'decimal:2',
|
||||||
'income' => 'decimal:2',
|
'income' => 'decimal:2',
|
||||||
'exit' => 'decimal:2',
|
'exit' => 'decimal:2',
|
||||||
'expected_balance' => 'decimal:2',
|
|
||||||
'difference' => 'decimal:2',
|
|
||||||
'close_date' => 'date',
|
'close_date' => 'date',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
@ -4,6 +4,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -40,4 +41,11 @@ public function simCards()
|
|||||||
->withPivot('assigned_at', 'released_at', 'is_active')
|
->withPivot('assigned_at', 'released_at', 'is_active')
|
||||||
->withTimestamps();
|
->withTimestamps();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function fullName(): Attribute
|
||||||
|
{
|
||||||
|
return Attribute::make(
|
||||||
|
get: fn () => $this->name . ' ' . $this->paternal . ' ' . $this->maternal,
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user