add server to monorepo.

This commit is contained in:
a.bouhuolia
2023-02-03 11:57:50 +02:00
parent 28e309981b
commit 80b97b5fdc
1303 changed files with 137049 additions and 0 deletions

View File

@@ -0,0 +1,30 @@
import { Inject, Service } from 'typedi';
import { ServiceError } from '@/exceptions';
import TenancyService from '@/services/Tenancy/TenancyService';
import { ERRORS } from './constants';
@Service()
export default class DeleteCustomerLinkedCreidtNote {
@Inject()
tenancy: TenancyService;
/**
* Validate the given customer has no linked credit note transactions.
* @param {number} tenantId
* @param {number} creditNoteId
*/
public validateCustomerHasNoCreditTransaction = async (
tenantId: number,
customerId: number
) => {
const { CreditNote } = this.tenancy.models(tenantId);
const associatedCredits = await CreditNote.query().where(
'customerId',
customerId
);
if (associatedCredits.length > 0) {
throw new ServiceError(ERRORS.CUSTOMER_HAS_LINKED_CREDIT_NOTES);
}
};
}