Merge branch 'master' into test
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
commit
5a82ce4aae
|
@ -17,6 +17,7 @@ BEGIN
|
|||
DECLARE vHasDailyInvoice BOOL;
|
||||
DECLARE vWithPackage BOOL;
|
||||
DECLARE vHasToInvoice BOOL;
|
||||
DECLARE vSerial VARCHAR(2);
|
||||
|
||||
DECLARE cur CURSOR FOR
|
||||
SELECT ticketFk FROM tmp.ticket_close;
|
||||
|
@ -83,14 +84,17 @@ BEGIN
|
|||
GROUP BY e.freightItemFk);
|
||||
|
||||
IF(vHasDailyInvoice) AND vHasToInvoice THEN
|
||||
SELECT invoiceSerial(vClientFk, vCompanyFk, 'quick') INTO vSerial;
|
||||
IF NOT vSerial THEN
|
||||
CALL util.throw('Cannot booking without a serial');
|
||||
END IF;
|
||||
|
||||
-- Facturacion rapida
|
||||
CALL ticket_setState(vCurTicketFk, 'DELIVERED');
|
||||
-- Facturar si está contabilizado
|
||||
|
||||
IF vIsTaxDataChecked THEN
|
||||
CALL invoiceOut_newFromClient(
|
||||
vClientFk,
|
||||
(SELECT invoiceSerial(vClientFk, vCompanyFk, 'multiple')),
|
||||
vSerial,
|
||||
vShipped,
|
||||
vCompanyFk,
|
||||
NULL,
|
||||
|
|
|
@ -0,0 +1,129 @@
|
|||
|
||||
use vn;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `material` (
|
||||
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(50) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `name_UNIQUE` (`name`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
|
||||
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Abedul');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Acacia');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Acero');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Acero Galvanizado');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Acetato');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Acrílico');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Alambre');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Algodón');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Aluminio');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Antracita');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Arcilla');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Bambú');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Banano');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Canneté');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Cartón');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Cartulina');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Celofán');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Cemento');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Cera');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Cerámica');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Chapa');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Chenilla');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Cloruro de polivinilo');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Cobre');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Corcho');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Cordel');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Cotton');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Cotton Chess');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Cristal');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Cubo Asa');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Cuerda');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Cuero');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Doble Raso');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Doble Velvet');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Eco Glass');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Encaje');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Esparto');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Espuma');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Felpa');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Fibra');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Fibra de Coco');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Fibra de Vidrio y Resina');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Fieltro');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Foam');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Gamuza');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Gasa');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Glass');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Goma');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Grafito');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Hierro');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Hoja Carbono');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Hoja de Mirto');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Hormigón');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Jute');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Kraft');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Lana');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Látex');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Latrix');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Lienzo');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Lino');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Lurex');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Madera');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Metacrilato');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Metal');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Mimbre');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Musgo');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Nonwoven');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Nylon');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Organza');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Paja');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Pana');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Papel');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Paperweb');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Paulownia');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Peluche');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Piedra');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Pizarra');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Plástico');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Poliestireno');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Polipropileno');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Poliresina');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Polyester');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Porcelana');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Puntilla');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('PVC');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Rafia');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Rama');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Raso');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Rattan');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Rayon');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Reciclable');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Red');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Resina');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Roca');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Rope');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Saco');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Salim');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Seagrass');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Silicona');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Sisal');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Tejido');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Tela');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Terciopelo');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Terracota');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Textil');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Titanio');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Tul');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Velvet');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Vidrio');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Yute');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Zinc');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Base de goma');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Base de madera');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Plumas');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Protección Uva');
|
||||
INSERT IGNORE INTO `material` (`name`) VALUES ('Purpurina');
|
||||
|
||||
UPDATE vn.tag SET isFree=0,sourceTable='material' WHERE name= 'Material';
|
||||
UPDATE vn.tag SET isFree=0,sourceTable='material' WHERE name='Material secundario';
|
|
@ -0,0 +1,42 @@
|
|||
/**
|
||||
* Flattens an array of objects by converting each object into a flat structure.
|
||||
*
|
||||
* @param {Array} dataArray Array of objects to be flattened
|
||||
* @return {Array} Array of flattened objects
|
||||
*/
|
||||
function flatten(dataArray) {
|
||||
return dataArray.map(item => flattenObj(item.__data));
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursively flattens an object, converting nested properties into a single level object
|
||||
* with keys representing the original nested structure.
|
||||
*
|
||||
* @param {Object} data The object to be flattened
|
||||
* @param {String} [prefix=''] Optional prefix for nested keys
|
||||
* @return {Object} Flattened object
|
||||
*/
|
||||
function flattenObj(data, prefix = '') {
|
||||
let result = {};
|
||||
try {
|
||||
for (let key in data) {
|
||||
if (!data[key]) continue;
|
||||
|
||||
const newKey = prefix ? `${prefix}_${key}` : key;
|
||||
const value = data[key];
|
||||
|
||||
if (typeof value === 'object' && value !== null && !Array.isArray(value))
|
||||
Object.assign(result, flattenObj(value.__data, newKey));
|
||||
else
|
||||
result[newKey] = value;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
module.exports = {
|
||||
flatten,
|
||||
flattenObj,
|
||||
};
|
|
@ -0,0 +1,44 @@
|
|||
const {toCSV} = require('vn-loopback/util/csv');
|
||||
const {flatten} = require('vn-loopback/util/flatten');
|
||||
const UserError = require('vn-loopback/util/user-error');
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('getBuysCsv', {
|
||||
description: 'Returns buys for one entry in CSV file format',
|
||||
accessType: 'READ',
|
||||
accepts: [{
|
||||
arg: 'id',
|
||||
type: 'number',
|
||||
required: true,
|
||||
description: 'The entry id',
|
||||
http: {source: 'path'}
|
||||
}
|
||||
],
|
||||
returns: [
|
||||
{
|
||||
arg: 'body',
|
||||
type: 'file',
|
||||
root: true
|
||||
}, {
|
||||
arg: 'Content-Type',
|
||||
type: 'String',
|
||||
http: {target: 'header'}
|
||||
}, {
|
||||
arg: 'Content-Disposition',
|
||||
type: 'String',
|
||||
http: {target: 'header'}
|
||||
}
|
||||
],
|
||||
http: {
|
||||
path: `/:id/getBuysCsv`,
|
||||
verb: 'GET'
|
||||
}
|
||||
});
|
||||
|
||||
Self.getBuysCsv = async(ctx, id, 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);
|
||||
return [toCSV(dataFlatted), 'text/csv', `inline; filename="buys-${id}.csv"`];
|
||||
};
|
||||
};
|
|
@ -3,6 +3,7 @@ module.exports = Self => {
|
|||
require('../methods/entry/filter')(Self);
|
||||
require('../methods/entry/getEntry')(Self);
|
||||
require('../methods/entry/getBuys')(Self);
|
||||
require('../methods/entry/getBuysCsv')(Self);
|
||||
require('../methods/entry/importBuys')(Self);
|
||||
require('../methods/entry/importBuysPreview')(Self);
|
||||
require('../methods/entry/lastItemBuys')(Self);
|
||||
|
|
Loading…
Reference in New Issue