Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 5914-transferInvoiceOut

This commit is contained in:
Jorge Penadés 2023-09-22 12:05:12 +02:00
commit 6bc9b7b232
2 changed files with 58 additions and 1 deletions

View File

@ -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 ;

View File

@ -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 businessId = 1106;
const workerId = 1106; const workerId = 1106;