231801_test_to_master #1519

Merged
alexm merged 490 commits from 231801_test_to_master into master 2023-05-12 06:29:59 +00:00
3 changed files with 21 additions and 17 deletions
Showing only changes of commit dd4d0bca84 - Show all commits

View File

@ -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() => {

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({});
try {
const options = {transaction: tx};
ctx.args = {
name: 'newSupplier'
name: 'newSupplier',
nif: '12345678Z'
};
const result = await models.Supplier.newSupplier(ctx, options);

View File

@ -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'],