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

This commit is contained in:
Carlos Satorres 2024-03-14 08:54:06 +00:00
commit 1457884252
21 changed files with 223 additions and 185 deletions

View File

@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [2414.01] - 2024-04-04
### Added
### Changed
### Fixed
## [2408.01] - 2024-02-22 ## [2408.01] - 2024-02-22
### Added ### Added

View File

@ -16,7 +16,7 @@
"Accounting": { "Accounting": {
"dataSource": "vn" "dataSource": "vn"
}, },
"Buyer": { "Buyer": {
"dataSource": "vn" "dataSource": "vn"
}, },
"Campaign": { "Campaign": {
@ -94,6 +94,9 @@
"Module": { "Module": {
"dataSource": "vn" "dataSource": "vn"
}, },
"MrwConfig": {
"dataSource": "vn"
},
"Notification": { "Notification": {
"dataSource": "vn" "dataSource": "vn"
}, },
@ -166,10 +169,10 @@
"VnRole": { "VnRole": {
"dataSource": "vn" "dataSource": "vn"
}, },
"MrwConfig": { "WorkerActivity": {
"dataSource": "vn"
},
"WorkerActivityType": {
"dataSource": "vn" "dataSource": "vn"
} }
} }

View File

@ -0,0 +1,39 @@
{
"name": "WorkerActivity",
"base": "VnModel",
"options": {
"mysql": {
"table": "workerActivity"
}
},
"properties": {
"id": {
"id": true,
"type": "number"
},
"created": {
"type": "date"
},
"model": {
"type": "string"
},
"event": {
"type": "string"
},
"description": {
"type": "string"
},
"relations": {
"workerFk": {
"type": "belongsTo",
"model": "Worker",
"foreignKey": "workerFk"
},
"workerActivityTypeFk": {
"type": "belongsTo",
"model": "WorkerActivityType",
"foreignKey": "workerActivityTypeFk"
}
}
}
}

View File

@ -0,0 +1,19 @@
{
"name": "WorkerActivityType",
"base": "VnModel",
"options": {
"mysql": {
"table": "workerActivityType"
}
},
"properties": {
"code": {
"id": true,
"type": "string"
},
"description": {
"type": "string",
"required": false
}
}
}

View File

@ -37,7 +37,7 @@ BEGIN
LEFT JOIN origin o ON o.id = i.originFk LEFT JOIN origin o ON o.id = i.originFk
) ON it.id = i.typeFk ) ON it.id = i.typeFk
LEFT JOIN edi.ekt ek ON b.ektFk = ek.id LEFT JOIN edi.ekt ek ON b.ektFk = ek.id
WHERE (b.packagingFk = "--" OR b.price2 = 0 OR b.packing = 0 OR b.buyingValue = 0) AND tr.landed > util.firstDayOfMonth(TIMESTAMPADD(MONTH,-1,util.VN_CURDATE())) AND s.name = 'INVENTARIO'; WHERE (b.packagingFk = "--" OR b.price2 = 0 OR b.buyingValue = 0) AND tr.landed > util.firstDayOfMonth(TIMESTAMPADD(MONTH,-1,util.VN_CURDATE())) AND s.name = 'INVENTARIO';
DROP TEMPORARY TABLE IF EXISTS tmp.lastEntryOk; DROP TEMPORARY TABLE IF EXISTS tmp.lastEntryOk;
CREATE TEMPORARY TABLE tmp.lastEntryOk CREATE TEMPORARY TABLE tmp.lastEntryOk
@ -94,11 +94,6 @@ BEGIN
JOIN tmp.lastEntryOkGroup eo ON eo.itemFk = lt.itemFk AND eo.warehouseFk = lt.warehouseFk JOIN tmp.lastEntryOkGroup eo ON eo.itemFk = lt.itemFk AND eo.warehouseFk = lt.warehouseFk
SET b.price2 = eo.price2 WHERE b.price2 = 0 ; SET b.price2 = eo.price2 WHERE b.price2 = 0 ;
UPDATE buy b
JOIN tmp.lastEntry lt ON lt.buyFk = b.id
JOIN tmp.lastEntryOkGroup eo ON eo.itemFk = lt.itemFk AND eo.warehouseFk = lt.warehouseFk
SET b.packing = eo.packing WHERE b.packing = 0;
UPDATE buy b UPDATE buy b
JOIN tmp.lastEntry lt ON lt.buyFk = b.id JOIN tmp.lastEntry lt ON lt.buyFk = b.id
JOIN tmp.lastEntryOkGroup eo ON eo.itemFk = lt.itemFk AND eo.warehouseFk = lt.warehouseFk JOIN tmp.lastEntryOkGroup eo ON eo.itemFk = lt.itemFk AND eo.warehouseFk = lt.warehouseFk

View File

@ -1,8 +1,11 @@
DELIMITER $$ DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`invoiceInTaxMakeByDua`(vDuaFk INT) CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`invoiceInTaxMakeByDua`(
vDuaFk INT
)
BEGIN BEGIN
/** /**
* Borra los valores de duaTax y sus vctos. y los vuelve a crear en base a la tabla duaEntry * Borra los valores de duaTax y sus vctos. y los vuelve a
* crear en base a la tabla duaEntry.
* *
* @param vDuaFk Id del dua a recalcular * @param vDuaFk Id del dua a recalcular
*/ */
@ -26,7 +29,7 @@ BEGIN
LEAVE l; LEAVE l;
END IF; END IF;
CALL vn2008.recibidaIvaInsert(vInvoiceInFk); CALL invoiceInTax_recalc(vInvoiceInFk);
CALL invoiceInDueDay_recalc(vInvoiceInFk); CALL invoiceInDueDay_recalc(vInvoiceInFk);
END LOOP; END LOOP;

View File

@ -0,0 +1,62 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`invoiceInTax_recalc`(
vInvoiceInFk INT
)
BEGIN
/**
* Recalcula y actualiza los impuestos de la factura
* usando la última tasa de cambio y detalles de compra.
*
* @param vInvoiceInFk Id de factura recibida
*/
DECLARE vRate DOUBLE DEFAULT 1;
DECLARE vDated DATE;
DECLARE vExpenseFk INT;
SELECT MAX(rr.dated) INTO vDated
FROM referenceRate rr
JOIN invoiceIn ii ON ii.id = vInvoiceInFk
WHERE rr.dated <= ii.issued
AND rr.currencyFk = ii.currencyFk;
IF vDated THEN
SELECT `value` INTO vRate
FROM referenceRate
WHERE dated = vDated;
END IF;
DELETE FROM invoiceInTax WHERE invoiceInFk = vInvoiceInFk;
SELECT id INTO vExpenseFk
FROM expense
WHERE code = 'extraCommGoodsAcquisition';
IF vExpenseFk IS NULL THEN
CALL util.throw('Expense extraCommGoodsAcquisition not exists');
END IF;
INSERT INTO invoiceInTax(
invoiceInFk,
taxableBase,
expenseFk,
foreignValue,
taxTypeSageFk,
transactionTypeSageFk
)
SELECT ii.id,
SUM(b.buyingValue * b.quantity) / vRate bi,
vExpenseFk,
IF(c.code = 'EUR', NULL, SUM(b.buyingValue * b.quantity)),
s.taxTypeSageFk,
s.transactionTypeSageFk
FROM invoiceIn ii
JOIN currency c ON c.id = ii.currencyFk
JOIN `entry` e ON e.invoiceInFk = ii.id
JOIN supplier s ON s.id = e.supplierFk
JOIN buy b ON b.entryFk = e.id
LEFT JOIN referenceRate rr ON rr.currencyFk = ii.currencyFk
AND rr.dated = ii.issued
WHERE ii.id = vInvoiceInFk
HAVING bi IS NOT NULL;
END$$
DELIMITER ;

View File

@ -1,25 +0,0 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`ListaTicketsEncajados`(IN intId_Trabajador int)
BEGIN
SELECT Agencia,
Consignatario,
ti.Id_Ticket,
ts.userFk Id_Trabajador,
IFNULL(ncajas,0) AS ncajas,
IFNULL(nbultos,0) AS nbultos,
IFNULL(notros,0) AS notros,
ts.code AS Estado
FROM Tickets ti
INNER JOIN Consignatarios ON ti.Id_Consigna = Consignatarios.Id_consigna
INNER JOIN Agencias ON ti.Id_Agencia = Agencias.Id_Agencia
LEFT JOIN (SELECT ticketFk,count(*) AS ncajas FROM vn.expedition WHERE packagingFk=94 GROUP BY ticketFk) sub1 ON ti.Id_Ticket=sub1.ticketFk
LEFT JOIN (SELECT ticketFk,count(*) AS nbultos FROM vn.expedition WHERE packagingFk IS NULL GROUP BY ticketFk) sub2 ON ti.Id_Ticket=sub2.ticketFk
LEFT JOIN (SELECT ticketFk,count(*) AS notros FROM vn.expedition WHERE packagingFk >0 GROUP BY ticketFk) sub3 ON ti.Id_Ticket=sub3.ticketFk
INNER JOIN vn.ticketState ts ON ti.Id_ticket = ts.ticketFk
WHERE ti.Fecha=util.VN_CURDATE() AND
ts.userFk=intId_Trabajador
GROUP BY ti.Id_Ticket;
END$$
DELIMITER ;

View File

@ -1,49 +0,0 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`customerDebtEvolution`(IN vCustomer INT)
BEGIN
SELECT * FROM
(
SELECT day, date, @s:= round(IFNULL(Euros,0) + @s,2) as Saldo, Euros, Credito, 0 as Cero
FROM
(
SELECT day, date, IFNULL(Euros,0) as Euros, Credito
FROM time
JOIN (SELECT @s:= 0, - Credito as Credito FROM Clientes WHERE Id_Cliente = vCustomer) c
LEFT JOIN
(SELECT Euros, date(Fecha) as Fecha FROM
(
SELECT Fechacobro as Fecha, Entregado as Euros
FROM Recibos
WHERE Id_Cliente = vCustomer
AND Fechacobro >= '2017-01-01'
UNION ALL
SELECT vn.getDueDate(io.issued,c.Vencimiento), - io.amount
FROM vn.invoiceOut io
JOIN Clientes c ON io.clientFk = c.Id_Cliente
WHERE io.clientFk = vCustomer
AND io.issued >= '2017-01-01'
UNION ALL
SELECT '2016-12-31', Debt
FROM bi.customerDebtInventory
WHERE Id_Cliente = vCustomer
UNION ALL
SELECT Fecha, - SUM(Cantidad * Preu * (100 - Descuento ) * 1.10 / 100)
FROM Tickets t
JOIN Movimientos m on m.Id_Ticket = t.Id_Ticket
WHERE Id_Cliente = vCustomer
AND Factura IS NULL
AND Fecha >= '2017-01-01'
GROUP BY Fecha
) sub2
ORDER BY Fecha
)sub ON time.date = sub.Fecha
WHERE time.date BETWEEN '2016-12-31' AND util.VN_CURDATE()
ORDER BY date
) sub3
)sub4
;
END$$
DELIMITER ;

View File

@ -1,22 +0,0 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`preOrdenarRuta`(IN vRutaId INT)
BEGIN
/* Usa los valores del ultimo año para adivinar el orden de los tickets en la ruta
* vRutaId id ruta
* DEPRECATED use vn.routeGressPriority
*/
UPDATE Tickets mt
JOIN (
SELECT tt.Id_Consigna, round(ifnull(avg(t.Prioridad),0),0) as Prioridad
from Tickets t
JOIN Tickets tt on tt.Id_Consigna = t.Id_Consigna
where t.Fecha > TIMESTAMPADD(YEAR,-1,util.VN_CURDATE())
AND tt.Id_Ruta = vRutaId
GROUP BY Id_Consigna
) sub ON sub.Id_Consigna = mt.Id_Consigna
SET mt.Prioridad = sub.Prioridad
WHERE mt.Id_Ruta = vRutaId;
END$$
DELIMITER ;

View File

@ -1,22 +0,0 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`prepare_ticket_list`(vStartingDate DATETIME, vEndingDate DATETIME)
BEGIN
DROP TEMPORARY TABLE IF EXISTS tmp.ticket_list;
CREATE TEMPORARY TABLE tmp.ticket_list
(PRIMARY KEY (Id_Ticket))
ENGINE = MEMORY
SELECT t.Id_Ticket, c.Id_Cliente
FROM Tickets t
LEFT JOIN vn.ticketState ts ON ts.ticketFk = t.Id_Ticket
JOIN Clientes c ON c.Id_Cliente = t.Id_Cliente
WHERE c.typeFk IN ('normal','handMaking','internalUse')
AND (
Fecha BETWEEN util.today() AND vEndingDate
OR (
ts.alertLevel < 3
AND t.Fecha >= vStartingDate
AND t.Fecha < util.today()
)
);
END$$
DELIMITER ;

View File

@ -1,39 +0,0 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`recibidaIvaInsert`(IN vId INT)
BEGIN
DECLARE vRate DOUBLE DEFAULT 1;
DECLARE vDated DATE;
SELECT MAX(rr.date) INTO vDated
FROM reference_rate rr
JOIN recibida r ON r.id = vId
WHERE rr.date <= r.fecha
AND rr.moneda_id = r.moneda_id ;
IF vDated THEN
SELECT rate INTO vRate
FROM reference_rate
WHERE `date` = vDated;
END IF;
DELETE FROM recibida_iva WHERE recibida_id = vId;
INSERT INTO recibida_iva(recibida_id, bi, gastos_id, divisa, taxTypeSageFk, transactionTypeSageFk)
SELECT r.id,
SUM(Costefijo * Cantidad) / IFNULL(vRate,1) bi,
6003000000,
IF(r.moneda_id = 1,NULL,SUM(Costefijo * Cantidad )) divisa,
taxTypeSageFk,
transactionTypeSageFk
FROM recibida r
JOIN Entradas e ON e.recibida_id = r.id
JOIN Proveedores p ON p.Id_Proveedor = e.Id_Proveedor
JOIN Compres c ON c.Id_Entrada = e.Id_Entrada
LEFT JOIN reference_rate rr ON rr.moneda_id = r.moneda_id AND rr.date = r.fecha
WHERE r.id = vId
HAVING bi IS NOT NULL;
END$$
DELIMITER ;

View File

@ -0,0 +1,19 @@
SET @isTriggerDisabled := TRUE;
UPDATE vn.buy
SET packing = 1
WHERE packing IS NULL
OR packing <= 0;
UPDATE vn.itemShelving
SET packing = 1
WHERE packing IS NULL
OR NOT packing;
SET @isTriggerDisabled := FALSE;
ALTER TABLE vn.buy MODIFY COLUMN packing int(11) NOT NULL CHECK(packing > 0);
ALTER TABLE vn.itemShelving MODIFY COLUMN packing int(11) NOT NULL CHECK(packing > 0);
-- Antes tenia '0=sin obligar 1=groping 2=packing' (groping → grouping)
ALTER TABLE vn.buy MODIFY COLUMN groupingMode tinyint(4) DEFAULT 0 NOT NULL COMMENT '0=sin obligar 1=grouping 2=packing';

View File

@ -0,0 +1,36 @@
USE vn;
CREATE OR REPLACE TABLE vn.workerActivityType (
`code` varchar(20) NOT NULL,
`description` varchar(45) NOT NULL,
PRIMARY KEY (`code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
ALTER TABLE vn.department ADD workerActivityTypeFk varchar(20) NULL COMMENT 'Indica la actitividad que desempeña por defecto ese departamento';
ALTER TABLE vn.department ADD CONSTRAINT department_workerActivityType_FK FOREIGN KEY (workerActivityTypeFk) REFERENCES vn.workerActivityType(code) ON DELETE CASCADE ON UPDATE CASCADE;
INSERT INTO vn.workerActivityType (code, description) VALUES('ON_CHECKING', 'REVISION');
INSERT INTO vn.workerActivityType (code, description) VALUES('PREVIOUS_CAM', 'CAMARA');
INSERT INTO vn.workerActivityType (code, description) VALUES('PREVIOUS_ART', 'ARTIFICIAL');
INSERT INTO vn.workerActivityType (code, description) VALUES('ON_PREPARATION', 'SACADO');
INSERT INTO vn.workerActivityType (code, description) VALUES('PACKING', 'ENCAJADO');
INSERT INTO vn.workerActivityType (code, description) VALUES('FIELD', 'CAMPOS');
INSERT INTO vn.workerActivityType (code, description) VALUES('DELIVERY', 'REPARTO');
INSERT INTO vn.workerActivityType (code, description) VALUES('STORAGE', 'ALMACENAJE');
INSERT INTO vn.workerActivityType (code, description) VALUES('PALLETIZING', 'PALETIZADO');
INSERT INTO vn.workerActivityType (code, description) VALUES('STOP', 'PARADA');
INSERT INTO salix.ACL ( model, property, accessType, permission, principalType, principalId) VALUES('WorkerActivityType', '*', 'READ', 'ALLOW', 'ROLE', 'production');
INSERT INTO salix.ACL ( model, property, accessType, permission, principalType, principalId) VALUES('WorkerActivity', '*', '*', 'ALLOW', 'ROLE', 'production');
ALTER TABLE vn.workerActivity MODIFY COLUMN event enum('open','close','insert','delete','update','refresh') CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci NULL;
ALTER TABLE vn.workerActivity MODIFY COLUMN model enum('COM','ENT','TPV','ENC','LAB','ETI','APP') CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci NOT NULL;
ALTER TABLE vn.workerActivity ADD workerActivityTypeFk varchar(20) NULL;
ALTER TABLE vn.workerActivity ADD CONSTRAINT workerActivity_workerActivityType_FK FOREIGN KEY (workerActivityTypeFk) REFERENCES vn.workerActivityType(code) ON DELETE CASCADE ON UPDATE CASCADE;

View File

@ -102,7 +102,7 @@
</vn-item> </vn-item>
<vn-item class="dropdown" <vn-item class="dropdown"
vn-click-stop="refundMenu.show($event, 'left')" vn-click-stop="refundMenu.show($event, 'left')"
vn-tooltip="Create a single ticket with all the content of the current invoice" vn-tooltip="Create a refund ticket for each ticket on the current invoice"
vn-acl="invoicing, claimManager, salesAssistant" vn-acl="invoicing, claimManager, salesAssistant"
vn-acl-action="remove" vn-acl-action="remove"
translate> translate>

View File

@ -118,11 +118,14 @@ class Controller extends Section {
const query = 'InvoiceOuts/refund'; const query = 'InvoiceOuts/refund';
const params = {ref: this.invoiceOut.ref, withWarehouse: withWarehouse}; const params = {ref: this.invoiceOut.ref, withWarehouse: withWarehouse};
this.$http.post(query, params).then(res => { this.$http.post(query, params).then(res => {
const refundTicket = res.data; const tickets = res.data;
this.vnApp.showSuccess(this.$t('The following refund ticket have been created', { const refundTickets = tickets.map(ticket => ticket.id);
ticketId: refundTicket.id
this.vnApp.showSuccess(this.$t('The following refund tickets have been created', {
ticketId: refundTickets.join(',')
})); }));
this.$state.go('ticket.card.sale', {id: refundTicket.id}); if (refundTickets.length == 1)
this.$state.go('ticket.card.sale', {id: refundTickets[0]});
}); });
} }

View File

@ -15,7 +15,7 @@ Are you sure you want to clone this invoice?: Estas seguro de clonar esta factur
InvoiceOut booked: Factura asentada InvoiceOut booked: Factura asentada
Are you sure you want to book this invoice?: Estas seguro de querer asentar esta factura? Are you sure you want to book this invoice?: Estas seguro de querer asentar esta factura?
Are you sure you want to refund this invoice?: Estas seguro de querer abonar esta factura? Are you sure you want to refund this invoice?: Estas seguro de querer abonar esta factura?
Create a single ticket with all the content of the current invoice: Crear un ticket unico con todo el contenido de la factura actual Create a refund ticket for each ticket on the current invoice: Crear un ticket abono por cada ticket de la factura actual
Regenerate PDF invoice: Regenerar PDF factura Regenerate PDF invoice: Regenerar PDF factura
The invoice PDF document has been regenerated: El documento PDF de la factura ha sido regenerado The invoice PDF document has been regenerated: El documento PDF de la factura ha sido regenerado
The email can't be empty: El correo no puede estar vacío The email can't be empty: El correo no puede estar vacío

View File

@ -30,9 +30,11 @@ module.exports = Self => {
}); });
function validateDistance(err) { function validateDistance(err) {
const routeTotalKm = this.kmEnd - this.kmStart; if (this.kmEnd) {
const routeMaxKm = 4000; const routeTotalKm = this.kmEnd - this.kmStart;
if (routeTotalKm > routeMaxKm || this.kmStart > this.kmEnd) const routeMaxKm = 4000;
err(); if (routeTotalKm > routeMaxKm || this.kmStart > this.kmEnd)
err();
}
} }
}; };

View File

@ -14,7 +14,8 @@ Refund all...: Abonar todo...
with warehouse: con almacén with warehouse: con almacén
without warehouse: sin almacén without warehouse: sin almacén
Invoice sent: Factura enviada Invoice sent: Factura enviada
The following refund ticket have been created: "Se ha creado siguiente ticket de abono: {{ticketId}}" The following refund ticket have been created: "Se ha creado el siguiente ticket de abono: {{ticketId}}"
The following refund tickets have been created: "Se han creado los siguientes tickets de abono: {{ticketId}}"
Transfer client: Transferir cliente Transfer client: Transferir cliente
Send SMS...: Enviar SMS... Send SMS...: Enviar SMS...
Notify changes: Notificar cambios Notify changes: Notificar cambios

View File

@ -62,6 +62,11 @@
"type": "belongsTo", "type": "belongsTo",
"model": "Worker", "model": "Worker",
"foreignKey": "workerFk" "foreignKey": "workerFk"
},
"workerActivity": {
"type": "belongsTo",
"model": "Worker",
"foreignKey": "workerActivityTypeFk"
} }
} }
} }

View File

@ -1,6 +1,6 @@
{ {
"name": "salix-back", "name": "salix-back",
"version": "24.12.0", "version": "24.14.0",
"author": "Verdnatura Levante SL", "author": "Verdnatura Levante SL",
"description": "Salix backend", "description": "Salix backend",
"license": "GPL-3.0", "license": "GPL-3.0",