FactuGES_ERP/modules/customers/src/api/application/specs/customer-not-exists.spec.ts
2025-09-14 12:50:29 +02:00

22 lines
604 B
TypeScript

import { CompositeSpecification, UniqueID } from "@repo/rdx-ddd";
import { CustomerService } from "../../domain";
export class CustomerNotExistsInCompanySpecification extends CompositeSpecification<UniqueID> {
constructor(
private readonly service: CustomerService,
private readonly companyId: UniqueID,
private readonly transaction?: any
) {
super();
}
public async isSatisfiedBy(customerId: UniqueID): Promise<boolean> {
const exists = await this.service.existsByIdInCompany(
customerId,
this.companyId,
this.transaction
);
return !exists;
}
}