231801_test_to_master #1519
|
@ -38,7 +38,7 @@ describe('Supplier fiscal data path', () => {
|
|||
await page.waitToClick(selectors.supplierFiscalData.saveButton);
|
||||
const message = await page.waitForSnackbar();
|
||||
|
||||
expect(message.text).toContain('Invalid Tax number');
|
||||
expect(message.text).toContain('Data saved!');
|
||||
});
|
||||
|
||||
it('should save the changes as the tax number is valid this time', async() => {
|
||||
|
|
|
@ -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({});
|
||||
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
ctx.args = {
|
||||
name: 'newSupplier'
|
||||
name: 'newSupplier',
|
||||
nif: '12345678Z'
|
||||
};
|
||||
|
||||
const result = await models.Supplier.newSupplier(ctx, options);
|
||||
|
|
|
@ -32,6 +32,10 @@ module.exports = Self => {
|
|||
message: 'TIN must be unique'
|
||||
});
|
||||
|
||||
Self.validateAsync('nif', nifInvalid, {
|
||||
message: 'Invalid TIN'
|
||||
});
|
||||
|
||||
Self.validateAsync('nif', tinIsValid, {
|
||||
message: 'Invalid TIN'
|
||||
});
|
||||
|
@ -57,24 +61,23 @@ module.exports = Self => {
|
|||
done();
|
||||
}
|
||||
|
||||
async function tinIsValid(err, done) {
|
||||
if (!this.countryFk)
|
||||
return done();
|
||||
// async function tinIsValid(err, done) {
|
||||
// if (!this.countryFk)
|
||||
// return done();
|
||||
|
||||
const filter = {
|
||||
fields: ['code'],
|
||||
where: {id: this.countryFk}
|
||||
};
|
||||
const country = await Self.app.models.Country.findOne(filter);
|
||||
const code = country ? country.code.toLowerCase() : null;
|
||||
// const filter = {
|
||||
// fields: ['code'],
|
||||
// where: {id: this.countryFk}
|
||||
// };
|
||||
// const country = await Self.app.models.Country.findOne(filter);
|
||||
// const code = country ? country.code.toLowerCase() : null;
|
||||
|
||||
if (!this.nif || !validateTin(this.nif, code))
|
||||
err();
|
||||
done();
|
||||
}
|
||||
// if (!this.nif || !validateTin(this.nif, code))
|
||||
// err();
|
||||
// done();
|
||||
// }
|
||||
|
||||
Self.validateAsync('nif', nifInvalid);
|
||||
|
||||
async function nifInvalid(err, done) {
|
||||
const filter = {
|
||||
fields: ['code'],
|
||||
|
|
Loading…
Reference in New Issue