Merge branch 'dev' into 232401_dev_init
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
commit
99f87aaf38
|
@ -84,6 +84,7 @@
|
|||
"The current ticket can't be modified": "El ticket actual no puede ser modificado",
|
||||
"The current claim can't be modified": "La reclamación actual no puede ser modificada",
|
||||
"The sales of this ticket can't be modified": "Las lineas de este ticket no pueden ser modificadas",
|
||||
"The sales do not exists": "La(s) línea(s) seleccionada(s) no existe(n)",
|
||||
"Please select at least one sale": "Por favor selecciona al menos una linea",
|
||||
"All sales must belong to the same ticket": "Todas las lineas deben pertenecer al mismo ticket",
|
||||
"NO_ZONE_FOR_THIS_PARAMETERS": "Para este día no hay ninguna zona configurada",
|
||||
|
|
|
@ -38,6 +38,9 @@ module.exports = Self => {
|
|||
}
|
||||
}, myOptions);
|
||||
|
||||
if (!salesData.length)
|
||||
throw new UserError(`The sales do not exists`);
|
||||
|
||||
const ticketId = salesData[0].ticketFk;
|
||||
|
||||
const isTicketEditable = await models.Ticket.isEditable(ctx, ticketId, myOptions);
|
||||
|
@ -62,7 +65,5 @@ module.exports = Self => {
|
|||
throw new UserError('It is not possible to modify cloned sales');
|
||||
if (!shouldEditFloramondo)
|
||||
throw new UserError('It is not possible to modify sales that their articles are from Floramondo');
|
||||
|
||||
return true;
|
||||
};
|
||||
};
|
||||
|
|
|
@ -17,6 +17,32 @@ describe('sale canEdit()', () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe('sale not exists', () => {
|
||||
it('should return error if sale not exists', async() => {
|
||||
const tx = await models.Sale.beginTransaction({});
|
||||
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
const developerId = 9;
|
||||
const ctx = {req: {accessToken: {userId: developerId}}};
|
||||
|
||||
let max = await models.Sale.findOne({fields: ['id'], order: 'id DESC'}, options);
|
||||
max.id = max.id + 1;
|
||||
|
||||
const sales = [max.id];
|
||||
await models.Sale.canEdit(ctx, sales, options);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
error = e.message;
|
||||
}
|
||||
|
||||
expect(error).toEqual('The sales do not exists');
|
||||
});
|
||||
});
|
||||
|
||||
describe('sale editTracked', () => {
|
||||
it('should return true if the role is production regardless of the saleTrackings', async() => {
|
||||
const tx = await models.Sale.beginTransaction({});
|
||||
|
@ -29,9 +55,7 @@ describe('sale canEdit()', () => {
|
|||
|
||||
const sales = [25];
|
||||
|
||||
const result = await models.Sale.canEdit(ctx, sales, options);
|
||||
|
||||
expect(result).toEqual(true);
|
||||
await models.Sale.canEdit(ctx, sales, options);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
|
@ -51,9 +75,7 @@ describe('sale canEdit()', () => {
|
|||
|
||||
const sales = [10];
|
||||
|
||||
const result = await models.Sale.canEdit(ctx, sales, options);
|
||||
|
||||
expect(result).toEqual(true);
|
||||
await models.Sale.canEdit(ctx, sales, options);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
|
@ -87,9 +109,7 @@ describe('sale canEdit()', () => {
|
|||
});
|
||||
const ctx = {req: {accessToken: {userId: role.id}}};
|
||||
|
||||
const result = await models.Sale.canEdit(ctx, saleCloned, options);
|
||||
|
||||
expect(result).toEqual(true);
|
||||
await models.Sale.canEdit(ctx, saleCloned, options);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
|
@ -150,9 +170,7 @@ describe('sale canEdit()', () => {
|
|||
const saleToEdit = await models.Sale.findById(sales[0], null, options);
|
||||
await saleToEdit.updateAttribute('itemFk', 9, options);
|
||||
|
||||
const result = await models.Sale.canEdit(ctx, sales, options);
|
||||
|
||||
expect(result).toEqual(true);
|
||||
await models.Sale.canEdit(ctx, sales, options);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
|
|
Loading…
Reference in New Issue