Tirando error cuando se intenta modificar un pedido aprobado
This commit is contained in:
parent
0dba210a6a
commit
f837b7f066
2 changed files with 24 additions and 15 deletions
|
@ -57,7 +57,7 @@ class SubpedidoController extends Controller
|
||||||
// recibe request, saca producto y cantidad, valida, y pasa a syncProducto en Subpedido
|
// recibe request, saca producto y cantidad, valida, y pasa a syncProducto en Subpedido
|
||||||
public function syncProductos(Subpedido $subpedido) {
|
public function syncProductos(Subpedido $subpedido) {
|
||||||
if ($subpedido->aprobado)
|
if ($subpedido->aprobado)
|
||||||
return new SubpedidoResource($subpedido);
|
abort(400, "No se puede modificar un pedido aprobado.");
|
||||||
|
|
||||||
$valid = request()->validate([
|
$valid = request()->validate([
|
||||||
'cantidad' => ['integer','required','min:0'],
|
'cantidad' => ['integer','required','min:0'],
|
||||||
|
@ -84,7 +84,8 @@ class SubpedidoController extends Controller
|
||||||
}
|
}
|
||||||
|
|
||||||
public function syncDevoluciones(Subpedido $subpedido) {
|
public function syncDevoluciones(Subpedido $subpedido) {
|
||||||
if ($subpedido->aprobado) return new SubpedidoResource($subpedido);
|
if ($subpedido->aprobado)
|
||||||
|
abort(400, "No se puede modificar un pedido aprobado.");
|
||||||
|
|
||||||
$valid = request()->validate([
|
$valid = request()->validate([
|
||||||
'total' => 'required|min:0',
|
'total' => 'required|min:0',
|
||||||
|
|
34
resources/js/store/modules/pedido.js
vendored
34
resources/js/store/modules/pedido.js
vendored
|
@ -42,20 +42,28 @@ const actions = {
|
||||||
const response = await axios.get(`/api/subpedidos/${pedido.id}`);
|
const response = await axios.get(`/api/subpedidos/${pedido.id}`);
|
||||||
commit('setState', response.data.data);
|
commit('setState', response.data.data);
|
||||||
},
|
},
|
||||||
async modificarChismosa({ commit }, { producto_id, cantidad, notas }) {
|
async modificarChismosa({ commit, dispatch }, { producto_id, cantidad, notas }) {
|
||||||
const response = await axios.post("/api/subpedidos/" + state.pedido_id + "/sync", {
|
try {
|
||||||
cantidad: cantidad,
|
const response = await axios.post("/api/subpedidos/" + state.pedido_id + "/sync", {
|
||||||
producto_id: producto_id,
|
cantidad: cantidad,
|
||||||
notas: notas,
|
producto_id: producto_id,
|
||||||
});
|
notas: notas,
|
||||||
commit('setState', response.data.data);
|
});
|
||||||
|
commit('setState', response.data.data);
|
||||||
|
} catch (error) {
|
||||||
|
dispatch("ui/error", { error: error }, { root: true });
|
||||||
|
}
|
||||||
},
|
},
|
||||||
async modificarDevoluciones({ commit }, { monto, notas }) {
|
async modificarDevoluciones({ commit, dispatch }, { monto, notas }) {
|
||||||
const response = await axios.post("api/subpedidos/" + state.pedido_id + "/sync_devoluciones", {
|
try {
|
||||||
total: monto,
|
const response = await axios.post("api/subpedidos/" + state.pedido_id + "/sync_devoluciones", {
|
||||||
notas: notas,
|
total: monto,
|
||||||
});
|
notas: notas,
|
||||||
commit('setState', response.data.data);
|
});
|
||||||
|
commit('setState', response.data.data);
|
||||||
|
} catch (error) {
|
||||||
|
dispatch("ui/error", { error: error }, { root: true });
|
||||||
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue