diff --git a/db/routines/bs/procedures/manaCustomerUpdate.sql b/db/routines/bs/procedures/manaCustomerUpdate.sql index b77ddc1fd..e9ba70423 100644 --- a/db/routines/bs/procedures/manaCustomerUpdate.sql +++ b/db/routines/bs/procedures/manaCustomerUpdate.sql @@ -5,97 +5,90 @@ BEGIN DECLARE vFromDated DATE; DECLARE vForDeleteDated DATE; DECLARE vManaId INT; - DECLARE vManaAutoId INT; - DECLARE vClaimManaId INT; - DECLARE vManaBankId INT; - DECLARE vManaGreugeTypeId INT; - DECLARE vManaFromDays INT; - DECLARE vManaToDays INT; + DECLARE vManaAutoId INT; + DECLARE vClaimManaId INT; + DECLARE vManaBankId INT; + DECLARE vManaGreugeTypeId INT; + DECLARE vManaFromDays INT; + DECLARE vManaToDays INT; - SELECT id INTO vManaId - FROM vn.component WHERE code = 'mana'; + SELECT id INTO vManaId + FROM vn.component WHERE code = 'mana'; - SELECT id INTO vManaAutoId + SELECT id INTO vManaAutoId FROM vn.component WHERE code = 'autoMana'; SELECT id INTO vClaimManaId FROM vn.component WHERE code = 'manaClaim'; - SELECT id INTO vManaBankId + SELECT id INTO vManaBankId FROM vn.accounting WHERE code = 'mana'; - SELECT id INTO vManaGreugeTypeId + SELECT id INTO vManaGreugeTypeId FROM vn.greugeType WHERE code = 'mana'; - SELECT manaFromDays, manaToDays - INTO vManaFromDays, vManaToDays - FROM vn.salespersonConfig; + SELECT manaFromDays, manaToDays + INTO vManaFromDays, vManaToDays + FROM vn.salespersonConfig; - SELECT MAX(dated) - INTO vFromDated - FROM vn.clientManaCache; + SELECT MAX(dated) INTO vFromDated + FROM vn.clientManaCache; - DELETE - FROM vn.clientManaCache - WHERE dated = vFromDated; - - SELECT MAX(dated) - INTO vFromDated - FROM vn.clientManaCache; - - IF ISNULL(vFromDated) THEN - SELECT manaDateFrom - INTO vFromDated - FROM vn.salespersonConfig; - END IF; + DELETE FROM vn.clientManaCache + WHERE dated = vFromDated; + + SELECT MAX(dated) INTO vFromDated + FROM vn.clientManaCache; + + IF vFromDated IS NULL THEN + SELECT manaDateFrom + INTO vFromDated + FROM vn.salespersonConfig; + END IF; - WHILE vFromDated + INTERVAL vManaToDays DAY < util.VN_CURDATE() DO - SELECT - vFromDated + INTERVAL vManaToDays DAY, - vFromDated - INTERVAL vManaFromDays DAY - INTO - vToDated, - vForDeleteDated; - - DELETE FROM vn.clientManaCache - WHERE dated <= vForDeleteDated; + WHILE vFromDated + INTERVAL vManaToDays DAY < util.VN_CURDATE() DO + SELECT vFromDated + INTERVAL vManaToDays DAY, + vFromDated - INTERVAL vManaFromDays DAY + INTO vToDated, + vForDeleteDated; + + DELETE FROM vn.clientManaCache + WHERE dated <= vForDeleteDated; - INSERT INTO vn.clientManaCache(clientFk, mana, dated) - SELECT - Id_Cliente, - SUM(mana), - vToDated - FROM - ( - SELECT a.clientFk Id_Cliente, s.quantity * sc.value as mana - FROM vn.ticket t - JOIN vn.address a ON a.id = t.addressFk - JOIN vn.sale s on s.ticketFk = t.id - JOIN vn.saleComponent sc on sc.saleFk = s.id - WHERE sc.componentFk IN (vManaAutoId, vManaId, vClaimManaId) - AND t.shipped > vFromDated - AND date(t.shipped) <= vToDated - UNION ALL - SELECT clientFk, - amountPaid - FROM vn.receipt - WHERE bankFk = vManaBankId - AND payed > vFromDated - AND payed <= vToDated - UNION ALL - SELECT clientFk, amount - FROM vn.greuge - WHERE greugeTypeFk = vManaGreugeTypeId - AND shipped > vFromDated - AND shipped <= vToDated - UNION ALL - SELECT clientFk, mana - FROM vn.clientManaCache - WHERE dated = vFromDated - ) sub - GROUP BY Id_Cliente - HAVING Id_Cliente; + INSERT INTO vn.clientManaCache(clientFk, mana, dated) + SELECT Id_Cliente, + SUM(mana), + vToDated + FROM ( + SELECT a.clientFk Id_Cliente, s.quantity * sc.value mana + FROM vn.ticket t + JOIN vn.address a ON a.id = t.addressFk + JOIN vn.sale s ON s.ticketFk = t.id + JOIN vn.saleComponent sc ON sc.saleFk = s.id + WHERE sc.componentFk IN (vManaAutoId, vManaId, vClaimManaId) + AND t.shipped > vFromDated + AND DATE(t.shipped) <= vToDated + UNION ALL + SELECT clientFk, - amountPaid + FROM vn.receipt + WHERE bankFk = vManaBankId + AND payed > vFromDated + AND payed <= vToDated + UNION ALL + SELECT clientFk, amount + FROM vn.greuge + WHERE greugeTypeFk = vManaGreugeTypeId + AND shipped > vFromDated + AND shipped <= vToDated + UNION ALL + SELECT clientFk, mana + FROM vn.clientManaCache + WHERE dated = vFromDated + ) sub + GROUP BY Id_Cliente + HAVING Id_Cliente; - SET vFromDated = vToDated; - END WHILE; + SET vFromDated = vToDated; + END WHILE; END$$ DELIMITER ; diff --git a/db/routines/vn/procedures/catalog_componentCalculate.sql b/db/routines/vn/procedures/catalog_componentCalculate.sql index 4b860103d..92fe233c5 100644 --- a/db/routines/vn/procedures/catalog_componentCalculate.sql +++ b/db/routines/vn/procedures/catalog_componentCalculate.sql @@ -259,7 +259,7 @@ BEGIN JOIN tmp.ticketComponentSum tcs ON tcs.itemFk = tcc.itemFk AND tcs.warehouseFk = tcc.warehouseFk WHERE IFNULL(tcs.classRate, 1) = 1 - AND NOT tcc.groupingMode = 'packing' + AND (tcc.groupingMode = 'grouping' OR tcc.groupingMode IS NULL) AND (tcc.packing > tcc.`grouping` OR tcc.groupingMode IS NULL) GROUP BY tcs.warehouseFk, tcs.itemFk; diff --git a/db/routines/vn/procedures/duaInvoiceInBooking.sql b/db/routines/vn/procedures/duaInvoiceInBooking.sql index f95e836b1..981f3026d 100644 --- a/db/routines/vn/procedures/duaInvoiceInBooking.sql +++ b/db/routines/vn/procedures/duaInvoiceInBooking.sql @@ -28,11 +28,10 @@ BEGIN JOIN entry e ON e.invoiceInFk = ii.id JOIN duaEntry de ON de.entryFk = e.id JOIN dua d ON d.id = de.duaFk - SET ii.isBooked = TRUE, - ii.booked = IFNULL(ii.booked,d.booked), - ii.operated = IFNULL(ii.operated,d.operated), - ii.issued = IFNULL(ii.issued,d.issued), - ii.bookEntried = IFNULL(ii.bookEntried,d.bookEntried), + SET ii.booked = IFNULL(ii.booked, d.booked), + ii.operated = IFNULL(ii.operated, d.operated), + ii.issued = IFNULL(ii.issued, d.issued), + ii.bookEntried = IFNULL(ii.bookEntried, d.bookEntried), e.isBooked = TRUE, e.isConfirmed = TRUE WHERE d.id = vDuaFk; @@ -71,5 +70,9 @@ BEGIN SET ASIEN = vASIEN WHERE id = vDuaFk; + UPDATE invoiceIn ii + JOIN duaInvoiceIn dii ON dii.invoiceInFk = ii.id + SET ii.isBooked = TRUE + WHERE dii.duaFk = vDuaFk; END$$ DELIMITER ; diff --git a/db/routines/vn/procedures/fv_pca.sql b/db/routines/vn/procedures/fv_pca.sql deleted file mode 100644 index b8e7343ef..000000000 --- a/db/routines/vn/procedures/fv_pca.sql +++ /dev/null @@ -1,101 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`fv_pca`() -BEGIN - -DECLARE done INT DEFAULT FALSE; - -DECLARE vTicketFk INT; -DECLARE vSaleFk INT; -DECLARE vClonTicket INT DEFAULT 0; - -DECLARE cur1 CURSOR FOR -SELECT s.ticketFk, s.id - FROM vn.sale s - JOIN vn.ticket t ON t.id = s.ticketFk - JOIN vn.item i ON i.id = s.itemFk - JOIN vn.itemType it ON it.id = i.typeFk - WHERE t.shipped BETWEEN '2020-10-18' AND '2020-10-31' - AND it.code IN ('ANT','ANS','ORQ','TRO') - and t.warehouseFk = 1; - -DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE; - -OPEN cur1; - -FETCH cur1 INTO vTicketFk, vSaleFk; - - WHILE done = 0 DO - - SELECT t.id INTO vClonTicket - FROM vn.ticket t - JOIN (SELECT addressFk, shipped FROM vn.ticket WHERE id = vTicketFk) sub USING(addressFk, shipped) - WHERE t.warehouseFk = 44 - LIMIT 1; - - SELECT vTicketFk, vClonTicket; - - IF vClonTicket = 0 THEN - - INSERT INTO ticket ( - clientFk, - shipped, - addressFk, - agencyModeFk, - nickname, - warehouseFk, - companyFk, - landed, - zoneFk, - zonePrice, - zoneBonus, - routeFk - ) - SELECT - clientFk, - shipped, - addressFk, - agencyModeFk, - nickname, - 44, - companyFk, - landed, - zoneFk, - zonePrice, - zoneBonus, - routeFk - - FROM ticket - WHERE id = vTicketFk; - - SET vClonTicket = LAST_INSERT_ID(); - - SELECT 'lstID', vClonTicket; - /* - INSERT INTO ticketObservation(ticketFk, observationTypeFk, description) - SELECT vTicketFk, ao.observationTypeFk, ao.description - FROM addressObservation ao - JOIN ticket t ON t.addressFk = ao.addressFk - WHERE t.id = vClonTicket; -*/ - INSERT INTO ticketLog - SET originFk = vTicketFk, userFk = account.myUser_getId(), `action` = 'insert', - description = CONCAT('Ha creado el ticket:', ' ', vClonTicket, ' clonando el ', vTicketFk); - - END IF; - - UPDATE vn.sale - SET ticketFk = vClonTicket - WHERE id = vSaleFk; - - SET vClonTicket = 0; - - SET done = 0; - FETCH cur1 INTO vTicketFk, vSaleFk; - - END WHILE; - - CLOSE cur1; - - -END$$ -DELIMITER ; diff --git a/db/routines/vn/procedures/invoiceInTax_afterUpsert.sql b/db/routines/vn/procedures/invoiceInTax_afterUpsert.sql index 43d54c28c..60ec34696 100644 --- a/db/routines/vn/procedures/invoiceInTax_afterUpsert.sql +++ b/db/routines/vn/procedures/invoiceInTax_afterUpsert.sql @@ -10,8 +10,6 @@ BEGIN DECLARE vLines INT; DECLARE vHasDistinctTransactions INT; - CALL invoiceIn_checkBooked(vInvoiceInFk); - SELECT taxRowLimit INTO vTaxRowLimit FROM invoiceInConfig; SELECT COUNT(*) INTO vLines diff --git a/db/routines/vn/procedures/invoiceInTax_getFromEntries.sql b/db/routines/vn/procedures/invoiceInTax_getFromEntries.sql index 631b8f31c..b64996a66 100644 --- a/db/routines/vn/procedures/invoiceInTax_getFromEntries.sql +++ b/db/routines/vn/procedures/invoiceInTax_getFromEntries.sql @@ -5,8 +5,6 @@ BEGIN DECLARE vDated DATE; DECLARE vExpenseFk VARCHAR(10); - CALL invoiceIn_checkBooked(vInvoiceInFk); - SELECT MAX(rr.dated) INTO vDated FROM referenceRate rr JOIN invoiceIn ii ON ii.id = vInvoiceInFk diff --git a/db/routines/vn/triggers/invoiceInCorrection_beforeDelete.sql b/db/routines/vn/triggers/invoiceInCorrection_beforeDelete.sql deleted file mode 100644 index f4df48dcd..000000000 --- a/db/routines/vn/triggers/invoiceInCorrection_beforeDelete.sql +++ /dev/null @@ -1,8 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceInCorrection_beforeDelete` - BEFORE DELETE ON `invoiceInCorrection` - FOR EACH ROW -BEGIN - CALL invoiceIn_checkBooked(OLD.correctingFk); -END$$ -DELIMITER ; diff --git a/db/routines/vn/triggers/invoiceInCorrection_beforeInsert.sql b/db/routines/vn/triggers/invoiceInCorrection_beforeInsert.sql deleted file mode 100644 index aec58a265..000000000 --- a/db/routines/vn/triggers/invoiceInCorrection_beforeInsert.sql +++ /dev/null @@ -1,8 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceInCorrection_beforeInsert` - BEFORE INSERT ON `invoiceInCorrection` - FOR EACH ROW -BEGIN - CALL invoiceIn_checkBooked(NEW.correctingFk); -END$$ -DELIMITER ; diff --git a/db/routines/vn/triggers/invoiceInCorrection_beforeUpdate.sql b/db/routines/vn/triggers/invoiceInCorrection_beforeUpdate.sql deleted file mode 100644 index bd324863b..000000000 --- a/db/routines/vn/triggers/invoiceInCorrection_beforeUpdate.sql +++ /dev/null @@ -1,8 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceInCorrection_beforeUpdate` - BEFORE UPDATE ON `invoiceInCorrection` - FOR EACH ROW -BEGIN - CALL invoiceIn_checkBooked(OLD.correctingFk); -END$$ -DELIMITER ; diff --git a/db/routines/vn/triggers/invoiceInDueDay_beforeDelete.sql b/db/routines/vn/triggers/invoiceInDueDay_beforeDelete.sql deleted file mode 100644 index 10c9d0b52..000000000 --- a/db/routines/vn/triggers/invoiceInDueDay_beforeDelete.sql +++ /dev/null @@ -1,8 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceInDueDay_beforeDelete` - BEFORE DELETE ON `invoiceInDueDay` - FOR EACH ROW -BEGIN - CALL invoiceIn_checkBooked(OLD.invoiceInFk); -END$$ -DELIMITER ; diff --git a/db/routines/vn/triggers/invoiceInDueDay_beforeInsert.sql b/db/routines/vn/triggers/invoiceInDueDay_beforeInsert.sql index 95b227616..f7e4265a7 100644 --- a/db/routines/vn/triggers/invoiceInDueDay_beforeInsert.sql +++ b/db/routines/vn/triggers/invoiceInDueDay_beforeInsert.sql @@ -5,8 +5,6 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceInDueDay_befor BEGIN DECLARE vIsNotified BOOLEAN; - CALL invoiceIn_checkBooked(NEW.invoiceInFk); - SET NEW.editorFk = account.myUser_getId(); SELECT isNotified INTO vIsNotified diff --git a/db/routines/vn/triggers/invoiceInDueDay_beforeUpdate.sql b/db/routines/vn/triggers/invoiceInDueDay_beforeUpdate.sql index 5d58ef28b..2452ff0d1 100644 --- a/db/routines/vn/triggers/invoiceInDueDay_beforeUpdate.sql +++ b/db/routines/vn/triggers/invoiceInDueDay_beforeUpdate.sql @@ -5,7 +5,6 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceInDueDay_befor BEGIN DECLARE vIsNotified BOOLEAN; - CALL invoiceIn_checkBooked(OLD.invoiceInFk); SET NEW.editorFk = account.myUser_getId(); SELECT isNotified INTO vIsNotified diff --git a/db/routines/vn/triggers/invoiceInIntrastat_beforeDelete.sql b/db/routines/vn/triggers/invoiceInIntrastat_beforeDelete.sql deleted file mode 100644 index 412b091f4..000000000 --- a/db/routines/vn/triggers/invoiceInIntrastat_beforeDelete.sql +++ /dev/null @@ -1,8 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceInIntrastat_beforeDelete` - BEFORE DELETE ON `invoiceInIntrastat` - FOR EACH ROW -BEGIN - CALL invoiceIn_checkBooked(OLD.invoiceInFk); -END$$ -DELIMITER ; diff --git a/db/routines/vn/triggers/invoiceInIntrastat_beforeInsert.sql b/db/routines/vn/triggers/invoiceInIntrastat_beforeInsert.sql deleted file mode 100644 index d6c25c505..000000000 --- a/db/routines/vn/triggers/invoiceInIntrastat_beforeInsert.sql +++ /dev/null @@ -1,8 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceInIntrastat_beforeInsert` - BEFORE INSERT ON `invoiceInIntrastat` - FOR EACH ROW -BEGIN - CALL invoiceIn_checkBooked(NEW.invoiceInFk); -END$$ -DELIMITER ; diff --git a/db/routines/vn/triggers/invoiceInIntrastat_beforeUpdate.sql b/db/routines/vn/triggers/invoiceInIntrastat_beforeUpdate.sql deleted file mode 100644 index 649c9ef30..000000000 --- a/db/routines/vn/triggers/invoiceInIntrastat_beforeUpdate.sql +++ /dev/null @@ -1,8 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceInIntrastat_beforeUpdate` - BEFORE UPDATE ON `invoiceInIntrastat` - FOR EACH ROW -BEGIN - CALL invoiceIn_checkBooked(OLD.invoiceInFk); -END$$ -DELIMITER ; diff --git a/db/routines/vn/triggers/invoiceInTax_beforeDelete.sql b/db/routines/vn/triggers/invoiceInTax_beforeDelete.sql deleted file mode 100644 index a43f602b4..000000000 --- a/db/routines/vn/triggers/invoiceInTax_beforeDelete.sql +++ /dev/null @@ -1,8 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceInTax_beforeDelete` - BEFORE DELETE ON `invoiceInTax` - FOR EACH ROW -BEGIN - CALL invoiceIn_checkBooked(OLD.invoiceInFk); -END$$ -DELIMITER ; diff --git a/db/routines/vn/triggers/invoiceInTax_beforeUpdate.sql b/db/routines/vn/triggers/invoiceInTax_beforeUpdate.sql index 3e5ecf030..30918b7c5 100644 --- a/db/routines/vn/triggers/invoiceInTax_beforeUpdate.sql +++ b/db/routines/vn/triggers/invoiceInTax_beforeUpdate.sql @@ -3,8 +3,6 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceInTax_beforeUp BEFORE UPDATE ON `invoiceInTax` FOR EACH ROW BEGIN - CALL invoiceIn_checkBooked(OLD.invoiceInFk); - IF NOT (NEW.invoiceInFk <=> OLD.invoiceInFk) THEN CALL invoiceInTax_afterUpsert(NEW.invoiceInFk); END IF; diff --git a/db/routines/vn/triggers/invoiceIn_beforeUpdate.sql b/db/routines/vn/triggers/invoiceIn_beforeUpdate.sql index d0762de96..4503c7dbd 100644 --- a/db/routines/vn/triggers/invoiceIn_beforeUpdate.sql +++ b/db/routines/vn/triggers/invoiceIn_beforeUpdate.sql @@ -5,10 +5,6 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceIn_beforeUpdat BEGIN DECLARE vWithholdingSageFk INT; - IF NEW.isBooked = OLD.isBooked THEN - CALL invoiceIn_checkBooked(OLD.id); - END IF; - IF NOT (NEW.supplierRef <=> OLD.supplierRef) AND NOT util.checkPrintableChars(NEW.supplierRef) THEN CALL util.throw('The invoiceIn reference contains invalid characters'); END IF; diff --git a/db/versions/11033-aquaPaniculata/00-rollbackAcls.sql b/db/versions/11033-aquaPaniculata/00-rollbackAcls.sql new file mode 100644 index 000000000..a01efe3fb --- /dev/null +++ b/db/versions/11033-aquaPaniculata/00-rollbackAcls.sql @@ -0,0 +1,9 @@ +DELETE FROM salix.ACL + WHERE model = 'Worker' + AND property = '__get__summary' + AND principalId = 'employee'; + +UPDATE salix.ACL SET principalId = 'employee' + WHERE model = 'Worker' + AND property IN ('find','findById','findOne') + AND principalId = 'hr'; diff --git a/e2e/paths/03-worker/01_summary.spec.js b/e2e/paths/03-worker/01_summary.spec.js index 3c6149726..51992b41d 100644 --- a/e2e/paths/03-worker/01_summary.spec.js +++ b/e2e/paths/03-worker/01_summary.spec.js @@ -2,6 +2,7 @@ import selectors from '../../helpers/selectors.js'; import getBrowser from '../../helpers/puppeteer'; describe('Worker summary path', () => { + const workerId = 3; let browser; let page; beforeAll(async() => { @@ -9,7 +10,7 @@ describe('Worker summary path', () => { page = browser.page; await page.loginAndModule('employee', 'worker'); const httpDataResponse = page.waitForResponse(response => { - return response.status() === 200 && response.url().includes(`Workers/summary`); + return response.status() === 200 && response.url().includes(`Workers/${workerId}`); }); await page.accessToSearchResult('agencyNick'); await httpDataResponse; diff --git a/modules/worker/back/models/worker.json b/modules/worker/back/models/worker.json index 4c28cf217..ed430f133 100644 --- a/modules/worker/back/models/worker.json +++ b/modules/worker/back/models/worker.json @@ -92,86 +92,5 @@ "model": "WorkerTeamCollegues", "foreignKey": "workerFk" } - }, - "scopes":{ - "summary": { - "include": [ - { - "relation": "user", - "scope": { - "fields": ["email", "name", "nickname", "roleFk", "emailVerified"], - "include": [ - { - "relation": "role", - "scope": { - "fields": ["name"] - } - }, - { - "relation": "emailUser", - "scope": { - "fields": ["email"] - } - } - ] - } - }, { - "relation": "department", - "scope": { - "include": { - "relation": "department" - } - } - }, { - "relation": "boss" - }, { - "relation": "client", - "scope": { - "fields": [ - "id", - "name", - "fi", - "socialName", - "contact", - "street", - "city", - "postcode", - "email", - "mobile", - "isActive", - "credit", - "creditInsurance", - "iban", - "dueDay", - "isEqualizated", - "isFreezed", - "hasToInvoiceByAddress", - "hasToInvoice", - "isToBeMailed", - "hasSepaVnl", - "hasLcr", - "hasCoreVnl", - "hasCoreVnh", - "hasIncoterms", - "isTaxDataChecked", - "quality", - "isVies", - "isRelevant", - "accountingAccount", - "created", - "sageTaxTypeFk", - "sageTransactionTypeFk", - "businessTypeFk", - "salesPersonFk", - "hasElectronicInvoice", - "rating", - "recommendedCredit" - ] - } - }, { - "relation": "sip" - } - ] - } } } diff --git a/modules/worker/front/card/index.js b/modules/worker/front/card/index.js index 1aa548db9..9a40e31c2 100644 --- a/modules/worker/front/card/index.js +++ b/modules/worker/front/card/index.js @@ -4,13 +4,37 @@ import ModuleCard from 'salix/components/module-card'; class Controller extends ModuleCard { reload() { const filter = { - where: { - id: this.$params.id} + include: [ + { + relation: 'user', + scope: { + fields: ['name', 'emailVerified'], + include: { + relation: 'emailUser', + scope: { + fields: ['email'] + } + } + } + }, { + relation: 'sip', + scope: { + fields: ['extension', 'secret'] + } + }, { + relation: 'department', + scope: { + include: { + relation: 'department' + } + } + } + ] }; return Promise.all([ - this.$http.get(`Workers/summary`, {filter}) - .then(res => this.worker = res.data[0]), + this.$http.get(`Workers/${this.$params.id}`, {filter}) + .then(res => this.worker = res.data), this.$http.get(`Workers/${this.$params.id}/activeContract`) .then(res => this.hasWorkCenter = res.data?.workCenterFk) ]); diff --git a/modules/worker/front/descriptor/index.js b/modules/worker/front/descriptor/index.js index 9263b857b..75265acb4 100644 --- a/modules/worker/front/descriptor/index.js +++ b/modules/worker/front/descriptor/index.js @@ -37,11 +37,41 @@ class Controller extends Descriptor { loadData() { const filter = { - where: {id: this.id}, + include: [ + { + relation: 'user', + scope: { + fields: ['name', 'emailVerified'], + include: { + relation: 'emailUser', + scope: { + fields: ['email'] + } + } + } + }, { + relation: 'client', + scope: { + fields: ['fi'] + } + }, { + relation: 'sip', + scope: { + fields: ['extension'] + } + }, { + relation: 'department', + scope: { + include: { + relation: 'department' + } + } + } + ] }; - return this.getData(`Workers/summary`, {filter}) - .then(res => this.entity = res.data[0]); + return this.getData(`Workers/${this.id}`, {filter}) + .then(res => this.entity = res.data); } getPassRequirements() { diff --git a/modules/worker/front/descriptor/index.spec.js b/modules/worker/front/descriptor/index.spec.js index cee8b0def..4f7fa6a05 100644 --- a/modules/worker/front/descriptor/index.spec.js +++ b/modules/worker/front/descriptor/index.spec.js @@ -14,14 +14,14 @@ describe('vnWorkerDescriptor', () => { describe('loadData()', () => { it(`should perform a get query to store the worker data into the controller`, () => { const id = 1; - const response = ['foo']; + const response = 'foo'; $httpBackend.whenGET('UserConfigs/getUserConfig').respond({}); - $httpBackend.expectRoute('GET', `Workers/summary`).respond(response); + $httpBackend.expectRoute('GET', `Workers/${id}`).respond(response); controller.id = id; $httpBackend.flush(); - expect([controller.worker]).toEqual(response); + expect(controller.worker).toEqual(response); }); }); diff --git a/modules/worker/front/summary/index.js b/modules/worker/front/summary/index.js index d1a27a6d4..212609f58 100644 --- a/modules/worker/front/summary/index.js +++ b/modules/worker/front/summary/index.js @@ -10,14 +10,53 @@ class Controller extends Summary { this.$.worker = null; if (!value) return; + const query = `Workers/${value.id}`; const filter = { - where: { - id: value.id - } + include: [ + { + relation: 'user', + scope: { + fields: ['name', 'roleFk'], + include: [{ + relation: 'role', + scope: { + fields: ['name'] + } + }, + { + relation: 'emailUser', + scope: { + fields: ['email'] + } + }] + } + }, + { + relation: 'client', + scope: {fields: ['fi', 'phone']} + }, + { + relation: 'boss', + scope: {fields: ['id', 'name']} + }, + { + relation: 'sip', + scope: {fields: ['extension']} + }, + { + relation: 'department', + scope: { + include: { + relation: 'department', + scope: {fields: ['id', 'code', 'name']} + } + } + } + ] }; - this.$http.get(`Workers/summary`, {filter}).then(res => { - this.$.worker = res.data[0]; + this.$http.get(query, {params: {filter}}).then(res => { + this.$.worker = res.data; }); }