fix: save payee contact to expense transaction.

This commit is contained in:
a.bouhuolia
2020-12-16 12:23:07 +02:00
parent 76488008c1
commit ddf31feb72
6 changed files with 45 additions and 14 deletions

View File

@@ -31,13 +31,17 @@ export default class ContactsService {
* @param {TContactService} contactService
* @return {Promise<IContact>}
*/
public async getContactByIdOrThrowError(tenantId: number, contactId: number, contactService: TContactService) {
public async getContactByIdOrThrowError(
tenantId: number,
contactId: number,
contactService?: TContactService
) {
const { contactRepository } = this.tenancy.repositories(tenantId);
this.logger.info('[contact] trying to validate contact existance.', { tenantId, contactId });
const contact = await contactRepository.findOne({
id: contactId,
contactService: contactService,
...(contactService) && ({ contactService }),
});
if (!contact) {