5120-reports_loopback #1389

Merged
joan merged 8 commits from 5120-reports_loopback into dev 2023-03-16 06:34:52 +00:00
4 changed files with 3 additions and 56 deletions
Showing only changes of commit 29df1ba894 - Show all commits

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) {