Files
customer-service/lib/customer_service/projections/customer.ex
HaimKortovich b1b1c21e4e
Some checks failed
Build and Publish / build-release (push) Failing after 1s
init commit
2026-04-15 16:20:22 -05:00

71 lines
1.5 KiB
Elixir

defmodule CustomerService.Projections.Customer do
use Ecto.Schema
@derive {Jason.Encoder,
only: [
:id,
:customer_type,
# individual
:first_name,
:last_name,
:birth_date,
:gender,
:document_id,
# corporate
:legal_name,
:commercial_name,
:ruc,
:legal_rep_name,
:legal_rep_document_id,
# shared
:address,
:email,
:phone,
:inserted_at,
:updated_at
]}
@derive {
Flop.Schema,
filterable: [:customer_type, :email, :phone, :document_id, :ruc, :search],
sortable: [:last_name, :legal_name, :inserted_at],
default_limit: 20,
max_limit: 100,
custom_fields: [
search: [
filter: {CustomerService.Customers.Filters, :search, []},
ecto_type: :string,
operators: [:==]
]
]
}
@primary_key {:id, :binary_id, autogenerate: false}
@timestamps_opts [type: :utc_datetime_usec]
schema "customers" do
field :customer_type, :string, default: "individual"
# individual fields
field :first_name, :string
field :last_name, :string
field :birth_date, :date
field :gender, :string
field :document_id, :string
# corporate fields
field :legal_name, :string
field :commercial_name, :string
field :ruc, :string
field :legal_rep_name, :string
field :legal_rep_document_id, :string
# shared
field :address, :string
field :email, :string
field :phone, :string
timestamps()
end
end