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

This commit is contained in:
Guillermo Bonet 2024-02-12 07:56:38 +00:00
commit fc5daf119c
10 changed files with 154 additions and 42 deletions

View File

@ -15,11 +15,13 @@ BEGIN
p.code, p.code,
ish.id, ish.id,
s.priority, s.priority,
ish.isChecked ish.isChecked,
ic.url
FROM itemShelving ish FROM itemShelving ish
JOIN item i ON i.id = ish.itemFk JOIN item i ON i.id = ish.itemFk
JOIN shelving s ON vSelf = s.code COLLATE utf8_unicode_ci JOIN shelving s ON vSelf = s.code COLLATE utf8_unicode_ci
LEFT JOIN parking p ON s.parkingFk = p.id LEFT JOIN parking p ON s.parkingFk = p.id
JOIN hedera.imageConfig ic
WHERE ish.shelvingFk COLLATE utf8_unicode_ci = vSelf; WHERE ish.shelvingFk COLLATE utf8_unicode_ci = vSelf;
END$$ END$$
DELIMITER ; DELIMITER ;

View File

@ -1 +0,0 @@
REVOKE EXECUTE ON FUNCTION vn2008.red FROM hrBoss, salesPerson;

View File

@ -1 +1,60 @@
REVOKE EXECUTE ON FUNCTION vn2008.cc_to_iban FROM hr, financial; DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `util`.`accountNumberToIban`(
vAccount VARCHAR(20)
)
RETURNS varchar(4) CHARSET utf8mb3 COLLATE utf8mb3_general_ci
DETERMINISTIC
BEGIN
/**
* Calcula y genera el código IBAN correspondiente
* a un número de cuenta bancaria español.
*
* @param vAccount Número de cuenta bancaria
* @return vIban Código IBAN de 4 caracteres.
*/
DECLARE vIban VARCHAR(4);
SELECT
CONCAT('ES',
RIGHT(
CONCAT(0,
98-MOD(
CONCAT(
MOD(
CONCAT(
MOD(
CONCAT(
MOD(
SUBSTRING(vAccount, 1, 8),
97
),
SUBSTRING(vAccount,9,8)
),
97
),
SUBSTRING(
CONCAT(vAccount, 142800),
17,
8
)
),
97
),
SUBSTRING(
CONCAT(vAccount, 142800),
25,
2
)
),
97
)
),
2
)
) INTO vIban;
RETURN vIban;
END$$
DELIMITER ;
GRANT EXECUTE ON FUNCTION util.accountNumberToIban TO hr, financial;

View File

@ -0,0 +1,34 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`intrastat_estimateNet`(
vSelf INT,
vStems INT
)
RETURNS double
DETERMINISTIC
BEGIN
/**
* Calcula un valor neto estimado en función de
* datos históricos de facturas intrastat.
*
* @param vSelf Id de intrastat
* @param vStems Número de unidades
* @return vNet
*/
DECLARE vNet DOUBLE;
SELECT ROUND(vStems / (SUM(average) / COUNT(average)), 2) INTO vNet
FROM (
SELECT *, stems / net average
FROM invoiceInIntrastat
WHERE intrastatFk = vSelf
AND net
AND stems > 0
ORDER BY dated DESC
LIMIT 20
) sub;
RETURN vNet/2;
END$$
DELIMITER ;
GRANT EXECUTE ON FUNCTION vn.intrastat_estimateNet TO administrative;

View File

@ -206,5 +206,6 @@
"Incorrect pin": "Incorrect pin.", "Incorrect pin": "Incorrect pin.",
"The notification subscription of this worker cant be modified": "The notification subscription of this worker cant be modified", "The notification subscription of this worker cant be modified": "The notification subscription of this worker cant be modified",
"Name should be uppercase": "Name should be uppercase", "Name should be uppercase": "Name should be uppercase",
"You cannot update these fields": "You cannot update these fields" "You cannot update these fields": "You cannot update these fields",
"CountryFK cannot be empty": "Country cannot be empty"
} }

View File

@ -340,5 +340,6 @@
"Name should be uppercase": "El nombre debe ir en mayúscula", "Name should be uppercase": "El nombre debe ir en mayúscula",
"Bank entity must be specified": "La entidad bancaria es obligatoria", "Bank entity must be specified": "La entidad bancaria es obligatoria",
"An email is necessary": "Es necesario un email", "An email is necessary": "Es necesario un email",
"You cannot update these fields": "No puedes actualizar estos campos" "You cannot update these fields": "No puedes actualizar estos campos",
"CountryFK cannot be empty": "El país no puede estar vacío"
} }

View File

@ -66,6 +66,7 @@ module.exports = Self => {
cou.country, cou.country,
c.id clientId, c.id clientId,
c.socialName clientSocialName, c.socialName clientSocialName,
u.nickname workerSocialName,
SUM(s.quantity * s.price * ( 100 - s.discount ) / 100) amount, SUM(s.quantity * s.price * ( 100 - s.discount ) / 100) amount,
negativeBase.taxableBase, negativeBase.taxableBase,
negativeBase.ticketFk, negativeBase.ticketFk,
@ -80,6 +81,7 @@ module.exports = Self => {
JOIN vn.client c ON c.id = t.clientFk JOIN vn.client c ON c.id = t.clientFk
JOIN vn.country cou ON cou.id = c.countryFk JOIN vn.country cou ON cou.id = c.countryFk
LEFT JOIN vn.worker w ON w.id = c.salesPersonFk LEFT JOIN vn.worker w ON w.id = c.salesPersonFk
JOIN account.user u ON u.id = w.id
LEFT JOIN ( LEFT JOIN (
SELECT ticketFk, taxableBase SELECT ticketFk, taxableBase
FROM tmp.ticketAmount FROM tmp.ticketAmount

View File

@ -16,7 +16,7 @@ class Controller extends Section {
this.filter = { this.filter = {
where: { where: {
itemFk: this.$params.id, itemFk: this.$params.id,
shipped: { landed: {
between: [from, to] between: [from, to]
} }
} }
@ -36,7 +36,7 @@ class Controller extends Section {
const to = new Date(this._dateTo); const to = new Date(this._dateTo);
to.setHours(23, 59, 59, 59); to.setHours(23, 59, 59, 59);
this.filter.where.shipped = { this.filter.where.landed = {
between: [from, to] between: [from, to]
}; };
this.$.model.refresh(); this.$.model.refresh();
@ -53,7 +53,7 @@ class Controller extends Section {
const to = new Date(value); const to = new Date(value);
to.setHours(23, 59, 59, 59); to.setHours(23, 59, 59, 59);
this.filter.where.shipped = { this.filter.where.landed = {
between: [from, to] between: [from, to]
}; };
this.$.model.refresh(); this.$.model.refresh();

View File

@ -1,3 +1,4 @@
const UserError = require('vn-loopback/util/user-error');
module.exports = Self => { module.exports = Self => {
Self.remoteMethodCtx('driverRouteEmail', { Self.remoteMethodCtx('driverRouteEmail', {
description: 'Sends the driver route email with an attached PDF', description: 'Sends the driver route email with an attached PDF',
@ -9,24 +10,14 @@ module.exports = Self => {
required: true, required: true,
description: 'The client id', description: 'The client id',
http: {source: 'path'} http: {source: 'path'}
}, }, {
{
arg: 'recipient',
type: 'string',
description: 'The recipient email',
required: true,
},
{
arg: 'replyTo', arg: 'replyTo',
type: 'string', type: 'string',
description: 'The sender email to reply to', description: 'The sender email to reply to',
required: false }, {
},
{
arg: 'recipientId', arg: 'recipientId',
type: 'number', type: 'number',
description: 'The recipient id to send to the recipient preferred language', description: 'The recipient id to send to the recipient preferred language',
required: false
} }
], ],
returns: { returns: {
@ -39,5 +30,28 @@ module.exports = Self => {
} }
}); });
Self.driverRouteEmail = ctx => Self.sendTemplate(ctx, 'driver-route'); Self.driverRouteEmail = async(ctx, id) => {
const models = Self.app.models;
const {workerFk, agencyMode} = await Self.findById(id, {
fields: ['workerFk', 'agencyModeFk'],
include: {relation: 'agencyMode'}
});
const {reportMail} = agencyMode();
let user;
let account;
if (workerFk) {
user = await models.VnUser.findById(workerFk, {
fields: ['active', 'id'],
include: {relation: 'emailUser'}
});
account = await models.Account.findById(workerFk);
}
if (user?.active && account) ctx.args.recipient = user.emailUser().email;
else ctx.args.recipient = reportMail;
if (!ctx.args.recipient) throw new UserError('An email is necessary');
return Self.sendTemplate(ctx, 'driver-route');
};
}; };