import production structure db to local and fix test
gitea/salix/dev This commit looks good Details

This commit is contained in:
Bernat 2019-03-20 08:52:54 +01:00
parent 8521382838
commit 981800a0e2
16 changed files with 6772 additions and 5458 deletions

View File

@ -1,17 +1,19 @@
#!/bin/bash
echo "USE \`account\`;" > install/dump/dumpedFixtures.sql
mysqldump --defaults-file=connect.ini --no-create-info account role roleRole roleInherit >> install/dump/dumpedFixtures.sql
mysqldump --defaults-file=config.production.ini --no-create-info account role roleRole roleInherit >> install/dump/dumpedFixtures.sql
echo "USE \`salix\`;" >> install/dump/dumpedFixtures.sql
mysqldump --defaults-file=connect.ini --no-create-info salix ACL fieldAcl>> install/dump/dumpedFixtures.sql
mysqldump --defaults-file=config.production.ini --no-create-info salix ACL fieldAcl>> install/dump/dumpedFixtures.sql
echo "USE \`vn\`;" >> install/dump/dumpedFixtures.sql
mysqldump --defaults-file=connect.ini --no-create-info vn cplusInvoiceType477 cplusSubjectOp cplusTaxBreak bookingPlanner pgc tag alertLevel >> install/dump/dumpedFixtures.sql
mysqldump --defaults-file=config.production.ini --no-create-info vn cplusInvoiceType477 cplusSubjectOp cplusTaxBreak bookingPlanner pgc tag alertLevel >> install/dump/dumpedFixtures.sql
echo "USE \`vn2008\`;" >> install/dump/dumpedFixtures.sql
mysqldump --defaults-file=connect.ini --no-create-info vn2008 accion_dits Gastos Tintas tarifa_componentes tarifa_componentes_series state bionic_updating_options Grupos Monedas container iva_group_codigo escritos cl_est cl_con cl_res cl_dev cl_mot department businessReasonEnd>> install/dump/dumpedFixtures.sql
mysqldump --defaults-file=config.production.ini --no-create-info vn2008 accion_dits Gastos Tintas tarifa_componentes tarifa_componentes_series state bionic_updating_options \
Grupos Monedas container iva_group_codigo escritos cl_est cl_con cl_res cl_dev cl_mot department businessReasonEnd>> install/dump/dumpedFixtures.sql
echo "USE \`bi\`;" >> install/dump/dumpedFixtures.sql
mysqldump --defaults-file=connect.ini --no-create-info bi tarifa_componentes tarifa_componentes_series >> install/dump/dumpedFixtures.sql
mysqldump --defaults-file=config.production.ini --no-create-info bi tarifa_componentes tarifa_componentes_series >> install/dump/dumpedFixtures.sql
echo "USE \`cache\`;" >> install/dump/dumpedFixtures.sql
mysqldump --defaults-file=connect.ini --no-create-info cache cache >> install/dump/dumpedFixtures.sql
mysqldump --defaults-file=config.production.ini --no-create-info cache cache >> install/dump/dumpedFixtures.sql
echo "USE \`hedera\`;" >> install/dump/dumpedFixtures.sql
mysqldump --defaults-file=connect.ini --no-create-info hedera tpvError tpvResponse tpvConfig >> install/dump/dumpedFixtures.sql
mysqldump --defaults-file=config.production.ini --no-create-info hedera tpvError tpvResponse tpvConfig >> install/dump/dumpedFixtures.sql
echo "USE \`postgresql\`;" >> install/dump/dumpedFixtures.sql
mysqldump --defaults-file=connect.ini --no-create-info postgresql profile_type media_type professional_category labour_agreement calendar_labour_type workcenter>> install/dump/dumpedFixtures.sql
mysqldump --defaults-file=config.production.ini --no-create-info postgresql profile_type media_type professional_category labour_agreement \
calendar_labour_type workcenter>> install/dump/dumpedFixtures.sql

View File

@ -1,3 +1,4 @@
#!/bin/bash
#IMPORTANT Any changes in this file are to applyed to mirror file export-structure.cmd
mysqldump --defaults-file=connect.ini --default-character-set=utf8 --no-data --comments --triggers --routines --events --databases account util vn2008 vn edi bs bi pbx cache salix vncontrol hedera stock postgresql> install/dump/structure.sql
mysqldump --defaults-file=config.production.ini --default-character-set=utf8 --no-data --comments --triggers --routines --events --databases \
account util vn2008 vn edi bs bi pbx cache salix vncontrol hedera stock postgresql> install/dump/structure.sql

View File

@ -1,4 +1,4 @@
INSERT INTO `salix`.`ACL` (`id`,`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES (149, 'Sip', '*', 'WRITE', 'ALLOW', 'ROLE', 'hr');
INSERT INTO `salix`.`ACL` (`id`,`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES (150, 'Sip', '*', 'READ', 'ALLOW', 'ROLE', 'employee');
INSERT INTO `salix`.`ACL` (`id`,`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES (151, 'Department','*','READ','ALLOW','ROLE','employee');
INSERT INTO `salix`.`ACL` (`id`,`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES (152, 'Department','*','WRITE','ALLOW','ROLE','hr');
-- INSERT INTO `salix`.`ACL` (`id`,`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES (149, 'Sip', '*', 'WRITE', 'ALLOW', 'ROLE', 'hr');
-- INSERT INTO `salix`.`ACL` (`id`,`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES (150, 'Sip', '*', 'READ', 'ALLOW', 'ROLE', 'employee');
-- INSERT INTO `salix`.`ACL` (`id`,`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES (151, 'Department','*','READ','ALLOW','ROLE','employee');
-- INSERT INTO `salix`.`ACL` (`id`,`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES (152, 'Department','*','WRITE','ALLOW','ROLE','hr');

View File

@ -1,4 +0,0 @@
USE `vn`;
CREATE UNIQUE INDEX zoneGeo_lft_IDX USING BTREE ON vn.zoneGeo (lft);
CREATE UNIQUE INDEX zoneGeo_rgt_IDX USING BTREE ON vn.zoneGeo (rgt);

View File

@ -1,16 +1,16 @@
ALTER TABLE `vn`.`itemLog`
CHANGE COLUMN `id` `id` INT(11) NOT NULL AUTO_INCREMENT ,
ADD PRIMARY KEY (`id`);
-- ALTER TABLE `vn`.`itemLog`
-- CHANGE COLUMN `id` `id` INT(11) NOT NULL AUTO_INCREMENT ,
-- ADD PRIMARY KEY (`id`);
ALTER TABLE `vn`.`itemLog`
DROP FOREIGN KEY `itemLogUserFk`;
ALTER TABLE `vn`.`itemLog`
CHANGE COLUMN `id` `id` INT(11) NOT NULL AUTO_INCREMENT ,
CHANGE COLUMN `userFk` `userFk` INT(10) UNSIGNED NULL DEFAULT NULL ;
ALTER TABLE `vn`.`itemLog`
ADD CONSTRAINT `itemLogUserFk`
FOREIGN KEY (`userFk`)
REFERENCES `account`.`user` (`id`)
ON DELETE CASCADE
ON UPDATE CASCADE;
-- ALTER TABLE `vn`.`itemLog`
-- DROP FOREIGN KEY `itemLogUserFk`;
-- ALTER TABLE `vn`.`itemLog`
-- CHANGE COLUMN `id` `id` INT(11) NOT NULL AUTO_INCREMENT ,
-- CHANGE COLUMN `userFk` `userFk` INT(10) UNSIGNED NULL DEFAULT NULL ;
-- ALTER TABLE `vn`.`itemLog`
-- ADD CONSTRAINT `itemLogUserFk`
-- FOREIGN KEY (`userFk`)
-- REFERENCES `account`.`user` (`id`)
-- ON DELETE CASCADE
-- ON UPDATE CASCADE;

View File

@ -0,0 +1,148 @@
USE `vn`;
DROP procedure IF EXISTS `ticketComponentUpdateSale`;
DELIMITER $$
USE `vn`$$
CREATE DEFINER=`root`@`%` PROCEDURE `ticketComponentUpdateSale`(vOption INT)
BEGIN
DECLARE vComponentFk INT;
DECLARE vRenewComponents BOOLEAN;
DECLARE vKeepPrices BOOLEAN;
CASE vOption
WHEN 1 THEN
SET vRenewComponents = TRUE;
SET vKeepPrices = FALSE;
WHEN 2 THEN
SET vComponentFk = 17;
SET vRenewComponents = TRUE;
SET vKeepPrices = TRUE;
WHEN 3 THEN
SET vComponentFk = 37;
SET vRenewComponents = TRUE;
SET vKeepPrices = TRUE;
WHEN 4 THEN
SET vComponentFk = 34;
SET vRenewComponents = TRUE;
SET vKeepPrices = TRUE;
WHEN 5 THEN
SET vComponentFk = 35;
SET vRenewComponents = TRUE;
SET vKeepPrices = TRUE;
WHEN 6 THEN
SET vComponentFk = 36;
SET vRenewComponents = TRUE;
SET vKeepPrices = TRUE;
WHEN 7 THEN
REPLACE INTO saleComponent(saleFk, componentFk, value)
SELECT s.id, 28, ROUND(((s.price * (100 - s.discount) / 100) - SUM(IFNULL(sc.value, 0))) * 0.8, 3)
FROM sale s
JOIN tmp.sale tmps ON tmps.saleFk = s.id
LEFT JOIN saleComponent sc ON sc.saleFk = s.id
AND sc.componentFk NOT IN (28, 29)
GROUP BY s.id;
REPLACE INTO saleComponent(saleFk, componentFk, value)
SELECT s.id, 29, ROUND(((s.price * (100 - s.discount) / 100) - SUM(IFNULL(sc.value, 0))) * 0.2, 3)
FROM sale s
JOIN tmp.sale tmps ON tmps.saleFk = s.id
LEFT JOIN saleComponent sc ON sc.saleFk = s.id
AND sc.componentFk NOT IN (28, 29)
GROUP BY s.id;
SET vRenewComponents = FALSE;
SET vKeepPrices = FALSE;
WHEN 8 THEN
DELETE sc.*
FROM tmp.sale tmps JOIN saleComponent sc ON sc.saleFk = tmps.saleFk;
REPLACE INTO saleComponent(saleFk, componentFk, value)
SELECT s.id, 28, ROUND(((s.price * (100 - s.discount) / 100)), 3)
FROM sale s
JOIN tmp.sale tmps ON tmps.saleFk = s.id;
SET vRenewComponents = FALSE;
SET vKeepPrices = FALSE;
WHEN 9 THEN
SET vRenewComponents = TRUE;
SET vKeepPrices = TRUE;
END CASE;
IF vRenewComponents THEN
DELETE sc.*
FROM tmp.sale tmps
JOIN saleComponent sc ON sc.saleFk = tmps.saleFk
JOIN componentRate cr ON cr.id = sc.componentFk
WHERE cr.isRenewable;
REPLACE INTO saleComponent(saleFk, componentFk, value)
SELECT s.id, tc.componentFk, tc.cost
FROM sale s
JOIN tmp.sale tmps ON tmps.saleFk = s.id
JOIN tmp.ticketComponent tc ON tc.itemFk = s.itemFk AND tc.warehouseFk = tmps.warehouseFk
LEFT JOIN saleComponent sc ON sc.saleFk = s.id
AND sc.componentFk = tc.componentFk
LEFT JOIN componentRate cr ON cr.id = tc.componentFk
WHERE IF(sc.componentFk IS NULL AND NOT cr.isRenewable, FALSE, TRUE);
END IF;
IF vKeepPrices THEN
REPLACE INTO saleComponent(saleFk, componentFk, value)
SELECT s.id, vComponentFk, ROUND((s.price * (100 - s.discount) / 100) - SUM(sc.value), 3) dif
FROM sale s
JOIN tmp.sale tmps ON tmps.saleFk = s.id
LEFT JOIN saleComponent sc ON sc.saleFk = s.id
WHERE sc.saleFk <> vComponentFk
GROUP BY s.id
HAVING dif <> 0;
ELSE
UPDATE sale s
JOIN item i on i.id = s.itemFk
JOIN itemType it on it.id = i.typeFk
JOIN (SELECT SUM(sc.value) sumValue, sc.saleFk
FROM saleComponent sc
JOIN tmp.sale tmps ON tmps.saleFk = sc.saleFk
GROUP BY sc.saleFk) sc ON sc.saleFk = s.id
SET s.price = sumValue
WHERE it.code != 'PRT';
REPLACE INTO saleComponent(saleFk, componentFk, value)
SELECT s.id, 21, ROUND((s.price * (100 - s.discount) / 100) - SUM(value), 3) saleValue
FROM sale s
JOIN tmp.sale tmps ON tmps.saleFk = s.id
LEFT JOIN saleComponent sc ON sc.saleFk = s.id
WHERE sc.componentFk != 21
GROUP BY s.id
HAVING ROUND(saleValue, 4) <> 0;
END IF;
UPDATE sale s
JOIN (
SELECT SUM(sc.value) sumValue, sc.saleFk
FROM saleComponent sc
JOIN tmp.sale tmps ON tmps.saleFk = sc.saleFk
JOIN componentRate cr ON cr.id = sc.componentFk
JOIN componentTypeRate ctr on ctr.id = cr.componentTypeRate AND ctr.base
GROUP BY sc.saleFk) sc ON sc.saleFk = s.id
SET s.priceFixed = sumValue, s.isPriceFixed = 1;
DELETE sc.*
FROM saleComponent sc
JOIN tmp.sale tmps ON tmps.saleFk = sc.saleFk
JOIN sale s on s.id = sc.saleFk
JOIN item i ON i.id = s.itemFk
JOIN itemType it ON it.id = i.typeFk
WHERE it.code = 'PRT';
INSERT INTO saleComponent(saleFk, componentFk, value)
SELECT s.id, 15, s.price
FROM sale s
JOIN tmp.sale tmps ON tmps.saleFk = s.id
JOIN item i ON i.id = s.itemFK
JOIN itemType it ON it.id = i.typeFk
WHERE it.code = 'PRT' AND s.price > 0;
END$$
DELIMITER ;

View File

@ -1,7 +0,0 @@
USE `vn`;
ALTER TABLE `vn`.`zone`
ADD COLUMN `isVolumetric` TINYINT(1) NOT NULL DEFAULT 0 AFTER `bonus`;
ALTER TABLE `vn`.`zone`
DROP INDEX `name_UNIQUE` ;

File diff suppressed because one or more lines are too long

View File

@ -6,6 +6,10 @@ ALTER TABLE `vn2008`.`Consignatarios` AUTO_INCREMENT = 1;
INSERT INTO `util`.`config` ( `dbVersion`, `hasTriggersDisabled`, `environment`)
VALUES ('1.0.0', '0', 'development');
INSERT INTO `account`.`mailConfig` (`id`, `domain`)
VALUES
('1', 'verdnatura.es');
INSERT INTO `account`.`user`(`id`,`name`, `nickname`, `password`,`role`,`active`,`email`)
SELECT id, name, CONCAT(name, 'Nick'),MD5('nightmare'), id, 1, CONCAT(name, '@mydomain.com')
FROM `account`.`role`;
@ -574,7 +578,8 @@ INSERT INTO `vn`.`expedition`(`id`, `agencyModeFk`, `ticketFk`, `isBox`, `create
INSERT INTO `vn`.`packaging`(`id`, `volume`, `width`, `height`, `depth`, `isPackageReturnable`, `created`, `itemFk`, `price`)
VALUES
(1, 0.00, 10, 10, 0, 0, CURDATE(), 6, 1.50),
(2, 100.00, 20, 20, 0, 0, CURDATE(), 7, 1.00);
(2, 100.00, 20, 20, 0, 0, CURDATE(), 7, 1.00),
(94, 140875.00, 49.00, 115.00,25.00, 0, CURDATE(), 71, 0.00);
INSERT INTO `vn`.`ticketPackaging`(`id`, `ticketFk`, `packagingFk`, `quantity`, `created`, `pvp`)
VALUES
@ -590,7 +595,7 @@ INSERT INTO `vn`.`sale`(`id`, `itemFk`, `ticketFk`, `concept`, `quantity`, `pric
(4, 4, 1 , 'Object4 Armor2 2', 20, 3.06, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL -15 DAY)),
(5, 1, 2 , 'Object1 Gem1 5', 10, 9.10, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL -10 DAY)),
(6, 1, 3 , 'Object1 Gem1 5', 15, 6.50, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL -5 DAY)),
(7, 2, 11, 'Object2 Gem2 3', 15, 1.30, 0, 0, 0, CURDATE()),
(7, 2, 11, 'Object2 Gem2 3', 15, 1.46, 0, 0, 0, CURDATE()),
(8, 4, 11, 'Object4 Armor2 2', 10, 3.05, 0, 0, 0, CURDATE()),
(9, 1, 16, 'Object1 Gem1 5', 5, 9.10, 0, 0, 0, CURDATE()),
(10, 2, 16, 'Object2 Gem2 3', 10, 1.07, 0, 0, 0, CURDATE()),
@ -637,12 +642,13 @@ INSERT INTO `vn`.`saleComponent`(`saleFk`, `componentFk`, `value`)
(5, 29, -18.72),
(5, 39, 0.02),
(6, 23, 6.5),
(7, 15, 0.2899),
(7, 15, 0.2839),
(7, 21, 0.166),
(7, 28, 5.6),
(7, 29, -4.6),
(7, 39, 0.01),
(8, 15, 0.0435),
(8, 21, -0.004),
(8, 15, 0.0426),
(8, 21, -0.003),
(8, 28, 20.72),
(8, 29, -19.72),
(8, 37, 2),
@ -1212,5 +1218,3 @@ INSERT INTO `postgresql`.`business_labour`(`business_id`, `notes`, `department_i
(1, NULL, 22, 4, 0, 1, 1, 1, 1),
(2, 'From las friday worker ownes the company 1 hour', 23, 1, 0, 1, 0, 1, 1);
INSERT INTO `account`.`mailConfig` (`id`, `domain`) VALUES ('1', 'verdnatura.es');

File diff suppressed because it is too large Load Diff

View File

@ -73,7 +73,7 @@ describe('Ticket Edit basic data path', () => {
.wait(1900)
.waitToGetProperty(selectors.ticketBasicData.stepTwoTotalPriceDif, 'innerText');
expect(result).toContain('-€208.75');
expect(result).toContain('-€204.25');
});
it(`should then click next to move on to step three`, async() => {

View File

@ -7,6 +7,6 @@ describe('Client get', () => {
expect(result.id).toEqual(101);
expect(result.name).toEqual('Bruce Wayne');
expect(result.debt).toEqual(595.81);
expect(result.debt).toEqual(598.45);
});
});

View File

@ -17,7 +17,7 @@ describe('client summary()', () => {
it('should return a summary object containing debt', async() => {
let result = await app.models.Client.summary(101);
expect(result.debt.debt).toEqual(595.81);
expect(result.debt.debt).toEqual(598.45);
});
it('should return a summary object containing averageInvoiced', async() => {

View File

@ -5,6 +5,6 @@ describe('order getTotalVolume()', () => {
let result = await app.models.Order.getTotalVolume(1);
expect(result.totalVolume).toEqual(0.066);
expect(result.totalBoxes).toBeFalsy();
expect(result.totalBoxes).toEqual(0.5);
});
});

View File

@ -59,6 +59,9 @@ module.exports = Self => {
salesObj.totalUnitPrice += sale.price;
salesObj.totalNewPrice += sale.component.newPrice;
salesObj.totalDifference += sale.component.difference;
salesObj.totalUnitPrice = Math.round(salesObj.totalUnitPrice * 100) / 100;
salesObj.totalNewPrice = Math.round(salesObj.totalNewPrice * 100) / 100;
salesObj.totalDifference = Math.round(salesObj.totalDifference * 100) / 100;
});
return salesObj;

View File

@ -11,7 +11,7 @@ describe('sale priceDifference()', () => {
let result = await app.models.Sale.priceDifference(1, data);
expect(result.totalUnitPrice).toEqual(22.33);
expect(result.totalNewPrice).toEqual(22.29);
expect(result.totalDifference).toEqual(0.8);
expect(result.totalNewPrice).toEqual(22.27);
expect(result.totalDifference).toEqual(0.87);
});
});