lib/iso_20022/camt/053/entry.ex

defmodule ISO20022.Camt053.Entry do
  @moduledoc """
  A single booked transaction entry from `<Ntry>`.

  `amount` is always positive. Direction is conveyed by `credit_debit`.
  `reversal` being `true` indicates this entry cancels a previously booked entry —
  the `credit_debit` indicator already reflects the net effect of the reversal.
  """

  alias ISO20022.Camt053.{BankTxCode, EntryDetails}

  @type credit_debit :: :credit | :debit

  @type t :: %__MODULE__{
          ref: String.t(),
          amount: Decimal.t(),
          currency: String.t(),
          credit_debit: credit_debit(),
          reversal: boolean(),
          status: :booked,
          booking_date: Date.t() | nil,
          value_date: Date.t() | nil,
          account_servicer_ref: String.t() | nil,
          bank_transaction_code: BankTxCode.t() | nil,
          additional_info: String.t() | nil,
          details: [EntryDetails.t()]
        }

  defstruct [
    :ref,
    :amount,
    :currency,
    :credit_debit,
    :bank_transaction_code,
    :account_servicer_ref,
    :booking_date,
    :value_date,
    :additional_info,
    reversal: false,
    status: :booked,
    details: []
  ]
end