import { DomainEntity, Name, TINNumber, UniqueID } from "core/common/domain";
import { Result } from "core/common/helpers";
import { InvoiceAddress } from "./invoice-address";

export interface IInvoiceCustomerProps {
  tin: TINNumber;
  companyName: Name;
  firstName: Name;
  lastName: Name;

  billingAddress?: InvoiceAddress;
  shippingAddress?: InvoiceAddress;
}

export interface IInvoiceCustomer {
  id: UniqueID;
  tin: TINNumber;
  companyName: Name;
  firstName: Name;
  lastName: Name;

  billingAddress?: InvoiceAddress;
  shippingAddress?: InvoiceAddress;
}

export class InvoiceCustomer
  extends DomainEntity<IInvoiceCustomerProps>
  implements IInvoiceCustomer
{
  public static create(
    props: IInvoiceCustomerProps,
    id?: UniqueID
  ): Result<InvoiceCustomer, Error> {
    const participant = new InvoiceCustomer(props, id);
    return Result.ok<InvoiceCustomer>(participant);
  }

  get tin(): TINNumber {
    return this.props.tin;
  }

  get companyName(): Name {
    return this.props.companyName;
  }

  get firstName(): Name {
    return this.props.firstName;
  }

  get lastName(): Name {
    return this.props.lastName;
  }

  get billingAddress() {
    return this.props.billingAddress;
  }

  get shippingAddress() {
    return this.props.shippingAddress;
  }
}
