Uecko_ERP/modules/customers/src/api/application/specs/customer-not-exists.spec.ts

22 lines
604 B
TypeScript
Raw Normal View History

2025-09-14 10:50:29 +00:00
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;
}
}