Uecko_ERP/apps/server/archive/contexts/customer-billing/domain/entities/customer.ts
2025-05-09 12:45:32 +02:00

46 lines
1.0 KiB
TypeScript

import { AggregateRoot, PostalAddress, TINNumber, UniqueID } from "@/core/common/domain";
import { Result } from "@repo/rdx-utils";
export interface ICustomerProps {
name: string;
tin: TINNumber;
address: PostalAddress;
}
export interface ICustomer {
id: UniqueID;
name: string;
tin: TINNumber;
address: PostalAddress;
}
export class Customer extends AggregateRoot<ICustomerProps> implements ICustomer {
id: UniqueID;
static create(props: ICustomerProps, id?: UniqueID): Result<Customer, Error> {
const customer = new Customer(props, id);
// Reglas de negocio / validaciones
// ...
// ...
// 🔹 Disparar evento de dominio "CustomerAuthenticatedEvent"
//const { customer } = props;
//user.addDomainEvent(new CustomerAuthenticatedEvent(id, customer.toString()));
return Result.ok(customer);
}
get name() {
return this.props.name;
}
get tin(): TINNumber {
return this.props.tin;
}
get address(): PostalAddress {
return this.props.address;
}
}