diff --git a/db/changes/231601/00-clientWorkerName.sql b/db/changes/231601/00-clientWorkerName.sql
new file mode 100644
index 000000000..676d26691
--- /dev/null
+++ b/db/changes/231601/00-clientWorkerName.sql
@@ -0,0 +1,73 @@
+DELIMITER $$
+CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`clientCreate`(
+ vFirstname VARCHAR(50),
+ vSurnames VARCHAR(50),
+ vFi VARCHAR(9),
+ vAddress TEXT,
+ vPostcode CHAR(5),
+ vCity VARCHAR(25),
+ vProvinceFk SMALLINT(5),
+ vCompanyFk SMALLINT(5),
+ vPhone VARCHAR(11),
+ vEmail VARCHAR(255),
+ vUserFk INT)
+BEGIN
+/**
+ * Create new client
+ *
+ */
+ DECLARE vPayMethodFk INT DEFAULT 4;
+ DECLARE vDueDay INT DEFAULT 5;
+ DECLARE vDefaultCredit DECIMAL(10, 2) DEFAULT 300.00;
+ DECLARE vIsTaxDataChecked TINYINT(1) DEFAULT 1;
+ DECLARE vHasCoreVnl BOOLEAN DEFAULT TRUE;
+ DECLARE vMandateTypeFk INT DEFAULT 2;
+
+ INSERT INTO `client` (
+ id,
+ name,
+ street,
+ fi,
+ phone,
+ email,
+ provinceFk,
+ city,
+ postcode,
+ socialName,
+ payMethodFk,
+ dueDay,
+ credit,
+ isTaxDataChecked,
+ hasCoreVnl,
+ isEqualizated)
+ VALUES (
+ vUserFk,
+ CONCAT(vFirstname, ' ', vSurnames),
+ vAddress,
+ TRIM(vFi),
+ vPhone,
+ vEmail,
+ vProvinceFk,
+ vCity,
+ vPostcode,
+ CONCAT(vSurnames, ' ', vFirstname),
+ vPayMethodFk,
+ vDueDay,
+ vDefaultCredit,
+ vIsTaxDataChecked,
+ vHasCoreVnl,
+ FALSE
+ ) ON duplicate key update
+ payMethodFk = vPayMethodFk,
+ dueDay = vDueDay,
+ credit = vDefaultCredit,
+ isTaxDataChecked = vIsTaxDataChecked,
+ hasCoreVnl = vHasCoreVnl,
+ isActive = TRUE;
+
+ IF (SELECT COUNT(*) FROM mandate WHERE clientFk = vUserFk AND companyFk = vCompanyFk AND mandateTypeFk = vMandateTypeFk) = 0 THEN
+ INSERT INTO mandate (clientFk, companyFk, mandateTypeFk)
+ VALUES (vUserFk, vCompanyFk, vMandateTypeFk);
+ END IF;
+END$$
+DELIMITER ;
\ No newline at end of file
diff --git a/db/changes/231601/00-createWorker.sql b/db/changes/231601/00-createWorker.sql
new file mode 100644
index 000000000..7a128415c
--- /dev/null
+++ b/db/changes/231601/00-createWorker.sql
@@ -0,0 +1,9 @@
+INSERT INTO vn.businessType (code,description)
+ VALUES ('worker','Trabajador');
+
+ALTER TABLE `vn`.`workerConfig` ADD businessTypeFk varchar(100) NULL
+ COMMENT 'Tipo de negocio por defecto al dar de alta un trabajador nuevo';
+
+UPDATE `vn`.`workerConfig`
+ SET businessTypeFk = 'worker'
+ WHERE id = 1;
\ No newline at end of file
diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql
index 4dc7dcafc..aae76afa7 100644
--- a/db/dump/fixtures.sql
+++ b/db/dump/fixtures.sql
@@ -2800,9 +2800,9 @@ INSERT INTO `vn`.`payDemDetail` (`id`, `detail`)
VALUES
(1, 1);
-INSERT INTO `vn`.`workerConfig` (`id`, `businessUpdated`, `roleFk`)
+INSERT INTO `vn`.`workerConfig` (`id`, `businessUpdated`, `roleFk`, `businessTypeFk`)
VALUES
- (1, NULL, 1);
+ (1, NULL, 1, 'worker');
INSERT INTO `vn`.`ticketRefund`(`refundTicketFk`, `originalTicketFk`)
VALUES
diff --git a/modules/client/back/methods/client/summary.js b/modules/client/back/methods/client/summary.js
index caa3d8033..7dab1f68b 100644
--- a/modules/client/back/methods/client/summary.js
+++ b/modules/client/back/methods/client/summary.js
@@ -27,7 +27,6 @@ module.exports = Self => {
Object.assign(myOptions, options);
const summaryObj = await getSummary(models.Client, clientFk, myOptions);
-
summaryObj.mana = await models.Client.getMana(clientFk, myOptions);
summaryObj.debt = await models.Client.getDebt(clientFk, myOptions);
summaryObj.averageInvoiced = await models.Client.getAverageInvoiced(clientFk, myOptions);
@@ -115,6 +114,12 @@ module.exports = Self => {
fields: ['claimingRate', 'priceIncreasing'],
limit: 1
}
+ },
+ {
+ relation: 'businessType',
+ scope: {
+ fields: ['description']
+ }
}
],
where: {id: clientId}
diff --git a/modules/client/front/summary/index.html b/modules/client/front/summary/index.html
index 1b58d42cc..a0d4b918a 100644
--- a/modules/client/front/summary/index.html
+++ b/modules/client/front/summary/index.html
@@ -64,6 +64,9 @@
+
+
diff --git a/modules/client/front/summary/locale/es.yml b/modules/client/front/summary/locale/es.yml
index ca6e96fef..c1fde0c17 100644
--- a/modules/client/front/summary/locale/es.yml
+++ b/modules/client/front/summary/locale/es.yml
@@ -23,3 +23,4 @@ Latest tickets: Últimos tickets
Rating: Clasificación
Value from 1 to 20. The higher the better value: Valor del 1 al 20. Cuanto más alto mejor valoración
Go to grafana: Ir a grafana
+Business type: Tipo de negocio
\ No newline at end of file
diff --git a/modules/worker/back/methods/worker/new.js b/modules/worker/back/methods/worker/new.js
index 144b07f10..16c1a0011 100644
--- a/modules/worker/back/methods/worker/new.js
+++ b/modules/worker/back/methods/worker/new.js
@@ -1,4 +1,4 @@
-/* eslint max-len: ["error", { "code": 130 }]*/
+/* eslint max-len: ["error", { "code": 150 }]*/
const UserError = require('vn-loopback/util/user-error');
module.exports = Self => {
@@ -139,7 +139,7 @@ module.exports = Self => {
if (!client) {
const nickname = args.firstName.concat(' ', args.lastNames);
- const workerConfig = await models.WorkerConfig.findOne({fields: ['roleFk']});
+ const workerConfig = await models.WorkerConfig.findOne({fields: ['roleFk', 'businessTypeFk']});
const [randomPassword] = await models.Worker.rawSql(
'SELECT account.passwordGenerate() as password;'
);
@@ -196,7 +196,7 @@ module.exports = Self => {
client = await models.Client.findById(
user.id,
- {fields: ['id', 'name', 'socialName', 'street', 'city', 'iban', 'bankEntityFk', 'defaultAddressFk']},
+ {fields: ['id', 'name', 'socialName', 'street', 'city', 'iban', 'bankEntityFk', 'defaultAddressFk', 'businessTypeFk']},
myOptions
);
diff --git a/modules/worker/back/models/worker-config.json b/modules/worker/back/models/worker-config.json
index 05cdfef42..bcee74067 100644
--- a/modules/worker/back/models/worker-config.json
+++ b/modules/worker/back/models/worker-config.json
@@ -14,6 +14,9 @@
},
"roleFk": {
"type": "number"
+ },
+ "businessTypeFk": {
+ "type": "string"
}
},
"acls": [