Merge branch 'dev' into 5151-claim.descriptor-2-botones-mas
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Pablo Natek 2023-03-13 16:24:31 +00:00
commit 584f25dd77
5 changed files with 8 additions and 56 deletions

View File

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

View File

@ -154,6 +154,11 @@
"model": "Account", "model": "Account",
"foreignKey": "id" "foreignKey": "id"
}, },
"user": {
"type": "belongsTo",
"model": "Account",
"foreignKey": "id"
},
"payMethod": { "payMethod": {
"type": "belongsTo", "type": "belongsTo",
"model": "PayMethod", "model": "PayMethod",

View File

@ -65,7 +65,7 @@ module.exports = Self => {
try { try {
await fs.access(file.path); await fs.access(file.path);
} catch (error) { } catch (error) {
await Self.createPdf(ctx, id); await Self.createPdf(ctx, id, myOptions);
} }
const stream = fs.createReadStream(file.path); 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.labelsData = await this.rawSqlFromDef('labelData', this.id);
this.username = await this.findOneFromDef('username', this.userFk); this.username = await this.findOneFromDef('username', this.userFk);
this.labelData = this.labelsData[0]; this.labelData = this.labelsData[0];
this.checkMainEntity(this.labelData);
let QRdata = JSON.stringify({ let QRdata = JSON.stringify({
company: 'vnl', company: 'vnl',
@ -32,7 +33,6 @@ module.exports = {
}); });
this.QR = await this.getQR(QRdata); this.QR = await this.getQR(QRdata);
this.checkMainEntity(this.labelsData);
}, },
methods: { methods: {
getQR(id) { getQR(id) {