DEP: #7004 - HOTFIX Create new Supplier #2148

Closed
jsegarra wants to merge 9 commits from 7004_hotFix_newSupplier into master
8 changed files with 232 additions and 233 deletions

View File

@ -32,6 +32,7 @@ describe('Supplier fiscal data path', () => {
};
const errorMessage = await page.sendForm(form, {
city: 'Valencia',
taxNumber: 'Wrong tax number'
});
const message = await page.sendForm(form, values);

View File

@ -209,5 +209,6 @@
"You cannot update these fields": "You cannot update these fields",
"CountryFK cannot be empty": "Country cannot be empty",
"You are not allowed to modify the alias": "You are not allowed to modify the alias",
"You already have the mailAlias": "You already have the mailAlias"
"You already have the mailAlias": "You already have the mailAlias",
"The city cannot be empty": "The city cannot be empty"
}

View File

@ -170,6 +170,7 @@
"companyFk": "Empresa",
"The social name cannot be empty": "La razón social no puede quedar en blanco",
"The nif cannot be empty": "El NIF no puede quedar en blanco",
"The city cannot be empty": "La ciudad no puede estar vacía",
"You need to fill sage information before you check verified data": "Debes rellenar la información de sage antes de marcar datos comprobados",
"ASSIGN_ZONE_FIRST": "Asigna una zona primero",
"Amount cannot be zero": "El importe no puede ser cero",

View File

@ -25,9 +25,7 @@ describe('Supplier newSupplier()', () => {
try {
const options = {transaction: tx};
ctx.args = {
name: 'NEWSUPPLIER',
nif: '12345678Z',
city: 'Gotham'
name: 'NEWSUPPLIER'
};
const result = await models.Supplier.newSupplier(ctx, options);

View File

@ -61,7 +61,7 @@ describe('Supplier updateFiscalData()', () => {
sageTransactionTypeFk,
undefined,
undefined,
undefined,
city,
provinceFk,
countryFk,
supplierActivityFk,
@ -78,7 +78,7 @@ describe('Supplier updateFiscalData()', () => {
const supplier = await models.Supplier.updateFiscalData(ctx,
supplierId,
undefined,
undefined,
nif,
account,
phone,
undefined,
@ -96,9 +96,9 @@ describe('Supplier updateFiscalData()', () => {
options);
expect(supplier.account).toEqual(account);
expect(supplier.nif).toEqual(nif);
expect(supplier.phone).toEqual(phone);
expect(supplier.postCode).toEqual(postCode);
expect(supplier.account).toEqual(account);
expect(supplier.city).toEqual(city);
expect(supplier.provinceFk).toEqual(provinceFk);
});

View File

@ -13,7 +13,7 @@ module.exports = Self => {
type: 'string'
}, {
arg: 'nif',
type: 'string'
type: 'any'
}, {
arg: 'account',
type: 'any'
@ -37,7 +37,7 @@ module.exports = Self => {
type: 'any'
}, {
arg: 'city',
type: 'string'
type: 'any'
}, {
arg: 'provinceFk',
type: 'any'
@ -87,6 +87,14 @@ module.exports = Self => {
}
}
if (city === null || (city === undefined && !supplier.city)) {
Outdated
Review

Y pq no poner los argumentos como requeridos?

Y pq no poner los argumentos como requeridos?

No puedes hacer eso porque la segunda vez que guardas, si esos campos no los has modificado te dará error porque en el body de la request no aparece

No puedes hacer eso porque la segunda vez que guardas, si esos campos no los has modificado te dará error porque en el body de la request no aparece
Outdated
Review

Entonces con if pasaria lo mismo

Entonces con if pasaria lo mismo

He modificado la condición porque lo que no queremos que sea null y antes aceptaba undefined y null.
Ahora es mas restrictivo.

He modificado la condición porque lo que no queremos que sea null y antes aceptaba undefined y null. Ahora es mas restrictivo.
throw new UserError('The city cannot be empty'
);
}
if (nif === null || (nif === undefined && !supplier.nif)) {
throw new UserError('The nif cannot be empty'
);
}
return supplier.updateAttributes({
name,
nif,

View File

@ -16,15 +16,6 @@ module.exports = Self => {
Self.validatesPresenceOf('name', {
message: 'The social name cannot be empty'
});
Self.validatesPresenceOf('city', {
message: 'City cannot be empty'
});
Self.validatesPresenceOf('nif', {
message: 'The nif cannot be empty'
});
Self.validatesUniquenessOf('nif', {
message: 'TIN must be unique'
});

View File

@ -53,8 +53,8 @@
label="Tax number"
vn-name="taxNumber"
ng-model="$ctrl.supplier.nif"
required="true"
rule>
>
</vn-textfield>
</vn-horizontal>
<vn-horizontal>
@ -168,8 +168,7 @@
fields="['id', 'name', 'provinceFk']"
show-field="name"
value-field="name"
required="true"
rule>
>
<tpl-item>
{{name}}, {{province.name}}
({{province.country.country}})