Compare commits

..

29 Commits

Author SHA1 Message Date
Javier Segarra a8b0a7a5b3 Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 6264-renewToken
gitea/salix/pipeline/head There was a failure building this commit Details
2023-12-04 14:46:21 +01:00
Javier Segarra 5656ed7a2b refs #6264 perf: use functions extracted previously 2023-12-04 14:46:05 +01:00
Javier Segarra b9671c0b67 refs #6264 perf: remove files related to token 2023-12-04 14:44:50 +01:00
Jorge Penadés 0b1bbbaaa6 Merge pull request 'refs #5835 rate added' (!1865) from 5835-summaryRate into dev
gitea/salix/pipeline/head This commit looks good Details
Reviewed-on: #1865
Reviewed-by: Javi Gallego <jgallego@verdnatura.es>
2023-12-01 07:22:26 +00:00
Jorge Penadés 611b45bae0 Merge branch 'dev' into 5835-summaryRate
gitea/salix/pipeline/head This commit looks good Details
2023-11-30 15:16:18 +00:00
Alex Moreno ee7dd66ce9 Merge branch 'test' of https://gitea.verdnatura.es/verdnatura/salix into dev
gitea/salix/pipeline/head This commit looks good Details
2023-11-30 12:49:42 +01:00
Alex Moreno 35e74a7635 Merge branch 'master' of https://gitea.verdnatura.es/verdnatura/salix into test
gitea/salix/pipeline/head This commit looks good Details
2023-11-30 12:48:27 +01:00
Alex Moreno ab69dcd4fe refs #6524 fix: fixtures and feat: new changelog format
gitea/salix/pipeline/head This commit looks good Details
2023-11-30 12:32:41 +01:00
Javier Segarra b241efc961 Merge pull request 'refs #6434 feat: improve signIn method' (!1867) from 6434-signInLog_improve_test into test
gitea/salix/pipeline/head This commit looks good Details
Reviewed-on: #1867
Reviewed-by: Alex Moreno <alexm@verdnatura.es>
Reviewed-by: Javi Gallego <jgallego@verdnatura.es>
2023-11-30 11:20:57 +00:00
Alex Moreno 016e4ae37c Merge branch 'master' of https://gitea.verdnatura.es/verdnatura/salix 2023-11-30 12:20:50 +01:00
Carlos Satorres e7d3ef0763 Merge pull request 'refs #6065 remove workcenter' (!1871) from hotfix-hoursFetch into master
gitea/salix/pipeline/head This commit looks good Details
Reviewed-on: #1871
Reviewed-by: Alex Moreno <alexm@verdnatura.es>
Reviewed-by: Javi Gallego <jgallego@verdnatura.es>
2023-11-30 09:20:26 +00:00
Jorge Penadés 6121eeaa3a Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 5835-summaryRate
gitea/salix/pipeline/head This commit looks good Details
2023-11-30 09:44:05 +01:00
Carlos Satorres 9cdb7c3cca refs #6065 remove workcenter
gitea/salix/pipeline/head This commit looks good Details
2023-11-30 09:18:00 +01:00
Javi Gallego 69e555e7b4 Merge pull request '5652-fixtures-fix' (!1870) from 5652-fixtures-fix into dev
gitea/salix/pipeline/head This commit looks good Details
Reviewed-on: #1870
Reviewed-by: Alex Moreno <alexm@verdnatura.es>
2023-11-30 08:13:05 +00:00
Javier Segarra 7611acb8f2 refs #6434 perf rename version folder for sql file
gitea/salix/pipeline/head This commit looks good Details
2023-11-30 08:34:10 +01:00
Javier Segarra 80f8037f58 refs #6434 perf remove version folder for sql file
gitea/salix/pipeline/head This commit looks good Details
2023-11-30 08:23:14 +01:00
Javier Segarra 58855a7cdd refs #6434 perf: remove bad characters method description
gitea/salix/pipeline/head There was a failure building this commit Details
2023-11-30 08:14:56 +01:00
Javier Segarra 6b354a20ad refs #6434 perf: add sql table description
gitea/salix/pipeline/head Build queued... Details
2023-11-30 08:13:28 +01:00
Javier Segarra 138d11b7b0 refs #6434 perf new version folder for sql file
gitea/salix/pipeline/head There was a failure building this commit Details
2023-11-30 08:10:32 +01:00
Javier Segarra 1576ab992d refs #6434 perf: new field in SignInLog table
gitea/salix/pipeline/head This commit looks good Details
2023-11-29 19:36:30 +00:00
Javier Segarra 46774b2e73 refs #6434 perf: new field in SignInLog table
gitea/salix/pipeline/head Build queued... Details
2023-11-29 19:35:37 +00:00
Javier Segarra 9176cdb4cb refs #6434 perf: new field in SignInLog table
gitea/salix/pipeline/head This commit looks good Details
2023-11-29 19:34:00 +00:00
Javier Segarra ed6c0924d7 refs #6434 perf: remove console.error
gitea/salix/pipeline/head Build queued... Details
2023-11-29 19:33:04 +00:00
Javier Segarra 48b82b02ca refs #6434 change param type for signInValidate
gitea/salix/pipeline/head This commit looks good Details
2023-11-29 19:32:10 +00:00
Javi Gallego d246b5f9a8 Merge branch 'dev' into 5652-fixtures-fix
gitea/salix/pipeline/head This commit looks good Details
2023-11-29 15:26:51 +01:00
Javier Segarra 63533459b0 refs #6434 feat: improve signIn method
gitea/salix/pipeline/head This commit looks good Details
2023-11-28 13:22:17 +01:00
Jorge Penadés f2673c3818 refs #5835 rate added
gitea/salix/pipeline/head There was a failure building this commit Details
2023-11-28 12:12:42 +01:00
Javi Gallego 2fa56cce4b fix: refs #5652 arreglo fixtures
gitea/salix/pipeline/head This commit looks good Details
2023-11-28 09:22:00 +01:00
Alex Moreno 37555cbb63 refs #6335 warmFix(ticketAdvance): correct properties
gitea/salix/pipeline/head This commit looks good Details
2023-11-27 15:10:00 +01:00
17 changed files with 87 additions and 69 deletions

View File

@ -14,14 +14,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [2348.01] - 2023-11-30 ## [2348.01] - 2023-11-30
### Added ### Características Añadidas 🆕
- (Ticket -> Adelantar) Permite mover lineas sin generar negativos - **Tickets → Adelantar:** Permite mover lineas sin generar negativos
- (Ticket -> Adelantar) Permite modificar la fecha de los tickets - **Tickets → Adelantar:** Permite modificar la fecha de los tickets
- (Trabajadores -> Notificaciones) Nueva sección (lilium) - **Trabajadores → Notificaciones:** Nueva sección (lilium)
### Changed ### Correcciones 🛠️
### Fixed - **Tickets → RocketChat:** Arreglada detección de cambios
- (Ticket -> RocketChat) Arreglada detección de cambios
## [2346.01] - 2023-11-16 ## [2346.01] - 2023-11-16

View File

@ -1,9 +0,0 @@
const tokenConfig = require('./token-config');
module.exports = async token => {
const accessTokenConfig = await tokenConfig();
const now = Date.now();
const differenceMilliseconds = now - token.created;
const differenceSeconds = Math.floor(differenceMilliseconds / 1000);
return differenceSeconds < accessTokenConfig.renewPeriod - accessTokenConfig.courtesyTime;
};

View File

@ -1,5 +1,6 @@
const UserError = require('vn-loopback/util/user-error'); const UserError = require('vn-loopback/util/user-error');
const tokenConfig = require('./token-config'); const {models} = require('vn-loopback/server/server');
const DEFAULT_COURTESY_TIME = 60; const DEFAULT_COURTESY_TIME = 60;
const handlePromiseLogout = (Self, {id}, courtesyTime = DEFAULT_COURTESY_TIME) => { const handlePromiseLogout = (Self, {id}, courtesyTime = DEFAULT_COURTESY_TIME) => {
new Promise(res => { new Promise(res => {
@ -31,7 +32,7 @@ module.exports = Self => {
const isValid = await Self.validateToken(token); const isValid = await Self.validateToken(token);
if (isValid) throw new UserError(`The renew period has not been exceeded`, 'periodNotExceeded'); if (isValid) throw new UserError(`The renew period has not been exceeded`, 'periodNotExceeded');
const {courtesyTime} = await tokenConfig(); const {courtesyTime} = await models.AccessTokenConfig.findOne({fields: ['renewPeriod', 'courtesyTime']});
// Schedule to remove current token // Schedule to remove current token
handlePromiseLogout(Self, token, courtesyTime); handlePromiseLogout(Self, token, courtesyTime);

View File

@ -49,13 +49,7 @@ module.exports = Self => {
if (vnUser.twoFactor) if (vnUser.twoFactor)
throw new ForbiddenError(null, 'REQUIRES_2FA'); throw new ForbiddenError(null, 'REQUIRES_2FA');
} }
const validateLogin = await Self.validateLogin(user, password); return Self.validateLogin(user, password, ctx);
await Self.app.models.SignInLog.create({
token: validateLogin.token,
userFk: vnUser.id,
ip: ctx.req.ip
});
return validateLogin;
}; };
Self.passExpired = async vnUser => { Self.passExpired = async vnUser => {

View File

@ -22,6 +22,7 @@ describe('VnUser Sign-in()', () => {
expect(signInLog.length).toEqual(1); expect(signInLog.length).toEqual(1);
expect(signInLog[0].userFk).toEqual(accessToken.userId); expect(signInLog[0].userFk).toEqual(accessToken.userId);
expect(signInLog[0].owner).toEqual(true);
expect(login.token).toBeDefined(); expect(login.token).toBeDefined();
await VnUser.logout(ctx.req.accessToken.id); await VnUser.logout(ctx.req.accessToken.id);

View File

@ -1,9 +0,0 @@
const DEFAULT_FIELDS = ['renewPeriod', 'courtesyTime'];
const {models} = require('vn-loopback/server/server');
let currentAccessTokenConfig = null;
module.exports = async(fields = DEFAULT_FIELDS) => {
if (currentAccessTokenConfig) return currentAccessTokenConfig;
const accessTokenConfig = await models.AccessTokenConfig.findOne({fields});
if (!accessTokenConfig) currentAccessTokenConfig = accessTokenConfig;
return accessTokenConfig;
};

View File

@ -1,5 +1,4 @@
const isTokenValid = require('./is-token-valid'); const {models} = require('vn-loopback/server/server');
module.exports = Self => { module.exports = Self => {
Self.remoteMethod('validateToken', { Self.remoteMethod('validateToken', {
description: 'Validates the current logged user token', description: 'Validates the current logged user token',
@ -14,7 +13,12 @@ module.exports = Self => {
}); });
Self.validateToken = async function(token) { Self.validateToken = async function(token) {
const isValid = await isTokenValid(token); const accessTokenConfig = await models.AccessTokenConfig.findOne({fields: ['renewPeriod', 'courtesyTime']});
const now = Date.now();
const differenceMilliseconds = now - token.created;
const differenceSeconds = Math.floor(differenceMilliseconds / 1000);
const isValid = differenceSeconds < accessTokenConfig.renewPeriod - accessTokenConfig.courtesyTime;
return isValid; return isValid;
}; };
}; };

View File

@ -124,20 +124,42 @@ module.exports = function(Self) {
return email.send(); return email.send();
}); });
Self.signInValidate = (user, userToken) => {
/**
* Sign-in validate
* @param {String} user The user
* @param {Object} userToken Options
* @param {Object} token accessToken
* @param {Object} ctx context
*/
Self.signInValidate = async(user, userToken, token, ctx) => {
const [[key, value]] = Object.entries(Self.userUses(user)); const [[key, value]] = Object.entries(Self.userUses(user));
if (userToken[key].toLowerCase().trim() !== value.toLowerCase().trim()) { const isOwner = Self.rawSql(`SELECT ? = ? `, [userToken[key], value]);
console.error('ERROR!!! - Signin with other user', userToken, user); await Self.app.models.SignInLog.create({
userName: user,
token: token.id,
userFk: userToken.id,
ip: ctx.req.ip,
owner: isOwner
});
if (!isOwner)
throw new UserError('Try again'); throw new UserError('Try again');
}
}; };
Self.validateLogin = async function(user, password) { /**
* Validate login params
* @param {String} user The user
* @param {String} password
* @param {Object} ctx context
*/
Self.validateLogin = async function(user, password, ctx) {
const loginInfo = Object.assign({password}, Self.userUses(user)); const loginInfo = Object.assign({password}, Self.userUses(user));
const token = await Self.login(loginInfo, 'user'); const token = await Self.login(loginInfo, 'user');
const userToken = await token.user.get(); const userToken = await token.user.get();
Self.signInValidate(user, userToken);
if (ctx)
await Self.signInValidate(user, userToken, token, ctx);
try { try {
await Self.app.models.Account.sync(userToken.name, password); await Self.app.models.Account.sync(userToken.name, password);
@ -187,8 +209,8 @@ module.exports = function(Self) {
}; };
Self.sharedClass._methods.find(method => method.name == 'changePassword').ctor.settings.acls = Self.sharedClass._methods.find(method => method.name == 'changePassword').ctor.settings.acls =
Self.sharedClass._methods.find(method => method.name == 'changePassword').ctor.settings.acls Self.sharedClass._methods.find(method => method.name == 'changePassword').ctor.settings.acls
.filter(acl => acl.property != 'changePassword'); .filter(acl => acl.property != 'changePassword');
Self.userSecurity = async(ctx, userId, options) => { Self.userSecurity = async(ctx, userId, options) => {
const models = Self.app.models; const models = Self.app.models;
@ -226,10 +248,12 @@ module.exports = function(Self) {
const env = process.env.NODE_ENV; const env = process.env.NODE_ENV;
const liliumUrl = await Self.app.models.Url.findOne({ const liliumUrl = await Self.app.models.Url.findOne({
where: {and: [ where: {
{appName: 'lilium'}, and: [
{environment: env} {appName: 'lilium'},
]} {environment: env}
]
}
}); });
class Mailer { class Mailer {

View File

@ -1,5 +1,4 @@
-- --
-- Table structure for table `signInLog` -- Table structure for table `signInLog`
-- Description: log to debug cross-login error -- Description: log to debug cross-login error
@ -13,7 +12,9 @@ CREATE TABLE `account`.`signInLog` (
`token` varchar(255) NOT NULL , `token` varchar(255) NOT NULL ,
`userFk` int(10) unsigned DEFAULT NULL, `userFk` int(10) unsigned DEFAULT NULL,
`creationDate` timestamp NULL DEFAULT current_timestamp(), `creationDate` timestamp NULL DEFAULT current_timestamp(),
`userName` varchar(30) NOT NULL,
`ip` varchar(100) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL, `ip` varchar(100) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL,
`owner` tinyint(1) DEFAULT 1,
KEY `userFk` (`userFk`), KEY `userFk` (`userFk`),
CONSTRAINT `signInLog_ibfk_1` FOREIGN KEY (`userFk`) REFERENCES `user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE CONSTRAINT `signInLog_ibfk_1` FOREIGN KEY (`userFk`) REFERENCES `user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
); );

View File

@ -5,6 +5,10 @@ SET DEFAULT ROLE 'salix' FOR 'root'@'%';
CREATE SCHEMA IF NOT EXISTS `vn2008`; CREATE SCHEMA IF NOT EXISTS `vn2008`;
CREATE SCHEMA IF NOT EXISTS `tmp`; CREATE SCHEMA IF NOT EXISTS `tmp`;
CREATE ROLE 'salix';
GRANT 'salix' TO 'root'@'%';
SET DEFAULT ROLE 'salix' FOR 'root'@'%';
UPDATE `util`.`config` UPDATE `util`.`config`
SET `environment`= 'development'; SET `environment`= 'development';
@ -366,7 +370,7 @@ INSERT INTO `vn`.`contactChannel`(`id`, `name`)
INSERT INTO `vn`.`client`(`id`,`name`,`fi`,`socialName`,`contact`,`street`,`city`,`postcode`,`phone`,`mobile`,`isRelevant`,`email`,`iban`,`dueDay`,`accountingAccount`,`isEqualizated`,`provinceFk`,`hasToInvoice`,`credit`,`countryFk`,`isActive`,`gestdocFk`,`quality`,`payMethodFk`,`created`,`isToBeMailed`,`contactChannelFk`,`hasSepaVnl`,`hasCoreVnl`,`hasCoreVnh`,`riskCalculated`,`clientTypeFk`, `hasToInvoiceByAddress`,`isTaxDataChecked`,`isFreezed`,`creditInsurance`,`isCreatedAsServed`,`hasInvoiceSimplified`,`salesPersonFk`,`isVies`,`eypbc`, `businessTypeFk`,`typeFk`) INSERT INTO `vn`.`client`(`id`,`name`,`fi`,`socialName`,`contact`,`street`,`city`,`postcode`,`phone`,`mobile`,`isRelevant`,`email`,`iban`,`dueDay`,`accountingAccount`,`isEqualizated`,`provinceFk`,`hasToInvoice`,`credit`,`countryFk`,`isActive`,`gestdocFk`,`quality`,`payMethodFk`,`created`,`isToBeMailed`,`contactChannelFk`,`hasSepaVnl`,`hasCoreVnl`,`hasCoreVnh`,`riskCalculated`,`clientTypeFk`, `hasToInvoiceByAddress`,`isTaxDataChecked`,`isFreezed`,`creditInsurance`,`isCreatedAsServed`,`hasInvoiceSimplified`,`salesPersonFk`,`isVies`,`eypbc`, `businessTypeFk`,`typeFk`)
VALUES VALUES
(1101, 'Bruce Wayne', '84612325V', 'BATMAN', 'Alfred', '1007 MOUNTAIN DRIVE, GOTHAM', 'Gotham', 46460, 1111111111, 222222222, 1, 'BruceWayne@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1, 'florist','loses'), (1101, 'Bruce Wayne', '84612325V', 'BATMAN', 'Alfred', '1007 MOUNTAIN DRIVE, GOTHAM', 'Gotham', 46460, 1111111111, 222222222, 1, 'BruceWayne@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1, 'florist','normal'),
(1102, 'Petter Parker', '87945234L', 'SPIDER MAN', 'Aunt May', '20 INGRAM STREET, QUEENS, USA', 'Gotham', 46460, 1111111111, 222222222, 1, 'PetterParker@mydomain.com', NULL, 0, 1234567890, 0, 2, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1, 'florist','normal'), (1102, 'Petter Parker', '87945234L', 'SPIDER MAN', 'Aunt May', '20 INGRAM STREET, QUEENS, USA', 'Gotham', 46460, 1111111111, 222222222, 1, 'PetterParker@mydomain.com', NULL, 0, 1234567890, 0, 2, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1, 'florist','normal'),
(1103, 'Clark Kent', '06815934E', 'SUPER MAN', 'lois lane', '344 CLINTON STREET, APARTAMENT 3-D', 'Gotham', 46460, 1111111111, 222222222, 1, 'ClarkKent@mydomain.com', NULL, 0, 1234567890, 0, 3, 1, 0, 19, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1, 'florist','normal'), (1103, 'Clark Kent', '06815934E', 'SUPER MAN', 'lois lane', '344 CLINTON STREET, APARTAMENT 3-D', 'Gotham', 46460, 1111111111, 222222222, 1, 'ClarkKent@mydomain.com', NULL, 0, 1234567890, 0, 3, 1, 0, 19, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1, 'florist','normal'),
(1104, 'Tony Stark', '06089160W', 'IRON MAN', 'Pepper Potts', '10880 MALIBU POINT, 90265', 'Gotham', 46460, 1111111111, 222222222, 1, 'TonyStark@mydomain.com', NULL, 0, 1234567890, 0, 2, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1, 'florist','normal'), (1104, 'Tony Stark', '06089160W', 'IRON MAN', 'Pepper Potts', '10880 MALIBU POINT, 90265', 'Gotham', 46460, 1111111111, 222222222, 1, 'TonyStark@mydomain.com', NULL, 0, 1234567890, 0, 2, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1, 'florist','normal'),
@ -376,8 +380,8 @@ INSERT INTO `vn`.`client`(`id`,`name`,`fi`,`socialName`,`contact`,`street`,`city
(1108, 'Charles Xavier', '22641921P', 'PROFESSOR X', 'Beast', '3800 VICTORY PKWY, CINCINNATI, OH 45207, USA', 'Gotham', 46460, 1111111111, 222222222, 1, 'CharlesXavier@mydomain.com', NULL, 0, 1234567890, 0, 5, 1, 300, 13, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, NULL, 0, 0, 19, 0, 1, 'florist','normal'), (1108, 'Charles Xavier', '22641921P', 'PROFESSOR X', 'Beast', '3800 VICTORY PKWY, CINCINNATI, OH 45207, USA', 'Gotham', 46460, 1111111111, 222222222, 1, 'CharlesXavier@mydomain.com', NULL, 0, 1234567890, 0, 5, 1, 300, 13, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 1, NULL, 0, 0, 19, 0, 1, 'florist','normal'),
(1109, 'Bruce Banner', '16104829E', 'HULK', 'Black widow', 'SOMEWHERE IN NEW YORK', 'Gotham', 46460, 1111111111, 222222222, 1, 'BruceBanner@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 0, 0, NULL, 0, 0, 9, 0, 1, 'florist','normal'), (1109, 'Bruce Banner', '16104829E', 'HULK', 'Black widow', 'SOMEWHERE IN NEW YORK', 'Gotham', 46460, 1111111111, 222222222, 1, 'BruceBanner@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 0, 0, NULL, 0, 0, 9, 0, 1, 'florist','normal'),
(1110, 'Jessica Jones', '58282869H', 'JESSICA JONES', 'Luke Cage', 'NYCC 2015 POSTER', 'Gotham', 46460, 1111111111, 222222222, 1, 'JessicaJones@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 0, 0, NULL, 0, 0, NULL, 0, 1, 'florist','normal'), (1110, 'Jessica Jones', '58282869H', 'JESSICA JONES', 'Luke Cage', 'NYCC 2015 POSTER', 'Gotham', 46460, 1111111111, 222222222, 1, 'JessicaJones@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 0, 0, NULL, 0, 0, NULL, 0, 1, 'florist','normal'),
(1111, 'Missing', NULL, 'MISSING MAN', 'Anton', 'THE SPACE, UNIVERSE FAR AWAY', 'Gotham', 46460, 1111111111, 222222222, 1, NULL, NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 4, 0, 1, 0, NULL, 1, 0, NULL, 0, 1, 'others','normal'), (1111, 'Missing', NULL, 'MISSING MAN', 'Anton', 'THE SPACE, UNIVERSE FAR AWAY', 'Gotham', 46460, 1111111111, 222222222, 1, NULL, NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 4, 0, 1, 0, NULL, 1, 0, NULL, 0, 1, 'others','loses'),
(1112, 'Trash', NULL, 'GARBAGE MAN', 'Unknown name', 'NEW YORK CITY, UNDERGROUND', 'Gotham', 46460, 1111111111, 222222222, 1, NULL, NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 4, 0, 1, 0, NULL, 1, 0, NULL, 0, 1, 'others','normal'); (1112, 'Trash', NULL, 'GARBAGE MAN', 'Unknown name', 'NEW YORK CITY, UNDERGROUND', 'Gotham', 46460, 1111111111, 222222222, 1, NULL, NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 4, 0, 1, 0, NULL, 1, 0, NULL, 0, 1, 'others','loses');
INSERT INTO `vn`.`client`(`id`, `name`, `fi`, `socialName`, `contact`, `street`, `city`, `postcode`, `isRelevant`, `email`, `iban`,`dueDay`,`accountingAccount`, `isEqualizated`, `provinceFk`, `hasToInvoice`, `credit`, `countryFk`, `isActive`, `gestdocFk`, `quality`, `payMethodFk`,`created`, `isTaxDataChecked`) INSERT INTO `vn`.`client`(`id`, `name`, `fi`, `socialName`, `contact`, `street`, `city`, `postcode`, `isRelevant`, `email`, `iban`,`dueDay`,`accountingAccount`, `isEqualizated`, `provinceFk`, `hasToInvoice`, `credit`, `countryFk`, `isActive`, `gestdocFk`, `quality`, `payMethodFk`,`created`, `isTaxDataChecked`)
SELECT id, name, CONCAT(RPAD(CONCAT(id,9),8,id),'A'), CONCAT(name, 'Social'), CONCAT(name, 'Contact'), CONCAT(name, 'Street'), 'GOTHAM', 46460, 1, CONCAT(name,'@mydomain.com'), NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1,NULL, 10, 5, util.VN_CURDATE(), 1 SELECT id, name, CONCAT(RPAD(CONCAT(id,9),8,id),'A'), CONCAT(name, 'Social'), CONCAT(name, 'Contact'), CONCAT(name, 'Street'), 'GOTHAM', 46460, 1, CONCAT(name,'@mydomain.com'), NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1,NULL, 10, 5, util.VN_CURDATE(), 1

View File

@ -25,7 +25,15 @@
"type": "number" "type": "number"
}, },
"ip": { "ip": {
"type": "string" "type": "string"
},
"userName": {
"type": "string"
},
"owner": {
"type": "boolean",
"required": true,
"default": true
} }
}, },
"relations": { "relations": {

View File

@ -112,7 +112,7 @@ module.exports = Self => {
{ {
relation: 'taxTypeSage', relation: 'taxTypeSage',
scope: { scope: {
fields: ['vat'] fields: ['vat', 'rate']
} }
}] }]
} }

View File

@ -151,7 +151,7 @@ describe('SalesMonitor salesFilter()', () => {
const result = await models.SalesMonitor.salesFilter(ctx, filter, options); const result = await models.SalesMonitor.salesFilter(ctx, filter, options);
const firstRow = result[0]; const firstRow = result[0];
expect(result.length).toEqual(15); expect(result.length).toEqual(12);
expect(firstRow.alertLevel).not.toEqual(0); expect(firstRow.alertLevel).not.toEqual(0);
await tx.rollback(); await tx.rollback();

View File

@ -68,7 +68,7 @@ describe('ticket filter()', () => {
const filter = {}; const filter = {};
const result = await models.Ticket.filter(ctx, filter, options); const result = await models.Ticket.filter(ctx, filter, options);
expect(result.length).toEqual(9); expect(result.length).toEqual(6);
await tx.rollback(); await tx.rollback();
} catch (e) { } catch (e) {

View File

@ -9,7 +9,7 @@ describe('ticket getSalesPersonMana()', () => {
const mana = await models.Ticket.getSalesPersonMana(1, options); const mana = await models.Ticket.getSalesPersonMana(1, options);
expect(mana).toEqual(73); expect(mana).toEqual(124);
await tx.rollback(); await tx.rollback();
} catch (e) { } catch (e) {

View File

@ -202,9 +202,9 @@ export default class Controller extends Section {
if (!ticket.landed) { if (!ticket.landed) {
const newLanded = await this.getLanded({ const newLanded = await this.getLanded({
shipped: this.$.model.userParams.dateToAdvance, shipped: this.$.model.userParams.dateToAdvance,
addressFk: ticket.addressFk, addressFk: ticket.futureAddressFk,
agencyModeFk: ticket.agencyModeFk, agencyModeFk: ticket.agencyModeFk ?? ticket.futureAgencyModeFk,
warehouseFk: ticket.warehouseFk warehouseFk: ticket.futureWarehouseFk
}); });
if (!newLanded) if (!newLanded)
throw new Error(this.$t(`No delivery zone available for this landing date`)); throw new Error(this.$t(`No delivery zone available for this landing date`));
@ -213,13 +213,13 @@ export default class Controller extends Section {
ticket.zoneFk = newLanded.zoneFk; ticket.zoneFk = newLanded.zoneFk;
} }
const params = { const params = {
clientFk: ticket.clientFk, clientFk: ticket.futureClientFk,
nickname: ticket.nickname, nickname: ticket.nickname,
agencyModeFk: ticket.agencyModeFk ?? ticket.futureAgencyModeFk, agencyModeFk: ticket.agencyModeFk ?? ticket.futureAgencyModeFk,
addressFk: ticket.addressFk, addressFk: ticket.futureAddressFk,
zoneFk: ticket.zoneFk ?? ticket.futureZoneFk, zoneFk: ticket.zoneFk ?? ticket.futureZoneFk,
warehouseFk: ticket.warehouseFk, warehouseFk: ticket.futureWarehouseFk,
companyFk: ticket.companyFk, companyFk: ticket.futureCompanyFk,
shipped: this.$.model.userParams.dateToAdvance, shipped: this.$.model.userParams.dateToAdvance,
landed: ticket.landed, landed: ticket.landed,
isDeleted: false, isDeleted: false,

View File

@ -111,8 +111,10 @@ class Controller extends Section {
dayIndex.setDate(dayIndex.getDate() + 1); dayIndex.setDate(dayIndex.getDate() + 1);
} }
this.fetchHours(); if (this.worker) {
this.getWeekData(); this.fetchHours();
this.getWeekData();
}
} }
set weekTotalHours(totalHours) { set weekTotalHours(totalHours) {
@ -171,8 +173,6 @@ class Controller extends Section {
]} ]}
}; };
this.$.model.applyFilter(filter, params).then(() => { this.$.model.applyFilter(filter, params).then(() => {
if (!this.card.hasWorkCenter) return;
this.getWorkedHours(this.started, this.ended); this.getWorkedHours(this.started, this.ended);
this.getAbsences(); this.getAbsences();
}); });