Merge branch 'dev'

This commit is contained in:
Daniel Herrero 2018-02-08 07:10:54 +01:00
commit 9bfd1989f2
12 changed files with 739 additions and 507 deletions

View File

@ -11,6 +11,10 @@ const exec = require('child_process').exec;
// Configuration // Configuration
const isWindows = /^win/.test(process.platform); const isWindows = /^win/.test(process.platform);
if (gutil.env.NODE_ENV)
process.env.NODE_ENV = gutil.env.NODE_ENV;
const env = process.env.NODE_ENV ? process.env.NODE_ENV : 'development'; const env = process.env.NODE_ENV ? process.env.NODE_ENV : 'development';
const langs = ['es', 'en']; const langs = ['es', 'en'];
@ -118,7 +122,7 @@ gulp.task('docker-compose', async () => {
let services = await getServices(); let services = await getServices();
for (let service of services) { for (let service of services) {
let dockerFile = `${__dirname}/${service.name}/Dockerfile`; let dockerFile = `${__dirname}/services/${service.name}/Dockerfile`;
// if (await fs.exists(`./services/${service.name}/Dockerfile`)) // if (await fs.exists(`./services/${service.name}/Dockerfile`))
// dockerFile = 'Dockerfile'; // dockerFile = 'Dockerfile';

View File

@ -88,7 +88,7 @@ module.exports = function(config) {
customLaunchers: { customLaunchers: {
FirefoxHeadless: { FirefoxHeadless: {
base: 'Firefox', base: 'Firefox',
flags: ['--headless'] flags: ['-headless']
} }
} }
}; };

File diff suppressed because it is too large Load Diff

View File

@ -1,17 +0,0 @@
CREATE TABLE vn.itemLog
SELECT * FROM vn.entryLog LIMIT 0;
ALTER TABLE `vn`.`itemLog`
ADD INDEX `itemLogItemFk_idx` (`originFk` ASC),
ADD INDEX `itemLogUserFk_idx` (`userFk` ASC);
ALTER TABLE `vn`.`itemLog`
ADD CONSTRAINT `itemLogItemFk`
FOREIGN KEY (`originFk`)
REFERENCES `vn2008`.`Articles` (`Id_Article`)
ON DELETE NO ACTION
ON UPDATE CASCADE,
ADD CONSTRAINT `itemLogUserFk`
FOREIGN KEY (`userFk`)
REFERENCES `account`.`user` (`id`)
ON DELETE NO ACTION
ON UPDATE CASCADE;

6
services/db/02-changes.sh Executable file
View File

@ -0,0 +1,6 @@
#!/bin/bash
for file in changes/*/*.sql; do
echo "Importing $file"
mysql -u root < $file
done

View File

@ -272,14 +272,14 @@ INSERT INTO `account`.`user`(`id`,`name`,`password`,`role`,`active`,`email`)
(10, 'JessicaJones', 'ac754a330530832ba1bf7687f577da91', 9, 1, 'JessicaJones@verdnatura.es'), (10, 'JessicaJones', 'ac754a330530832ba1bf7687f577da91', 9, 1, 'JessicaJones@verdnatura.es'),
(11, 'Cyborg', 'ac754a330530832ba1bf7687f577da91', 1, 1, 'cyborg@verdnatura.es'); (11, 'Cyborg', 'ac754a330530832ba1bf7687f577da91', 1, 1, 'cyborg@verdnatura.es');
INSERT INTO `salix`.`Country`(`id`, `name`, `inCee`, `code`, `currencyFk`, `realCountryFk`) INSERT INTO `vn`.`country`(`id`, `country`, `isUeeMember`, `code`, `currencyFk`)
VALUES VALUES
(1, 'España', 0, 'ES', 1, 1), (1, 'España', 0, 'ES', 1),
(2, 'Italia', 1, 'IT', 1, 2), (2, 'Italia', 1, 'IT', 1),
(3, 'Alemania', 1, 'DE', 1, 3), (3, 'Alemania', 1, 'DE', 1),
(4, 'Rumania', 1, 'RO', 1, 4), (4, 'Rumania', 1, 'RO', 1),
(5, 'Holanda', 1, 'NL', 1, 5), (5, 'Holanda', 1, 'NL', 1),
(30,'Francia', 1, 'FR', 1, 6); (30,'Francia', 1, 'FR', 1);
INSERT INTO `vn`.`warehouse`(`id`, `name`, `isComparative`, `isInventory`, `isManaged`) INSERT INTO `vn`.`warehouse`(`id`, `name`, `isComparative`, `isInventory`, `isManaged`)
VALUES VALUES
@ -305,7 +305,7 @@ INSERT INTO `vn`.`bank`(`id`, `bank`, `account`, `cash`, `entityFk`, `isActive`)
VALUES VALUES
(8, 'Pay on receipt', '0000000000', 4, 0, 1); (8, 'Pay on receipt', '0000000000', 4, 0, 1);
INSERT INTO `salix`.`Agency`(`id`, `name`, `warehouseFk`, `isVolumetric`, `bankFk`, `warehouseAliasFk`) INSERT INTO `vn`.`agency`(`id`, `name`, `warehouseFk`, `isVolumetric`, `bankFk`, `warehouseAliasFk`)
VALUES VALUES
(1, 'inhouse pickup', 1, 0, 8, 1), (1, 'inhouse pickup', 1, 0, 8, 1),
(2, 'Super-Man delivery', 1, 0, 8, 1), (2, 'Super-Man delivery', 1, 0, 8, 1),
@ -329,7 +329,7 @@ INSERT INTO `vn`.`payMethod`(`id`, `name`, `graceDays`, `outstandingDebt`, `iban
(4, 'PayMethod with IBAN', 0, 001, 1), (4, 'PayMethod with IBAN', 0, 001, 1),
(5, 'PayMethod five', 10, 001, 0); (5, 'PayMethod five', 10, 001, 0);
INSERT INTO `salix`.`Zone`(`id`, `name`, `printingOrder`) INSERT INTO `vn2008`.`zones`(`zone_id`, `name`, `printingOrder`)
VALUES VALUES
(1, 'zone one', 1), (1, 'zone one', 1),
(2, 'zone two', 2), (2, 'zone two', 2),
@ -388,7 +388,7 @@ INSERT INTO `vn`.`client`(`id`,`name`,`fi`,`socialName`,`contact`,`street`,`city
(9, 'Bruce Banner', '16104829E', 'Hulk', 'Black widow', 'Somewhere in New York', 'Silla', 46460, 1111111111, 222222222, 333333333, 1, 'BruceBanner@verdnatura.es', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1,NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1,'0000-00-00', 1, NULL, 1, 1, 1, 1, NULL, 0, 0, 4, 0, 1), (9, 'Bruce Banner', '16104829E', 'Hulk', 'Black widow', 'Somewhere in New York', 'Silla', 46460, 1111111111, 222222222, 333333333, 1, 'BruceBanner@verdnatura.es', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1,NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1,'0000-00-00', 1, NULL, 1, 1, 1, 1, NULL, 0, 0, 4, 0, 1),
(10, 'Jessica Jones', '58282869H', 'Jessica Jones', 'Luke Cage', 'NYCC 2015 Poster', 'Silla', 46460, 1111111111, 222222222, 333333333, 1, 'JessicaJones@verdnatura.es', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1,NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1,'0000-00-00', 1, NULL, 1, 1, 1, 1, NULL, 0, 0, 4, 0, 1); (10, 'Jessica Jones', '58282869H', 'Jessica Jones', 'Luke Cage', 'NYCC 2015 Poster', 'Silla', 46460, 1111111111, 222222222, 333333333, 1, 'JessicaJones@verdnatura.es', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1,NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1,'0000-00-00', 1, NULL, 1, 1, 1, 1, NULL, 0, 0, 4, 0, 1);
INSERT INTO `salix`.`Address`(`id`, `consignee`, `street`, `city`, `postcode`, `provinceFk`, `phone`, `mobile`, `isEnabled`, `isDefaultAddress`, `clientFk`, `defaultAgencyFk`, `longitude`, `latitude`, `isEqualizated`) INSERT INTO `vn`.`address`(`id`, `nickname`, `street`, `city`, `postalCode`, `provinceFk`, `phone`, `mobile`, `isActive`, `isDefaultAddress`, `clientFk`, `agencyFk`, `longitude`, `latitude`, `isEqualizated`)
VALUES VALUES
(101, 'Bruce Wayne', 'The Bat cave', 'Silla', 46460, 1, NULL, NULL, 1, 1, 1, 2, NULL, NULL, 0), (101, 'Bruce Wayne', 'The Bat cave', 'Silla', 46460, 1, NULL, NULL, 1, 1, 1, 2, NULL, NULL, 0),
(102, 'Petter Parker', 'NY roofs', 'Silla', 46460, 1, NULL, NULL, 1, 1, 2, 2, NULL, NULL, 0), (102, 'Petter Parker', 'NY roofs', 'Silla', 46460, 1, NULL, NULL, 1, 1, 2, 2, NULL, NULL, 0),
@ -401,7 +401,7 @@ INSERT INTO `salix`.`Address`(`id`, `consignee`, `street`, `city`, `postcode`, `
(109, 'Bruce Banner', 'Somewhere in Thailand', 'Silla', 46460, 1, NULL, NULL, 1, 1, 9, 2, NULL, NULL, 0), (109, 'Bruce Banner', 'Somewhere in Thailand', 'Silla', 46460, 1, NULL, NULL, 1, 1, 9, 2, NULL, NULL, 0),
(110, 'Jessica Jones', 'Luke Cages Bar', 'Silla', 46460, 1, NULL, NULL, 1, 1, 10, 2, NULL, NULL, 0); (110, 'Jessica Jones', 'Luke Cages Bar', 'Silla', 46460, 1, NULL, NULL, 1, 1, 10, 2, NULL, NULL, 0);
INSERT INTO `salix`.`ClientCredit`(`id`, `clientFk`, `employeeFk`, `amount`, `created`) INSERT INTO `vn`.`clientCredit`(`id`, `clientFk`, `workerFk`, `amount`, `created`)
VALUES VALUES
(1, 1, 1, 1200, CURDATE()), (1, 1, 1, 1200, CURDATE()),
(2, 2, 2, 800, CURDATE()), (2, 2, 2, 800, CURDATE()),
@ -409,13 +409,13 @@ INSERT INTO `salix`.`ClientCredit`(`id`, `clientFk`, `employeeFk`, `amount`, `cr
(4, 4, 4, 90, CURDATE()), (4, 4, 4, 90, CURDATE()),
(5, 5, 5, 90, CURDATE()); (5, 5, 5, 90, CURDATE());
INSERT INTO `salix`.`ClientCreditLimit`(`id`, `maxAmount`, `roleFk`) INSERT INTO `vn`.`clientCreditLimit`(`id`, `maxAmount`, `roleFk`)
VALUES VALUES
(1, 1000, 5), (1, 1000, 5),
(2, 600, 5), (2, 600, 5),
(3, 0, 5); (3, 0, 5);
INSERT INTO `salix`.`ClientObservation`(`id`, `clientFk`, `employeeFk`, `text`, `created`) INSERT INTO `vn`.`clientObservation`(`id`, `clientFk`, `workerFk`, `text`, `created`)
VALUES VALUES
(1, 1, 1, 'Madness, as you know, is like gravity, all it takes is a little push', CURDATE()), (1, 1, 1, 'Madness, as you know, is like gravity, all it takes is a little push', CURDATE()),
(2, 2, 1, 'With great power, comes great responsibility', CURDATE()), (2, 2, 1, 'With great power, comes great responsibility', CURDATE()),
@ -448,7 +448,7 @@ INSERT INTO `vn`.`creditClassification`(`id`, `client`, `dateStart`, `dateEnd`)
(4, 4, CURDATE(), CURDATE()), (4, 4, CURDATE(), CURDATE()),
(5, 5, CURDATE(), CURDATE()); (5, 5, CURDATE(), CURDATE());
INSERT INTO `salix`.`Route`(`id`, `date`) INSERT INTO `vn`.`route`(`id`, `created`)
VALUES VALUES
(1, CURDATE()), (1, CURDATE()),
(2, CURDATE()), (2, CURDATE()),
@ -458,7 +458,7 @@ INSERT INTO `salix`.`Route`(`id`, `date`)
(6, CURDATE()), (6, CURDATE()),
(7, CURDATE()); (7, CURDATE());
INSERT INTO `salix`.`State`(`id`, `name`, `order`, `alertLevel`, `code`) INSERT INTO `vn`.`state`(`id`, `name`, `order`, `alertLevel`, `code`)
VALUES VALUES
(1, 'To check', 2, 0, 'FIXING'), (1, 'To check', 2, 0, 'FIXING'),
(2, 'Owes', 1, 0, 'FREE'), (2, 'Owes', 1, 0, 'FREE'),

View File

@ -3,9 +3,11 @@ FROM mysql:5.6.37
ENV MYSQL_ALLOW_EMPTY_PASSWORD yes ENV MYSQL_ALLOW_EMPTY_PASSWORD yes
ENV TZ GMT-1 ENV TZ GMT-1
COPY *.sql /docker-entrypoint-initdb.d/ WORKDIR /docker-entrypoint-initdb.d
COPY *.sql ./
RUN chmod -R 755 /docker-entrypoint-initdb.d COPY 02-changes.sh .
COPY changes changes
RUN chmod -R 755 .
CMD ["mysqld"] CMD ["mysqld"]

View File

@ -8,17 +8,12 @@ VIEW `vn`.`agencyMode` AS
`a`.`Agencia` AS `name`, `a`.`Agencia` AS `name`,
`a`.`description` AS `description`, `a`.`description` AS `description`,
`a`.`Vista` AS `deliveryMethodFk`, `a`.`Vista` AS `deliveryMethodFk`,
`a`.`Vista` AS `__deliveryMethod`,
`a`.`Vista` AS `__view`,
`a`.`m3` AS `m3`, `a`.`m3` AS `m3`,
`a`.`cod71` AS `cod71`, `a`.`cod71` AS `cod71`,
`a`.`web` AS `web`, `a`.`web` AS `web`,
`a`.`agency_id` AS `agencyFk`, `a`.`agency_id` AS `agencyFk`,
`a`.`agency_id` AS `__agency`,
`a`.`agency_service_id` AS `agencyServiceFk`, `a`.`agency_service_id` AS `agencyServiceFk`,
`a`.`agency_service_id` AS `__agencyService`,
`a`.`inflacion` AS `inflation`, `a`.`inflacion` AS `inflation`,
`a`.`inflacion` AS `__inflacion`,
`a`.`is_volumetric` AS `isVolumetric`, `a`.`is_volumetric` AS `isVolumetric`,
`a`.`send_mail` AS `reportMail` `a`.`send_mail` AS `reportMail`
FROM FROM

View File

@ -6,12 +6,9 @@ VIEW `vn`.`agencyHour` AS
SELECT SELECT
`h`.`agency_hour_id` AS `id`, `h`.`agency_hour_id` AS `id`,
`h`.`agency_id` AS `agencyFk`, `h`.`agency_id` AS `agencyFk`,
`h`.`agency_id` AS `__agency`,
`h`.`week_day` AS `weekDay`, `h`.`week_day` AS `weekDay`,
`h`.`warehouse_id` AS `warehouseFk`, `h`.`warehouse_id` AS `warehouseFk`,
`h`.`warehouse_id` AS `__warehouse`,
`h`.`province_id` AS `provinceFk`, `h`.`province_id` AS `provinceFk`,
`h`.`province_id` AS `__province`,
`h`.`subtract_day` AS `substractDay`, `h`.`subtract_day` AS `substractDay`,
`h`.`max_hour` AS `maxHour` `h`.`max_hour` AS `maxHour`
FROM FROM

View File

@ -1,36 +0,0 @@
USE `account`;
CREATE
OR REPLACE ALGORITHM = UNDEFINED
DEFINER = `root`@`%`
SQL SECURITY DEFINER
VIEW `account`.`__userRole` AS
SELECT
`r`.`inheritsFrom` AS `id`
FROM
(`account`.`roleRole` `r`
JOIN `account`.`user` `u` ON ((`u`.`role` = `r`.`role`)))
WHERE
(`u`.`id` = USERGETID());
DROP VIEW `account`.`userRole`;
CREATE TABLE `account`.`userRole` (
`userFk` INT(10) UNSIGNED NOT NULL,
`roleFk` INT(10) UNSIGNED NOT NULL,
PRIMARY KEY (`userFk`, `roleFk`));
ALTER TABLE `account`.`userRole`
ADD INDEX `user` (`userFk` ASC),
ADD INDEX `role` (`roleFk` ASC);
ALTER TABLE `account`.`userRole`
ADD CONSTRAINT `user`
FOREIGN KEY (`userFk`)
REFERENCES `account`.`user` (`id`)
ON DELETE CASCADE
ON UPDATE CASCADE,
ADD CONSTRAINT `role`
FOREIGN KEY (`roleFk`)
REFERENCES `account`.`role` (`id`)
ON DELETE CASCADE
ON UPDATE CASCADE;

View File

@ -1,31 +0,0 @@
DROP function IF EXISTS `userHasRoleId`;
DELIMITER $$
CREATE DEFINER=`root`@`%` FUNCTION `account`.`userHasRoleId`(vRoleId INT) RETURNS tinyint(1)
DETERMINISTIC
BEGIN
/**
* Comprueba si el usuario actual tiene asociado un rol.
*
* @param vRoleId Identificador del rol a comprobar
* @return %TRUE si tiene el rol, %FALSE en caso contrario
*/
DECLARE vHasRole BOOL DEFAULT FALSE;
SELECT COUNT(*) > 0 INTO vHasRole
FROM user u
JOIN roleRole r ON r.role = u.role
WHERE u.id = userGetId()
AND r.inheritsFrom = vRoleId;
IF NOT vHasRole
THEN
SELECT COUNT(*) > 0 INTO vHasRole
FROM userRole
WHERE userFk = userGetId()
AND roleFk = vRoleId;
END IF;
RETURN vHasRole;
END$$
DELIMITER ;