Merge branch 'dev' into 2443
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Javi Gallego 2020-09-30 14:07:38 +02:00
commit 2714857227
95 changed files with 3167 additions and 2640 deletions

View File

@ -79,12 +79,6 @@
}, },
"WorkerTimeControlMail": { "WorkerTimeControlMail": {
"dataSource": "vn" "dataSource": "vn"
},
"Mail": {
"dataSource": "vn"
},
"MailForward": {
"dataSource": "vn"
} }
} }

View File

@ -1,26 +0,0 @@
{
"name": "MailForward",
"base": "VnModel",
"options": {
"mysql": {
"table": "account.mailForward"
}
},
"properties": {
"account": {
"id": true,
"type": "Number"
},
"forwardTo": {
"type": "String"
}
},
"acls": [
{
"accessType": "READ",
"principalType": "ROLE",
"principalId": "$everyone",
"permission": "ALLOW"
}
]
}

View File

@ -1,4 +1,4 @@
FROM mysql:8.0.18 FROM mariadb:10.4.13
ENV MYSQL_ROOT_PASSWORD root ENV MYSQL_ROOT_PASSWORD root
ENV TZ Europe/Madrid ENV TZ Europe/Madrid
@ -7,33 +7,54 @@ ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update \ RUN apt-get update \
&& apt-get install -y --no-install-recommends curl ca-certificates \ && apt-get install -y --no-install-recommends curl ca-certificates \
&& curl -sL https://apt.verdnatura.es/conf/verdnatura.gpg | apt-key add - \ && curl -sL https://apt.verdnatura.es/conf/verdnatura.gpg | apt-key add - \
&& echo "deb http://apt.verdnatura.es/ stretch main" > /etc/apt/sources.list.d/vn.list \ && echo "deb http://apt.verdnatura.es/ jessie main" > /etc/apt/sources.list.d/vn.list \
&& apt-get update \ && apt-get update \
&& apt-get install -y vn-mysql libmysqlclient21 \ && apt-get install -y vn-mariadb \
&& apt-get purge -y --auto-remove curl ca-certificates \ && apt-get purge -y --auto-remove curl ca-certificates \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
COPY docker/docker.cnf /etc/mysql/conf.d/ COPY docker/docker.cnf /etc/mysql/conf.d/
COPY docker/docker-init.sh docker/docker-start.sh /usr/local/bin/ COPY \
docker/docker-init.sh \
docker/docker-temp-start.sh \
docker/docker-temp-stop.sh \
docker/docker-dump.sh \
docker/docker-start.sh \
/usr/local/bin/
RUN mkdir /mysql-data \ RUN mkdir /mysql-data \
&& chown -R mysql:mysql /mysql-data && chown -R mysql:mysql /mysql-data
WORKDIR /docker-entrypoint-initdb.d WORKDIR /docker-boot
COPY dump dump COPY \
COPY docker/docker-boot.sh /docker-entrypoint-initdb.d/ import-changes.sh \
COPY changes import/changes config.ini \
COPY import-changes.sh config.ini import/ dump/mysqlPlugins.sql \
dump/structure.sql \
dump/dumpedFixtures.sql \
./
RUN gosu mysql docker-init.sh \
&& docker-dump.sh mysqlPlugins \
&& docker-dump.sh structure \
&& docker-dump.sh dumpedFixtures \
&& gosu mysql docker-temp-stop.sh
COPY changes ./changes
COPY dump/fixtures.sql ./
ARG STAMP=unknown ARG STAMP=unknown
RUN gosu mysql docker-init.sh mysqld \ RUN gosu mysql docker-temp-start.sh \
&& rm -rf /docker-entrypoint-initdb.d/* && ./import-changes.sh \
&& docker-dump.sh fixtures \
&& gosu mysql docker-temp-stop.sh
RUN echo "[INFO] -> Import finished" \
&& rm -rf /docker-boot
USER mysql USER mysql
ENTRYPOINT ["docker-start.sh"] ENTRYPOINT ["docker-start.sh"]
CMD ["mysqld"] CMD ["mysqld"]
HEALTHCHECK --interval=5s --timeout=10s --retries=200 \ HEALTHCHECK --interval=2s --timeout=10s --retries=200 \
CMD mysqladmin ping -h 127.0.0.1 -u root || exit 1 CMD mysqladmin ping -h 127.0.0.1 -u root --password=root || exit 1

View File

@ -0,0 +1,4 @@
/**
* Hay una versión en salix que machacará toda esta función/procedimiento avisa
* a ___ de los cambios que quieres hacer.
*/

View File

@ -15,7 +15,7 @@ BEGIN
SELECT loginKey INTO vLoginKey FROM userConfig; SELECT loginKey INTO vLoginKey FROM userConfig;
IF vLoginKey = vKey THEN IF vLoginKey = vKey THEN
CALL user_loginWithName(vUserName); CALL myUser_loginWithName(vUserName);
ELSE ELSE
CALL util.throw('INVALID_KEY'); CALL util.throw('INVALID_KEY');
END IF; END IF;

View File

@ -13,8 +13,8 @@ BEGIN
SELECT `name` INTO vName SELECT `name` INTO vName
FROM user FROM user
WHERE id = vId; WHERE id = vSelf;
RETURN vSelf; RETURN vName;
END$$ END$$
DELIMITER ; DELIMITER ;

View File

@ -1,4 +0,0 @@
/*
Hay una versión en salix que machacará toda esta función/procedimiento
avisa a ___ de los cambios que quieres hacer
*/

View File

@ -53,7 +53,7 @@ module.exports = class Docker {
this.dbConf.port = netSettings.Ports['3306/tcp'][0]['HostPort']; this.dbConf.port = netSettings.Ports['3306/tcp'][0]['HostPort'];
} }
await this.waitForHealthy(); await this.wait();
} catch (err) { } catch (err) {
if (this.isRandom) if (this.isRandom)
await this.rm(); await this.rm();
@ -147,7 +147,7 @@ module.exports = class Docker {
let state; let state;
try { try {
let result = await this.execP(`docker container inspect -f "{{json .State}}" ${this.id}`); let result = await this.execP(`docker inspect -f "{{json .State}}" ${this.id}`);
state = JSON.parse(result.stdout); state = JSON.parse(result.stdout);
} catch (err) { } catch (err) {
return reject(new Error(err.message)); return reject(new Error(err.message));

View File

@ -1,17 +0,0 @@
#!/bin/bash
export MYSQL_PWD=root
mysql_import() {
FILE=$1
echo "[INFO] -> Importing $FILE"
mysql -u root --default-character-set=utf8 --comments -f < "$FILE"
}
mysql_import dump/structure.sql
mysql_import dump/mysqlPlugins.sql
mysql_import dump/dumpedFixtures.sql
import/import-changes.sh
mysql_import dump/fixtures.sql
echo "[INFO] -> Import finished"

6
db/docker/docker-dump.sh Executable file
View File

@ -0,0 +1,6 @@
#!/bin/bash
export MYSQL_PWD=root
FILE="/docker-boot/$1.sql"
echo "[INFO] -> Importing $FILE"
mysql -u root --default-character-set=utf8 --comments -f < "$FILE"

View File

@ -1,17 +1,14 @@
#!/bin/bash #!/bin/bash
. /usr/local/bin/docker-entrypoint.sh . /usr/local/bin/docker-entrypoint.sh
CMD=mysqld
mysql_check_config "$@" mysql_check_config "$CMD"
docker_setup_env "$@" docker_setup_env "$CMD"
docker_create_db_directories docker_create_db_directories
docker_verify_minimum_env docker_verify_minimum_env
docker_init_database_dir "$@" docker_init_database_dir "$CMD"
docker_temp_server_start "$@" docker_temp_server_start "$CMD"
docker_setup_db docker_setup_db
docker_process_init_files /docker-entrypoint-initdb.d/* docker_process_init_files /docker-entrypoint-initdb.d/*
mysql_expire_root_user
docker_temp_server_stop

7
db/docker/docker-temp-start.sh Executable file
View File

@ -0,0 +1,7 @@
#!/bin/bash
. /usr/local/bin/docker-entrypoint.sh
CMD=mysqld
docker_setup_env "$CMD"
docker_temp_server_start "$CMD"

7
db/docker/docker-temp-stop.sh Executable file
View File

@ -0,0 +1,7 @@
#!/bin/bash
. /usr/local/bin/docker-entrypoint.sh
CMD=mysqld
docker_setup_env "$CMD"
docker_temp_server_stop

View File

@ -2,9 +2,7 @@
innodb_log_file_size = 4M innodb_log_file_size = 4M
innodb_autoextend_increment = 4 innodb_autoextend_increment = 4
innodb_page_size = 8K innodb_page_size = 8K
innodb_default_row_format = COMPACT
log_bin_trust_function_creators = ON log_bin_trust_function_creators = ON
datadir = /mysql-data datadir = /mysql-data
sql_mode = NO_ENGINE_SUBSTITUTION sql_mode = NO_ENGINE_SUBSTITUTION
innodb_temp_data_file_path = /tmp/ibtmp1:12M:autoextend
skip-log-bin skip-log-bin

File diff suppressed because one or more lines are too long

View File

@ -1,8 +1,6 @@
CREATE SCHEMA IF NOT EXISTS `vn2008`; CREATE SCHEMA IF NOT EXISTS `vn2008`;
CREATE SCHEMA IF NOT EXISTS `tmp`; CREATE SCHEMA IF NOT EXISTS `tmp`;
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'root';
ALTER TABLE `vn`.`itemTaxCountry` AUTO_INCREMENT = 1; ALTER TABLE `vn`.`itemTaxCountry` AUTO_INCREMENT = 1;
ALTER TABLE `vn`.`address` AUTO_INCREMENT = 1; ALTER TABLE `vn`.`address` AUTO_INCREMENT = 1;
ALTER TABLE `vn`.`zoneGeo` AUTO_INCREMENT = 1; ALTER TABLE `vn`.`zoneGeo` AUTO_INCREMENT = 1;
@ -776,10 +774,16 @@ INSERT INTO `vn`.`item`(`id`, `typeFk`, `size`, `inkFk`, `stems`, `originFk`, `d
(12, 3, 30, 'RED', 1, 2, NULL, 2, 06021010, 1, 4751000000, 0, NULL, 0, 82, 2, NULL, 0), (12, 3, 30, 'RED', 1, 2, NULL, 2, 06021010, 1, 4751000000, 0, NULL, 0, 82, 2, NULL, 0),
(13, 5, 30, 'RED', 1, 2, NULL, NULL, 06021010, 0, 4751000000, 0, NULL, 0, 83, 2, NULL, 0), (13, 5, 30, 'RED', 1, 2, NULL, NULL, 06021010, 0, 4751000000, 0, NULL, 0, 83, 2, NULL, 0),
(14, 5, 90, 'BLU', 1, 2, NULL, NULL, 06021010, 0, 4751000000, 0, NULL, 0, 84, 2, NULL, 0), (14, 5, 90, 'BLU', 1, 2, NULL, NULL, 06021010, 0, 4751000000, 0, NULL, 0, 84, 2, NULL, 0),
(15, 4, NULL, NULL, NULL, 1, NULL, NULL, 06021010, 0, 4751000000, 0, NULL, 0, 67350, 2, NULL, 0), (15, 4, NULL, NULL, NULL, 1, NULL, NULL, 06021010, 0, 4751000000, 0, NULL, 0, 88, 2, NULL, 0),
(16, 4, NULL, NULL, NULL, 1, NULL, NULL, 06021010, 0, 4751000000, 0, NULL, 0, 67350, 2, NULL, 0), (16, 4, NULL, NULL, NULL, 1, NULL, NULL, 06021010, 0, 4751000000, 0, NULL, 0, 88, 2, NULL, 0),
(71, 4, NULL, NULL, NULL, 1, NULL, NULL, 06021010, 1, 4751000000, 0, NULL, 0, 88, 2, NULL, 0); (71, 4, NULL, NULL, NULL, 1, NULL, NULL, 06021010, 1, 4751000000, 0, NULL, 0, 88, 2, NULL, 0);
INSERT INTO `vn`.`priceFixed`(`id`, `itemFk`, `rate0`, `rate1`, `rate2`, `rate3`, `started`, `ended`, `bonus`, `warehouseFk`, `created`)
VALUES
(1, 1, 0, 0, 2.5, 2, CURDATE(), DATE_ADD(CURDATE(), INTERVAL +1 MONTH), 0, 1, CURDATE()),
(2, 3, 10, 10, 10, 10, CURDATE(), DATE_ADD(CURDATE(), INTERVAL +1 MONTH), 0, 1, CURDATE()),
(3, 5, 8.5, 10, 7.5, 6, CURDATE(), DATE_ADD(CURDATE(), INTERVAL +1 MONTH), 1, 2, CURDATE());
INSERT INTO `vn`.`expedition`(`id`, `agencyModeFk`, `ticketFk`, `isBox`, `created`, `itemFk`, `counter`, `checked`, `workerFk`) INSERT INTO `vn`.`expedition`(`id`, `agencyModeFk`, `ticketFk`, `isBox`, `created`, `itemFk`, `counter`, `checked`, `workerFk`)
VALUES VALUES
(1, 1, 1, 71, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 1, 1, 1, 18), (1, 1, 1, 71, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 1, 1, 1, 18),
@ -1071,105 +1075,107 @@ INSERT INTO `vn`.`itemBotanical`(`itemFk`, `botanical`, `genusFk`, `specieFk`)
INSERT INTO `vn`.`itemTag`(`id`,`itemFk`,`tagFk`,`value`,`priority`) INSERT INTO `vn`.`itemTag`(`id`,`itemFk`,`tagFk`,`value`,`priority`)
VALUES VALUES
(1 , 1, 56, 'Ranged weapon', 1), (1, 1, 56, 'Ranged weapon', 1),
(2 , 1, 58, 'longbow', 2), (2, 1, 58, 'longbow', 2),
(3 , 1, 27, '2m', 3), (3, 1, 27, '2m', 3),
(4 , 1, 36, 'Stark Industries', 4), (4, 1, 36, 'Stark Industries', 4),
(5 , 1, 1, 'Brown', 5), (5, 1, 1, 'Brown', 5),
(6 , 1, 67, '+1 precission', 6), (6, 1, 67, '+1 precission', 6),
(7 , 1, 23, '1', 7), (7, 1, 23, '1', 7),
(8 , 2, 56, 'Melee weapon', 1), (8, 2, 56, 'Melee weapon', 1),
(9 , 2, 58, 'combat fist', 2), (9, 2, 58, 'combat fist', 2),
(10, 2, 27, '15cm', 3), (10, 2, 27, '15cm', 3),
(11, 2, 36, 'Stark Industries', 4), (11, 2, 36, 'Stark Industries', 4),
(12, 2, 1, 'Silver', 5), (12, 2, 1, 'Silver', 5),
(13, 2, 67, 'Concussion', 6), (13, 2, 67, 'Concussion', 6),
(14, 2, 23, '2', 7), (14, 2, 23, '2', 7),
(15, 3, 56, 'Ranged weapon', 1), (15, 3, 56, 'Ranged weapon', 1),
(16, 3, 58, 'sniper rifle', 2), (16, 3, 58, 'sniper rifle', 2),
(17, 3, 4, '300mm', 3), (17, 3, 4, '300mm', 3),
(18, 3, 36, 'Stark Industries', 4), (18, 3, 36, 'Stark Industries', 4),
(19, 3, 1, 'Green', 5), (19, 3, 1, 'Green', 5),
(20, 3, 67, 'precission', 6), (20, 3, 67, 'precission', 6),
(21, 3, 23, '3', 7), (21, 3, 23, '3', 7),
(22, 4, 56, 'Melee weapon', 1), (22, 4, 56, 'Melee weapon', 1),
(23, 4, 58, 'heavy shield', 2), (23, 4, 58, 'heavy shield', 2),
(24, 4, 4, '1x0.5m', 3), (24, 4, 4, '1x0.5m', 3),
(25, 4, 36, 'Stark Industries', 4), (25, 4, 36, 'Stark Industries', 4),
(26, 4, 1, 'Black', 5), (26, 4, 1, 'Black', 5),
(27, 4, 67, 'containtment', 6), (27, 4, 67, 'containtment', 6),
(28, 4, 23, '4', 7), (28, 4, 23, '4', 7),
(29, 5, 56, 'Ranged weapon', 1), (29, 5, 56, 'Ranged weapon', 1),
(30, 5, 58, 'pistol', 2), (30, 5, 58, 'pistol', 2),
(31, 5, 27, '9mm', 3), (31, 5, 27, '9mm', 3),
(32, 5, 36, 'Stark Industries', 4), (32, 5, 36, 'Stark Industries', 4),
(33, 5, 1, 'Silver', 5), (33, 5, 1, 'Silver', 5),
(34, 5, 67, 'rapid fire', 6), (34, 5, 67, 'rapid fire', 6),
(35, 5, 23, '5', 7), (35, 5, 23, '5', 7),
(36, 6, 56, 'Container', 1), (36, 6, 56, 'Container', 1),
(37, 6, 58, 'ammo box', 2), (37, 6, 58, 'ammo box', 2),
(38, 6, 27, '1m', 3), (38, 6, 27, '1m', 3),
(39, 6, 36, 'Stark Industries', 4), (39, 6, 36, 'Stark Industries', 4),
(40, 6, 1, 'Green', 5), (40, 6, 1, 'Green', 5),
(41, 6, 67, 'supply', 6), (41, 6, 67, 'supply', 6),
(42, 6, 23, '6', 7), (42, 6, 23, '6', 7),
(43, 7, 56, 'Container', 1), (43, 7, 56, 'Container', 1),
(44, 7, 58, 'medical box', 2), (44, 7, 58, 'medical box', 2),
(45, 7, 27, '1m', 3), (45, 7, 27, '1m', 3),
(46, 7, 36, 'Stark Industries', 4), (46, 7, 36, 'Stark Industries', 4),
(47, 7, 1, 'White', 5), (47, 7, 1, 'White', 5),
(48, 7, 67, 'supply', 6), (48, 7, 67, 'supply', 6),
(49, 7, 23, '7', 7), (49, 7, 23, '7', 7),
(50, 8, 56, 'Ranged Reinforced weapon', 1), (50, 8, 56, 'Ranged Reinforced weapon', 1),
(51, 8, 58, '+1 longbow', 2), (51, 8, 58, '+1 longbow', 2),
(52, 8, 27, '2m', 3), (52, 8, 27, '2m', 3),
(53, 8, 36, 'Stark Industries', 4), (53, 8, 36, 'Stark Industries', 4),
(54, 8, 1, 'Brown', 5), (54, 8, 1, 'Brown', 5),
(55, 8, 67, 'precission', 6), (55, 8, 67, 'precission', 6),
(56, 8, 23, '8', 7), (56, 8, 23, '8', 7),
(57, 9, 56, 'Melee Reinforced weapon', 1), (57, 9, 56, 'Melee Reinforced weapon', 1),
(58, 9, 58, 'combat fist', 2), (58, 9, 58, 'combat fist', 2),
(59, 9, 27, '15cm', 3), (59, 9, 27, '15cm', 3),
(60, 9, 36, 'Stark Industries', 4), (60, 9, 36, 'Stark Industries', 4),
(61, 9, 1, 'Silver', 5), (61, 9, 1, 'Silver', 5),
(62, 9, 67, 'Concussion', 6), (62, 9, 67, 'Concussion', 6),
(63, 9, 23, '9', 7), (63, 9, 23, '9', 7),
(64, 10, 56, 'Ranged Reinforced weapon', 1), (64, 10, 56, 'Ranged Reinforced weapon', 1),
(65, 10, 58, 'sniper rifle', 2), (65, 10, 58, 'sniper rifle', 2),
(66, 10, 4, '300mm', 3), (66, 10, 4, '300mm', 3),
(67, 10, 36, 'Stark Industries', 4), (67, 10, 36, 'Stark Industries', 4),
(68, 10, 1, 'Green', 5), (68, 10, 1, 'Green', 5),
(69, 10, 67, 'precission', 6), (69, 10, 67, 'precission', 6),
(70, 10, 23, '10', 7), (70, 10, 23, '10', 7),
(71, 11, 56, 'Melee Reinforced weapon', 1), (71, 11, 56, 'Melee Reinforced weapon', 1),
(72, 11, 58, 'heavy shield', 2), (72, 11, 58, 'heavy shield', 2),
(73, 11, 4, '1x0.5m', 3), (73, 11, 4, '1x0.5m', 3),
(74, 11, 36, 'Stark Industries', 4), (74, 11, 36, 'Stark Industries', 4),
(75, 11, 1, 'Black', 5), (75, 11, 1, 'Black', 5),
(76, 11, 67, 'containtment', 6), (76, 11, 67, 'containtment', 6),
(77, 11, 23, '11', 7), (77, 11, 23, '11', 7),
(78, 12, 56, 'Ranged Reinforced weapon', 1), (78, 12, 56, 'Ranged Reinforced weapon', 1),
(79, 12, 58, 'pistol', 2), (79, 12, 58, 'pistol', 2),
(80, 12, 27, '9mm', 3), (80, 12, 27, '9mm', 3),
(81, 12, 36, 'Stark Industries', 4), (81, 12, 36, 'Stark Industries', 4),
(82, 12, 1, 'Silver', 5), (82, 12, 1, 'Silver', 5),
(83, 12, 67, 'rapid fire', 6), (83, 12, 67, 'rapid fire', 6),
(84, 12, 23, '12', 7), (84, 12, 23, '12', 7),
(85, 13, 56, 'Chest', 1), (85, 13, 56, 'Chest', 1),
(86, 13, 58, 'ammo box', 2), (86, 13, 58, 'ammo box', 2),
(87, 13, 27, '1m', 3), (87, 13, 27, '1m', 3),
(88, 13, 36, 'Stark Industries', 4), (88, 13, 36, 'Stark Industries', 4),
(89, 13, 1, 'Green', 5), (89, 13, 1, 'Green', 5),
(90, 13, 67, 'supply', 6), (90, 13, 67, 'supply', 6),
(91, 13, 23, '13', 7), (91, 13, 23, '13', 7),
(92, 14, 56, 'Chest', 1), (92, 14, 56, 'Chest', 1),
(93, 14, 58, 'medical box', 2), (93, 14, 58, 'medical box', 2),
(94, 14, 27, '1m', 3), (94, 14, 27, '1m', 3),
(95, 14, 36, 'Stark Industries', 4), (95, 14, 36, 'Stark Industries', 4),
(96, 14, 1, 'White', 5), (96, 14, 1, 'White', 5),
(97, 14, 67, 'supply', 6), (97, 14, 67, 'supply', 6),
(98, 14, 23, '1', 7), (98, 14, 23, '1', 7),
(99, 71, 92, 'Shipping cost', 2); (99, 15, 92, 'Shipping cost', 2),
(100, 16, 92, 'Shipping cost', 2),
(101, 71, 92, 'Shipping cost', 2);
INSERT INTO `vn`.`itemTypeTag`(`id`, `itemTypeFk`, `tagFk`, `priority`) INSERT INTO `vn`.`itemTypeTag`(`id`, `itemTypeFk`, `tagFk`, `priority`)
VALUES VALUES
@ -1637,13 +1643,13 @@ INSERT INTO `vn`.`ticketRequest`(`id`, `description`, `requesterFk`, `attenderFk
(4, 'Melee weapon combat first 15cm', 18, 35, 15, NULL, 1.30, NULL, NULL, 11, CURDATE()), (4, 'Melee weapon combat first 15cm', 18, 35, 15, NULL, 1.30, NULL, NULL, 11, CURDATE()),
(5, 'Melee weapon combat first 15cm', 18, 35, 15, 4, 1.30, 0, NULL, 18, CURDATE()); (5, 'Melee weapon combat first 15cm', 18, 35, 15, 4, 1.30, 0, NULL, 18, CURDATE());
INSERT INTO `vn`.`ticketServiceType`(`id`, `name`) INSERT INTO `vn`.`ticketServiceType`(`id`, `name`, `expenceFk`)
VALUES VALUES
(1, 'Porte Agencia'), (1, 'Porte Agencia', 7001000000),
(2, 'Portes Retorno'), (2, 'Portes Retorno', 7001000000),
(3, 'Porte Carry'), (3, 'Porte Carry', 7001000000),
(4, 'Cargo FITOSANITARIO'), (4, 'Cargo FITOSANITARIO', 4751000000),
(5, 'Documentos'); (5, 'Documentos', 2000000000);
INSERT INTO `vn`.`ticketService`(`id`, `description`, `quantity`, `price`, `taxClassFk`, `ticketFk`, `ticketServiceTypeFk`) INSERT INTO `vn`.`ticketService`(`id`, `description`, `quantity`, `price`, `taxClassFk`, `ticketFk`, `ticketServiceTypeFk`)
VALUES VALUES
@ -2063,9 +2069,9 @@ INSERT INTO `vn`.`queuePriority`(`id`, `priority`)
(2, 'Normal'), (2, 'Normal'),
(3, 'Baja'); (3, 'Baja');
INSERT INTO `vn`.`workerTimeControlParams` (`id`, `dayBreak`, `weekBreak`, `weekScope`, `dayWorkMax`, `dayStayMax`, `weekMaxBreak`, `weekMaxScope`, `askInOut`, `mailSuccessFolder`, `mailErrorFolder`) INSERT INTO `vn`.`workerTimeControlParams` (`id`, `dayBreak`, `weekBreak`, `weekScope`, `dayWorkMax`, `dayStayMax`, `weekMaxBreak`, `weekMaxScope`, `askInOut`)
VALUES VALUES
(1, 43200, 129600, 734400, 43200, 50400, 259200, 1296000, 36000, 'Leidos.exito', 'Leidos.error'); (1, 43200, 129600, 734400, 43200, 50400, 259200, 1296000, 36000);
INSERT IGNORE INTO `vn`.`greugeConfig` (`id`, `freightPickUpPrice`) VALUES ('1', '11'); INSERT IGNORE INTO `vn`.`greugeConfig` (`id`, `freightPickUpPrice`) VALUES ('1', '11');

File diff suppressed because it is too large Load Diff

View File

@ -44,6 +44,7 @@ TABLES=(
cplusTaxBreak cplusTaxBreak
pgc pgc
tag tag
time
claimResponsible claimResponsible
claimReason claimReason
claimRedelivery claimRedelivery

View File

@ -251,7 +251,7 @@ export default class Searchbar extends Component {
this.model.clear(); this.model.clear();
if (source != 'state') if (source != 'state')
this.transition = this.$state.go(state, params, opts).transition; this.transition = this.$state.go(state, params, opts).transition;
if (source != 'bar') if (source != 'bar' && (source != 'state' || this.$state.is(this.baseState)))
focus(this.element.querySelector('vn-textfield input')); focus(this.element.querySelector('vn-textfield input'));
} }

View File

@ -34,5 +34,8 @@
}, },
"UserSync": { "UserSync": {
"dataSource": "vn" "dataSource": "vn"
},
"Mail": {
"dataSource": "vn"
} }
} }

View File

@ -1,7 +1,6 @@
const app = require('vn-loopback/server/server'); const app = require('vn-loopback/server/server');
// #2457 fix regularizeClaim unit test describe('regularizeClaim()', () => {
xdescribe('regularizeClaim()', () => {
const claimFk = 1; const claimFk = 1;
const pendentState = 1; const pendentState = 1;
const resolvedState = 3; const resolvedState = 3;
@ -26,7 +25,6 @@ xdescribe('regularizeClaim()', () => {
done(); done();
}); });
// #2457 fix regularizeClaim unit test (this one fails)
it('should send a chat message with value "Trash" and then change claim state to resolved', async() => { it('should send a chat message with value "Trash" and then change claim state to resolved', async() => {
const ctx = { const ctx = {
req: { req: {
@ -46,9 +44,8 @@ xdescribe('regularizeClaim()', () => {
ticketFk: 1 ticketFk: 1
}); });
claimEnds.forEach(async claimEnd => { for (claimEnd of claimEnds)
claimEnd.updateAttributes({claimDestinationFk: trashDestination}); await claimEnd.updateAttributes({claimDestinationFk: trashDestination});
});
let claimBefore = await app.models.Claim.findById(claimFk); let claimBefore = await app.models.Claim.findById(claimFk);
await app.models.Claim.regularizeClaim(ctx, claimFk); await app.models.Claim.regularizeClaim(ctx, claimFk);

View File

@ -24,7 +24,7 @@ describe('client consumption() filter', () => {
where: { where: {
clientFk: 101 clientFk: 101
}, },
order: 'itemTypeFk, itemName, itemSize' order: 'itemFk'
}; };
const result = await app.models.Client.consumption(ctx, filter); const result = await app.models.Client.consumption(ctx, filter);

View File

@ -1,3 +1,2 @@
Invoice out: Facturas InvoiceOut: Facturas
invoiceOut: factura
Search invoices by reference: Buscar facturas por referencia Search invoices by reference: Buscar facturas por referencia

View File

@ -22,7 +22,7 @@
"url": "/index?q", "url": "/index?q",
"state": "invoiceOut.index", "state": "invoiceOut.index",
"component": "vn-invoice-out-index", "component": "vn-invoice-out-index",
"description": "Invoice out" "description": "InvoiceOut"
}, },
{ {
"url": "/summary", "url": "/summary",

View File

@ -3,7 +3,7 @@
url="Orders/filter" url="Orders/filter"
limit="20" limit="20"
data="orders" data="orders"
order="landed DESC, clientFk"> order="landed DESC, clientFk, id DESC">
</vn-crud-model> </vn-crud-model>
<vn-portal slot="topbar"> <vn-portal slot="topbar">
<vn-searchbar <vn-searchbar

View File

@ -8,7 +8,6 @@ describe('route updateVolume()', () => {
let ticketToRestore; let ticketToRestore;
let logIdToDestroy; let logIdToDestroy;
afterAll(async done => { afterAll(async done => {
await originalRoute.updateAttributes({m3: 1.8}); await originalRoute.updateAttributes({m3: 1.8});
await ticketToRestore.updateAttributes({routeFk: null}); await ticketToRestore.updateAttributes({routeFk: null});

View File

@ -29,6 +29,6 @@ describe('ticket editableStates()', () => {
let result = await app.models.State.editableStates(ctx, filter); let result = await app.models.State.editableStates(ctx, filter);
let pickerDesignedState = result.some(state => state.code == 'PICKER_DESIGNED'); let pickerDesignedState = result.some(state => state.code == 'PICKER_DESIGNED');
expect(pickerDesignedState).toBeFalsy(); expect(pickerDesignedState).toBeTruthy();
}); });
}); });

View File

@ -30,7 +30,7 @@ describe('state isEditable()', () => {
it('should return false if the state is not editable for the given role', async() => { it('should return false if the state is not editable for the given role', async() => {
const employeeRole = 1; const employeeRole = 1;
const asignedState = 20; const asignedState = 13;
let ctx = {req: {accessToken: {userId: employeeRole}}}; let ctx = {req: {accessToken: {userId: employeeRole}}};
let result = await app.models.State.isEditable(ctx, asignedState); let result = await app.models.State.isEditable(ctx, asignedState);

View File

@ -66,7 +66,7 @@ describe('ticket-request filter()', () => {
it('should return the ticket request matching the warehouse ID', async() => { it('should return the ticket request matching the warehouse ID', async() => {
let ctx = {req: {accessToken: {userId: 9}}, args: {warehouse: 1}}; let ctx = {req: {accessToken: {userId: 9}}, args: {warehouse: 1}};
let result = await app.models.TicketRequest.filter(ctx); let result = await app.models.TicketRequest.filter(ctx, {order: 'id'});
let requestId = result[0].id; let requestId = result[0].id;
expect(requestId).toEqual(3); expect(requestId).toEqual(3);

View File

@ -2,13 +2,15 @@ const app = require('vn-loopback/server/server');
describe('ticket-weekly filter()', () => { describe('ticket-weekly filter()', () => {
const authUserId = 9; const authUserId = 9;
it('should return the tickets matching the filter', async() => { it('should all return the tickets matching the filter', async() => {
const ctx = {req: {accessToken: {userId: authUserId}}, args: {}}; const filter = {order: 't.id ASC'};
const filter = {order: 'id DESC'}; const ctx = {req: {accessToken: {userId: authUserId}}, args: {filter: filter}};
const result = await app.models.TicketWeekly.filter(ctx, filter); const result = await app.models.TicketWeekly.filter(ctx);
const firstRow = result[0]; const firstRow = result[0];
expect(firstRow.ticketFk).toEqual(1); expect(firstRow.ticketFk).toEqual(1);
expect(result.length).toEqual(5);
}); });
it('should return the ticket with id one', async() => { it('should return the ticket with id one', async() => {

View File

@ -161,8 +161,13 @@ module.exports = Self => {
if (value) { if (value) {
return {and: [ return {and: [
{'st.alertLevel': 0}, {'st.alertLevel': 0},
{'st.code': {neq: 'OK'}}, {'st.code': {nin: [
{'st.code': {neq: 'BOARDING'}} 'OK',
'BOARDING',
'PRINTED',
'PRINTED_AUTO',
'PICKER_DESIGNED'
]}}
]}; ]};
} else { } else {
return {and: [ return {and: [

View File

@ -63,8 +63,7 @@ describe('ticket filter()', () => {
expect(firstRow.id).toEqual(11); expect(firstRow.id).toEqual(11);
}); });
// #2456 fix ticket.filter unit test it('should return the tickets with grouped state "Pending" and not "Ok" nor "BOARDING"', async() => {
xit('should return the tickets with grouped state "Pending" and not "Ok"', async() => {
const ctx = {req: {accessToken: {userId: 9}}, args: {pending: true}}; const ctx = {req: {accessToken: {userId: 9}}, args: {pending: true}};
const filter = {}; const filter = {};
const result = await app.models.Ticket.filter(ctx, filter); const result = await app.models.Ticket.filter(ctx, filter);

View File

@ -17,8 +17,7 @@ describe('sale priceDifference()', () => {
let result = await app.models.Ticket.priceDifference(httpCtx, ticketId, landed, let result = await app.models.Ticket.priceDifference(httpCtx, ticketId, landed,
addressId, agencyModeId, zoneId, warehouseId); addressId, agencyModeId, zoneId, warehouseId);
expect(result.totalUnitPrice).toEqual(215.78); expect(result.totalUnitPrice).toEqual(result.totalNewPrice);
expect(result.totalNewPrice).toEqual(215.78);
expect(result.totalDifference).toEqual(0); expect(result.totalDifference).toEqual(0);
}); });
@ -35,7 +34,6 @@ describe('sale priceDifference()', () => {
error = e; error = e;
}); });
expect(error).toEqual(new UserError(`The sales of this ticket can't be modified`)); expect(error).toEqual(new UserError(`The sales of this ticket can't be modified`));
}); });
}); });

View File

@ -25,7 +25,7 @@ describe('ticket setDeleted()', () => {
expect(error.message).toEqual('You must delete the claim id %d first'); expect(error.message).toEqual('You must delete the claim id %d first');
}); });
it('should delete the ticket, remove the stowaway link and change the stowaway ticket state to "FIXING" and get ride of the itemshelving', async() => { it('should delete the ticket, remove the stowaway link and change the stowaway ticket state to "FIXING" and get rid of the itemshelving', async() => {
const employeeUser = 110; const employeeUser = 110;
const ctx = { const ctx = {
req: { req: {

View File

@ -26,7 +26,6 @@ describe('ticket updateEditableTicket()', () => {
expect(error).toBeDefined(); expect(error).toBeDefined();
}); });
it('should edit the ticket address', async() => { it('should edit the ticket address', async() => {
let ctx = {req: {accessToken: {userId: 9}}}; let ctx = {req: {accessToken: {userId: 9}}};

View File

@ -161,7 +161,8 @@
</div> </div>
<vn-popup vn-id="summary"> <vn-popup vn-id="summary">
<vn-ticket-summary <vn-ticket-summary
ticket="$ctrl.selectedTicket"> ticket="$ctrl.selectedTicket"
model="model">
</vn-ticket-summary> </vn-ticket-summary>
</vn-popup> </vn-popup>
<vn-client-descriptor-popover <vn-client-descriptor-popover

View File

@ -57,8 +57,12 @@ class Controller extends Section {
this.vnApp.showSuccess(this.$t('Data saved!')); this.vnApp.showSuccess(this.$t('Data saved!'));
if (this.card) if (this.card)
this.card.reload(); this.card.reload();
else else {
this.getSummary(); this.getSummary();
// Refresh index model
if (this.model)
this.model.refresh();
}
}); });
} }
@ -78,7 +82,8 @@ ngModule.vnComponent('vnTicketSummary', {
template: require('./index.html'), template: require('./index.html'),
controller: Controller, controller: Controller,
bindings: { bindings: {
ticket: '<' ticket: '<',
model: '<?'
}, },
require: { require: {
card: '?^vnTicketCard' card: '?^vnTicketCard'

View File

@ -12,7 +12,6 @@ describe('AgencyMode byWarehhouse()', () => {
it('should return only the agencies for a warehouse', async() => { it('should return only the agencies for a warehouse', async() => {
const where = {warehouseFk: warehouseId}; const where = {warehouseFk: warehouseId};
const agencies = await app.models.AgencyMode.byWarehouse({where}); const agencies = await app.models.AgencyMode.byWarehouse({where});
const validWarehouse = agencies.every(agency => agency.warehouseFk = warehouseId); const validWarehouse = agencies.every(agency => agency.warehouseFk = warehouseId);
expect(agencies.length).toEqual(6); expect(agencies.length).toEqual(6);

View File

@ -4,6 +4,7 @@ describe('zone deletezone()', () => {
let zoneId = 9; let zoneId = 9;
let originalZoneTickets; let originalZoneTickets;
let originalZone; let originalZone;
let originalZoneWarehouses;
let originalZoneIncluded; let originalZoneIncluded;
let ticketsId; let ticketsId;
let originalTicketsState; let originalTicketsState;
@ -11,6 +12,7 @@ describe('zone deletezone()', () => {
beforeAll(async done => { beforeAll(async done => {
originalZone = await app.models.Zone.findById(zoneId); originalZone = await app.models.Zone.findById(zoneId);
originalZoneTickets = await app.models.Ticket.find({where: {zoneFk: zoneId}}); originalZoneTickets = await app.models.Ticket.find({where: {zoneFk: zoneId}});
originalZoneWarehouses = await app.models.ZoneWarehouse.findById(zoneId);
originalZoneIncluded = await app.models.ZoneIncluded.find({where: {zoneFk: zoneId}}); originalZoneIncluded = await app.models.ZoneIncluded.find({where: {zoneFk: zoneId}});
ticketsId = originalZoneTickets.map(originalZoneTickets => originalZoneTickets.id); ticketsId = originalZoneTickets.map(originalZoneTickets => originalZoneTickets.id);
originalTicketsState = await app.models.TicketState.find({where: { originalTicketsState = await app.models.TicketState.find({where: {
@ -21,13 +23,23 @@ describe('zone deletezone()', () => {
afterAll(async done => { afterAll(async done => {
await originalZone.save(); await originalZone.save();
await app.models.ZoneWarehouse.create(originalZoneWarehouses);
originalZoneTickets.forEach(async ticket => { for (ticket of originalZoneTickets)
await ticket.updateAttributes({zoneFk: zoneId}); await ticket.updateAttributes({zoneFk: zoneId});
});
originalZoneIncluded.forEach(async zoneIncluded => { for (zoneIncluded of originalZoneIncluded)
await zoneIncluded.save(); await zoneIncluded.save();
});
const fixingStateId = 1;
const ticketIds = originalZoneTickets.map(ticket => ticket.id);
const trackings = await app.models.TicketTracking.find({where: {
ticketFk: {inq: ticketIds},
stateFk: fixingStateId}});
for (let tracking of trackings)
await app.models.TicketTracking.destroyById(tracking.id);
done(); done();
}); });
@ -48,4 +60,3 @@ describe('zone deletezone()', () => {
expect(originalTicketsState.length).not.toBeGreaterThan(updatedTicketState.length); expect(originalTicketsState.length).not.toBeGreaterThan(updatedTicketState.length);
}); });
}); });

58
package-lock.json generated
View File

@ -5835,7 +5835,7 @@
}, },
"util": { "util": {
"version": "0.10.3", "version": "0.10.3",
"resolved": "https://registry.npmjs.org/util/-/util-0.10.3.tgz", "resolved": "http://registry.npmjs.org/util/-/util-0.10.3.tgz",
"integrity": "sha1-evsa/lCAUkZInj23/g7TeTNqwPk=", "integrity": "sha1-evsa/lCAUkZInj23/g7TeTNqwPk=",
"dev": true, "dev": true,
"requires": { "requires": {
@ -6806,7 +6806,7 @@
"base": { "base": {
"version": "0.11.2", "version": "0.11.2",
"resolved": "https://registry.npmjs.org/base/-/base-0.11.2.tgz", "resolved": "https://registry.npmjs.org/base/-/base-0.11.2.tgz",
"integrity": "sha1-e95c7RRbbVUakNuH+DxVi060io8=", "integrity": "sha512-5T6P4xPgpp0YDFvSWwEZ4NoE3aM4QBQXDzmVbraCkFj8zHM+mba8SyqB5DbZWyR7mYHo6Y7BdQo3MoA4m0TeQg==",
"dev": true, "dev": true,
"requires": { "requires": {
"cache-base": "^1.0.1", "cache-base": "^1.0.1",
@ -7127,7 +7127,7 @@
}, },
"browserify-rsa": { "browserify-rsa": {
"version": "4.0.1", "version": "4.0.1",
"resolved": "https://registry.npmjs.org/browserify-rsa/-/browserify-rsa-4.0.1.tgz", "resolved": "http://registry.npmjs.org/browserify-rsa/-/browserify-rsa-4.0.1.tgz",
"integrity": "sha1-IeCr+vbyApzy+vsTNWenAdQTVSQ=", "integrity": "sha1-IeCr+vbyApzy+vsTNWenAdQTVSQ=",
"dev": true, "dev": true,
"requires": { "requires": {
@ -7187,7 +7187,7 @@
}, },
"buffer": { "buffer": {
"version": "4.9.1", "version": "4.9.1",
"resolved": "https://registry.npmjs.org/buffer/-/buffer-4.9.1.tgz", "resolved": "http://registry.npmjs.org/buffer/-/buffer-4.9.1.tgz",
"integrity": "sha1-bRu2AbB6TvztlwlBMgkwJ8lbwpg=", "integrity": "sha1-bRu2AbB6TvztlwlBMgkwJ8lbwpg=",
"requires": { "requires": {
"base64-js": "^1.0.2", "base64-js": "^1.0.2",
@ -7329,7 +7329,7 @@
"cache-base": { "cache-base": {
"version": "1.0.1", "version": "1.0.1",
"resolved": "https://registry.npmjs.org/cache-base/-/cache-base-1.0.1.tgz", "resolved": "https://registry.npmjs.org/cache-base/-/cache-base-1.0.1.tgz",
"integrity": "sha1-Cn9GQWgxyLZi7jb+TnxZ129marI=", "integrity": "sha512-AKcdTnFSWATd5/GCPRxr2ChwIJ85CeyrEyjRHlKxQ56d4XJMGym0uAiKn0xbLOGOl3+yRpOTi484dVCEc5AUzQ==",
"dev": true, "dev": true,
"requires": { "requires": {
"collection-visit": "^1.0.0", "collection-visit": "^1.0.0",
@ -7399,7 +7399,7 @@
}, },
"camelcase-keys": { "camelcase-keys": {
"version": "2.1.0", "version": "2.1.0",
"resolved": "https://registry.npmjs.org/camelcase-keys/-/camelcase-keys-2.1.0.tgz", "resolved": "http://registry.npmjs.org/camelcase-keys/-/camelcase-keys-2.1.0.tgz",
"integrity": "sha1-MIvur/3ygRkFHvodkyITyRuPkuc=", "integrity": "sha1-MIvur/3ygRkFHvodkyITyRuPkuc=",
"dev": true, "dev": true,
"requires": { "requires": {
@ -7543,7 +7543,7 @@
"class-utils": { "class-utils": {
"version": "0.3.6", "version": "0.3.6",
"resolved": "https://registry.npmjs.org/class-utils/-/class-utils-0.3.6.tgz", "resolved": "https://registry.npmjs.org/class-utils/-/class-utils-0.3.6.tgz",
"integrity": "sha1-+TNprouafOAv1B+q0MqDAzGQxGM=", "integrity": "sha512-qOhPa/Fj7s6TY8H8esGu5QNpMMQxz79h+urzrNYN6mn+9BnxlDGf5QZ+XeCDsxSjPqsSR56XOZOJmpeurnLMeg==",
"dev": true, "dev": true,
"requires": { "requires": {
"arr-union": "^3.1.0", "arr-union": "^3.1.0",
@ -8703,7 +8703,7 @@
}, },
"readable-stream": { "readable-stream": {
"version": "1.1.14", "version": "1.1.14",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", "resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz",
"integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=",
"dev": true, "dev": true,
"requires": { "requires": {
@ -9796,7 +9796,7 @@
}, },
"file-loader": { "file-loader": {
"version": "1.1.11", "version": "1.1.11",
"resolved": "https://registry.npmjs.org/file-loader/-/file-loader-1.1.11.tgz", "resolved": "http://registry.npmjs.org/file-loader/-/file-loader-1.1.11.tgz",
"integrity": "sha512-TGR4HU7HUsGg6GCOPJnFk06RhWgEWFLAGWiT6rcD+GRC2keU3s9RGJ+b3Z6/U73jwwNb2gKLJ7YCrp+jvU4ALg==", "integrity": "sha512-TGR4HU7HUsGg6GCOPJnFk06RhWgEWFLAGWiT6rcD+GRC2keU3s9RGJ+b3Z6/U73jwwNb2gKLJ7YCrp+jvU4ALg==",
"dev": true, "dev": true,
"requires": { "requires": {
@ -10982,7 +10982,7 @@
"global-modules": { "global-modules": {
"version": "1.0.0", "version": "1.0.0",
"resolved": "https://registry.npmjs.org/global-modules/-/global-modules-1.0.0.tgz", "resolved": "https://registry.npmjs.org/global-modules/-/global-modules-1.0.0.tgz",
"integrity": "sha1-bXcPDrUjrHgWTXK15xqIdyZcw+o=", "integrity": "sha512-sKzpEkf11GpOFuw0Zzjzmt4B4UZwjOcG757PPvrfhxcLFbq0wpsgpOqxpxtxFiCG4DtG93M6XRVbF2oGdev7bg==",
"dev": true, "dev": true,
"requires": { "requires": {
"global-prefix": "^1.0.1", "global-prefix": "^1.0.1",
@ -11019,7 +11019,7 @@
}, },
"globby": { "globby": {
"version": "5.0.0", "version": "5.0.0",
"resolved": "https://registry.npmjs.org/globby/-/globby-5.0.0.tgz", "resolved": "http://registry.npmjs.org/globby/-/globby-5.0.0.tgz",
"integrity": "sha1-69hGZ8oNuzMLmbz8aOrCvFQ3Dg0=", "integrity": "sha1-69hGZ8oNuzMLmbz8aOrCvFQ3Dg0=",
"dev": true, "dev": true,
"requires": { "requires": {
@ -13177,7 +13177,7 @@
}, },
"is-obj": { "is-obj": {
"version": "1.0.1", "version": "1.0.1",
"resolved": "https://registry.npmjs.org/is-obj/-/is-obj-1.0.1.tgz", "resolved": "http://registry.npmjs.org/is-obj/-/is-obj-1.0.1.tgz",
"integrity": "sha1-PkcprB9f3gJc19g6iW2rn09n2w8=" "integrity": "sha1-PkcprB9f3gJc19g6iW2rn09n2w8="
}, },
"is-path-cwd": { "is-path-cwd": {
@ -13207,7 +13207,7 @@
"is-plain-object": { "is-plain-object": {
"version": "2.0.4", "version": "2.0.4",
"resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz", "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz",
"integrity": "sha1-LBY7P6+xtgbZ0Xko8FwqHDjgdnc=", "integrity": "sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==",
"dev": true, "dev": true,
"requires": { "requires": {
"isobject": "^3.0.1" "isobject": "^3.0.1"
@ -18645,7 +18645,7 @@
}, },
"load-json-file": { "load-json-file": {
"version": "1.1.0", "version": "1.1.0",
"resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-1.1.0.tgz", "resolved": "http://registry.npmjs.org/load-json-file/-/load-json-file-1.1.0.tgz",
"integrity": "sha1-lWkFcI1YtLq0wiYbBPWfMcmTdMA=", "integrity": "sha1-lWkFcI1YtLq0wiYbBPWfMcmTdMA=",
"dev": true, "dev": true,
"requires": { "requires": {
@ -19588,7 +19588,7 @@
}, },
"media-typer": { "media-typer": {
"version": "0.3.0", "version": "0.3.0",
"resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", "resolved": "http://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
"integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=" "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g="
}, },
"mem": { "mem": {
@ -19613,7 +19613,7 @@
}, },
"meow": { "meow": {
"version": "3.7.0", "version": "3.7.0",
"resolved": "https://registry.npmjs.org/meow/-/meow-3.7.0.tgz", "resolved": "http://registry.npmjs.org/meow/-/meow-3.7.0.tgz",
"integrity": "sha1-cstmi0JSKCkKu/qFaJJYcwioAfs=", "integrity": "sha1-cstmi0JSKCkKu/qFaJJYcwioAfs=",
"dev": true, "dev": true,
"requires": { "requires": {
@ -20068,7 +20068,7 @@
}, },
"multipipe": { "multipipe": {
"version": "0.1.2", "version": "0.1.2",
"resolved": "https://registry.npmjs.org/multipipe/-/multipipe-0.1.2.tgz", "resolved": "http://registry.npmjs.org/multipipe/-/multipipe-0.1.2.tgz",
"integrity": "sha1-Ko8t33Du1WTf8tV/HhoTfZ8FB4s=", "integrity": "sha1-Ko8t33Du1WTf8tV/HhoTfZ8FB4s=",
"dev": true, "dev": true,
"requires": { "requires": {
@ -21027,7 +21027,7 @@
}, },
"os-homedir": { "os-homedir": {
"version": "1.0.2", "version": "1.0.2",
"resolved": "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz", "resolved": "http://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz",
"integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M=", "integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M=",
"dev": true "dev": true
}, },
@ -21043,7 +21043,7 @@
}, },
"os-tmpdir": { "os-tmpdir": {
"version": "1.0.2", "version": "1.0.2",
"resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", "resolved": "http://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz",
"integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=", "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=",
"dev": true "dev": true
}, },
@ -22227,7 +22227,7 @@
"dependencies": { "dependencies": {
"jsesc": { "jsesc": {
"version": "0.5.0", "version": "0.5.0",
"resolved": "https://registry.npmjs.org/jsesc/-/jsesc-0.5.0.tgz", "resolved": "http://registry.npmjs.org/jsesc/-/jsesc-0.5.0.tgz",
"integrity": "sha1-597mbjXW/Bb3EP6R1c9p9w8IkR0=", "integrity": "sha1-597mbjXW/Bb3EP6R1c9p9w8IkR0=",
"dev": true "dev": true
} }
@ -22620,7 +22620,7 @@
}, },
"safe-regex": { "safe-regex": {
"version": "1.1.0", "version": "1.1.0",
"resolved": "https://registry.npmjs.org/safe-regex/-/safe-regex-1.1.0.tgz", "resolved": "http://registry.npmjs.org/safe-regex/-/safe-regex-1.1.0.tgz",
"integrity": "sha1-QKNmnzsHfR6UPURinhV91IAjvy4=", "integrity": "sha1-QKNmnzsHfR6UPURinhV91IAjvy4=",
"dev": true, "dev": true,
"requires": { "requires": {
@ -22834,7 +22834,7 @@
"dependencies": { "dependencies": {
"source-map": { "source-map": {
"version": "0.4.4", "version": "0.4.4",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.4.4.tgz", "resolved": "http://registry.npmjs.org/source-map/-/source-map-0.4.4.tgz",
"integrity": "sha1-66T12pwNyZneaAMti092FzZSA2s=", "integrity": "sha1-66T12pwNyZneaAMti092FzZSA2s=",
"dev": true, "dev": true,
"requires": { "requires": {
@ -23295,7 +23295,7 @@
"snapdragon-node": { "snapdragon-node": {
"version": "2.1.1", "version": "2.1.1",
"resolved": "https://registry.npmjs.org/snapdragon-node/-/snapdragon-node-2.1.1.tgz", "resolved": "https://registry.npmjs.org/snapdragon-node/-/snapdragon-node-2.1.1.tgz",
"integrity": "sha1-bBdfhv8UvbByRWPo88GwIaKGhTs=", "integrity": "sha512-O27l4xaMYt/RSQ5TR3vpWCAB5Kb/czIcqUFOM/C4fYcLnbZUc1PkjTAMjof2pBWaSTwOUd6qUHcFGVGj7aIwnw==",
"dev": true, "dev": true,
"requires": { "requires": {
"define-property": "^1.0.0", "define-property": "^1.0.0",
@ -23346,7 +23346,7 @@
"snapdragon-util": { "snapdragon-util": {
"version": "3.0.1", "version": "3.0.1",
"resolved": "https://registry.npmjs.org/snapdragon-util/-/snapdragon-util-3.0.1.tgz", "resolved": "https://registry.npmjs.org/snapdragon-util/-/snapdragon-util-3.0.1.tgz",
"integrity": "sha1-+VZHlIbyrNeXAGk/b3uAXkWrVuI=", "integrity": "sha512-mbKkMdQKsjX4BAL4bRYTj21edOf8cN7XHdYUJEe+Zn99hVEYcMvKPct1IqNe7+AZPirn8BCDOQBHQZknqmKlZQ==",
"dev": true, "dev": true,
"requires": { "requires": {
"kind-of": "^3.2.0" "kind-of": "^3.2.0"
@ -23630,7 +23630,7 @@
"split-string": { "split-string": {
"version": "3.1.0", "version": "3.1.0",
"resolved": "https://registry.npmjs.org/split-string/-/split-string-3.1.0.tgz", "resolved": "https://registry.npmjs.org/split-string/-/split-string-3.1.0.tgz",
"integrity": "sha1-fLCd2jqGWFcFxks5pkZgOGguj+I=", "integrity": "sha512-NzNVhJDYpwceVVii8/Hu6DKfD2G+NrQHlS/V/qgv763EYudVwEcMQNxd2lh+0VrUByXN/oJkl5grOhYWvQUYiw==",
"dev": true, "dev": true,
"requires": { "requires": {
"extend-shallow": "^3.0.0" "extend-shallow": "^3.0.0"
@ -24735,7 +24735,7 @@
}, },
"through": { "through": {
"version": "2.3.8", "version": "2.3.8",
"resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", "resolved": "http://registry.npmjs.org/through/-/through-2.3.8.tgz",
"integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=" "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU="
}, },
"through2": { "through2": {
@ -24941,7 +24941,7 @@
"touch": { "touch": {
"version": "3.1.0", "version": "3.1.0",
"resolved": "https://registry.npmjs.org/touch/-/touch-3.1.0.tgz", "resolved": "https://registry.npmjs.org/touch/-/touch-3.1.0.tgz",
"integrity": "sha1-/jZfX3XsntTlaCXgu3bSSrdK+Ds=", "integrity": "sha512-WBx8Uy5TLtOSRtIq+M03/sKDrXCLHxwDcquSP2c43Le03/9serjQBIztjRz6FkJez9D/hleyAXTBGLwwZUw9lA==",
"dev": true, "dev": true,
"requires": { "requires": {
"nopt": "~1.0.10" "nopt": "~1.0.10"
@ -25023,7 +25023,7 @@
}, },
"tty-browserify": { "tty-browserify": {
"version": "0.0.0", "version": "0.0.0",
"resolved": "https://registry.npmjs.org/tty-browserify/-/tty-browserify-0.0.0.tgz", "resolved": "http://registry.npmjs.org/tty-browserify/-/tty-browserify-0.0.0.tgz",
"integrity": "sha1-oVe6QC2iTpv5V/mqadUk7tQpAaY=", "integrity": "sha1-oVe6QC2iTpv5V/mqadUk7tQpAaY=",
"dev": true "dev": true
}, },
@ -26733,7 +26733,7 @@
}, },
"xmlbuilder": { "xmlbuilder": {
"version": "9.0.7", "version": "9.0.7",
"resolved": "http://registry.npmjs.org/xmlbuilder/-/xmlbuilder-9.0.7.tgz", "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-9.0.7.tgz",
"integrity": "sha1-Ey7mPS7FVlxVfiD0wi35rKaGsQ0=" "integrity": "sha1-Ey7mPS7FVlxVfiD0wi35rKaGsQ0="
}, },
"xmlchars": { "xmlchars": {

View File

@ -93,10 +93,11 @@ class Component {
const component = this.build(); const component = this.build();
const i18n = new VueI18n(config.i18n); const i18n = new VueI18n(config.i18n);
const props = {tplPath: this.path, ...this.args};
this._component = new Vue({ this._component = new Vue({
i18n: i18n, i18n: i18n,
render: h => h(component, { render: h => h(component, {
props: this.args props: props
}) })
}); });

View File

@ -1,5 +1,6 @@
const mysql = require('mysql2/promise'); const mysql = require('mysql2/promise');
const config = require('./config.js'); const config = require('./config.js');
const fs = require('fs-extra');
module.exports = { module.exports = {
init() { init() {
@ -10,6 +11,7 @@ module.exports = {
}); });
} }
}, },
/** /**
* Makes a query from a raw sql * Makes a query from a raw sql
* @param {String} query - The raw SQL query * @param {String} query - The raw SQL query
@ -22,6 +24,20 @@ module.exports = {
return rows; return rows;
}); });
}, },
/**
* Makes a query from a SQL file
* @param {String} queryName - The SQL file name
* @param {Object} params - Parameterized values
*
* @return {Object} - Result promise
*/
rawSqlFromDef(queryName, params) {
const query = fs.readFileSync(`${queryName}.sql`, 'utf8');
return this.rawSql(query, params);
},
/** /**
* Returns the first row from a given raw sql * Returns the first row from a given raw sql
* @param {String} query - The raw SQL query * @param {String} query - The raw SQL query
@ -32,6 +48,19 @@ module.exports = {
findOne(query, params) { findOne(query, params) {
return this.rawSql(query, params).then(([row]) => row); return this.rawSql(query, params).then(([row]) => row);
}, },
/**
* Returns the first row from a given SQL file
* @param {String} queryName - The SQL file name
* @param {Object} params - Parameterized values
*
* @return {Object} - Result promise
*/
findOneFromDef(queryName, params) {
return this.rawSqlFromDef(queryName, params)
.then(([row]) => row);
},
/** /**
* Returns the first property from a given raw sql * Returns the first property from a given raw sql
* @param {String} query - The raw SQL query * @param {String} query - The raw SQL query
@ -44,7 +73,17 @@ module.exports = {
return Object.values(row)[0]; return Object.values(row)[0];
}); });
}, },
findFromDef() {
/**
* Returns the first property from a given SQL file
* @param {String} queryName - The SQL file name
* @param {Object} params - Parameterized values
*
* @return {Object} - Result promise
*/
findValueFromDef(queryName, params) {
return this.findOneFromDef(queryName, params).then(row => {
return Object.values(row)[0];
});
} }
}; };

View File

@ -0,0 +1,74 @@
const Vue = require('vue');
const path = require('path');
const db = require('../database');
const dbHelper = {
methods: {
/**
* Makes a query from a raw sql
* @param {String} query - The raw SQL query
* @param {Object} params - Parameterized values
*
* @return {Object} - Result promise
*/
rawSql: db.rawSql,
/**
* Makes a query from a SQL file
* @param {String} queryName - The SQL file name
* @param {Object} params - Parameterized values
*
* @return {Object} - Result promise
*/
rawSqlFromDef(queryName, params) {
const absolutePath = path.join(__dirname, '../', this.tplPath, 'sql', queryName);
return db.rawSqlFromDef(absolutePath, params);
},
/**
* Returns the first row from a given raw sql
* @param {String} query - The raw SQL query
* @param {Object} params - Parameterized values
*
* @return {Object} - Result promise
*/
findOne: db.findOne,
/**
* Returns the first row from a given SQL file
* @param {String} queryName - The SQL file name
* @param {Object} params - Parameterized values
*
* @return {Object} - Result promise
*/
findOneFromDef(queryName, params) {
return this.rawSqlFromDef(queryName, params)
.then(([row]) => row);
},
/**
* Returns the first property from a given raw sql
* @param {String} query - The raw SQL query
* @param {Object} params - Parameterized values
*
* @return {Object} - Result promise
*/
findValue: db.findValue,
/**
* Returns the first property from a given SQL file
* @param {String} queryName - The SQL file name
* @param {Object} params - Parameterized values
*
* @return {Object} - Result promise
*/
findValueFromDef(queryName, params) {
return this.findOneFromDef(queryName, params).then(row => {
return Object.values(row)[0];
});
}
},
props: ['tplPath']
};
Vue.mixin(dbHelper);

View File

@ -2,3 +2,4 @@
require('./image-src'); require('./image-src');
require('./user-locale'); require('./user-locale');
require('./prop-validator'); require('./prop-validator');
require('./db-helper');

View File

@ -1,5 +1,4 @@
const Component = require(`${appPath}/core/component`); const Component = require(`${appPath}/core/component`);
const db = require(`${appPath}/core/database`);
const emailHeader = new Component('email-header'); const emailHeader = new Component('email-header');
const emailFooter = new Component('email-footer'); const emailFooter = new Component('email-footer');
@ -10,18 +9,7 @@ module.exports = {
}, },
methods: { methods: {
fetchClient(clientId) { fetchClient(clientId) {
return db.findOne(` return this.findOneFromDef('client', [clientId]);
SELECT
c.id,
u.name AS userName,
CONCAT(w.lastName, ' ', w.firstName) salesPersonName,
w.phone AS salesPersonPhone,
CONCAT(wu.name, '@verdnatura.es') AS salesPersonEmail
FROM client c
JOIN account.user u ON u.id = c.id
LEFT JOIN worker w ON w.id = c.salesPersonFk
LEFT JOIN account.user wu ON wu.id = w.userFk
WHERE c.id = ?`, [clientId]);
}, },
}, },
components: { components: {

View File

@ -0,0 +1,11 @@
SELECT
c.id,
u.name AS userName,
CONCAT(w.lastName, ' ', w.firstName) salesPersonName,
w.phone AS salesPersonPhone,
CONCAT(wu.name, '@verdnatura.es') AS salesPersonEmail
FROM client c
JOIN account.user u ON u.id = c.id
LEFT JOIN worker w ON w.id = c.salesPersonFk
LEFT JOIN account.user wu ON wu.id = w.userFk
WHERE c.id = ?

View File

@ -1,5 +1,4 @@
const Component = require(`${appPath}/core/component`); const Component = require(`${appPath}/core/component`);
const db = require(`${appPath}/core/database`);
const emailHeader = new Component('email-header'); const emailHeader = new Component('email-header');
const emailFooter = new Component('email-footer'); const emailFooter = new Component('email-footer');
const attachment = new Component('attachment'); const attachment = new Component('attachment');
@ -18,17 +17,7 @@ module.exports = {
}, },
methods: { methods: {
fetchDebtor(clientId, companyId) { fetchDebtor(clientId, companyId) {
return db.findOne(` return this.findOneFromDef('client', [clientId, companyId]);
SELECT
c.dueDay,
c.iban,
sa.iban,
be.name AS bankName
FROM client c
JOIN company AS cny
JOIN supplierAccount AS sa ON sa.id = cny.supplierAccountFk
JOIN bankEntity be ON be.id = sa.bankEntityFk
WHERE c.id = ? AND cny.id = ?`, [clientId, companyId]);
} }
}, },
components: { components: {

View File

@ -0,0 +1,10 @@
SELECT
c.dueDay,
c.iban,
sa.iban,
be.name AS bankName
FROM client c
JOIN company AS cny
JOIN supplierAccount AS sa ON sa.id = cny.supplierAccountFk
JOIN bankEntity be ON be.id = sa.bankEntityFk
WHERE c.id = ? AND cny.id = ?`

View File

@ -18,17 +18,7 @@ module.exports = {
}, },
methods: { methods: {
fetchDebtor(clientId, companyId) { fetchDebtor(clientId, companyId) {
return db.findOne(` return this.findOneFromDef('client', [clientId, companyId]);
SELECT
c.dueDay,
c.iban,
sa.iban,
be.name AS bankName
FROM client c
JOIN company AS cny
JOIN supplierAccount AS sa ON sa.id = cny.supplierAccountFk
JOIN bankEntity be ON be.id = sa.bankEntityFk
WHERE c.id = ? AND cny.id = ?`, [clientId, companyId]);
} }
}, },
components: { components: {

View File

@ -0,0 +1,10 @@
SELECT
c.dueDay,
c.iban,
sa.iban,
be.name AS bankName
FROM client c
JOIN company AS cny
JOIN supplierAccount AS sa ON sa.id = cny.supplierAccountFk
JOIN bankEntity be ON be.id = sa.bankEntityFk
WHERE c.id = ? AND cny.id = ?

View File

@ -1,5 +1,4 @@
const Component = require(`${appPath}/core/component`); const Component = require(`${appPath}/core/component`);
const db = require(`${appPath}/core/database`);
const emailHeader = new Component('email-header'); const emailHeader = new Component('email-header');
const emailFooter = new Component('email-footer'); const emailFooter = new Component('email-footer');
@ -18,15 +17,7 @@ module.exports = {
}, },
methods: { methods: {
fetchPayMethod(clientId) { fetchPayMethod(clientId) {
return db.findOne( return this.findOneFromDef('payMethod', {clientId: clientId});
`SELECT
c.dueDay,
c.iban,
pm.name,
pm.code
FROM client c
JOIN payMethod pm ON pm.id = c.payMethodFk
WHERE c.id = :clientId`, {clientId: clientId});
} }
}, },
components: { components: {

View File

@ -0,0 +1,8 @@
SELECT
c.dueDay,
c.iban,
pm.name,
pm.code
FROM client c
JOIN payMethod pm ON pm.id = c.payMethodFk
WHERE c.id = :clientId

View File

@ -1,5 +1,4 @@
const Component = require(`${appPath}/core/component`); const Component = require(`${appPath}/core/component`);
const db = require(`${appPath}/core/database`);
const emailHeader = new Component('email-header'); const emailHeader = new Component('email-header');
const emailFooter = new Component('email-footer'); const emailFooter = new Component('email-footer');
const attachment = new Component('attachment'); const attachment = new Component('attachment');
@ -15,20 +14,7 @@ module.exports = {
}, },
methods: { methods: {
fetchClient(clientId) { fetchClient(clientId) {
return db.findOne(` return this.findOneFromDef('client', [clientId]);
SELECT
c.id,
u.lang locale,
u.name AS userName,
c.email recipient,
CONCAT(w.lastName, ' ', w.firstName) salesPersonName,
w.phone AS salesPersonPhone,
CONCAT(wu.name, '@verdnatura.es') AS salesPersonEmail
FROM client c
JOIN account.user u ON u.id = c.id
LEFT JOIN worker w ON w.id = c.salesPersonFk
LEFT JOIN account.user wu ON wu.id = w.userFk
WHERE c.id = ?`, [clientId]);
} }
}, },
components: { components: {

View File

@ -0,0 +1,12 @@
SELECT
c.id,
u.name AS userName,
c.email recipient,
CONCAT(w.lastName, ' ', w.firstName) salesPersonName,
w.phone AS salesPersonPhone,
CONCAT(wu.name, '@verdnatura.es') AS salesPersonEmail
FROM client c
JOIN account.user u ON u.id = c.id
LEFT JOIN worker w ON w.id = c.salesPersonFk
LEFT JOIN account.user wu ON wu.id = w.userFk
WHERE c.id = ?

View File

@ -1,5 +1,4 @@
const Component = require(`${appPath}/core/component`); const Component = require(`${appPath}/core/component`);
const db = require(`${appPath}/core/database`);
const reportHeader = new Component('report-header'); const reportHeader = new Component('report-header');
const reportFooter = new Component('report-footer'); const reportFooter = new Component('report-footer');
@ -14,44 +13,10 @@ module.exports = {
}, },
methods: { methods: {
fetchClient(clientId) { fetchClient(clientId) {
return db.findOne( return this.findOneFromDef('client', [clientId]);
`SELECT
c.street,
c.socialName,
c.city,
c.postcode,
c.id,
c.name AS clientName,
p.name AS province,
co.country
FROM client c
JOIN province p ON c.provinceFk = p.id
JOIN country co ON c.countryFk = co.id
WHERE
c.id = ?`, [clientId]);
}, },
fetchSales(clientId, from, to) { fetchSales(clientId, from, to) {
return db.rawSql( return this.rawSqlFromDef('sales', [clientId, from, to]);
`SELECT
SUM(s.quantity) AS subtotal,
s.itemFk,
s.concept,
i.subName,
i.tag5,
i.value5,
i.tag6,
i.value6,
i.tag7,
i.value7
FROM sale s
JOIN ticket t ON t.id = s.ticketFk
JOIN item i ON i.id = s.itemFk
JOIN itemType it ON it.id = i.typeFk
WHERE
t.clientFk = ? AND it.isPackaging = FALSE
AND DATE(t.shipped) BETWEEN ? AND ?
GROUP BY s.itemFk
ORDER BY i.typeFk , i.name`, [clientId, from, to]);
}, },
}, },
components: { components: {

View File

@ -0,0 +1,13 @@
SELECT
c.street,
c.socialName,
c.city,
c.postcode,
c.id,
c.name AS clientName,
p.name AS province,
co.country
FROM client c
JOIN province p ON c.provinceFk = p.id
JOIN country co ON c.countryFk = co.id
WHERE c.id = ?

View File

@ -0,0 +1,20 @@
SELECT
SUM(s.quantity) AS subtotal,
s.itemFk,
s.concept,
i.subName,
i.tag5,
i.value5,
i.tag6,
i.value6,
i.tag7,
i.value7
FROM sale s
JOIN ticket t ON t.id = s.ticketFk
JOIN item i ON i.id = s.itemFk
JOIN itemType it ON it.id = i.typeFk
WHERE
t.clientFk = ? AND it.isPackaging = FALSE
AND DATE(t.shipped) BETWEEN ? AND ?
GROUP BY s.itemFk
ORDER BY i.typeFk , i.name

View File

@ -1,5 +1,4 @@
const Component = require(`${appPath}/core/component`); const Component = require(`${appPath}/core/component`);
const db = require(`${appPath}/core/database`);
const reportHeader = new Component('report-header'); const reportHeader = new Component('report-header');
const reportFooter = new Component('report-footer'); const reportFooter = new Component('report-footer');
@ -21,37 +20,10 @@ module.exports = {
}, },
methods: { methods: {
fetchClient(claimId) { fetchClient(claimId) {
return db.findOne( return this.findOneFromDef('client', [claimId]);
`SELECT
c.id,
c.socialName,
c.name,
c.fi,
a.city,
a.postalCode,
a.street,
a.nickname,
p.name AS province,
ct.country
FROM claim cl
JOIN client c ON c.id = cl.clientFk
JOIN account.user u ON u.id = c.id
JOIN country ct ON ct.id = c.countryFk
JOIN ticket t ON t.id = cl.ticketFk
JOIN address a ON a.id = t.addressFk
LEFT JOIN province p ON p.id = c.provinceFk
WHERE cl.id = ?`, [claimId]);
}, },
fetchSales(claimId) { fetchSales(claimId) {
return db.rawSql( return this.rawSqlFromDef('sales', [claimId]);
`SELECT
s.id,
s.quantity,
s.concept,
cb.quantity claimQuantity
FROM claimBeginning cb
JOIN sale s ON s.id = cb.saleFk
WHERE cb.claimFk = ?`, [claimId]);
}, },
}, },
components: { components: {

View File

@ -0,0 +1,19 @@
SELECT
c.id,
c.socialName,
c.name,
c.fi,
a.city,
a.postalCode,
a.street,
a.nickname,
p.name AS province,
ct.country
FROM claim cl
JOIN client c ON c.id = cl.clientFk
JOIN account.user u ON u.id = c.id
JOIN country ct ON ct.id = c.countryFk
JOIN ticket t ON t.id = cl.ticketFk
JOIN address a ON a.id = t.addressFk
LEFT JOIN province p ON p.id = c.provinceFk
WHERE cl.id = ?

View File

@ -0,0 +1,8 @@
SELECT
s.id,
s.quantity,
s.concept,
cb.quantity claimQuantity
FROM claimBeginning cb
JOIN sale s ON s.id = cb.saleFk
WHERE cb.claimFk = ?

View File

@ -16,4 +16,8 @@
h3 { h3 {
font-weight: 100; font-weight: 100;
color: #555 color: #555
}
.ticket-info {
font-size: 20px
} }

View File

@ -16,7 +16,7 @@
<div class="size50"> <div class="size50">
<div class="size75"> <div class="size75">
<h1 class="title uppercase">{{$t('title')}}</h1> <h1 class="title uppercase">{{$t('title')}}</h1>
<table class="row-oriented"> <table class="row-oriented ticket-info">
<tbody> <tbody>
<tr> <tr>
<td class="font gray uppercase">{{$t('clientId')}}</td> <td class="font gray uppercase">{{$t('clientId')}}</td>

View File

@ -1,5 +1,4 @@
const config = require(`${appPath}/core/config`); const config = require(`${appPath}/core/config`);
const db = require(`${appPath}/core/database`);
const Component = require(`${appPath}/core/component`); const Component = require(`${appPath}/core/component`);
const reportHeader = new Component('report-header'); const reportHeader = new Component('report-header');
const reportFooter = new Component('report-footer'); const reportFooter = new Component('report-footer');
@ -42,132 +41,30 @@ module.exports = {
}, },
methods: { methods: {
fetchClient(ticketId) { fetchClient(ticketId) {
return db.findOne( return this.findOneFromDef('client', [ticketId]);
`SELECT
c.id,
c.socialName,
c.street,
c.fi
FROM ticket t
JOIN client c ON c.id = t.clientFk
WHERE t.id = ?`, [ticketId]);
}, },
fetchTicket(ticketId) { fetchTicket(ticketId) {
return db.findOne( return this.findOneFromDef('ticket', [ticketId]);
`SELECT
t.id,
t.shipped,
c.code companyCode
FROM ticket t
JOIN company c ON c.id = t.companyFk
WHERE t.id = ?`, [ticketId]);
}, },
fetchAddress(ticketId) { fetchAddress(ticketId) {
return db.findOne( return this.findOneFromDef(`address`, [ticketId]);
`SELECT
a.nickname,
a.street,
a.postalCode,
a.city,
p.name province
FROM ticket t
JOIN address a ON a.clientFk = t.clientFk
AND a.id = t.addressFk
LEFT JOIN province p ON p.id = a.provinceFk
WHERE t.id = ?`, [ticketId]);
},
fetchSales(ticketId) {
return db.rawSql(
`SELECT
s.id,
s.itemFk,
s.concept,
s.quantity,
s.price,
s.price - SUM(IF(ctr.id = 6,
sc.value,
0)) netPrice,
s.discount,
i.size,
i.stems,
i.category,
it.id itemTypeId,
o.code AS origin,
i.inkFk,
s.ticketFk,
tcl.code vatType,
ibwg.ediBotanic, ppa.denomination, pp.number passportNumber,
be.isProtectedZone, c.code AS countryCode,
i.tag5, i.value5,
i.tag6, i.value6, i.tag7, i.value7
FROM vn.sale s
LEFT JOIN saleComponent sc ON sc.saleFk = s.id
LEFT JOIN component cr ON cr.id = sc.componentFk
LEFT JOIN componentType ctr ON ctr.id = cr.typeFk
LEFT JOIN item i ON i.id = s.itemFk
LEFT JOIN ticket t ON t.id = s.ticketFk
LEFT JOIN origin o ON o.id = i.originFk
LEFT JOIN country c ON c.id = o.countryFk
LEFT JOIN supplier sp ON sp.id = t.companyFk
LEFT JOIN itemType it ON it.id = i.typeFk
LEFT JOIN itemTaxCountry itc ON itc.itemFk = i.id
AND itc.countryFk = sp.countryFk
LEFT JOIN taxClass tcl ON tcl.id = itc.taxClassFk
LEFT JOIN plantpassport pp ON pp.producerFk = i.producerFk
LEFT JOIN plantpassportAuthority ppa ON ppa.id = pp.plantpassportAuthorityFk
LEFT JOIN itemBotanicalWithGenus ibwg ON ibwg.itemFk = i.id
LEFT JOIN botanicExport be ON be.restriction = 'pasaporte fitosanitario'
LEFT JOIN ediGenus eg ON eg.id = be.ediGenusFk
LEFT JOIN ediSpecie es ON es.id = be.ediSpecieFk
AND ibwg.ediBotanic LIKE CONCAT(
IFNULL(eg.latinGenusName, ''),
IF(es.latinSpeciesName > '',
CONCAT(' ', es.latinSpeciesName), ''),
'%')
WHERE s.ticketFk = ?
GROUP BY s.id
ORDER BY (it.isPackaging), s.concept, s.itemFk`, [ticketId]);
},
fetchTaxes(ticketId) {
return db.rawSql(`CALL vn.ticketGetTaxAdd(?)`, [ticketId]).then(rows => {
return rows[0];
});
},
fetchPackagings(ticketId) {
return db.rawSql(
`SELECT
tp.quantity,
i.name,
p.itemFk
FROM ticketPackaging tp
JOIN packaging p ON p.id = tp.packagingFk
JOIN item i ON i.id = p.itemFk
WHERE tp.ticketFk = ?
ORDER BY itemFk`, [ticketId]);
},
fetchServices(ticketId) {
return db.rawSql(
`SELECT
tc.description taxDescription,
ts.description,
ts.quantity,
ts.price
FROM ticketService ts
JOIN taxClass tc ON tc.id = ts.taxClassFk
WHERE ts.ticketFk = ?`, [ticketId]);
}, },
fetchSignature(ticketId) { fetchSignature(ticketId) {
return db.findOne( return this.findOneFromDef('signature', [ticketId]);
`SELECT
d.id,
d.created
FROM ticket t
JOIN ticketDms dt ON dt.ticketFk = t.id
JOIN dms d ON d.id = dt.dmsFk
AND d.file LIKE '%.png'
WHERE t.id = ?`, [ticketId]);
}, },
fetchTaxes(ticketId) {
return this.findOneFromDef(`taxes`, [ticketId]);
},
fetchSales(ticketId) {
return this.rawSqlFromDef('sales', [ticketId]);
},
fetchPackagings(ticketId) {
return this.rawSqlFromDef('packagings', [ticketId]);
},
fetchServices(ticketId) {
return this.rawSqlFromDef('services', [ticketId]);
},
getSubTotal() { getSubTotal() {
let subTotal = 0.00; let subTotal = 0.00;
this.sales.forEach(sale => { this.sales.forEach(sale => {
@ -194,7 +91,7 @@ module.exports = {
}, },
getTotal() { getTotal() {
return this.getTotalBase() + this.getTotalTax(); return this.getTotalBase() + this.getTotalTax();
}, }
}, },
components: { components: {
'report-header': reportHeader.build(), 'report-header': reportHeader.build(),

View File

@ -0,0 +1,11 @@
SELECT
a.nickname,
a.street,
a.postalCode,
a.city,
p.name province
FROM ticket t
JOIN address a ON a.clientFk = t.clientFk
AND a.id = t.addressFk
LEFT JOIN province p ON p.id = a.provinceFk
WHERE t.id = ?

View File

@ -0,0 +1,8 @@
SELECT
c.id,
c.socialName,
c.street,
c.fi
FROM ticket t
JOIN client c ON c.id = t.clientFk
WHERE t.id = ?

View File

@ -0,0 +1,9 @@
SELECT
tp.quantity,
i.name,
p.itemFk
FROM ticketPackaging tp
JOIN packaging p ON p.id = tp.packagingFk
JOIN item i ON i.id = p.itemFk
WHERE tp.ticketFk = ?
ORDER BY itemFk

View File

@ -0,0 +1,53 @@
SELECT
s.id,
s.itemFk,
s.concept,
s.quantity,
s.price,
s.price - SUM(IF(ctr.id = 6, sc.value, 0)) netPrice,
s.discount,
i.size,
i.stems,
i.category,
it.id itemTypeId,
o.code AS origin,
i.inkFk,
s.ticketFk,
tcl.code vatType,
ibwg.ediBotanic,
ppa.denomination,
pp.number passportNumber,
be.isProtectedZone, c.code AS countryCode,
i.tag5,
i.value5,
i.tag6,
i.value6,
i.tag7,
i.value7
FROM vn.sale s
LEFT JOIN saleComponent sc ON sc.saleFk = s.id
LEFT JOIN component cr ON cr.id = sc.componentFk
LEFT JOIN componentType ctr ON ctr.id = cr.typeFk
LEFT JOIN item i ON i.id = s.itemFk
LEFT JOIN ticket t ON t.id = s.ticketFk
LEFT JOIN origin o ON o.id = i.originFk
LEFT JOIN country c ON c.id = o.countryFk
LEFT JOIN supplier sp ON sp.id = t.companyFk
LEFT JOIN itemType it ON it.id = i.typeFk
LEFT JOIN itemTaxCountry itc ON itc.itemFk = i.id
AND itc.countryFk = sp.countryFk
LEFT JOIN taxClass tcl ON tcl.id = itc.taxClassFk
LEFT JOIN plantpassport pp ON pp.producerFk = i.producerFk
LEFT JOIN plantpassportAuthority ppa ON ppa.id = pp.plantpassportAuthorityFk
LEFT JOIN itemBotanicalWithGenus ibwg ON ibwg.itemFk = i.id
LEFT JOIN botanicExport be ON be.restriction = 'pasaporte fitosanitario'
LEFT JOIN ediGenus eg ON eg.id = be.ediGenusFk
LEFT JOIN ediSpecie es ON es.id = be.ediSpecieFk
AND ibwg.ediBotanic LIKE CONCAT(
IFNULL(eg.latinGenusName, ''),
IF(es.latinSpeciesName > '',
CONCAT(' ', es.latinSpeciesName), ''),
'%')
WHERE s.ticketFk = ?
GROUP BY s.id
ORDER BY (it.isPackaging), s.concept, s.itemFk

View File

@ -0,0 +1,8 @@
SELECT
tc.description taxDescription,
ts.description,
ts.quantity,
ts.price
FROM ticketService ts
JOIN taxClass tc ON tc.id = ts.taxClassFk
WHERE ts.ticketFk = ?

View File

@ -0,0 +1,8 @@
SELECT
d.id,
d.created
FROM ticket t
JOIN ticketDms dt ON dt.ticketFk = t.id
JOIN dms d ON d.id = dt.dmsFk
AND d.file LIKE '%.png'
WHERE t.id = ?

View File

@ -0,0 +1 @@
CALL vn.ticketGetTaxAdd(?)

View File

@ -0,0 +1,7 @@
SELECT
t.id,
t.shipped,
c.code companyCode
FROM ticket t
JOIN company c ON c.id = t.companyFk
WHERE t.id = ?

View File

@ -1,5 +1,4 @@
const Component = require(`${appPath}/core/component`); const Component = require(`${appPath}/core/component`);
const db = require(`${appPath}/core/database`);
const reportHeader = new Component('report-header'); const reportHeader = new Component('report-header');
const reportFooter = new Component('report-footer'); const reportFooter = new Component('report-footer');
@ -28,60 +27,10 @@ module.exports = {
}, },
methods: { methods: {
fetchRoutes(routesId) { fetchRoutes(routesId) {
return db.rawSql( return this.rawSqlFromDef('routes', {routesId});
`SELECT
r.id,
r.m3,
r.created,
r.time,
u.nickName userNickName,
v.tradeMark vehicleTradeMark,
v.model vehicleModel,
v.numberPlate plateNumber,
am.name agencyName
FROM route r
LEFT JOIN vehicle v ON v.id = r.vehicleFk
LEFT JOIN worker w ON w.id = r.workerFk
LEFT JOIN account.user u ON u.id = w.userFk
LEFT JOIN agencyMode am ON am.id = r.agencyModeFk
WHERE r.id IN(:routesId)`, {routesId});
}, },
fetchTickets(routesId) { fetchTickets(routesId) {
return db.rawSql( return this.rawSqlFromDef('tickets', {routesId});
`SELECT
t.nickname addressName,
t.packages,
t.priority,
t.id,
t.clientFk,
t.companyFk,
t.routeFk,
if(a.phone, a.phone, c.phone) AS phone,
if(a.mobile, a.mobile, c.mobile) AS mobile,
wh.name warehouseName,
a.city,
a.street,
a.postalCode,
LPAD(a.id, 5, '0') AS addressFk,
p.name province,
0 AS import,
am.name ticketAgency,
tob.description,
s.shipFk,
u.nickName salesPersonName
FROM route r
LEFT JOIN ticket t ON t.routeFk = r.id
LEFT JOIN address a ON a.id = t.addressFk
LEFT JOIN client c ON c.id = t.clientFk
LEFT JOIN worker w ON w.id = client_getSalesPerson(t.clientFk, CURDATE())
LEFT JOIN account.user u ON u.id = w.userFk
LEFT JOIN ticketObservation tob ON tob.ticketFk = t.id AND tob.observationTypeFk = 3
LEFT JOIN province p ON a.provinceFk = p.id
LEFT JOIN warehouse wh ON wh.id = t.warehouseFk
LEFT JOIN agencyMode am ON am.id = t.agencyModeFk
LEFT JOIN stowaway s ON s.id = t.id
WHERE r.id IN(:routesId)
ORDER BY t.priority, t.id`, {routesId});
} }
}, },
components: { components: {

View File

@ -0,0 +1,16 @@
SELECT
r.id,
r.m3,
r.created,
r.time,
u.nickName userNickName,
v.tradeMark vehicleTradeMark,
v.model vehicleModel,
v.numberPlate plateNumber,
am.name agencyName
FROM route r
LEFT JOIN vehicle v ON v.id = r.vehicleFk
LEFT JOIN worker w ON w.id = r.workerFk
LEFT JOIN account.user u ON u.id = w.userFk
LEFT JOIN agencyMode am ON am.id = r.agencyModeFk
WHERE r.id IN(:routesId)

View File

@ -0,0 +1,34 @@
SELECT
t.nickname addressName,
t.packages,
t.priority,
t.id,
t.clientFk,
t.companyFk,
t.routeFk,
if(a.phone, a.phone, c.phone) AS phone,
if(a.mobile, a.mobile, c.mobile) AS mobile,
wh.name warehouseName,
a.city,
a.street,
a.postalCode,
LPAD(a.id, 5, '0') AS addressFk,
p.name province,
0 AS import,
am.name ticketAgency,
tob.description,
s.shipFk,
u.nickName salesPersonName
FROM route r
LEFT JOIN ticket t ON t.routeFk = r.id
LEFT JOIN address a ON a.id = t.addressFk
LEFT JOIN client c ON c.id = t.clientFk
LEFT JOIN worker w ON w.id = client_getSalesPerson(t.clientFk, CURDATE())
LEFT JOIN account.user u ON u.id = w.userFk
LEFT JOIN ticketObservation tob ON tob.ticketFk = t.id AND tob.observationTypeFk = 3
LEFT JOIN province p ON a.provinceFk = p.id
LEFT JOIN warehouse wh ON wh.id = t.warehouseFk
LEFT JOIN agencyMode am ON am.id = t.agencyModeFk
LEFT JOIN stowaway s ON s.id = t.id
WHERE r.id IN(:routesId)
ORDER BY t.priority, t.id

View File

@ -1,4 +1,3 @@
const db = require(`${appPath}/core/database`);
const Component = require(`${appPath}/core/component`); const Component = require(`${appPath}/core/component`);
const reportHeader = new Component('report-header'); const reportHeader = new Component('report-header');
const reportFooter = new Component('report-footer'); const reportFooter = new Component('report-footer');
@ -18,50 +17,13 @@ module.exports = {
}, },
methods: { methods: {
fetchSupplier(entryId) { fetchSupplier(entryId) {
return db.findOne( return this.findOneFromDef('supplier', [entryId]);
`SELECT
s.name,
s.street,
s.nif,
s.postCode,
s.city,
p.name province
FROM supplier s
JOIN entry e ON e.supplierFk = s.id
LEFT JOIN province p ON p.id = s.provinceFk
WHERE e.id = ?`, [entryId]);
}, },
fetchEntry(entryId) { fetchEntry(entryId) {
return db.findOne( return this.findOneFromDef('entry', [entryId]);
`SELECT
e.id,
e.ref,
e.notes,
c.code companyCode,
t.landed
FROM entry e
JOIN travel t ON t.id = e.travelFk
JOIN company c ON c.id = e.companyFk
WHERE e.id = ?`, [entryId]);
}, },
fetchBuys(entryId) { fetchBuys(entryId) {
return db.rawSql( return this.rawSqlFromDef('buys', [entryId]);
`SELECT
b.itemFk,
b.quantity,
b.buyingValue,
b.stickers box,
b.packing,
i.name itemName,
i.tag5,
i.value5,
i.tag6,
i.value6,
i.tag7,
i.value7
FROM buy b
JOIN item i ON i.id = b.itemFk
WHERE b.entryFk = ?`, [entryId]);
}, },
getTotal() { getTotal() {
let total = 0.00; let total = 0.00;

View File

@ -0,0 +1,16 @@
SELECT
b.itemFk,
b.quantity,
b.buyingValue,
b.stickers box,
b.packing,
i.name itemName,
i.tag5,
i.value5,
i.tag6,
i.value6,
i.tag7,
i.value7
FROM buy b
JOIN item i ON i.id = b.itemFk
WHERE b.entryFk = ?

View File

@ -0,0 +1,10 @@
SELECT
e.id,
e.ref,
e.notes,
c.code companyCode,
t.landed
FROM entry e
JOIN travel t ON t.id = e.travelFk
JOIN company c ON c.id = e.companyFk
WHERE e.id = ?

View File

@ -0,0 +1,11 @@
SELECT
s.name,
s.street,
s.nif,
s.postCode,
s.city,
p.name province
FROM supplier s
JOIN entry e ON e.supplierFk = s.id
LEFT JOIN province p ON p.id = s.provinceFk
WHERE e.id = ?

View File

@ -1,5 +1,4 @@
const Component = require(`${appPath}/core/component`); const Component = require(`${appPath}/core/component`);
const db = require(`${appPath}/core/database`);
const reportHeader = new Component('report-header'); const reportHeader = new Component('report-header');
const reportFooter = new Component('report-footer'); const reportFooter = new Component('report-footer');
const qrcode = require('qrcode'); const qrcode = require('qrcode');
@ -30,26 +29,10 @@ module.exports = {
}, },
methods: { methods: {
fetchItem(id, warehouseId) { fetchItem(id, warehouseId) {
return db.findOne( return this.findOneFromDef('item', [id, warehouseId]);
`SELECT
i.id,
i.name,
i.stems,
i.size,
b.packing
FROM vn.item i
JOIN cache.last_buy clb ON clb.item_id = i.id
JOIN vn.buy b ON b.id = clb.buy_id
JOIN vn.entry e ON e.id = b.entryFk
WHERE i.id = ? AND clb.warehouse_id = ?`, [id, warehouseId]);
}, },
fetchItemTags(itemId) { fetchItemTags(itemId) {
return db.rawSql( return this.rawSqlFromDef('itemTags', [itemId]).then(rows => {
`SELECT t.code, t.name, it.value
FROM vn.itemTag it
JOIN vn.tag t ON t.id = it.tagFk
WHERE it.itemFk = ?
`, [itemId]).then(rows => {
const tags = {}; const tags = {};
rows.forEach(row => tags[row.code] = row.value); rows.forEach(row => tags[row.code] = row.value);

View File

@ -0,0 +1,11 @@
SELECT
i.id,
i.name,
i.stems,
i.size,
b.packing
FROM vn.item i
JOIN cache.last_buy clb ON clb.item_id = i.id
JOIN vn.buy b ON b.id = clb.buy_id
JOIN vn.entry e ON e.id = b.entryFk
WHERE i.id = ? AND clb.warehouse_id = ?

View File

@ -0,0 +1,4 @@
SELECT t.code, t.name, it.value
FROM vn.itemTag it
JOIN vn.tag t ON t.id = it.tagFk
WHERE it.itemFk = ?

View File

@ -1,5 +1,4 @@
const Component = require(`${appPath}/core/component`); const Component = require(`${appPath}/core/component`);
const db = require(`${appPath}/core/database`);
const reportHeader = new Component('report-header'); const reportHeader = new Component('report-header');
const reportFooter = new Component('report-footer'); const reportFooter = new Component('report-footer');
@ -24,28 +23,12 @@ module.exports = {
}, },
methods: { methods: {
fetchClient(clientId) { fetchClient(clientId) {
return db.findOne( return this.findOneFromDef('client', [clientId]);
`SELECT
c.id,
c.socialName,
c.street,
c.postcode,
c.city,
c.fi,
p.name AS province,
ct.country
FROM client c
JOIN country ct ON ct.id = c.countryFk
LEFT JOIN province p ON p.id = c.provinceFk
WHERE c.id = ?`, [clientId]);
}, },
fetchSales(clientId, companyId) { fetchSales(clientId, companyId) {
return db.rawSql( return this.findOneFromDef('sales', {
`CALL vn.clientGetDebtDiary(:clientId, :companyId)`, { clientId: clientId,
clientId: clientId, companyId: companyId,
companyId: companyId,
}).then(rows => {
return rows[0];
}); });
}, },
getBalance(sale) { getBalance(sale) {

View File

@ -0,0 +1,13 @@
SELECT
c.id,
c.socialName,
c.street,
c.postcode,
c.city,
c.fi,
p.name AS province,
ct.country
FROM client c
JOIN country ct ON ct.id = c.countryFk
LEFT JOIN province p ON p.id = c.provinceFk
WHERE c.id = ?

View File

@ -0,0 +1 @@
CALL vn.clientGetDebtDiary(:clientId, :companyId)

View File

@ -1,5 +1,4 @@
const Component = require(`${appPath}/core/component`); const Component = require(`${appPath}/core/component`);
const db = require(`${appPath}/core/database`);
const reportHeader = new Component('report-header'); const reportHeader = new Component('report-header');
const reportFooter = new Component('report-footer'); const reportFooter = new Component('report-footer');
@ -14,27 +13,10 @@ module.exports = {
}, },
methods: { methods: {
fetchClient(receiptId) { fetchClient(receiptId) {
return db.findOne( return this.findOneFromDef('client', [receiptId]);
`SELECT
c.id,
c.socialName,
u.lang locale
FROM receipt r
JOIN client c ON c.id = r.clientFk
JOIN account.user u ON u.id = c.id
WHERE r.id = ?`, [receiptId]);
}, },
fetchReceipt(receiptId) { fetchReceipt(receiptId) {
return db.findOne( return this.findOneFromDef('receipt', [receiptId]);
`SELECT
r.id,
r.amountPaid,
r.amountUnpaid,
r.payed,
r.companyFk
FROM receipt r
JOIN client c ON c.id = r.clientFk
WHERE r.id = ?`, [receiptId]);
} }
}, },
components: { components: {

View File

@ -0,0 +1,8 @@
SELECT
c.id,
c.socialName,
u.lang locale
FROM receipt r
JOIN client c ON c.id = r.clientFk
JOIN account.user u ON u.id = c.id
WHERE r.id = ?

View File

@ -0,0 +1,9 @@
SELECT
r.id,
r.amountPaid,
r.amountUnpaid,
r.payed,
r.companyFk
FROM receipt r
JOIN client c ON c.id = r.clientFk
WHERE r.id = ?

View File

@ -1,5 +1,4 @@
const Component = require(`${appPath}/core/component`); const Component = require(`${appPath}/core/component`);
const db = require(`${appPath}/core/database`);
const reportHeader = new Component('report-header'); const reportHeader = new Component('report-header');
const reportFooter = new Component('report-footer'); const reportFooter = new Component('report-footer');
@ -21,46 +20,10 @@ const rptSepaCore = {
}, },
methods: { methods: {
fetchClient(clientId, companyId) { fetchClient(clientId, companyId) {
return db.findOne( return this.findOneFromDef('client', {companyId, clientId});
`SELECT
c.id,
m.code mandateCode,
c.socialName,
c.street,
c.postcode,
c.city,
c.fi,
p.name AS province,
ct.country,
ct.code AS countryCode,
ct.ibanLength AS ibanLength
FROM client c
JOIN country ct ON ct.id = c.countryFk
LEFT JOIN mandate m ON m.clientFk = c.id
AND m.companyFk = :companyId AND m.finished IS NULL
LEFT JOIN province p ON p.id = c.provinceFk
WHERE (m.companyFk = :companyId OR m.companyFk IS NULL) AND c.id = :clientId
ORDER BY m.created DESC LIMIT 1`, {companyId, clientId});
}, },
fetchSupplier(clientId, companyId) { fetchSupplier(clientId, companyId) {
return db.findOne( return this.findOneFromDef('supplier', {companyId, clientId});
`SELECT
m.code mandateCode,
s.name,
s.street,
sc.country,
s.postCode,
s.city,
sp.name province
FROM client c
LEFT JOIN mandate m ON m.clientFk = c.id
AND m.companyFk = :companyId AND m.finished IS NULL
LEFT JOIN supplier s ON s.id = m.companyFk
LEFT JOIN country sc ON sc.id = s.countryFk
LEFT JOIN province sp ON sp.id = s.provinceFk
LEFT JOIN province p ON p.id = c.provinceFk
WHERE (m.companyFk = :companyId OR m.companyFk IS NULL) AND c.id = :clientId
ORDER BY m.created DESC LIMIT 1`, {companyId, clientId});
} }
}, },
components: { components: {

View File

@ -0,0 +1,19 @@
SELECT
c.id,
m.code mandateCode,
c.socialName,
c.street,
c.postcode,
c.city,
c.fi,
p.name AS province,
ct.country,
ct.code AS countryCode,
ct.ibanLength AS ibanLength
FROM client c
JOIN country ct ON ct.id = c.countryFk
LEFT JOIN mandate m ON m.clientFk = c.id
AND m.companyFk = :companyId AND m.finished IS NULL
LEFT JOIN province p ON p.id = c.provinceFk
WHERE (m.companyFk = :companyId OR m.companyFk IS NULL) AND c.id = :clientId
ORDER BY m.created DESC LIMIT 1

View File

@ -0,0 +1,17 @@
SELECT
m.code mandateCode,
s.name,
s.street,
sc.country,
s.postCode,
s.city,
sp.name province
FROM client c
LEFT JOIN mandate m ON m.clientFk = c.id
AND m.companyFk = :companyId AND m.finished IS NULL
LEFT JOIN supplier s ON s.id = m.companyFk
LEFT JOIN country sc ON sc.id = s.countryFk
LEFT JOIN province sp ON sp.id = s.provinceFk
LEFT JOIN province p ON p.id = c.provinceFk
WHERE (m.companyFk = :companyId OR m.companyFk IS NULL) AND c.id = :clientId
ORDER BY m.created DESC LIMIT 1

View File

@ -2,8 +2,9 @@ div.text {
font-family: Tahoma; font-family: Tahoma;
font-weight: bold; font-weight: bold;
color: white; color: white;
font-size: 7.5em; font-size: 12em;
text-align: center; text-align: center;
background-color: black; background-color: black;
margin-bottom: 0.2em margin: 0.30em;
padding: 30px 0
} }

View File

@ -0,0 +1,4 @@
{
"landscape": true,
"format": "A4"
}

View File

@ -0,0 +1,9 @@
SELECT
r.id,
r.time,
am.name agencyName,
v.numberPlate plateNumber
FROM route r
JOIN agencyMode am ON am.id = r.agencyModeFk
JOIN vehicle v ON v.id = r.vehicleFk
WHERE r.id = :routeId

View File

@ -1,5 +1,3 @@
const db = require(`${appPath}/core/database`);
module.exports = { module.exports = {
name: 'zone', name: 'zone',
async serverPrefetch() { async serverPrefetch() {
@ -10,16 +8,7 @@ module.exports = {
}, },
methods: { methods: {
fetchZone(routeId) { fetchZone(routeId) {
return db.findOne( return this.findOneFromDef('zone', {routeId});
`SELECT
r.id,
r.time,
am.name agencyName,
v.numberPlate plateNumber
FROM route r
JOIN agencyMode am ON am.id = r.agencyModeFk
JOIN vehicle v ON v.id = r.vehicleFk
WHERE r.id = :routeId`, {routeId});
} }
}, },
props: { props: {