feat: mock dates front and back
This commit is contained in:
parent
5d81cfc121
commit
6b1a6fe44b
|
@ -1910,7 +1910,7 @@ DROP TEMPORARY TABLE IF EXISTS tmp.worker;
|
|||
CREATE TEMPORARY TABLE tmp.worker
|
||||
(PRIMARY KEY (id))
|
||||
ENGINE = MEMORY
|
||||
SELECT w.id, w.id as `workerFk`, 'VNL', CONCAT(YEAR(DATE_ADD(CURDATE(), INTERVAL -1 YEAR)), '-12-25'), CONCAT(YEAR(DATE_ADD(CURDATE(), INTERVAL +1 YEAR)), '-12-25'), CONCAT('E-46-', RPAD(CONCAT(w.id, 9), 8, w.id)), NULL as `notes`, NULL as `departmentFk`, 23, 1 as `workerBusinessProfessionalCategoryFk`, 1 as `calendarTypeFk`, 1 as `isHourlyLabor`, 1 as `workerBusinessAgreementFk`, 1 as `workcenterFk`
|
||||
SELECT w.id, w.id as `workerFk`, 'VNL', CONCAT(YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 YEAR)), '-12-25') as started, CONCAT(YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL +1 YEAR)), '-12-25') as ended, CONCAT('E-46-', RPAD(CONCAT(w.id, 9), 8, w.id)), NULL as `notes`, NULL as `departmentFk`, 23, 1 as `workerBusinessProfessionalCategoryFk`, 1 as `calendarTypeFk`, 1 as `isHourlyLabor`, 1 as `workerBusinessAgreementFk`, 1 as `workcenterFk`
|
||||
FROM `vn`.`worker` `w`;
|
||||
|
||||
INSERT INTO `vn`.`business`(`id`, `workerFk`, `companyCodeFk`, `started`, `ended`, `workerBusiness`, `reasonEndFk`, `notes`, `departmentFk`, `workerBusinessProfessionalCategoryFk`, `calendarTypeFk`, `isHourlyLabor`, `workerBusinessAgreementFk`, `workcenterFk`)
|
||||
|
@ -1920,7 +1920,7 @@ DROP TEMPORARY TABLE IF EXISTS tmp.worker;
|
|||
CREATE TEMPORARY TABLE tmp.worker
|
||||
(PRIMARY KEY (id))
|
||||
ENGINE = MEMORY
|
||||
SELECT '1111' as 'id', w.id as `workerFk`, 'VNL', CONCAT(YEAR(DATE_ADD(CURDATE(), INTERVAL -2 YEAR)), '-12-25'), CONCAT(YEAR(DATE_ADD(CURDATE(), INTERVAL -1 YEAR)), '-12-24'), CONCAT('E-46-', RPAD(CONCAT(w.id, 9), 8, w.id)), NULL as `notes`, NULL as `departmentFk`, 23, 1 as `workerBusinessProfessionalCategoryFk`, 1 as `calendarTypeFk`, 1 as `isHourlyLabor`, 1 as `workerBusinessAgreementFk`, 1 as `workcenterFk`
|
||||
SELECT '1111' as 'id', w.id as `workerFk`, 'VNL', CONCAT(YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -2 YEAR)), '-12-25') as started, CONCAT(YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 YEAR)) as ended, '-12-24'), CONCAT('E-46-', RPAD(CONCAT(w.id, 9), 8, w.id)), NULL as `notes`, NULL as `departmentFk`, 23, 1 as `workerBusinessProfessionalCategoryFk`, 1 as `calendarTypeFk`, 1 as `isHourlyLabor`, 1 as `workerBusinessAgreementFk`, 1 as `workcenterFk`
|
||||
FROM `vn`.`worker` `w`
|
||||
WHERE `w`.`id` = 1109;
|
||||
|
||||
|
@ -2629,7 +2629,7 @@ INSERT INTO `vn`.`machineWorker` (`workerFk`, `machineFk`, `inTimed`, `outTimed`
|
|||
|
||||
INSERT INTO `vn`.`zoneExclusion` (`id`, `zoneFk`, `dated`, `created`, `userFk`)
|
||||
VALUES
|
||||
(1, 1, DATE_ADD(CURDATE(), INTERVAL (IF(DAYOFWEEK(CURDATE())<=7, 7, 14) - DAYOFWEEK(util.VN_CURDATE())) DAY), util.VN_CURDATE(), 100),
|
||||
(1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL (IF(DAYOFWEEK(util.VN_CURDATE())<=7, 7, 14) - DAYOFWEEK(util.VN_CURDATE())) DAY), util.VN_CURDATE(), 100),
|
||||
(2, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL (IF(DAYOFWEEK(util.VN_CURDATE())<=8, 8, 15) - DAYOFWEEK(util.VN_CURDATE())) DAY), util.VN_CURDATE(), 100);
|
||||
|
||||
INSERT INTO `vn`.`zoneExclusionGeo` (`zoneExclusionFk`, `geoFk`)
|
||||
|
|
|
@ -3,18 +3,17 @@ USE `util`;
|
|||
|
||||
DELIMITER ;;
|
||||
DROP FUNCTION IF EXISTS `util`.`mockedDate`;
|
||||
CREATE FUNCTION `util`.`mockedDate`()
|
||||
CREATE FUNCTION `util`.`mockedDate`()
|
||||
RETURNS DATETIME
|
||||
DETERMINISTIC
|
||||
BEGIN
|
||||
RETURN NOW();
|
||||
-- '2022-01-19 08:00:00'
|
||||
RETURN '2022-06-15 11:00:00';
|
||||
END ;;
|
||||
DELIMITER ;
|
||||
|
||||
DELIMITER ;;
|
||||
DROP FUNCTION IF EXISTS `util`.`VN_CURDATE`;
|
||||
CREATE FUNCTION `util`.`VN_CURDATE`()
|
||||
CREATE FUNCTION `util`.`VN_CURDATE`()
|
||||
RETURNS DATE
|
||||
DETERMINISTIC
|
||||
BEGIN
|
||||
|
@ -24,7 +23,7 @@ DELIMITER ;
|
|||
|
||||
DELIMITER ;;
|
||||
DROP FUNCTION IF EXISTS `util`.`VN_CURTIME`;
|
||||
CREATE FUNCTION `util`.`VN_CURTIME`()
|
||||
CREATE FUNCTION `util`.`VN_CURTIME`()
|
||||
RETURNS TIME
|
||||
DETERMINISTIC
|
||||
BEGIN
|
||||
|
@ -34,10 +33,10 @@ DELIMITER ;
|
|||
|
||||
DELIMITER ;;
|
||||
DROP FUNCTION IF EXISTS `util`.`VN_NOW`;
|
||||
CREATE FUNCTION `util`.`VN_NOW`()
|
||||
CREATE FUNCTION `util`.`VN_NOW`()
|
||||
RETURNS DATETIME
|
||||
DETERMINISTIC
|
||||
BEGIN
|
||||
RETURN mockedDate();
|
||||
RETURN mockedDate();
|
||||
END ;;
|
||||
DELIMITER ;
|
||||
DELIMITER ;
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
Date.vnNew = () => {
|
||||
return new Date(Date.vnUTC());
|
||||
};
|
||||
|
||||
Date.vnNow = () => {
|
||||
return new Date(Date.vnUTC()).getTime();
|
||||
};
|
||||
|
||||
Date.vnUTC = () => {
|
||||
const env = process.env.NODE_ENV;
|
||||
if (!env || env === 'development')
|
||||
return new Date(Date.UTC(2022, 5, 15, 11));
|
||||
|
||||
return new Date(Date.UTC());
|
||||
};
|
|
@ -10,3 +10,4 @@ import './week-days';
|
|||
import './report';
|
||||
import './email';
|
||||
import './file';
|
||||
import './date';
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
<body>
|
||||
<vn-app></vn-app>
|
||||
<script type="text/javascript"
|
||||
src="/routes.js?<%= new Date().getTime() %>">
|
||||
src="/routes.js">
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
Date.vnNew = () => {
|
||||
return new Date(Date.vnUTC());
|
||||
};
|
||||
|
||||
Date.vnNow = () => {
|
||||
return new Date(Date.vnUTC()).getTime();
|
||||
};
|
||||
|
||||
Date.vnUTC = () => {
|
||||
const env = process.env.NODE_ENV;
|
||||
if (!env || env === 'development')
|
||||
return new Date(Date.UTC(2000, 0, 1, 11));
|
||||
|
||||
return new Date(Date.UTC());
|
||||
};
|
|
@ -36,6 +36,17 @@ window.ngModule = function(moduleName, ...args) {
|
|||
|
||||
if (args.length)
|
||||
fns = fns.concat(args);
|
||||
Date.vnUTC = () => {
|
||||
return new Date(Date.UTC(2000, 0, 1, 11));
|
||||
};
|
||||
|
||||
Date.vnNew = () => {
|
||||
return new Date(Date.UTC(2000, 0, 1, 11));
|
||||
};
|
||||
|
||||
Date.vnNow = () => {
|
||||
return new Date(Date.UTC(2000, 0, 1, 11)).getTime();
|
||||
};
|
||||
return angular.mock.module(...fns);
|
||||
};
|
||||
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
module.exports = () => {
|
||||
Date.vnNew = () => {
|
||||
return new Date(Date.vnUTC());
|
||||
};
|
||||
|
||||
Date.vnNow = () => {
|
||||
return new Date(Date.vnUTC()).getTime();
|
||||
};
|
||||
|
||||
Date.vnUTC = () => {
|
||||
const env = process.env.NODE_ENV;
|
||||
if (!env || env === 'development')
|
||||
return new Date(Date.UTC(2022, 5, 15, 11));
|
||||
|
||||
return new Date(Date.UTC());
|
||||
};
|
||||
};
|
Loading…
Reference in New Issue