Fix: Linea de Cero debe ser mayor a cero issue RedEcovida#57

This commit is contained in:
sinergia 2024-11-02 11:40:51 -05:00
parent 2a908d4e05
commit a90fb4d937

View File

@ -239,24 +239,34 @@
}, },
async submit() { async submit() {
if (this.$refs.form.validate()) { if (this.$refs.form.validate()) {
try { const hasInvalidQuantity = this.purchase.saleline_set.some(line => line.quantity <= 0);
const response = await fetch('/don_confiao/api/sales/', { if (hasInvalidQuantity) {
method: 'POST', this.errorMessage = 'La cantidad de cada línea de compra debe ser mayor que cero.';
headers: {
'Content-Type': 'application/json', console.log(this.errorMessage);
}, return; // Detener el submit si hay cantidades inválidas
body: JSON.stringify(this.purchase), }
});
if (response.ok) { this.errorMessage = ''; // Limpiar el mensaje de error
const data = await response.json();
console.log('Compra enviada:', data); try {
this.$router.push("SummaryPurchase"); const response = await fetch('/don_confiao/api/sales/', {
} else { method: 'POST',
console.error('Error al enviar la compra:', response.statusText); 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) { navigate(route) {