fix(Contacts): validate contact associated transcations.

This commit is contained in:
a.bouhuolia
2021-03-22 15:21:52 +02:00
parent 1f6aca63e2
commit d79be910f9
20 changed files with 382 additions and 384 deletions

View File

@@ -55,13 +55,6 @@ export default class VendorsController extends ContactsController {
asyncMiddleware(this.deleteVendor.bind(this)),
this.handlerServiceErrors,
);
router.delete('/', [
...this.bulkContactsSchema,
],
this.validationResult,
asyncMiddleware(this.deleteBulkVendors.bind(this)),
this.handlerServiceErrors,
);
router.get('/:id', [
...this.specificContactSchema,
],
@@ -297,21 +290,16 @@ export default class VendorsController extends ContactsController {
errors: [{ type: 'VENDORS.NOT.FOUND', code: 200 }],
});
}
if (error.errorType === 'some_vendors_have_bills') {
return res.boom.badRequest(null, {
errors: [{ type: 'SOME.VENDORS.HAVE.ASSOCIATED.BILLS', code: 300 }],
});
}
if (error.errorType === 'vendor_has_bills') {
return res.status(400).send({
errors: [{ type: 'VENDOR.HAS.ASSOCIATED.BILLS', code: 400 }],
});
}
if (error.errorType === 'OPENING_BALANCE_DATE_REQUIRED') {
return res.boom.badRequest(null, {
errors: [{ type: 'OPENING_BALANCE_DATE_REQUIRED', code: 500 }],
});
}
if (error.errorType === 'VENDOR_HAS_TRANSACTIONS') {
return res.boom.badRequest(null, {
errors: [{ type: 'VENDOR_HAS_TRANSACTIONS', code: 600 }],
});
}
}
next(error);
}