refs #4617 use temporary instead of vn #1451

Merged
alexm merged 6 commits from 4617-use_tmp_in_ticketToInvoice into dev 2023-05-04 05:07:26 +00:00
12 changed files with 47 additions and 23 deletions
Showing only changes of commit 306d73eb69 - Show all commits

View File

@ -0,0 +1,5 @@
UPDATE vn.supplier s
JOIN vn.country c ON c.id = s.countryFk
SET s.nif = MID(REPLACE(s.nif, ' ', ''), 3, LENGTH(REPLACE(s.nif, ' ', '')) - 1)
WHERE s.isVies = TRUE
AND c.code = LEFT(REPLACE(s.nif, ' ', ''), 2);

View File

@ -0,0 +1,5 @@
UPDATE IGNORE vn.client c
JOIN vn.country co ON co.id = c.countryFk
SET c.fi = MID(REPLACE(c.fi, ' ', ''), 3, LENGTH(REPLACE(c.fi, ' ', '')) - 1)
WHERE c.isVies = TRUE
AND co.code = LEFT(REPLACE(c.fi, ' ', ''), 2);

View File

@ -279,15 +279,16 @@
"Comment added to client": "Observación añadida al cliente {{clientFk}}", "Comment added to client": "Observación añadida al cliente {{clientFk}}",
"Cannot create a new claimBeginning from a different ticket": "No se puede crear una línea de reclamación de un ticket diferente al origen", "Cannot create a new claimBeginning from a different ticket": "No se puede crear una línea de reclamación de un ticket diferente al origen",
"company": "Compañía", "company": "Compañía",
"country": "País", "country": "País",
"clientId": "Id cliente", "clientId": "Id cliente",
"clientSocialName": "Cliente", "clientSocialName": "Cliente",
"amount": "Importe", "amount": "Importe",
"taxableBase": "Base", "taxableBase": "Base",
"ticketFk": "Id ticket", "ticketFk": "Id ticket",
"isActive": "Activo", "isActive": "Activo",
"hasToInvoice": "Facturar", "hasToInvoice": "Facturar",
"isTaxDataChecked": "Datos comprobados", "isTaxDataChecked": "Datos comprobados",
"comercialId": "Id comercial", "comercialId": "Id comercial",
"comercialName": "Comercial" "comercialName": "Comercial",
} "Invalid NIF for VIES": "Invalid NIF for VIES"
}

View File

@ -14,7 +14,7 @@ module.exports = Self => {
Self.validatesPresenceOf('street', { Self.validatesPresenceOf('street', {
message: 'Street cannot be empty' message: 'Street cannot be empty'
}); });
Self.validatesPresenceOf('city', { Self.validatesPresenceOf('city', {
message: 'City cannot be empty' message: 'City cannot be empty'
}); });
@ -89,8 +89,9 @@ module.exports = Self => {
}; };
const country = await Self.app.models.Country.findOne(filter); const country = await Self.app.models.Country.findOne(filter);
const code = country ? country.code.toLowerCase() : null; const code = country ? country.code.toLowerCase() : null;
const countryCode = this.fi.toLowerCase().substring(0, 2);
if (!this.fi || !validateTin(this.fi, code)) if (!this.fi || !validateTin(this.fi, code) || (this.isVies && countryCode == code))
err(); err();
done(); done();
} }

View File

@ -72,7 +72,9 @@
<vn-horizontal> <vn-horizontal>
<vn-check vn-one label="Has to invoice" ng-model="$ctrl.client.hasToInvoice"> <vn-check vn-one label="Has to invoice" ng-model="$ctrl.client.hasToInvoice">
</vn-check> </vn-check>
<vn-check vn-one label="Vies" ng-model="$ctrl.client.isVies"> <vn-check vn-one label="Vies"
info="When activating it, do not enter the country code in the ID field."
ng-model="$ctrl.client.isVies">
</vn-check> </vn-check>
</vn-horizontal> </vn-horizontal>
<vn-horizontal> <vn-horizontal>

View File

@ -12,3 +12,5 @@ Previous client: Cliente anterior
In case of a company succession, specify the grantor company: En el caso de que haya habido una sucesión de empresa, indicar la empresa cedente In case of a company succession, specify the grantor company: En el caso de que haya habido una sucesión de empresa, indicar la empresa cedente
Incoterms authorization: Autorización incoterms Incoterms authorization: Autorización incoterms
Electronic invoice: Factura electrónica Electronic invoice: Factura electrónica
When activating it, do not enter the country code in the IF.: Al activarlo, no informar el código del país en el campo IF
The first two values are letters: Los dos primeros valores son letras

View File

@ -19,13 +19,14 @@ describe('Supplier newSupplier()', () => {
}); });
}); });
it('should create a new supplier containing only the name', async() => { it('should create a new supplier containing only the name and the nif', async() => {
const tx = await models.Supplier.beginTransaction({}); const tx = await models.Supplier.beginTransaction({});
try { try {
const options = {transaction: tx}; const options = {transaction: tx};
ctx.args = { ctx.args = {
name: 'newSupplier' name: 'newSupplier',
nif: '12345678Z'
}; };
const result = await models.Supplier.newSupplier(ctx, options); const result = await models.Supplier.newSupplier(ctx, options);

View File

@ -67,8 +67,9 @@ module.exports = Self => {
}; };
const country = await Self.app.models.Country.findOne(filter); const country = await Self.app.models.Country.findOne(filter);
const code = country ? country.code.toLowerCase() : null; const code = country ? country.code.toLowerCase() : null;
const countryCode = this.nif.toLowerCase().substring(0, 2);
if (!this.nif || !validateTin(this.nif, code)) if (!this.nif || !validateTin(this.nif, code) || (this.isVies && countryCode == code))
err(); err();
done(); done();
} }

View File

@ -54,7 +54,8 @@
name="taxNumber" name="taxNumber"
ng-model="$ctrl.supplier.nif" ng-model="$ctrl.supplier.nif"
required="true" required="true"
rule> rule
>
</vn-textfield> </vn-textfield>
</vn-horizontal> </vn-horizontal>
<vn-horizontal> <vn-horizontal>
@ -210,7 +211,9 @@
<vn-check <vn-check
class="vn-ml-lg" class="vn-ml-lg"
label="Vies" label="Vies"
ng-model="$ctrl.supplier.isVies"> info="When activating it, do not enter the country code in the ID field."
ng-model="$ctrl.supplier.isVies"
>
</vn-check> </vn-check>
</vn-two> </vn-two>
</vn-horizontal> </vn-horizontal>

View File

@ -3,4 +3,6 @@ Sage transaction type: Tipo de transacción Sage
Sage withholding: Retención Sage Sage withholding: Retención Sage
Supplier activity: Actividad proveedor Supplier activity: Actividad proveedor
Healt register: Pasaporte sanitario Healt register: Pasaporte sanitario
Trucker: Transportista Trucker: Transportista
When activating it, do not enter the country code in the ID field.: Al activarlo, no informar el código del país en el campo nif
The first two values are letters.: Los dos primeros valores son letras

View File

@ -1 +1,2 @@
Accounts: Cuentas Accounts: Cuentas
Invalid NIF for VIES: NIF no valido por VIES

View File

@ -196,7 +196,7 @@ module.exports = Self => {
client = await models.Client.findById( client = await models.Client.findById(
user.id, user.id,
{fields: ['id', 'name', 'socialName', 'street', 'city', 'iban', 'bankEntityFk', 'defaultAddressFk']}, {fields: ['id', 'name', 'socialName', 'street', 'city', 'iban', 'bankEntityFk', 'defaultAddressFk', 'fi']},
myOptions myOptions
); );