feat: reponse readable text and linting some pages.

This commit is contained in:
a.bouhuolia
2021-01-02 10:44:38 +02:00
parent d30e76c5cf
commit b6392e4208
9 changed files with 164 additions and 85 deletions

View File

@@ -130,13 +130,12 @@ export default class CustomersService {
* @return {Promise<void>}
*/
public async deleteCustomer(tenantId: number, customerId: number): Promise<void> {
const { Contact } = this.tenancy.models(tenantId);
this.logger.info('[customer] trying to delete customer.', { tenantId, customerId });
await this.getCustomerByIdOrThrowError(tenantId, customerId);
await this.customerHasNoInvoicesOrThrowError(tenantId, customerId);
await Contact.query().findById(customerId).delete();
await this.contactService.deleteContact(tenantId, customerId, 'customer');
await this.eventDispatcher.dispatch(events.customers.onDeleted, { tenantId, customerId });
this.logger.info('[customer] deleted successfully.', { tenantId, customerId });

View File

@@ -120,8 +120,6 @@ export default class VendorsService {
* @return {Promise<void>}
*/
public async deleteVendor(tenantId: number, vendorId: number) {
const { Contact } = this.tenancy.models(tenantId);
await this.getVendorByIdOrThrowError(tenantId, vendorId);
await this.vendorHasNoBillsOrThrowError(tenantId, vendorId);
@@ -129,7 +127,7 @@ export default class VendorsService {
tenantId,
vendorId,
});
await Contact.query().findById(vendorId).delete();
await this.contactService.deleteContact(tenantId, vendorId, 'vendor');
await this.eventDispatcher.dispatch(events.vendors.onDeleted, {
tenantId,