Fix: Linea de Cero debe ser mayor a cero issue RedEcovida#57
This commit is contained in:
parent
2a908d4e05
commit
a90fb4d937
@ -239,24 +239,34 @@
|
||||
},
|
||||
async submit() {
|
||||
if (this.$refs.form.validate()) {
|
||||
try {
|
||||
const response = await fetch('/don_confiao/api/sales/', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify(this.purchase),
|
||||
});
|
||||
if (response.ok) {
|
||||
const data = await response.json();
|
||||
console.log('Compra enviada:', data);
|
||||
this.$router.push("SummaryPurchase");
|
||||
} else {
|
||||
console.error('Error al enviar la compra:', response.statusText);
|
||||
const hasInvalidQuantity = this.purchase.saleline_set.some(line => line.quantity <= 0);
|
||||
if (hasInvalidQuantity) {
|
||||
this.errorMessage = 'La cantidad de cada línea de compra debe ser mayor que cero.';
|
||||
|
||||
console.log(this.errorMessage);
|
||||
return; // Detener el submit si hay cantidades inválidas
|
||||
}
|
||||
|
||||
this.errorMessage = ''; // Limpiar el mensaje de error
|
||||
|
||||
try {
|
||||
const response = await fetch('/don_confiao/api/sales/', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify(this.purchase),
|
||||
});
|
||||
if (response.ok) {
|
||||
const data = await response.json();
|
||||
console.log('Compra enviada:', data);
|
||||
this.$router.push("SummaryPurchase");
|
||||
} else {
|
||||
console.error('Error al enviar la compra:', response.statusText);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error de red:', error);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error de red:', error);
|
||||
}
|
||||
}
|
||||
},
|
||||
navigate(route) {
|
||||
|
Loading…
Reference in New Issue
Block a user