Compare commits

...

15 Commits

Author SHA1 Message Date
Guillermo Bonet 65ca1b5af3 Merge pull request 'feat: refs #8149 Group by CuentaIvaRepercutido' (!3201) from 8149-ivaXDiario into dev
gitea/salix/pipeline/head This commit looks good Details
Reviewed-on: #3201
Reviewed-by: Carlos Andrés <carlosap@verdnatura.es>
2024-11-22 12:09:47 +00:00
Carlos Andrés 771aeaa9bd Merge pull request 'test' (!3237) from test into dev
gitea/salix/pipeline/head This commit looks good Details
Reviewed-on: #3237
Reviewed-by: Javi Gallego <jgallego@verdnatura.es>
2024-11-22 12:03:18 +00:00
Guillermo Bonet 1c6f59a0ec Merge branch '8149-ivaXDiario' of https://gitea.verdnatura.es/verdnatura/salix into 8149-ivaXDiario
gitea/salix/pipeline/pr-dev This commit looks good Details
2024-11-22 12:59:26 +01:00
Guillermo Bonet 4ab2d7fd09 feat: refs #8149 Group by CuentaIvaRepercutido 2024-11-22 12:59:24 +01:00
Carlos Andrés 7cf6acec19 Merge pull request '8124-enrutadoresNuevosRequerimientos' (!3235) from 8124-enrutadoresNuevosRequerimientos into test
gitea/salix/pipeline/pr-dev This commit looks good Details
gitea/salix/pipeline/head This commit looks good Details
Reviewed-on: #3235
Reviewed-by: Javi Gallego <jgallego@verdnatura.es>
2024-11-22 09:46:03 +00:00
Guillermo Bonet c440472693 Merge branch 'dev' into 8149-ivaXDiario
gitea/salix/pipeline/pr-dev This commit looks good Details
2024-11-22 09:43:26 +00:00
Jorge Penadés 470d9bde64 Merge pull request 'fix: refs #7229 set right urls' (!3226) from 7229-fixDownloadFile into dev
gitea/salix/pipeline/head This commit looks good Details
Reviewed-on: #3226
Reviewed-by: Alex Moreno <alexm@verdnatura.es>
2024-11-22 09:34:16 +00:00
Jorge Penadés b97058735c Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 7229-fixDownloadFile
gitea/salix/pipeline/pr-dev This commit looks good Details
2024-11-22 10:25:28 +01:00
Carlos Andrés 52364bbe2d feat: refs #8124 Enrutadores nuevos requerimientos
gitea/salix/pipeline/pr-test This commit looks good Details
2024-11-21 18:44:47 +01:00
Carlos Andrés 7ad17d75d7 feat: refs #8124 Enrutadores nuevos requerimientos 2024-11-21 18:41:55 +01:00
Jorge Penadés e125dee691 refactor: refs #7229 desestructure
gitea/salix/pipeline/pr-dev This commit looks good Details
2024-11-20 16:51:14 +01:00
Jorge Penadés 940bc8caed Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 7229-fixDownloadFile
gitea/salix/pipeline/pr-dev This commit looks good Details
2024-11-20 15:34:04 +01:00
Jorge Penadés 16111220fb Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 7229-fixDownloadFile
gitea/salix/pipeline/pr-dev This commit looks good Details
2024-11-20 13:52:55 +01:00
Jorge Penadés bbb7815765 fix: refs #7229 set right urls
gitea/salix/pipeline/pr-dev Build queued... Details
2024-11-20 13:52:24 +01:00
Guillermo Bonet 477fb7ded9 feat: refs #8149 Group by CuentaIvaRepercutido
gitea/salix/pipeline/pr-dev Build queued... Details
2024-11-13 14:27:54 +01:00
5 changed files with 94 additions and 24 deletions

View File

@ -26,7 +26,7 @@ BEGIN
DECLARE vCursor CURSOR FOR
SELECT it.taxableBase,
CAST((( it.taxableBase / 100) * t.PorcentajeIva) AS DECIMAL (10,2)),
CAST(SUM((( it.taxableBase / 100) * t.PorcentajeIva)) AS DECIMAL (10,2)),
t.PorcentajeIva,
it.transactionTypeSageFk,
it.taxTypeSageFk,
@ -39,7 +39,8 @@ BEGIN
JOIN TiposTransacciones tt ON tt.CodigoTransaccion = it.transactionTypeSageFk
LEFT JOIN vn.dua d ON d.id = vInvoiceInFk
WHERE i.id = vInvoiceInFk
AND d.id IS NULL;
AND d.id IS NULL
GROUP BY it.taxTypeSageFk;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;

View File

@ -219,7 +219,7 @@ BEGIN
) eWithheld ON TRUE
WHERE tii.taxTypeSageFk IS NOT NULL
AND (tii.taxCode IS NULL OR tii.taxCode NOT IN ('import10', 'import21'))
GROUP BY tii.PorcentajeIva, tii.expenseFk;
GROUP BY tii.CuentaIvaRepercutido;
-- Línea iva inversor sujeto pasivo
INSERT INTO XDiario(
@ -284,7 +284,7 @@ BEGIN
AND NOT(tii.isVies
AND c.nontaxableTransactionTypeFk = tii.transactionTypeSageFk
AND tii.taxCode = 'nonTaxable')
GROUP BY tii.PorcentajeIva, tii.expenseFk;
GROUP BY tii.CuentaIvaRepercutido;
-- Actualización del registro original
UPDATE invoiceIn ii

View File

@ -11,6 +11,8 @@ BEGIN
*/
DECLARE vIsUpdatable, vIsFreelance BOOL DEFAULT 0;
DECLARE vAgencyModePricePercentage DOUBLE;
DECLARE vIsKmTruckRate BOOL;
DECLARE vCountryFk INT;
SELECT r.created >= rc.cutoffDated INTO vIsUpdatable
FROM route r
@ -21,10 +23,16 @@ BEGIN
DELETE FROM routeCommission
WHERE routeFk = vSelf;
SELECT w.isFreelance INTO vIsFreelance
SELECT w.isFreelance, v.isKmTruckRate, c.countryFk INTO vIsFreelance, vIsKmTruckRate, vCountryFk
FROM route r
JOIN worker w ON w.id = r.workerFk
WHERE r.id = vSelf;
JOIN vehicle v ON v.id = r.vehicleFk
LEFT JOIN ticket t ON t.routeFk = r.id
LEFT JOIN client c ON c.id = t.clientFk
WHERE r.id = vSelf
GROUP BY c.countryFk
ORDER BY COUNT(*) DESC
LIMIT 1;
SELECT ampp.percentage INTO vAgencyModePricePercentage
FROM route r
@ -39,7 +47,9 @@ BEGIN
workCenterFk,
freelanceYearlyM3,
cat4m3,
cat5m3
cat5m3,
isKmTruckRate,
countryFk
)
SELECT vSelf,
r.commissionWorkCenterFk,
@ -51,11 +61,14 @@ BEGIN
IFNULL(r.m3, 0),
0
),
rc.distributionCat4M3 * IFNULL(r.m3, 0),
rc.distributionCat5M3 * IFNULL(r.m3, 0)
IFNULL(wc.distributionCat4M3, rc.distributionCat4M3) * IFNULL(r.m3, 0),
IFNULL(wc.distributionCat5M3, rc.distributionCat5M3) * IFNULL(r.m3, 0),
vIsKmTruckRate,
vCountryFk
FROM route r
JOIN vehicle v ON v.id = r.vehicleFk
JOIN routeConfig rc
LEFT JOIN workCenterCommission wc ON wc.workCenter = r.workCenterFk
WHERE r.id = vSelf
AND r.workerFk
AND r.commissionWorkCenterFk;
@ -68,7 +81,9 @@ BEGIN
yearlyKm,
yearlyM3,
cat4m3,
cat5m3
cat5m3,
isKmTruckRate,
countryFk
)
SELECT vSelf,
r.commissionWorkCenterFk,
@ -78,11 +93,14 @@ BEGIN
IF(v.isKmTruckRate, rc.deliveryM3Cat5, rc.deliveryM3Cat4),
(r.kmEnd - r.kmStart) * rc.kmYearly,
IFNULL(r.m3, 0) * rc.m3Yearly,
rc.distributionCat4M3 * IFNULL(r.m3, 0),
rc.distributionCat5M3 * IFNULL(r.m3, 0)
IFNULL(wc.distributionCat4M3, rc.distributionCat4M3) * IFNULL(r.m3, 0),
IFNULL(wc.distributionCat5M3, rc.distributionCat5M3) * IFNULL(r.m3, 0),
vIsKmTruckRate,
vCountryFk
FROM route r
JOIN vehicle v ON v.id = r.vehicleFk
JOIN routeConfig rc
LEFT JOIN workCenterCommission wc ON wc.workCenter = r.workCenterFk
WHERE r.id = vSelf
AND r.kmStart
AND r.kmEnd

View File

@ -0,0 +1,51 @@
ALTER TABLE vn.routeCommission ADD IF NOT EXISTS countryFk mediumint(8) unsigned DEFAULT NULL NULL;
ALTER TABLE vn.routeCommission ADD IF NOT EXISTS isKmTruckRate TINYINT(1) DEFAULT NULL NULL;
ALTER TABLE vn.routeCommission DROP FOREIGN KEY IF EXISTS routeCommission_country_FK;
ALTER TABLE vn.routeCommission ADD CONSTRAINT routeCommission_country_FK FOREIGN KEY (countryFk)
REFERENCES vn.country(id) ON DELETE RESTRICT ON UPDATE CASCADE;
CREATE TABLE IF NOT EXISTS vn.workCenterCommission (
`workCenterFk` INT(11) NOT NULL,
`deliveryManAdjustment` DECIMAL(4,2) DEFAULT NULL
COMMENT 'Número de trabajadores para equilibrar los repartidores de diferentes centros.
Utilizado en repartidores de grafana',
`distributionM3Category1` decimal(5,2) DEFAULT NULL,
`distributionM3Category2` decimal(5,2) DEFAULT NULL,
`distributionCat4M3` DECIMAL(5,2) DEFAULT NULL
COMMENT 'Comisión por gestión de la distribución Cat IV',
`distributionCat5M3` DECIMAL(5,2) DEFAULT NULL
COMMENT 'Comisión por gestión de la distribución Cat V',
PRIMARY KEY (`workCenterFk`),
CONSTRAINT `workCenterCommission_workCenterFk` FOREIGN KEY (`workCenterFk`)
REFERENCES `workCenter` (`id`) ON UPDATE CASCADE ON DELETE RESTRICT
);
UPDATE vn.routeCommission rc
JOIN (SELECT id, countryFk, isKmTruckRate
FROM (SELECT r.id, c.countryFk, v.isKmTruckRate
FROM vn.route r
JOIN vn.routeCommission rc ON rc.routeFk = r.id
LEFT JOIN vn.ticket t ON t.routeFk = r.id
LEFT JOIN vn.client c ON c.id = t.clientFk
LEFT JOIN vn.vehicle v ON v.id = r.vehicleFk
WHERE r.created >= '2023-12-01'
GROUP BY r.id, c.countryFk
ORDER BY r.id, COUNT(*) DESC
LIMIT 100000000000
)sub
GROUP BY id
)sub ON sub.id = rc.routeFk
SET rc.isKmTruckRate = sub.isKmTruckRate,
rc.countryFk = sub.countryFk;
ALTER TABLE vn.workerDistributionCategory ADD IF NOT EXISTS countryFk mediumint(8) unsigned DEFAULT NULL NULL;
ALTER TABLE vn.workerDistributionCategory ADD IF NOT EXISTS isKmTruckRate TINYINT(1) DEFAULT NULL NULL;
ALTER TABLE vn.workerDistributionCategory DROP FOREIGN KEY IF EXISTS workerDistributionCategory_country_FK;
ALTER TABLE vn.workerDistributionCategory ADD CONSTRAINT workerDistributionCategory_country_FK FOREIGN KEY (countryFk)
REFERENCES vn.country(id) ON DELETE RESTRICT ON UPDATE CASCADE;
ALTER TABLE vn.workerDistributionCategory ADD IF NOT EXISTS commissionSplitWorkers INT UNSIGNED NOT NULL DEFAULT 1
COMMENT 'Número de enrutadores entr los que se reparte la comsión';

View File

@ -86,30 +86,30 @@ module.exports = Self => {
'Tipo Documento': 'description',
'Stored on': 'created',
'Document ID': 'id',
'URL': 'download',
'URL': 'url',
'Stored by': 'name',
'Estado': 'state'
};
workerDocuware =
await models.Docuware.getById('hr', worker.lastName + ' ' + worker.firstName, docuwareParse) ?? [];
const url = (await Self.app.models.Url.getUrl('docuware')) + 'WebClient';
await models.Docuware.getById('hr', worker?.lastName + ' ' + worker?.firstName, docuwareParse) ?? [];
for (document of workerDocuware) {
const docuwareId = document.id;
const {id: documentId, dmsFk} = document;
const defaultData = {
id: docuwareId,
id: documentId,
workerFk: id,
dmsFk: docuwareId,
dmsFk: dmsFk,
dms: {
id: docuwareId,
file: docuwareId + '.pdf',
id: documentId,
file: dmsFk + '.pdf',
isDocuware: true,
hasFile: false,
reference: worker.fi,
dmsFk: docuwareId,
url,
reference: worker?.fi,
dmsFk: dmsFk,
url: document.url,
download: `WorkerDms/${document.dmsFk}/docuwareDownload`,
description: document.description + ' - ' + document.state,
download: document.download,
created: document.created,
dmsType: {name: 'Docuware'},
worker: {id: null, user: {name: document.name}},