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
|
||||
public function syncProductos(Subpedido $subpedido) {
|
||||
if ($subpedido->aprobado)
|
||||
return new SubpedidoResource($subpedido);
|
||||
abort(400, "No se puede modificar un pedido aprobado.");
|
||||
|
||||
$valid = request()->validate([
|
||||
'cantidad' => ['integer','required','min:0'],
|
||||
|
@ -84,7 +84,8 @@ class SubpedidoController extends Controller
|
|||
}
|
||||
|
||||
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([
|
||||
'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}`);
|
||||
commit('setState', response.data.data);
|
||||
},
|
||||
async modificarChismosa({ commit }, { producto_id, cantidad, notas }) {
|
||||
const response = await axios.post("/api/subpedidos/" + state.pedido_id + "/sync", {
|
||||
cantidad: cantidad,
|
||||
producto_id: producto_id,
|
||||
notas: notas,
|
||||
});
|
||||
commit('setState', response.data.data);
|
||||
async modificarChismosa({ commit, dispatch }, { producto_id, cantidad, notas }) {
|
||||
try {
|
||||
const response = await axios.post("/api/subpedidos/" + state.pedido_id + "/sync", {
|
||||
cantidad: cantidad,
|
||||
producto_id: producto_id,
|
||||
notas: notas,
|
||||
});
|
||||
commit('setState', response.data.data);
|
||||
} catch (error) {
|
||||
dispatch("ui/error", { error: error }, { root: true });
|
||||
}
|
||||
},
|
||||
async modificarDevoluciones({ commit }, { monto, notas }) {
|
||||
const response = await axios.post("api/subpedidos/" + state.pedido_id + "/sync_devoluciones", {
|
||||
total: monto,
|
||||
notas: notas,
|
||||
});
|
||||
commit('setState', response.data.data);
|
||||
async modificarDevoluciones({ commit, dispatch }, { monto, notas }) {
|
||||
try {
|
||||
const response = await axios.post("api/subpedidos/" + state.pedido_id + "/sync_devoluciones", {
|
||||
total: monto,
|
||||
notas: notas,
|
||||
});
|
||||
commit('setState', response.data.data);
|
||||
} catch (error) {
|
||||
dispatch("ui/error", { error: error }, { root: true });
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue