Merge branch 'dev' into 7335-modifyCmr
gitea/salix/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Guillermo Bonet 2024-05-08 08:29:00 +00:00
commit 16e7fb9662
25 changed files with 197 additions and 357 deletions

View File

@ -31,50 +31,43 @@ BEGIN
INTO vManaFromDays, vManaToDays INTO vManaFromDays, vManaToDays
FROM vn.salespersonConfig; FROM vn.salespersonConfig;
SELECT MAX(dated) SELECT MAX(dated) INTO vFromDated
INTO vFromDated
FROM vn.clientManaCache; FROM vn.clientManaCache;
DELETE DELETE FROM vn.clientManaCache
FROM vn.clientManaCache
WHERE dated = vFromDated; WHERE dated = vFromDated;
SELECT MAX(dated) SELECT MAX(dated) INTO vFromDated
INTO vFromDated
FROM vn.clientManaCache; FROM vn.clientManaCache;
IF ISNULL(vFromDated) THEN IF vFromDated IS NULL THEN
SELECT manaDateFrom SELECT manaDateFrom
INTO vFromDated INTO vFromDated
FROM vn.salespersonConfig; FROM vn.salespersonConfig;
END IF; END IF;
WHILE vFromDated + INTERVAL vManaToDays DAY < util.VN_CURDATE() DO WHILE vFromDated + INTERVAL vManaToDays DAY < util.VN_CURDATE() DO
SELECT SELECT vFromDated + INTERVAL vManaToDays DAY,
vFromDated + INTERVAL vManaToDays DAY,
vFromDated - INTERVAL vManaFromDays DAY vFromDated - INTERVAL vManaFromDays DAY
INTO INTO vToDated,
vToDated,
vForDeleteDated; vForDeleteDated;
DELETE FROM vn.clientManaCache DELETE FROM vn.clientManaCache
WHERE dated <= vForDeleteDated; WHERE dated <= vForDeleteDated;
INSERT INTO vn.clientManaCache(clientFk, mana, dated) INSERT INTO vn.clientManaCache(clientFk, mana, dated)
SELECT SELECT Id_Cliente,
Id_Cliente,
SUM(mana), SUM(mana),
vToDated vToDated
FROM FROM (
( SELECT a.clientFk Id_Cliente, s.quantity * sc.value mana
SELECT a.clientFk Id_Cliente, s.quantity * sc.value as mana
FROM vn.ticket t FROM vn.ticket t
JOIN vn.address a ON a.id = t.addressFk JOIN vn.address a ON a.id = t.addressFk
JOIN vn.sale s on s.ticketFk = t.id JOIN vn.sale s ON s.ticketFk = t.id
JOIN vn.saleComponent sc on sc.saleFk = s.id JOIN vn.saleComponent sc ON sc.saleFk = s.id
WHERE sc.componentFk IN (vManaAutoId, vManaId, vClaimManaId) WHERE sc.componentFk IN (vManaAutoId, vManaId, vClaimManaId)
AND t.shipped > vFromDated AND t.shipped > vFromDated
AND date(t.shipped) <= vToDated AND DATE(t.shipped) <= vToDated
UNION ALL UNION ALL
SELECT clientFk, - amountPaid SELECT clientFk, - amountPaid
FROM vn.receipt FROM vn.receipt

View File

@ -259,7 +259,7 @@ BEGIN
JOIN tmp.ticketComponentSum tcs ON tcs.itemFk = tcc.itemFk JOIN tmp.ticketComponentSum tcs ON tcs.itemFk = tcc.itemFk
AND tcs.warehouseFk = tcc.warehouseFk AND tcs.warehouseFk = tcc.warehouseFk
WHERE IFNULL(tcs.classRate, 1) = 1 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) AND (tcc.packing > tcc.`grouping` OR tcc.groupingMode IS NULL)
GROUP BY tcs.warehouseFk, tcs.itemFk; GROUP BY tcs.warehouseFk, tcs.itemFk;

View File

@ -28,8 +28,7 @@ BEGIN
JOIN entry e ON e.invoiceInFk = ii.id JOIN entry e ON e.invoiceInFk = ii.id
JOIN duaEntry de ON de.entryFk = e.id JOIN duaEntry de ON de.entryFk = e.id
JOIN dua d ON d.id = de.duaFk JOIN dua d ON d.id = de.duaFk
SET ii.isBooked = TRUE, SET ii.booked = IFNULL(ii.booked, d.booked),
ii.booked = IFNULL(ii.booked,d.booked),
ii.operated = IFNULL(ii.operated, d.operated), ii.operated = IFNULL(ii.operated, d.operated),
ii.issued = IFNULL(ii.issued, d.issued), ii.issued = IFNULL(ii.issued, d.issued),
ii.bookEntried = IFNULL(ii.bookEntried, d.bookEntried), ii.bookEntried = IFNULL(ii.bookEntried, d.bookEntried),
@ -71,5 +70,9 @@ BEGIN
SET ASIEN = vASIEN SET ASIEN = vASIEN
WHERE id = vDuaFk; WHERE id = vDuaFk;
UPDATE invoiceIn ii
JOIN duaInvoiceIn dii ON dii.invoiceInFk = ii.id
SET ii.isBooked = TRUE
WHERE dii.duaFk = vDuaFk;
END$$ END$$
DELIMITER ; DELIMITER ;

View File

@ -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 ;

View File

@ -10,8 +10,6 @@ BEGIN
DECLARE vLines INT; DECLARE vLines INT;
DECLARE vHasDistinctTransactions INT; DECLARE vHasDistinctTransactions INT;
CALL invoiceIn_checkBooked(vInvoiceInFk);
SELECT taxRowLimit INTO vTaxRowLimit FROM invoiceInConfig; SELECT taxRowLimit INTO vTaxRowLimit FROM invoiceInConfig;
SELECT COUNT(*) INTO vLines SELECT COUNT(*) INTO vLines

View File

@ -5,8 +5,6 @@ BEGIN
DECLARE vDated DATE; DECLARE vDated DATE;
DECLARE vExpenseFk VARCHAR(10); DECLARE vExpenseFk VARCHAR(10);
CALL invoiceIn_checkBooked(vInvoiceInFk);
SELECT MAX(rr.dated) INTO vDated SELECT MAX(rr.dated) INTO vDated
FROM referenceRate rr FROM referenceRate rr
JOIN invoiceIn ii ON ii.id = vInvoiceInFk JOIN invoiceIn ii ON ii.id = vInvoiceInFk

View File

@ -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 ;

View File

@ -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 ;

View File

@ -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 ;

View File

@ -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 ;

View File

@ -5,8 +5,6 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceInDueDay_befor
BEGIN BEGIN
DECLARE vIsNotified BOOLEAN; DECLARE vIsNotified BOOLEAN;
CALL invoiceIn_checkBooked(NEW.invoiceInFk);
SET NEW.editorFk = account.myUser_getId(); SET NEW.editorFk = account.myUser_getId();
SELECT isNotified INTO vIsNotified SELECT isNotified INTO vIsNotified

View File

@ -5,7 +5,6 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceInDueDay_befor
BEGIN BEGIN
DECLARE vIsNotified BOOLEAN; DECLARE vIsNotified BOOLEAN;
CALL invoiceIn_checkBooked(OLD.invoiceInFk);
SET NEW.editorFk = account.myUser_getId(); SET NEW.editorFk = account.myUser_getId();
SELECT isNotified INTO vIsNotified SELECT isNotified INTO vIsNotified

View File

@ -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 ;

View File

@ -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 ;

View File

@ -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 ;

View File

@ -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 ;

View File

@ -3,8 +3,6 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceInTax_beforeUp
BEFORE UPDATE ON `invoiceInTax` BEFORE UPDATE ON `invoiceInTax`
FOR EACH ROW FOR EACH ROW
BEGIN BEGIN
CALL invoiceIn_checkBooked(OLD.invoiceInFk);
IF NOT (NEW.invoiceInFk <=> OLD.invoiceInFk) THEN IF NOT (NEW.invoiceInFk <=> OLD.invoiceInFk) THEN
CALL invoiceInTax_afterUpsert(NEW.invoiceInFk); CALL invoiceInTax_afterUpsert(NEW.invoiceInFk);
END IF; END IF;

View File

@ -5,10 +5,6 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceIn_beforeUpdat
BEGIN BEGIN
DECLARE vWithholdingSageFk INT; 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 IF NOT (NEW.supplierRef <=> OLD.supplierRef) AND NOT util.checkPrintableChars(NEW.supplierRef) THEN
CALL util.throw('The invoiceIn reference contains invalid characters'); CALL util.throw('The invoiceIn reference contains invalid characters');
END IF; END IF;

View File

@ -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';

View File

@ -2,6 +2,7 @@ import selectors from '../../helpers/selectors.js';
import getBrowser from '../../helpers/puppeteer'; import getBrowser from '../../helpers/puppeteer';
describe('Worker summary path', () => { describe('Worker summary path', () => {
const workerId = 3;
let browser; let browser;
let page; let page;
beforeAll(async() => { beforeAll(async() => {
@ -9,7 +10,7 @@ describe('Worker summary path', () => {
page = browser.page; page = browser.page;
await page.loginAndModule('employee', 'worker'); await page.loginAndModule('employee', 'worker');
const httpDataResponse = page.waitForResponse(response => { 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 page.accessToSearchResult('agencyNick');
await httpDataResponse; await httpDataResponse;

View File

@ -92,86 +92,5 @@
"model": "WorkerTeamCollegues", "model": "WorkerTeamCollegues",
"foreignKey": "workerFk" "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"
}
]
}
} }
} }

View File

@ -4,13 +4,37 @@ import ModuleCard from 'salix/components/module-card';
class Controller extends ModuleCard { class Controller extends ModuleCard {
reload() { reload() {
const filter = { const filter = {
where: { include: [
id: this.$params.id} {
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([ return Promise.all([
this.$http.get(`Workers/summary`, {filter}) this.$http.get(`Workers/${this.$params.id}`, {filter})
.then(res => this.worker = res.data[0]), .then(res => this.worker = res.data),
this.$http.get(`Workers/${this.$params.id}/activeContract`) this.$http.get(`Workers/${this.$params.id}/activeContract`)
.then(res => this.hasWorkCenter = res.data?.workCenterFk) .then(res => this.hasWorkCenter = res.data?.workCenterFk)
]); ]);

View File

@ -37,11 +37,41 @@ class Controller extends Descriptor {
loadData() { loadData() {
const filter = { 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}) return this.getData(`Workers/${this.id}`, {filter})
.then(res => this.entity = res.data[0]); .then(res => this.entity = res.data);
} }
getPassRequirements() { getPassRequirements() {

View File

@ -14,14 +14,14 @@ describe('vnWorkerDescriptor', () => {
describe('loadData()', () => { describe('loadData()', () => {
it(`should perform a get query to store the worker data into the controller`, () => { it(`should perform a get query to store the worker data into the controller`, () => {
const id = 1; const id = 1;
const response = ['foo']; const response = 'foo';
$httpBackend.whenGET('UserConfigs/getUserConfig').respond({}); $httpBackend.whenGET('UserConfigs/getUserConfig').respond({});
$httpBackend.expectRoute('GET', `Workers/summary`).respond(response); $httpBackend.expectRoute('GET', `Workers/${id}`).respond(response);
controller.id = id; controller.id = id;
$httpBackend.flush(); $httpBackend.flush();
expect([controller.worker]).toEqual(response); expect(controller.worker).toEqual(response);
}); });
}); });

View File

@ -10,14 +10,53 @@ class Controller extends Summary {
this.$.worker = null; this.$.worker = null;
if (!value) return; if (!value) return;
const query = `Workers/${value.id}`;
const filter = { const filter = {
where: { include: [
id: value.id {
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.$http.get(query, {params: {filter}}).then(res => {
this.$.worker = res.data[0]; this.$.worker = res.data;
}); });
} }