chore: refs #7524 add select limit #2923
|
@ -1 +1,10 @@
|
||||||
-- Executed after dump
|
CREATE USER 'vn'@'localhost';
|
||||||
|
|
||||||
|
GRANT SELECT,
|
||||||
|
INSERT,
|
||||||
|
UPDATE,
|
||||||
|
DELETE,
|
||||||
|
CREATE TEMPORARY TABLES,
|
||||||
|
EXECUTE,
|
||||||
|
TRIGGER
|
||||||
|
ON *.* TO 'vn'@'localhost';
|
||||||
|
|
|
@ -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"
|
||||||
|
}
|
|
@ -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"`];
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue