refs #5858 fix accepts
This commit is contained in:
parent
7a0320270a
commit
728224cad9
|
@ -22,7 +22,7 @@ module.exports = Self => {
|
|||
},
|
||||
{
|
||||
arg: 'fi',
|
||||
type: 'string'
|
||||
type: 'any'
|
||||
},
|
||||
{
|
||||
arg: 'street',
|
||||
|
@ -30,19 +30,19 @@ module.exports = Self => {
|
|||
},
|
||||
{
|
||||
arg: 'postcode',
|
||||
type: 'string'
|
||||
type: 'any'
|
||||
},
|
||||
{
|
||||
arg: 'city',
|
||||
type: 'string'
|
||||
type: 'any'
|
||||
},
|
||||
{
|
||||
arg: 'countryFk',
|
||||
type: 'number'
|
||||
type: 'any'
|
||||
},
|
||||
{
|
||||
arg: 'provinceFk',
|
||||
type: 'number'
|
||||
type: 'any'
|
||||
},
|
||||
{
|
||||
arg: 'sageTaxTypeFk',
|
||||
|
|
|
@ -26,7 +26,8 @@ describe('Supplier newSupplier()', () => {
|
|||
const options = {transaction: tx};
|
||||
ctx.args = {
|
||||
name: 'NEWSUPPLIER',
|
||||
nif: '12345678Z'
|
||||
nif: '12345678Z',
|
||||
city: 'Gotham'
|
||||
};
|
||||
|
||||
const result = await models.Supplier.newSupplier(ctx, options);
|
||||
|
|
|
@ -46,10 +46,10 @@ module.exports = Self => {
|
|||
type: 'any'
|
||||
}, {
|
||||
arg: 'supplierActivityFk',
|
||||
type: 'string'
|
||||
type: 'any'
|
||||
}, {
|
||||
arg: 'healthRegister',
|
||||
type: 'string'
|
||||
type: 'any'
|
||||
}, {
|
||||
arg: 'isVies',
|
||||
type: 'boolean'
|
||||
|
|
|
@ -129,10 +129,13 @@ describe('loopback model Supplier', () => {
|
|||
const options = {transaction: tx};
|
||||
|
||||
try {
|
||||
const newSupplier = await models.Supplier.create({name: 'ALFRED PENNYWORTH'}, options);
|
||||
const fetchedSupplier = await models.Supplier.findById(newSupplier.id, null, options);
|
||||
const newSupplier = {
|
||||
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();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
|
|
|
@ -17,17 +17,13 @@ module.exports = Self => {
|
|||
message: 'The social name cannot be empty'
|
||||
});
|
||||
|
||||
if (this.city) {
|
||||
Self.validatesPresenceOf('city', {
|
||||
message: 'City cannot be empty'
|
||||
});
|
||||
}
|
||||
Self.validatesPresenceOf('city', {
|
||||
message: 'City cannot be empty'
|
||||
});
|
||||
|
||||
if (this.nif) {
|
||||
Self.validatesPresenceOf('nif', {
|
||||
message: 'The nif cannot be empty'
|
||||
});
|
||||
}
|
||||
Self.validatesPresenceOf('nif', {
|
||||
message: 'The nif cannot be empty'
|
||||
});
|
||||
|
||||
Self.validatesUniquenessOf('nif', {
|
||||
message: 'TIN must be unique'
|
||||
|
|
Loading…
Reference in New Issue