mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-15 12:20:31 +00:00
add server to monorepo.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user