This commit is contained in:
@@ -2,24 +2,66 @@ defmodule CustomerService.Projections.Customer do
|
||||
use Ecto.Schema
|
||||
|
||||
@derive {Jason.Encoder,
|
||||
only: [
|
||||
:id,
|
||||
:first_name,
|
||||
:last_name,
|
||||
:birth_date,
|
||||
:gender,
|
||||
:email,
|
||||
:phone,
|
||||
:inserted_at,
|
||||
:updated_at
|
||||
]}
|
||||
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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user