init commit
Some checks failed
Build and Publish / build-release (push) Failing after 1s

This commit is contained in:
2026-04-15 16:20:22 -05:00
parent 072dbf6e66
commit b1b1c21e4e
28 changed files with 822 additions and 194 deletions

View File

@@ -11,21 +11,40 @@ defmodule CustomerService.Projectors.Customer do
project(%Events.CustomerCreated{} = event, fn multi ->
Ecto.Multi.insert(multi, :customer, %Customer{
id: event.id,
customer_type: "individual",
first_name: event.first_name,
last_name: event.last_name,
birth_date: event.birth_date,
birth_date: parse_date(event.birth_date),
gender: event.gender,
email: event.email,
phone: event.phone
phone: event.phone,
address: event.address,
document_id: event.document_id
})
end)
# project %Events.CustomerDeactivated{} = event, _metadata do
# Ecto.Multi.update_all(
# multi,
# :deactivate_customer,
# from(c in Customer, where: c.customer_id == ^event.customer_id),
# set: [active: false]
# )
# end
defp parse_date(nil), do: nil
defp parse_date(%Date{} = d), do: d
defp parse_date(str) when is_binary(str) do
case Date.from_iso8601(str) do
{:ok, d} -> d
_ -> nil
end
end
project(%Events.CorporateCustomerCreated{} = e, _meta, fn multi ->
Ecto.Multi.insert(multi, :customer, %Customer{
id: e.id,
customer_type: "corporate",
legal_name: e.legal_name,
commercial_name: e.commercial_name,
ruc: e.ruc,
legal_rep_name: e.legal_rep_name,
legal_rep_document_id: e.legal_rep_document_id,
email: e.email,
phone: e.phone,
address: e.address
})
end)
end