21 lines
789 B
TypeScript
21 lines
789 B
TypeScript
|
|
import { IAdapter, RepositoryBuilder } from "@/contexts/common/domain";
|
||
|
|
import { UniqueID } from "@shared/contexts";
|
||
|
|
import { IInvoiceParticipantRepository } from "../../domain";
|
||
|
|
import { InvoiceParticipant } from "../../domain/InvoiceParticipant/InvoiceParticipant";
|
||
|
|
|
||
|
|
export const participantFinder = async (
|
||
|
|
participantId: UniqueID,
|
||
|
|
adapter: IAdapter,
|
||
|
|
repository: RepositoryBuilder<IInvoiceParticipantRepository>,
|
||
|
|
): Promise<InvoiceParticipant | undefined> => {
|
||
|
|
if (!participantId || (participantId && participantId.isNull())) {
|
||
|
|
return Promise.resolve(undefined);
|
||
|
|
}
|
||
|
|
|
||
|
|
const participant = await adapter
|
||
|
|
.startTransaction()
|
||
|
|
.complete((t) => repository({ transaction: t }).getById(participantId));
|
||
|
|
|
||
|
|
return Promise.resolve(participant ? participant : undefined);
|
||
|
|
};
|