Merge branch 'dev' into 7937-claimAgile
gitea/salix/pipeline/pr-dev This commit looks good
Details
gitea/salix/pipeline/pr-dev This commit looks good
Details
This commit is contained in:
commit
d1053642e9
|
@ -1,4 +1,5 @@
|
||||||
[mysqld]
|
[mysqld]
|
||||||
|
bind-address = 0.0.0.0
|
||||||
log-bin = bin.log
|
log-bin = bin.log
|
||||||
max_binlog_size = 1GB
|
max_binlog_size = 1GB
|
||||||
binlog_row_image = noblob
|
binlog_row_image = noblob
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION util.mockTime()
|
CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION util.mockTime()
|
||||||
RETURNS DATETIME
|
RETURNS DATETIME
|
||||||
DETERMINISTIC
|
DETERMINISTIC
|
||||||
BEGIN
|
BEGIN
|
||||||
|
@ -8,7 +8,7 @@ END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION util.mockUtcTime()
|
CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION util.mockUtcTime()
|
||||||
RETURNS DATETIME
|
RETURNS DATETIME
|
||||||
DETERMINISTIC
|
DETERMINISTIC
|
||||||
BEGIN
|
BEGIN
|
||||||
|
|
|
@ -1,26 +0,0 @@
|
||||||
DELIMITER $$
|
|
||||||
CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `util`.`mockTimeBase`(vIsUtc BOOL)
|
|
||||||
RETURNS datetime
|
|
||||||
DETERMINISTIC
|
|
||||||
BEGIN
|
|
||||||
/**
|
|
||||||
* Returns the date formatted to utc if vIsUtc or config.mocTz if not
|
|
||||||
*
|
|
||||||
* @param vIsUtc If date must be returned as UTC format
|
|
||||||
* @return The formatted mock time
|
|
||||||
*/
|
|
||||||
DECLARE vMockUtcTime DATETIME;
|
|
||||||
DECLARE vMockTz VARCHAR(255);
|
|
||||||
|
|
||||||
SELECT mockUtcTime, mockTz
|
|
||||||
INTO vMockUtcTime, vMockTz
|
|
||||||
FROM config
|
|
||||||
LIMIT 1;
|
|
||||||
|
|
||||||
IF vIsUtc OR vMockTz IS NULL THEN
|
|
||||||
RETURN vMockUtcTime;
|
|
||||||
ELSE
|
|
||||||
RETURN CONVERT_TZ(vMockUtcTime, '+00:00', vMockTz);
|
|
||||||
END IF;
|
|
||||||
END$$
|
|
||||||
DELIMITER ;
|
|
|
@ -4,22 +4,10 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `util`.`mockUtcTime`()
|
||||||
DETERMINISTIC
|
DETERMINISTIC
|
||||||
BEGIN
|
BEGIN
|
||||||
/**
|
/**
|
||||||
* Returns the UTC datetime in mockTime format or timeStamp depending on config table
|
* Returns current UTC dateTime
|
||||||
*
|
*
|
||||||
* @return The UTC datetime format
|
* @return The UTC datetime format
|
||||||
*/
|
*/
|
||||||
-- FIXME: #5041 Commented because there is slowness when querying a table
|
|
||||||
/*
|
|
||||||
DECLARE vMockEnabled BOOL;
|
|
||||||
|
|
||||||
SELECT mockEnabled INTO vMockEnabled FROM config LIMIT 1;
|
|
||||||
|
|
||||||
IF vMockEnabled THEN
|
|
||||||
RETURN mockTimeBase(TRUE);
|
|
||||||
ELSE
|
|
||||||
RETURN UTC_TIMESTAMP();
|
|
||||||
END IF;
|
|
||||||
*/
|
|
||||||
RETURN UTC_TIMESTAMP();
|
RETURN UTC_TIMESTAMP();
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -258,5 +258,6 @@
|
||||||
"clonedFromTicketWeekly": ", that is a cloned sale from ticket {{ ticketWeekly }}",
|
"clonedFromTicketWeekly": ", that is a cloned sale from ticket {{ ticketWeekly }}",
|
||||||
"negativeReplaced": "Replaced item [#{{oldItemId}}]({{{oldItemUrl}}}) {{oldItem}} with [#{{newItemId}}]({{{newItemUrl}}}) {{newItem}} from ticket [{{ticketId}}]({{{ticketUrl}}})",
|
"negativeReplaced": "Replaced item [#{{oldItemId}}]({{{oldItemUrl}}}) {{oldItem}} with [#{{newItemId}}]({{{newItemUrl}}}) {{newItem}} from ticket [{{ticketId}}]({{{ticketUrl}}})",
|
||||||
"The tag and priority can't be repeated": "The tag and priority can't be repeated",
|
"The tag and priority can't be repeated": "The tag and priority can't be repeated",
|
||||||
"duplicateWarehouse": "The introduced warehouse already exists"
|
"The introduced warehouse already exists": "The introduced warehouse already exists",
|
||||||
|
"The code already exists": "The code already exists"
|
||||||
}
|
}
|
||||||
|
|
|
@ -399,5 +399,6 @@
|
||||||
"Price cannot be blank": "El precio no puede estar en blanco",
|
"Price cannot be blank": "El precio no puede estar en blanco",
|
||||||
"clonedFromTicketWeekly": ", que es una linea clonada del ticket {{ticketWeekly}}",
|
"clonedFromTicketWeekly": ", que es una linea clonada del ticket {{ticketWeekly}}",
|
||||||
"negativeReplaced": "Sustituido el articulo [#{{oldItemId}}]({{{oldItemUrl}}}) {{oldItem}} por [#{{newItemId}}]({{{newItemUrl}}}) {{newItem}} del ticket [{{ticketId}}]({{{ticketUrl}}})",
|
"negativeReplaced": "Sustituido el articulo [#{{oldItemId}}]({{{oldItemUrl}}}) {{oldItem}} por [#{{newItemId}}]({{{newItemUrl}}}) {{newItem}} del ticket [{{ticketId}}]({{{ticketUrl}}})",
|
||||||
"duplicateWarehouse": "El almacén seleccionado ya existe en la zona"
|
"The introduced warehouse already exists": "El almacén seleccionado ya existe en la zona",
|
||||||
|
"The code already exists": "El código ya existe"
|
||||||
}
|
}
|
|
@ -43,6 +43,17 @@ module.exports = function(Self) {
|
||||||
password: String(Math.random() * 100000000000000)
|
password: String(Math.random() * 100000000000000)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const supplier = await models.Supplier.findOne({
|
||||||
|
where: {nif: data.fi}
|
||||||
|
});
|
||||||
|
|
||||||
|
const role = supplier ? await models.VnRole.findOne({
|
||||||
|
where: {name: 'supplier'}
|
||||||
|
}) : null;
|
||||||
|
|
||||||
|
if (role)
|
||||||
|
user.roleFk = role.id;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const province = await models.Province.findOne({
|
const province = await models.Province.findOne({
|
||||||
where: {id: data.provinceFk},
|
where: {id: data.provinceFk},
|
||||||
|
|
|
@ -48,11 +48,11 @@ describe('Client Create', () => {
|
||||||
expect(error.message).toEqual('An email is necessary');
|
expect(error.message).toEqual('An email is necessary');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should create a new account with dailyInvoice', async() => {
|
it('should create a new account with dailyInvoice and role supplier', async() => {
|
||||||
const newAccount = {
|
const newAccount = {
|
||||||
userName: 'deadpool',
|
userName: 'deadpool',
|
||||||
email: 'deadpool@marvel.com',
|
email: 'deadpool@marvel.com',
|
||||||
fi: '16195279J',
|
fi: '07972486L',
|
||||||
name: 'Wade',
|
name: 'Wade',
|
||||||
socialName: 'DEADPOOL MARVEL',
|
socialName: 'DEADPOOL MARVEL',
|
||||||
street: 'WALL STREET',
|
street: 'WALL STREET',
|
||||||
|
@ -61,7 +61,6 @@ describe('Client Create', () => {
|
||||||
provinceFk: 1
|
provinceFk: 1
|
||||||
};
|
};
|
||||||
|
|
||||||
try {
|
|
||||||
const province = await models.Province.findById(newAccount.provinceFk, {
|
const province = await models.Province.findById(newAccount.provinceFk, {
|
||||||
fields: ['id', 'name', 'autonomyFk'],
|
fields: ['id', 'name', 'autonomyFk'],
|
||||||
include: {
|
include: {
|
||||||
|
@ -71,7 +70,9 @@ describe('Client Create', () => {
|
||||||
|
|
||||||
const client = await models.Client.createWithUser(newAccount, options);
|
const client = await models.Client.createWithUser(newAccount, options);
|
||||||
const account = await models.VnUser.findOne({where: {name: newAccount.userName}}, options);
|
const account = await models.VnUser.findOne({where: {name: newAccount.userName}}, options);
|
||||||
|
const supplierRole = await models.VnRole.findOne({where: {name: 'supplier'}}, options);
|
||||||
|
|
||||||
|
expect(account.roleFk).toEqual(supplierRole.id);
|
||||||
expect(province.autonomy().hasDailyInvoice).toBeTruthy();
|
expect(province.autonomy().hasDailyInvoice).toBeTruthy();
|
||||||
expect(account.name).toEqual(newAccount.userName);
|
expect(account.name).toEqual(newAccount.userName);
|
||||||
expect(client.id).toEqual(account.id);
|
expect(client.id).toEqual(account.id);
|
||||||
|
@ -81,13 +82,9 @@ describe('Client Create', () => {
|
||||||
expect(client.socialName).toEqual(newAccount.socialName);
|
expect(client.socialName).toEqual(newAccount.socialName);
|
||||||
expect(client.businessTypeFk).toEqual(newAccount.businessTypeFk);
|
expect(client.businessTypeFk).toEqual(newAccount.businessTypeFk);
|
||||||
expect(client.hasDailyInvoice).toBeTruthy();
|
expect(client.hasDailyInvoice).toBeTruthy();
|
||||||
} catch (e) {
|
|
||||||
await tx.rollback();
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should create a new account without dailyInvoice', async() => {
|
it('should create a new account without dailyInvoice and role customer', async() => {
|
||||||
const newAccount = {
|
const newAccount = {
|
||||||
userName: 'deadpool',
|
userName: 'deadpool',
|
||||||
email: 'deadpool@marvel.com',
|
email: 'deadpool@marvel.com',
|
||||||
|
@ -100,7 +97,6 @@ describe('Client Create', () => {
|
||||||
provinceFk: 3
|
provinceFk: 3
|
||||||
};
|
};
|
||||||
|
|
||||||
try {
|
|
||||||
const province = await models.Province.findById(newAccount.provinceFk, {
|
const province = await models.Province.findById(newAccount.provinceFk, {
|
||||||
fields: ['id', 'name', 'autonomyFk'],
|
fields: ['id', 'name', 'autonomyFk'],
|
||||||
include: {
|
include: {
|
||||||
|
@ -109,13 +105,12 @@ describe('Client Create', () => {
|
||||||
}, options);
|
}, options);
|
||||||
|
|
||||||
const client = await models.Client.createWithUser(newAccount, options);
|
const client = await models.Client.createWithUser(newAccount, options);
|
||||||
|
const vnUser = await models.VnUser.findOne({where: {name: newAccount.userName}}, options);
|
||||||
|
const customerRole = await models.VnRole.findOne({where: {name: 'customer'}}, options);
|
||||||
|
|
||||||
|
expect(vnUser.roleFk).toEqual(customerRole.id);
|
||||||
expect(province.autonomy.hasDailyInvoice).toBeFalsy();
|
expect(province.autonomy.hasDailyInvoice).toBeFalsy();
|
||||||
expect(client.hasDailyInvoice).toBeFalsy();
|
expect(client.hasDailyInvoice).toBeFalsy();
|
||||||
} catch (e) {
|
|
||||||
await tx.rollback();
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not be able to create a user if exists', async() => {
|
it('should not be able to create a user if exists', async() => {
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
module.exports = Self => {
|
||||||
|
Self.validatesUniquenessOf('code', {
|
||||||
|
message: `The code already exists`
|
||||||
|
});
|
||||||
|
};
|
|
@ -1,4 +1,8 @@
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
require('../methods/shelving/getSummary')(Self);
|
require('../methods/shelving/getSummary')(Self);
|
||||||
require('../methods/shelving/addLog')(Self);
|
require('../methods/shelving/addLog')(Self);
|
||||||
|
|
||||||
|
Self.validatesUniquenessOf('code', {
|
||||||
|
message: `The code already exists`
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -3,7 +3,7 @@ let UserError = require('vn-loopback/util/user-error');
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
Self.rewriteDbError(function(err) {
|
Self.rewriteDbError(function(err) {
|
||||||
if (err.code === 'ER_DUP_ENTRY')
|
if (err.code === 'ER_DUP_ENTRY')
|
||||||
return new UserError(`duplicateWarehouse`);
|
return new UserError(`The introduced warehouse already exists`);
|
||||||
return err;
|
return err;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -60,7 +60,7 @@
|
||||||
"@babel/register": "^7.7.7",
|
"@babel/register": "^7.7.7",
|
||||||
"@commitlint/cli": "^19.2.1",
|
"@commitlint/cli": "^19.2.1",
|
||||||
"@commitlint/config-conventional": "^19.1.0",
|
"@commitlint/config-conventional": "^19.1.0",
|
||||||
"@verdnatura/myt": "^1.6.12",
|
"@verdnatura/myt": "^1.6.13",
|
||||||
"angular-mocks": "^1.7.9",
|
"angular-mocks": "^1.7.9",
|
||||||
"babel-jest": "^26.0.1",
|
"babel-jest": "^26.0.1",
|
||||||
"babel-loader": "^8.2.4",
|
"babel-loader": "^8.2.4",
|
||||||
|
|
|
@ -143,8 +143,8 @@ devDependencies:
|
||||||
specifier: ^19.1.0
|
specifier: ^19.1.0
|
||||||
version: 19.1.0
|
version: 19.1.0
|
||||||
'@verdnatura/myt':
|
'@verdnatura/myt':
|
||||||
specifier: ^1.6.12
|
specifier: ^1.6.13
|
||||||
version: 1.6.12
|
version: 1.6.13
|
||||||
angular-mocks:
|
angular-mocks:
|
||||||
specifier: ^1.7.9
|
specifier: ^1.7.9
|
||||||
version: 1.8.3
|
version: 1.8.3
|
||||||
|
@ -2846,8 +2846,8 @@ packages:
|
||||||
dev: false
|
dev: false
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
/@verdnatura/myt@1.6.12:
|
/@verdnatura/myt@1.6.13:
|
||||||
resolution: {integrity: sha512-t/SiDuQW9KJkcjhwQ9AkrcoTwghxQ7IyQ56e+88eYdoMi24l6bQGF0wHzMaIPRfQAoR8hqgfMOief4OAqW4Iqw==}
|
resolution: {integrity: sha512-Qw5cfXa2FnjrMBbzP3InYc3vIjbNhyHhmle12Y7FaYFeYE+CXlerryuMqtcoe4+9PsCqwDCKlW37YKmipy2cnQ==}
|
||||||
hasBin: true
|
hasBin: true
|
||||||
dependencies:
|
dependencies:
|
||||||
'@sqltools/formatter': 1.2.5
|
'@sqltools/formatter': 1.2.5
|
||||||
|
|
Loading…
Reference in New Issue