forked from nathalie/pedi2
Agregado saldo a grupo de compra
This commit is contained in:
parent
d8c8865d13
commit
afddeadeac
5 changed files with 60 additions and 4 deletions
|
@ -14,7 +14,7 @@ use Illuminate\Support\Facades\Log;
|
|||
|
||||
class GrupoDeCompra extends Model
|
||||
{
|
||||
protected $fillable = ["nombre", "region", "devoluciones_habilitadas"];
|
||||
protected $fillable = ["nombre", "region", "devoluciones_habilitadas", "saldo"];
|
||||
protected $table = 'grupos_de_compra';
|
||||
|
||||
public function subpedidos(): HasMany
|
||||
|
@ -69,11 +69,17 @@ class GrupoDeCompra extends Model
|
|||
return $total;
|
||||
}
|
||||
|
||||
public function totalATransferir()
|
||||
public function totalDePedido()
|
||||
{
|
||||
return $this->totalCentralesQueNoPaganTransporte()
|
||||
+ $this->totalCentralesQuePaganTransporte()
|
||||
+ $this->totalTransporte();
|
||||
+ $this->totalTransporte()
|
||||
;
|
||||
}
|
||||
|
||||
public function totalATransferir()
|
||||
{
|
||||
return $this->totalDePedido() - $this->saldo;
|
||||
}
|
||||
|
||||
public function totalCentralesQueNoPaganTransporte()
|
||||
|
|
|
@ -21,9 +21,11 @@ class GrupoDeCompraResource extends JsonResource
|
|||
'devoluciones_habilitadas' => $this->devoluciones_habilitadas,
|
||||
'pedidos' => SubpedidoResource::collection($this->subpedidos),
|
||||
'total_a_recaudar' => number_format($this->totalARecaudar(),2),
|
||||
'saldo' => number_format($this->saldo,2),
|
||||
'total_sin_devoluciones' => number_format($this->totalSinDevoluciones(),2),
|
||||
'total_barrial' => number_format($this->totalBarrial(),2),
|
||||
'total_devoluciones' => number_format($this->totalDevoluciones(),2),
|
||||
'total_de_pedido' => number_format($this->totalDePedido(),2),
|
||||
'total_a_transferir' => number_format($this->totalATransferir(),2),
|
||||
'total_transporte' => number_format($this->totalTransporte()),
|
||||
'cantidad_transporte' => number_format($this->cantidadTransporte()),
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AgregarSaldosABarrios extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
// Agregar columna 'saldo' a la tabla 'grupos_de_compra'
|
||||
Schema::table('grupos_de_compra', function (Blueprint $table) {
|
||||
$table->double('saldo', 10, 2);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
// Remover columna 'saldo' de la tabla 'grupos_de_compra'
|
||||
Schema::table('grupos_de_compra', function (Blueprint $table) {
|
||||
$table->dropColumn('saldo');
|
||||
});
|
||||
}
|
||||
}
|
|
@ -43,7 +43,15 @@
|
|||
<td class="has-text-right">$ {{ total_transporte }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Total a depositar:</th>
|
||||
<th>Total de pedido:</th>
|
||||
<td class="has-text-right">$ {{ total_de_pedido }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Saldo a favor:</th>
|
||||
<td class="has-text-right">$ {{ saldo }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Total a transferir:</th>
|
||||
<td class="has-text-right">$ {{ total_a_transferir }}</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
@ -67,7 +75,9 @@ export default {
|
|||
"total_devoluciones",
|
||||
"cantidad_transporte",
|
||||
"total_transporte",
|
||||
"total_de_pedido",
|
||||
"total_a_transferir",
|
||||
"saldo",
|
||||
]),
|
||||
...mapGetters('admin', ['pedidosAprobados']),
|
||||
},
|
||||
|
|
4
resources/js/store/modules/admin.js
vendored
4
resources/js/store/modules/admin.js
vendored
|
@ -10,9 +10,11 @@ const state = {
|
|||
total_sin_devoluciones: null,
|
||||
total_barrial: null,
|
||||
total_devoluciones: null,
|
||||
total_de_pedido: null,
|
||||
total_a_transferir: null,
|
||||
total_transporte: null,
|
||||
cantidad_transporte: null,
|
||||
saldo: null,
|
||||
};
|
||||
|
||||
const mutations = {
|
||||
|
@ -26,9 +28,11 @@ const mutations = {
|
|||
state.total_sin_devoluciones = grupo_de_compra.total_sin_devoluciones;
|
||||
state.total_barrial = grupo_de_compra.total_barrial;
|
||||
state.total_devoluciones = grupo_de_compra.total_devoluciones;
|
||||
state.total_de_pedido = grupo_de_compra.total_de_pedido;
|
||||
state.total_a_transferir = grupo_de_compra.total_a_transferir;
|
||||
state.total_transporte = grupo_de_compra.total_transporte;
|
||||
state.cantidad_transporte = grupo_de_compra.cantidad_transporte;
|
||||
state.saldo = grupo_de_compra.saldo;
|
||||
},
|
||||
toggleCaracteristica(state, { caracteristica_id }) {
|
||||
state[`${caracteristica_id}_habilitadas`] = !state[`${caracteristica_id}_habilitadas`];
|
||||
|
|
Loading…
Add table
Reference in a new issue