refs #5858 fix accepts

This commit is contained in:
Carlos Satorres 2024-02-20 13:04:45 +01:00
parent 7a0320270a
commit 728224cad9
5 changed files with 21 additions and 21 deletions

View File

@ -22,7 +22,7 @@ module.exports = Self => {
}, },
{ {
arg: 'fi', arg: 'fi',
type: 'string' type: 'any'
}, },
{ {
arg: 'street', arg: 'street',
@ -30,19 +30,19 @@ module.exports = Self => {
}, },
{ {
arg: 'postcode', arg: 'postcode',
type: 'string' type: 'any'
}, },
{ {
arg: 'city', arg: 'city',
type: 'string' type: 'any'
}, },
{ {
arg: 'countryFk', arg: 'countryFk',
type: 'number' type: 'any'
}, },
{ {
arg: 'provinceFk', arg: 'provinceFk',
type: 'number' type: 'any'
}, },
{ {
arg: 'sageTaxTypeFk', arg: 'sageTaxTypeFk',

View File

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

View File

@ -46,10 +46,10 @@ module.exports = Self => {
type: 'any' type: 'any'
}, { }, {
arg: 'supplierActivityFk', arg: 'supplierActivityFk',
type: 'string' type: 'any'
}, { }, {
arg: 'healthRegister', arg: 'healthRegister',
type: 'string' type: 'any'
}, { }, {
arg: 'isVies', arg: 'isVies',
type: 'boolean' type: 'boolean'

View File

@ -129,10 +129,13 @@ describe('loopback model Supplier', () => {
const options = {transaction: tx}; const options = {transaction: tx};
try { try {
const newSupplier = await models.Supplier.create({name: 'ALFRED PENNYWORTH'}, options); const newSupplier = {
const fetchedSupplier = await models.Supplier.findById(newSupplier.id, null, options); name: 'ALFRED PENNYWORTH', nif: '87805752D', city: 'Gotham'
};
const supplierCreated = await models.Supplier.create(newSupplier, options);
const fetchedSupplier = await models.Supplier.findById(supplierCreated.id, null, options);
expect(Number(fetchedSupplier.account)).toEqual(4100000000 + newSupplier.id); expect(Number(fetchedSupplier.account)).toEqual(4100000000 + supplierCreated.id);
await tx.rollback(); await tx.rollback();
} catch (e) { } catch (e) {
await tx.rollback(); await tx.rollback();

View File

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