All checks were successful
Build and Publish / build-release (push) Successful in 3m7s
76 lines
1.6 KiB
Elixir
76 lines
1.6 KiB
Elixir
defmodule CustomerService.Projections.Customer do
|
|
use Ecto.Schema
|
|
|
|
@derive {Jason.Encoder,
|
|
only: [
|
|
:id,
|
|
:org_id,
|
|
:customer_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: [:org_id, :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, :string, autogenerate: false}
|
|
@timestamps_opts [type: :utc_datetime_usec]
|
|
|
|
schema "customers" do
|
|
field :org_id, :string
|
|
field :customer_id, :string
|
|
|
|
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
|