ref #5914 back test added
gitea/salix/pipeline/head There was a failure building this commit Details

This commit is contained in:
Jorge Penadés 2023-09-25 12:54:31 +02:00
parent c8c06f498c
commit 98ee9bbaf3
3 changed files with 52 additions and 4 deletions

View File

@ -3,4 +3,8 @@ INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalTyp
('CplusRectificationType', '*', 'READ', 'ALLOW', 'ROLE', 'administrative'),
('CplusInvoiceType477', '*', 'READ', 'ALLOW', 'ROLE', 'administrative'),
('InvoiceCorrectionType', '*', 'READ', 'ALLOW', 'ROLE', 'administrative'),
('InvoiceOut', 'transferInvoice', 'WRITE', 'ALLOW', 'ROLE', 'administrative');
('InvoiceOut', 'transferInvoice', 'WRITE', 'ALLOW', 'ROLE', 'administrative');
INSERT INTO `vn`.`invoiceCorrectionType` (description)
VALUES
('Error en el cálculo del IVA')

View File

@ -0,0 +1,43 @@
const models = require('vn-loopback/server/server').models;
describe('InvoiceOut tranferInvoice()', () => {
const userId = 5;
const ctx = {req: {accessToken: userId}};
ctx.args = {
id: '1',
ref: 'T1111111',
newClientFk: 1,
cplusRectificationId: 1,
cplusInvoiceType477Id: 1,
invoiceCorrectionTypeId: 1
};
it('should return the id of the created issued invoice', async() => {
const tx = await models.InvoiceOut.beginTransaction({});
const options = {transaction: tx};
try {
const result = await models.InvoiceOut.transferInvoice(
ctx,
options);
expect(result).toBeDefined();
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
it('should throw an UserError when it is the same client', async() => {
const tx = await models.InvoiceOut.beginTransaction({});
const options = {transaction: tx};
try {
ctx.args.newClientFk = 1101;
await models.InvoiceOut.transferInvoice(
ctx,
options);
} catch (e) {
expect(e.message).toBe(`Select a different client`);
await tx.rollback();
}
});
});

View File

@ -97,9 +97,10 @@ module.exports = Self => {
invoiceCorrectionTypeFk: args.invoiceCorrectionTypeId
}, myOptions);
if (tx) await tx.commit();
await models.InvoiceOut.makePdfAndNotify(ctx, invoiceId, null);
if (tx) {
await tx.commit();
await models.InvoiceOut.makePdfAndNotify(ctx, invoiceId, null);
}
return invoiceId;
} catch (e) {