Uecko_ERP/apps/server/archive/contexts/customer-billing/domain/entities/customer.ts

46 lines
1.0 KiB
TypeScript
Raw Normal View History

2025-05-02 21:43:51 +00:00
import { AggregateRoot, PostalAddress, TINNumber, UniqueID } from "@/core/common/domain";
2025-05-09 10:45:32 +00:00
import { Result } from "@repo/rdx-utils";
2025-02-25 19:17:30 +00:00
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 {
2025-05-04 20:06:57 +00:00
id: UniqueID;
2025-02-25 19:17:30 +00:00
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;
}
}