chore: refs #7524 add select limit #2923

Merged
jorgep merged 5 commits from 7524-addFixture into dev 2024-09-06 08:44:36 +00:00
3 changed files with 15 additions and 3 deletions
Showing only changes of commit 2df9bb9bdb - Show all commits

View File

@ -1 +1,10 @@
-- Executed after dump CREATE USER 'vn'@'localhost';
GRANT SELECT,
INSERT,
UPDATE,
DELETE,
CREATE TEMPORARY TABLES,
EXECUTE,
TRIGGER
ON *.* TO 'vn'@'localhost';

View File

@ -371,5 +371,6 @@
"The sale not exists in the item shelving": "La venta no existe en la estantería del artículo", "The sale not exists in the item shelving": "La venta no existe en la estantería del artículo",
"The entry not have stickers": "La entrada no tiene etiquetas", "The entry not have stickers": "La entrada no tiene etiquetas",
"Too many records": "Demasiados registros", "Too many records": "Demasiados registros",
"Original invoice not found": "Factura original no encontrada" "Original invoice not found": "Factura original no encontrada",
} "The entry has no lines or does not exist": "La entrada no tiene lineas o no existe"
}

View File

@ -1,5 +1,6 @@
const {toCSV} = require('vn-loopback/util/csv'); const {toCSV} = require('vn-loopback/util/csv');
const {flatten} = require('vn-loopback/util/flatten'); const {flatten} = require('vn-loopback/util/flatten');
const UserError = require('vn-loopback/util/user-error');
module.exports = Self => { module.exports = Self => {
Self.remoteMethodCtx('getBuysCsv', { Self.remoteMethodCtx('getBuysCsv', {
@ -36,6 +37,7 @@ module.exports = Self => {
Self.getBuysCsv = async(ctx, id, options) => { Self.getBuysCsv = async(ctx, id, options) => {
const data = await Self.getBuys(ctx, id, null, options); const data = await Self.getBuys(ctx, id, null, options);
if (!data.length) throw new UserError('The entry has no lines or does not exist');
const dataFlatted = flatten(data); const dataFlatted = flatten(data);
return [toCSV(dataFlatted), 'text/csv', `inline; filename="buys-${id}.csv"`]; return [toCSV(dataFlatted), 'text/csv', `inline; filename="buys-${id}.csv"`];
}; };