forked from nathalie/pedi2
Formato
This commit is contained in:
parent
f909a78e74
commit
ead7483e19
1 changed files with 52 additions and 48 deletions
|
@ -16,18 +16,18 @@ class Subpedido extends Model
|
|||
|
||||
public function productos()
|
||||
{
|
||||
return $this->belongsToMany('App\Producto')->withPivot(["cantidad","total", "notas"]);
|
||||
return $this->belongsToMany('App\Producto')->withPivot(["cantidad", "total", "notas"]);
|
||||
}
|
||||
|
||||
//Bonos del MPS, Sororo, etc. NO devuelve bonos de transporte
|
||||
private function bonos()
|
||||
{
|
||||
return $this->productos()->where('bono',1);
|
||||
return $this->productos()->where('bono', 1);
|
||||
}
|
||||
|
||||
public function productosSinBonos()
|
||||
{
|
||||
return $this->productos()->where('bono',false);
|
||||
return $this->productos()->where('bono', false);
|
||||
}
|
||||
|
||||
public function grupoDeCompra()
|
||||
|
@ -35,7 +35,7 @@ class Subpedido extends Model
|
|||
return $this->belongsTo('App\GrupoDeCompra');
|
||||
}
|
||||
|
||||
//Permite que se apliquen los filtros al hacer una request (por ejemplo, de búsqueda)
|
||||
// Permite que se apliquen los filtros al hacer una request (por ejemplo, de búsqueda)
|
||||
public function scopeFiltrar($query, FiltroDeSubpedido $filtros)
|
||||
{
|
||||
return $filtros->aplicar($query);
|
||||
|
@ -103,8 +103,9 @@ class Subpedido extends Model
|
|||
}
|
||||
|
||||
//Actualiza el pedido, agregando o quitando del subpedido según sea necesario. Debe ser llamado desde el controlador de subpedidos, luego de validar que los parámetros $producto y $cantidad son correctos. También calcula el subtotal por producto.
|
||||
public function syncProducto(Producto $producto, Int $cantidad, string $notas) {
|
||||
if ($cantidad){
|
||||
public function syncProducto(Producto $producto, int $cantidad, string $notas)
|
||||
{
|
||||
if ($cantidad) {
|
||||
//si la cantidad es 1 o más se agrega el producto o actualiza la cantidad
|
||||
$this->productos()->syncWithoutDetaching([
|
||||
$producto->id => [
|
||||
|
@ -119,17 +120,20 @@ class Subpedido extends Model
|
|||
}
|
||||
}
|
||||
|
||||
public function toggleAprobacion(bool $aprobacion) {
|
||||
public function toggleAprobacion(bool $aprobacion)
|
||||
{
|
||||
$this->aprobado = $aprobacion;
|
||||
$this->save();
|
||||
}
|
||||
|
||||
public function generarHTML() {
|
||||
public function generarHTML()
|
||||
{
|
||||
$view = view("pdfgen.subpedido_tabla", ["subpedido" => $this]);
|
||||
return $view->render();
|
||||
}
|
||||
|
||||
public function syncDevoluciones(float $total, string $notas) {
|
||||
public function syncDevoluciones(float $total, string $notas)
|
||||
{
|
||||
$this->devoluciones_total = $total;
|
||||
$this->devoluciones_notas = $notas;
|
||||
$this->save();
|
||||
|
|
Loading…
Add table
Reference in a new issue