Compare commits
2 commits
d8c8865d13
...
02aba80fc9
Author | SHA1 | Date | |
---|---|---|---|
![]() |
02aba80fc9 | ||
![]() |
afddeadeac |
9 changed files with 123 additions and 7 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']),
|
||||
},
|
||||
|
|
|
@ -41,6 +41,22 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="block pb-6"
|
||||
id="saldos-compras-seccion"
|
||||
:class="seccionActiva === 'saldos-compras-seccion' ? 'is-active' : 'is-hidden'"
|
||||
>
|
||||
<div class="block" id="saldos-compras-seccion">
|
||||
<table>
|
||||
<tbody>
|
||||
<tr v-for="gdc in grupos_de_compra">
|
||||
<th>{{ gdc.nombre }}</th>
|
||||
<td>{{ gdc.saldo }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
@ -48,6 +64,7 @@
|
|||
import TabsSecciones from "../comunes/TabsSecciones.vue";
|
||||
import DropdownDescargar from "./DropdownDescargar.vue";
|
||||
import CanastaInput from "./CanastaInput.vue";
|
||||
import { mapActions, mapState } from "vuex";
|
||||
|
||||
export default {
|
||||
components: {
|
||||
|
@ -57,8 +74,11 @@ export default {
|
|||
},
|
||||
data() {
|
||||
return {
|
||||
tabs: [{ id: "pedidos-compras", nombre: "Pedidos" },
|
||||
{ id: "canasta-compras", nombre: "Canasta" }],
|
||||
tabs: [
|
||||
{ id: "pedidos-compras", nombre: "Pedidos" },
|
||||
{ id: "canasta-compras", nombre: "Canasta" },
|
||||
{ id: "saldos-compras", nombre: "Saldos" },
|
||||
],
|
||||
tabActiva: "pedidos-compras",
|
||||
seccionActiva: "pedidos-compras-seccion",
|
||||
archivo: undefined,
|
||||
|
@ -69,6 +89,15 @@ export default {
|
|||
this.tabActiva = tabId;
|
||||
this.seccionActiva = tabId + "-seccion";
|
||||
},
|
||||
}
|
||||
...mapActions('comisiones', ['getGruposDeCompra']),
|
||||
},
|
||||
computed: {
|
||||
...mapState('comisiones', [
|
||||
'grupos_de_compra',
|
||||
]),
|
||||
},
|
||||
async mounted() {
|
||||
await this.getGruposDeCompra();
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
|
2
resources/js/store/index.js
vendored
2
resources/js/store/index.js
vendored
|
@ -1,6 +1,7 @@
|
|||
import Vue from 'vue';
|
||||
import Vuex from 'vuex';
|
||||
import admin from "./modules/admin";
|
||||
import comisiones from "./modules/comisiones";
|
||||
import login from "./modules/login";
|
||||
import pedido from "./modules/pedido";
|
||||
import productos from "./modules/productos";
|
||||
|
@ -11,6 +12,7 @@ Vue.use(Vuex);
|
|||
export default new Vuex.Store({
|
||||
modules: {
|
||||
admin,
|
||||
comisiones,
|
||||
login,
|
||||
pedido,
|
||||
productos,
|
||||
|
|
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`];
|
||||
|
|
28
resources/js/store/modules/comisiones.js
vendored
Normal file
28
resources/js/store/modules/comisiones.js
vendored
Normal file
|
@ -0,0 +1,28 @@
|
|||
import axios from "axios";
|
||||
|
||||
const state = {
|
||||
grupos_de_compra: null,
|
||||
};
|
||||
|
||||
const mutations = {
|
||||
setGruposDeCompra(state, { grupos_de_compra }) {
|
||||
state.grupos_de_compra = grupos_de_compra;
|
||||
},
|
||||
};
|
||||
|
||||
const actions = {
|
||||
async getGruposDeCompra({ commit }) {
|
||||
const response = await axios.get('/api/grupos-de-compra');
|
||||
commit('setGruposDeCompra', response.data);
|
||||
},
|
||||
};
|
||||
|
||||
const getters = {};
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state,
|
||||
mutations,
|
||||
actions,
|
||||
getters,
|
||||
};
|
|
@ -18,6 +18,7 @@ Route::middleware('api')->group(function() {
|
|||
Route::get('/regiones/{region}', 'Api\GrupoDeCompraController@region');
|
||||
|
||||
Route::prefix('grupos-de-compra')->group(function() {
|
||||
Route::get('/', 'Api\GrupoDeCompraController@index');
|
||||
Route::get('/{grupoDeCompra}', 'Api\GrupoDeCompraController@show');
|
||||
Route::post('/{gdc}/devoluciones', 'Api\GrupoDeCompraController@toggleDevoluciones');
|
||||
});
|
||||
|
|
Loading…
Add table
Reference in a new issue