Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 5120-reports_loopback
gitea/salix/pipeline/head There was a failure building this commit Details

This commit is contained in:
Vicent Llopis 2023-03-14 08:00:02 +01:00
commit 29df1ba894
4 changed files with 3 additions and 56 deletions

View File

@ -131,7 +131,7 @@ module.exports = Self => {
WHERE u.id = ?`, [userId], options);
let roles = [];
for (role of result)
for (const role of result)
roles.push(role.name);
return roles;

View File

@ -65,7 +65,7 @@ module.exports = Self => {
try {
await fs.access(file.path);
} catch (error) {
await Self.createPdf(ctx, id);
await Self.createPdf(ctx, id, myOptions);
}
const stream = fs.createReadStream(file.path);

View File

@ -1,53 +0,0 @@
const models = require('vn-loopback/server/server').models;
const UserError = require('vn-loopback/util/user-error');
describe('InvoiceOut downloadZip()', () => {
const userId = 9;
const invoiceIds = '1,2';
const ctx = {
req: {
accessToken: {userId: userId},
headers: {origin: 'http://localhost:5000'},
}
};
it('should return part of link to dowloand the zip', async() => {
const tx = await models.InvoiceOut.beginTransaction({});
try {
const options = {transaction: tx};
const result = await models.InvoiceOut.downloadZip(ctx, invoiceIds, options);
expect(result).toBeDefined();
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
it('should return an error if the size of the files is too large', async() => {
const tx = await models.InvoiceOut.beginTransaction({});
let error;
try {
const options = {transaction: tx};
const zipConfig = {
maxSize: 0
};
await models.ZipConfig.create(zipConfig, options);
await models.InvoiceOut.downloadZip(ctx, invoiceIds, options);
await tx.rollback();
} catch (e) {
await tx.rollback();
error = e;
}
expect(error).toEqual(new UserError(`Files are too large`));
});
});

View File

@ -22,6 +22,7 @@ module.exports = {
this.labelsData = await this.rawSqlFromDef('labelData', this.id);
this.username = await this.findOneFromDef('username', this.userFk);
this.labelData = this.labelsData[0];
this.checkMainEntity(this.labelData);
let QRdata = JSON.stringify({
company: 'vnl',
@ -32,7 +33,6 @@ module.exports = {
});
this.QR = await this.getQR(QRdata);
this.checkMainEntity(this.labelsData);
},
methods: {
getQR(id) {