Merge pull request 'refs #6159 fixBusinessAfterInsert' (!1719) from 6159-businessAfterInsert into dev
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
Reviewed-on: #1719 Reviewed-by: Javi Gallego <jgallego@verdnatura.es>
This commit is contained in:
commit
13febd30f5
|
@ -0,0 +1,57 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `account`.`account_enable`(vSelf INT)
|
||||
BEGIN
|
||||
/**
|
||||
* Enables a worker's account and sets up email configurations.
|
||||
*/
|
||||
UPDATE user
|
||||
SET active = TRUE
|
||||
WHERE id = vSelf;
|
||||
|
||||
INSERT IGNORE INTO account
|
||||
SET id = vSelf;
|
||||
|
||||
INSERT IGNORE INTO mailAliasAccount (mailAlias, account)
|
||||
SELECT id, vSelf
|
||||
FROM mailAlias
|
||||
WHERE alias = 'general';
|
||||
|
||||
INSERT IGNORE INTO mailForward (account, forwardTo)
|
||||
SELECT vSelf, email
|
||||
FROM user
|
||||
WHERE id = vSelf;
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
||||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`worker_updateBusiness`(vSelf INT)
|
||||
BEGIN
|
||||
/**
|
||||
* Activates an account and configures its email settings.
|
||||
*
|
||||
* @param vSelf account id.
|
||||
*/
|
||||
DECLARE vOldBusinessFk INT;
|
||||
DECLARE vNewBusinessFk INT;
|
||||
|
||||
SELECT businessFk INTO vOldBusinessFk FROM worker WHERE id = vSelf;
|
||||
|
||||
SELECT id INTO vNewBusinessFk
|
||||
FROM business
|
||||
WHERE workerFk = vSelf
|
||||
AND util.VN_CURDATE() BETWEEN started AND IFNULL(ended, util.VN_CURDATE());
|
||||
|
||||
UPDATE worker
|
||||
SET businessFk = vNewBusinessFk
|
||||
WHERE id = vSelf;
|
||||
|
||||
IF NOT (vOldBusinessFk <=> vNewBusinessFk) THEN
|
||||
IF vNewBusinessFk IS NULL THEN
|
||||
CALL workerDisable(vSelf);
|
||||
END IF;
|
||||
IF vOldBusinessFk IS NULL THEN
|
||||
CALL account.account_enable(vSelf);
|
||||
END IF;
|
||||
END IF;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -50,7 +50,7 @@ describe('Worker absences()', () => {
|
|||
}
|
||||
});
|
||||
|
||||
it('should give the same holidays as worked days since the holidays amount matches the amount of days in a year', async() => {
|
||||
it('Should have an equal number of holidays and workdays, as they both total the days in a year', async() => {
|
||||
const businessId = 1106;
|
||||
const workerId = 1106;
|
||||
|
||||
|
|
Loading…
Reference in New Issue