diff --git a/db/changes/232801/00-client_create.sql b/db/changes/232801/00-client_create.sql index 0728ba05e..d21094dad 100644 --- a/db/changes/232801/00-client_create.sql +++ b/db/changes/232801/00-client_create.sql @@ -1,11 +1,11 @@ -DROP PROCEDURE IF EXISTS vn.clientCreate; +DROP PROCEDURE IF EXISTS `vn`.`clientCreate`; DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`client_create`( vFirstname VARCHAR(50), - vSurnames VARCHAR(50), - vFi VARCHAR(9), - vAddress TEXT, + vSurnames VARCHAR(50), + vFi VARCHAR(9), + vAddress TEXT, vPostcode CHAR(5), vCity VARCHAR(25), vProvinceFk SMALLINT(5), @@ -61,7 +61,7 @@ BEGIN provinceFk = vProvinceFk, city = vCity, postcode = vPostcode, - socialName = CONCAT(vSurnames, ' ', vFirstname), + socialName = CONCAT(vSurnames, ' ', vFirstname), payMethodFk = vPayMethodFk, dueDay = vDueDay, credit = vDefaultCredit, @@ -75,14 +75,14 @@ BEGIN isTaxDataChecked = vIsTaxDataChecked, hasCoreVnl = vHasCoreVnl, isActive = TRUE; - + INSERT INTO mandate (clientFk, companyFk, mandateTypeFk) SELECT vUserFk, vCompanyFk, vMandateTypeFk WHERE NOT EXISTS ( - SELECT id - FROM mandate - WHERE clientFk = vUserFk - AND companyFk = vCompanyFk + SELECT id + FROM mandate + WHERE clientFk = vUserFk + AND companyFk = vCompanyFk AND mandateTypeFk = vMandateTypeFk ); END$$ diff --git a/db/changes/232801/00-client_create2.sql b/db/changes/232801/00-client_create2.sql index 8ba4e78e5..f2e660351 100644 --- a/db/changes/232801/00-client_create2.sql +++ b/db/changes/232801/00-client_create2.sql @@ -1,17 +1,17 @@ -ALTER TABLE vn.clientConfig ADD defaultPayMethodFk tinyint(3) unsigned NULL; -ALTER TABLE vn.clientConfig ADD defaultDueDay int unsigned NULL; -ALTER TABLE vn.clientConfig ADD defaultCredit decimal(10, 2) NULL; -ALTER TABLE vn.clientConfig ADD defaultIsTaxDataChecked tinyint(1) NULL; -ALTER TABLE vn.clientConfig ADD defaultHasCoreVnl boolean NULL; -ALTER TABLE vn.clientConfig ADD defaultMandateTypeFk smallint(5) NULL; -ALTER TABLE vn.clientConfig ADD CONSTRAINT clientNewConfigPayMethod_FK FOREIGN KEY (dafaultPayMethodFk) REFERENCES vn.payMethod(id); -ALTER TABLE vn.clientConfig ADD CONSTRAINT clientNewConfigMandateType_FK FOREIGN KEY (defaultMandateTypeFk) REFERENCES vn.mandateType(id); +ALTER TABLE `vn`.`clientConfig` ADD defaultPayMethodFk tinyint(3) unsigned NULL; +ALTER TABLE `vn`.`clientConfig` ADD defaultDueDay int unsigned NULL; +ALTER TABLE `vn`.`clientConfig` ADD defaultCredit decimal(10, 2) NULL; +ALTER TABLE `vn`.`clientConfig` ADD defaultIsTaxDataChecked tinyint(1) NULL; +ALTER TABLE `vn`.`clientConfig` ADD defaultHasCoreVnl boolean NULL; +ALTER TABLE `vn`.`clientConfig` ADD defaultMandateTypeFk smallint(5) NULL; +ALTER TABLE `vn`.`clientConfig` ADD CONSTRAINT clientNewConfigPayMethod_FK FOREIGN KEY (defaultPayMethodFk) REFERENCES vn.payMethod(id); +ALTER TABLE `vn`.`clientConfig` ADD CONSTRAINT clientNewConfigMandateType_FK FOREIGN KEY (defaultMandateTypeFk) REFERENCES vn.mandateType(id); -UPDATE vn.clientConfig +UPDATE `vn`.`clientConfig` SET defaultPayMethodFk = 4, defaultDueDay = 5, defaultCredit = 300.0, defaultIsTaxDataChecked = 1, defaultHasCoreVnl = 1, defaultMandateTypeFk = 2 - WHERE id = 1; \ No newline at end of file + WHERE id = 1; diff --git a/db/changes/232801/00-department.sql b/db/changes/232801/00-department.sql index d9a91ee30..3dcb8501d 100644 --- a/db/changes/232801/00-department.sql +++ b/db/changes/232801/00-department.sql @@ -5,7 +5,7 @@ drop trigger `vn`.`department_afterUpdate`; DELIMITER $$ $$ -create definer = root@localhost trigger department_afterUpdate +create definer = root@localhost trigger `vn`.`department_afterUpdate` after update on department for each row diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 14c9fba5d..475a4992f 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -385,6 +385,12 @@ INSERT INTO `vn`.`clientManaCache`(`clientFk`, `mana`, `dated`) (1103, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)), (1104, -30, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)); +INSERT INTO `vn`.`mandateType`(`id`, `name`) + VALUES + (1, 'B2B'), + (2, 'CORE'), + (3, 'LCR'); + INSERT INTO `vn`.`clientConfig`(`id`, `riskTolerance`, `maxCreditRows`, `maxPriceIncreasingRatio`, `riskScope`, `defaultPayMethodFk`, `defaultDueDay`, `defaultCredit`, `defaultIsTaxDataChecked`, `defaultHasCoreVnl`, `defaultMandateTypeFk`) VALUES (1, 200, 10, 0.25, 2, 4, 5, 300.00, 1, 1, 2); @@ -828,12 +834,6 @@ INSERT INTO `vn`.`greuge`(`id`, `clientFk`, `description`, `amount`, `shipped`, (11, 1101, 'some heritage charges', -15.99, DATE_ADD(util.VN_CURDATE(), INTERVAL 1 MONTH), util.VN_CURDATE(), 5, 1), (12, 1101, 'some miscellaneous charges', 58.00, DATE_ADD(util.VN_CURDATE(), INTERVAL 1 MONTH), util.VN_CURDATE(), 6, 1); -INSERT INTO `vn`.`mandateType`(`id`, `name`) - VALUES - (1, 'B2B'), - (2, 'CORE'), - (3, 'LCR'); - INSERT INTO `vn`.`mandate`(`id`, `clientFk`, `companyFk`, `code`, `created`, `mandateTypeFk`) VALUES (1, 1102, 442, '1-1', util.VN_CURDATE(), 2); @@ -2597,7 +2597,7 @@ UPDATE `vn`.`ticket` UPDATE `vn`.`ticket` SET refFk = 'A1111111' - WHERE id = 6; + WHERE id = 6; INSERT INTO `vn`.`zoneAgencyMode`(`id`, `agencyModeFk`, `zoneFk`) VALUES