feat: refs #7731 modificar columna
gitea/salix/pipeline/pr-dev There was a failure building this commit Details

This commit is contained in:
Robert Ferrús 2024-10-21 14:50:53 +02:00
parent 1def362a8f
commit 7b1362a9d5
8 changed files with 139 additions and 9 deletions

View File

@ -50,7 +50,7 @@ BEGIN
s.account supplierAccount,
s.name supplierName,
s.nif,
s.IsVies,
s.viesCode,
iit.taxTypeSageFk,
tt.code taxCode,
ti.Iva,
@ -281,7 +281,7 @@ BEGIN
JOIN sage.config c
WHERE tii.taxCode = 'ISP21' OR MID(tii.supplierAccount, 4, 1) = '1'
AND tii.taxTypeSageFk IS NOT NULL
AND NOT(tii.isVies
AND NOT(tii.viesCode
AND c.nontaxableTransactionTypeFk = tii.transactionTypeSageFk
AND tii.taxCode = 'nonTaxable')
GROUP BY tii.PorcentajeIva, tii.expenseFk;

View File

@ -2,6 +2,9 @@ use vn;
ALTER TABLE vn.client
ADD COLUMN IF NOT EXISTS viesCode varchar(2) DEFAULT NULL;
ALTER TABLE vn.supplier
ADD COLUMN IF NOT EXISTS viesCode varchar(2) DEFAULT NULL;
UPDATE vn.client c
JOIN country c2 ON c2.id = c.countryFk
SET c.viesCode = 'ES'
@ -86,3 +89,123 @@ UPDATE client c
JOIN country c2 ON c2.id = c.countryFk
SET c.viesCode = 'HU'
WHERE c2.name = 'Hungria';
UPDATE supplier s
JOIN country c ON c.id = s.countryFk
SET c.viesCode = 'DE'
WHERE c.name = 'Alemania';
UPDATE supplier s
JOIN country c ON c.id = s.countryFk
SET c.viesCode = 'AT'
WHERE c.name = 'Austria';
UPDATE supplier s
JOIN country c ON c.id = s.countryFk
SET c.viesCode = 'BE'
WHERE c.name = 'Belgica';
UPDATE supplier s
JOIN country c ON c.id = s.countryFk
SET c.viesCode = 'BG'
WHERE c.name = 'Bulgaria';
UPDATE supplier s
JOIN country c ON c.id = s.countryFk
SET c.viesCode = 'CZ'
WHERE c.name = 'Chequia';
UPDATE supplier s
JOIN country c ON c.id = s.countryFk
SET c.viesCode = 'CY'
WHERE c.name = 'Chipre';
UPDATE supplier s
JOIN country c ON c.id = s.countryFk
SET c.viesCode = 'DK'
WHERE c.name = 'Dinamarca';
UPDATE supplier s
JOIN country c ON c.id = s.countryFk
SET c.viesCode = 'SK'
WHERE c.name = 'Eslovaquia';
UPDATE supplier s
JOIN country c ON c.id = s.countryFk
SET c.viesCode = 'SI'
WHERE c.name = 'Eslovenia';
UPDATE supplier s
JOIN country c ON c.id = s.countryFk
SET c.viesCode = 'ES'
WHERE c.name = 'España';
UPDATE supplier s
JOIN country c ON c.id = s.countryFk
SET c.viesCode = 'FI'
WHERE c.name = 'Finlandia';
UPDATE supplier s
JOIN country c ON c.id = s.countryFk
SET c.viesCode = 'FR'
WHERE c.name = 'Francia';
UPDATE supplier s
JOIN country c ON c.id = s.countryFk
SET c.viesCode = 'GB'
WHERE c.name = 'Gran Bretaña';
UPDATE supplier s
JOIN country c ON c.id = s.countryFk
SET c.viesCode = 'NL'
WHERE c.name = 'Holanda';
UPDATE supplier s
JOIN country c ON c.id = s.countryFk
SET c.viesCode = 'IE'
WHERE c.name = 'Irlanda';
UPDATE supplier s
JOIN country c ON c.id = s.countryFk
SET c.viesCode = 'IT'
WHERE c.name = 'Italia';
UPDATE supplier s
JOIN country c ON c.id = s.countryFk
SET c.viesCode = 'LV'
WHERE c.name = 'Letonia';
UPDATE supplier s
JOIN country c ON c.id = s.countryFk
SET c.viesCode = 'LT'
WHERE c.name = 'Lituania';
UPDATE supplier s
JOIN country c ON c.id = s.countryFk
SET c.viesCode = 'LU'
WHERE c.name = 'Luxemburgo';
UPDATE supplier s
JOIN country c ON c.id = s.countryFk
SET c.viesCode = 'NO'
WHERE c.name = 'Noruega';
UPDATE supplier s
JOIN country c ON c.id = s.countryFk
SET c.viesCode = 'PL'
WHERE c.name = 'Polonia';
UPDATE supplier s
JOIN country c ON c.id = s.countryFk
SET c.viesCode = 'PT'
WHERE c.name = 'Portugal';
UPDATE supplier s
JOIN country c ON c.id = s.countryFk
SET c.viesCode = 'SE'
WHERE c.name = 'Suecia';
UPDATE supplier s
JOIN country c ON c.id = s.countryFk
SET c.viesCode = 'CH'
WHERE c.name = 'Suiza';

View File

@ -112,7 +112,7 @@ module.exports = Self => {
c.email,
c.created,
c.isActive,
c.isVies,
c.viesCode,
c.isTaxDataChecked,
c.isEqualizated,
c.isFreezed,

View File

@ -121,7 +121,7 @@ module.exports = Self => {
const code = country ? country.code.toLowerCase() : null;
const countryCode = this.fi?.toLowerCase().substring(0, 2);
if (!this.fi || !validateTin(this.fi, code) || (this.isVies && countryCode == code))
if (!this.fi || !validateTin(this.fi, code) || (this.viesCode && countryCode == code))
err();
done();
}

View File

@ -56,6 +56,9 @@ module.exports = Self => {
}, {
arg: 'isTrucker',
type: 'boolean'
}, {
arg: 'viesCode',
type: 'any'
}],
returns: {
arg: 'res',
@ -68,7 +71,7 @@ module.exports = Self => {
}
});
Self.updateFiscalData = async(ctx, supplierId, name, nif, account, phone, sageTaxTypeFk, sageWithholdingFk, sageTransactionTypeFk, postCode, street, city, provinceFk, countryFk, supplierActivityFk, healthRegister, isVies, isTrucker, options) => {
Self.updateFiscalData = async(ctx, supplierId, name, nif, account, phone, sageTaxTypeFk, sageWithholdingFk, sageTransactionTypeFk, postCode, street, city, provinceFk, countryFk, supplierActivityFk, healthRegister, isVies, isTrucker, viesCode, options) => {
const models = Self.app.models;
const {args} = ctx;
const myOptions = {};
@ -103,7 +106,8 @@ module.exports = Self => {
supplierActivityFk,
healthRegister,
isVies,
isTrucker
isTrucker,
viesCode
}, myOptions);
};
};

View File

@ -73,7 +73,7 @@ module.exports = Self => {
const code = country ? country.code.toLowerCase() : null;
const countryCode = this.nif?.toLowerCase().substring(0, 2);
if (!validateTin(this.nif, code) || (this.isVies && countryCode == code))
if (!validateTin(this.nif, code) || (this.viesCode && countryCode == code))
err();
done();
}

View File

@ -113,7 +113,10 @@
},
"isVies": {
"type": "boolean"
}
},
"viesCode": {
"type": "string"
}
},
"relations": {
"payMethod": {

View File

@ -120,7 +120,7 @@ module.exports = async function(ctx, Self, tickets, options) {
JOIN client c ON c.id = t.clientFk
WHERE t.clientFk = ?
AND NOT t.isDeleted
AND c.isVies
AND c.viesCode
`,
[ticket.clientFk],
myOptions);