Merge branch 'dev' into 7524-fixE2e
gitea/salix/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Jorge Penadés 2024-10-28 08:43:45 +00:00
commit b20ca1d8d7
9 changed files with 54 additions and 9 deletions

View File

@ -241,5 +241,8 @@
"The height must be greater than 50cm": "The height must be greater than 50cm", "The height must be greater than 50cm": "The height must be greater than 50cm",
"The maximum height of the wagon is 200cm": "The maximum height of the wagon is 200cm", "The maximum height of the wagon is 200cm": "The maximum height of the wagon is 200cm",
"The quantity claimed cannot be greater than the quantity of the line": "The quantity claimed cannot be greater than the quantity of the line", "The quantity claimed cannot be greater than the quantity of the line": "The quantity claimed cannot be greater than the quantity of the line",
"There are tickets for this area, delete them first": "There are tickets for this area, delete them first" "There are tickets for this area, delete them first": "There are tickets for this area, delete them first",
"null": "null",
"Invalid or expired verification code": "Invalid or expired verification code",
"Payment method is required": "Payment method is required"
} }

View File

@ -385,5 +385,6 @@
"The quantity claimed cannot be greater than the quantity of the line": "La cantidad reclamada no puede ser mayor que la cantidad de la línea", "The quantity claimed cannot be greater than the quantity of the line": "La cantidad reclamada no puede ser mayor que la cantidad de la línea",
"type cannot be blank": "Se debe rellenar el tipo", "type cannot be blank": "Se debe rellenar el tipo",
"There are tickets for this area, delete them first": "Hay tickets para esta sección, borralos primero", "There are tickets for this area, delete them first": "Hay tickets para esta sección, borralos primero",
"There is no company associated with that warehouse": "No hay ninguna empresa asociada a ese almacén" "There is no company associated with that warehouse": "No hay ninguna empresa asociada a ese almacén",
"The web user's email already exists": "El correo del usuario web ya existe"
} }

View File

@ -363,5 +363,6 @@
"It has been invoiced but the PDF of refund not be generated": "Il a été facturé mais le PDF de remboursement n'a pas été généré", "It has been invoiced but the PDF of refund not be generated": "Il a été facturé mais le PDF de remboursement n'a pas été généré",
"Cannot send mail": "Impossible d'envoyer le mail", "Cannot send mail": "Impossible d'envoyer le mail",
"Original invoice not found": "Facture originale introuvable", "Original invoice not found": "Facture originale introuvable",
"The quantity claimed cannot be greater than the quantity of the line": "Le montant réclamé ne peut pas être supérieur au montant de la ligne" "The quantity claimed cannot be greater than the quantity of the line": "Le montant réclamé ne peut pas être supérieur au montant de la ligne",
"The web user's email already exists": "L'email de l'internaute existe déjà"
} }

View File

@ -363,5 +363,6 @@
"It has been invoiced but the PDF of refund not be generated": "Foi faturado mas não foi gerado o PDF do reembolso", "It has been invoiced but the PDF of refund not be generated": "Foi faturado mas não foi gerado o PDF do reembolso",
"Original invoice not found": "Fatura original não encontrada", "Original invoice not found": "Fatura original não encontrada",
"Cannot send mail": "Não é possível enviar o email", "Cannot send mail": "Não é possível enviar o email",
"The quantity claimed cannot be greater than the quantity of the line": "O valor reclamado não pode ser superior ao valor da linha" "The quantity claimed cannot be greater than the quantity of the line": "O valor reclamado não pode ser superior ao valor da linha",
"The web user's email already exists": "O e-mail do utilizador da web já existe."
} }

View File

@ -1,3 +1,4 @@
/* eslint max-len: ["error", { "code": 150 }]*/
const UserError = require('vn-loopback/util/user-error'); const UserError = require('vn-loopback/util/user-error');
module.exports = function(Self) { module.exports = function(Self) {
@ -98,6 +99,8 @@ module.exports = function(Self) {
return client; return client;
} catch (e) { } catch (e) {
if (tx) await tx.rollback(); if (tx) await tx.rollback();
if (e.message && e.message.includes(`Email already exists`)) throw new UserError(`The web user's email already exists`);
throw e; throw e;
} }
}; };

View File

@ -48,7 +48,7 @@ module.exports = Self => {
CALL vn.sale_recalcComponent(null); CALL vn.sale_recalcComponent(null);
DROP TEMPORARY TABLE tmp.recalculateSales;`; DROP TEMPORARY TABLE tmp.recalculateSales;`;
const recalculation = await Self.rawSql(query, salesIds, myOptions); const recalculation = await Self.rawSql(query, [salesIds], myOptions);
if (tx) await tx.commit(); if (tx) await tx.commit();

View File

@ -85,6 +85,25 @@ describe('sale updatePrice()', () => {
} }
}); });
it('should check if priceFixed has changed', async() => {
const tx = await models.Sale.beginTransaction({});
try {
const options = {transaction: tx};
const price = 3;
const beforeUpdate = await models.Sale.findById(saleId, null, options);
await models.Sale.updatePrice(ctx, saleId, price, options);
const afterUpdate = await models.Sale.findById(saleId, null, options);
expect(beforeUpdate.priceFixed).not.toEqual(afterUpdate.priceFixed);
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
it('should set price as a decimal number and check the sale has the mana component changing the salesPersonMana', async() => { it('should set price as a decimal number and check the sale has the mana component changing the salesPersonMana', async() => {
const tx = await models.Sale.beginTransaction({}); const tx = await models.Sale.beginTransaction({});

View File

@ -91,7 +91,21 @@ module.exports = Self => {
value: componentValue value: componentValue
}, myOptions); }, myOptions);
} }
await sale.updateAttributes({price: newPrice}, myOptions);
const [priceFixed] = await Self.rawSql(`
SELECT SUM(value) value
FROM sale s
JOIN saleComponent sc ON sc.saleFk = s.id
JOIN component c ON c.id = sc.componentFk
JOIN componentType ct ON ct.id = c.typeFk
WHERE ct.isBase
AND s.id = ?
`, [id], myOptions);
await sale.updateAttributes({
price: newPrice,
priceFixed: priceFixed.value
}, myOptions);
await Self.rawSql('CALL vn.manaSpellersRequery(?)', [userId], myOptions); await Self.rawSql('CALL vn.manaSpellersRequery(?)', [userId], myOptions);
await Self.rawSql('CALL vn.ticket_recalc(?, NULL)', [sale.ticketFk], myOptions); await Self.rawSql('CALL vn.ticket_recalc(?, NULL)', [sale.ticketFk], myOptions);

View File

@ -28,6 +28,9 @@
"discount": { "discount": {
"type": "number" "type": "number"
}, },
"priceFixed": {
"type": "number"
},
"reserved": { "reserved": {
"type": "boolean" "type": "boolean"
}, },