%= render DS::Dialog.new(frame: "drawer", responsive: true) do |dialog| %>
<% dialog.with_header(custom_header: true) do %>
<%= render "transactions/header", entry: @entry %>
<%= dialog.close_button %>
<% end %>
<% dialog.with_body do %>
<%# Potential duplicate alert %>
<% if @entry.transaction.has_potential_duplicate? %>
<% potential_match = @entry.transaction.potential_duplicate_entry %>
<% if potential_match %>
<%= styled_form_with model: @entry,
url: transaction_path(@entry),
class: "space-y-2",
data: { controller: "auto-submit-form" } do |f| %>
<%= f.text_field :name,
label: t(".name_label"),
"data-auto-submit-form-target": "auto" %>
<%= f.date_field :date,
label: t(".date_label"),
max: Date.current,
disabled: @entry.linked?,
"data-auto-submit-form-target": "auto" %>
<% unless @entry.transaction.transfer? %>
<%= f.select :nature,
[["Expense", "outflow"], ["Income", "inflow"]],
{ container_class: "w-1/3", label: t(".nature"), selected: @entry.amount.negative? ? "inflow" : "outflow" },
{ data: { "auto-submit-form-target": "auto" }, disabled: @entry.linked? } %>
<%= f.money_field :amount, label: t(".amount"),
container_class: "w-2/3",
auto_submit: true,
min: 0,
value: @entry.amount.abs,
disabled: @entry.linked?,
disable_currency: @entry.linked? %>
<%= f.fields_for :entryable do |ef| %>
<%= ef.collection_select :category_id,
Current.family.categories.alphabetically,
:id, :name,
{ label: t(".category_label"),
class: "text-subdued", include_blank: t(".uncategorized") },
"data-auto-submit-form-target": "auto" %>
<% end %>
<% end %>
<% end %>
<% end %>
<% dialog.with_section(title: t(".details")) do %>
<%= styled_form_with model: @entry,
url: transaction_path(@entry),
class: "space-y-2",
data: { controller: "auto-submit-form" } do |f| %>
<% unless @entry.transaction.transfer? %>
<%= f.select :account,
options_for_select(
Current.family.accounts.alphabetically.pluck(:name, :id),
@entry.account_id
),
{ label: t(".account_label") },
{ disabled: true } %>
<%= f.fields_for :entryable do |ef| %>
<%= ef.collection_select :merchant_id,
Current.family.available_merchants.alphabetically,
:id, :name,
{ include_blank: t(".none"),
label: t(".merchant_label"),
class: "text-subdued" },
"data-auto-submit-form-target": "auto" %>
<%= ef.select :tag_ids,
Current.family.tags.alphabetically.pluck(:name, :id),
{
include_blank: t(".none"),
multiple: true,
label: t(".tags_label")
},
{ "data-controller": "multi-select", "data-auto-submit-form-target": "auto" } %>
<% end %>
<% end %>
<%= f.text_area :notes,
label: t(".note_label"),
placeholder: t(".note_placeholder"),
rows: 5,
"data-auto-submit-form-target": "auto" %>
<% end %>
<% end %>
<% if (details = build_transaction_extra_details(@entry)) %>
<% dialog.with_section(title: "Additional details", open: false) do %>
<% if details[:kind] == :simplefin %>
<% sf = details[:simplefin] %>
<% if sf.present? %>
<% if sf[:payee].present? %>
- Payee
- <%= sf[:payee] %>
<% end %>
<% if sf[:description].present? %>
- Description
- <%= sf[:description] %>
<% end %>
<% if sf[:memo].present? %>
- Memo
- <%= sf[:memo] %>
<% end %>
<% end %>
<% if details[:provider_extras].present? %>
Provider extras
<% details[:provider_extras].each do |ex| %>
- <%= ex[:key] %>
- <%= ex[:value] %>
<% end %>
<% end %>
<% else %>
<%= details[:raw] %>
<% end %>
<% end %>
<% end %>
<% dialog.with_section(title: t(".settings")) do %>
<%= styled_form_with model: @entry,
url: transaction_path(@entry),
class: "p-3",
data: { controller: "auto-submit-form" } do |f| %>
<%= t(".exclude") %>
<%= t(".exclude_description") %>
<%= f.toggle :excluded, { data: { auto_submit_form_target: "auto" } } %>
<% end %>
<% if @entry.account.investment? || @entry.account.crypto? %>
<%= styled_form_with model: @entry,
url: transaction_path(@entry),
class: "p-3",
data: { controller: "auto-submit-form" } do |f| %>
<%= f.fields_for :entryable do |ef| %>
<%= t(".activity_type") %>
<%= t(".activity_type_description") %>
<%= ef.select :investment_activity_label,
options_for_select(
[["—", nil]] + Transaction::ACTIVITY_LABELS.map { |l| [t("transactions.activity_labels.#{l.parameterize(separator: '_')}"), l] },
@entry.entryable.investment_activity_label
),
{ label: false },
{ class: "form-field__input border border-secondary rounded-lg px-3 py-1.5 max-w-40 text-sm",
data: { auto_submit_form_target: "auto" } } %>
<% end %>
<% end %>
<% end %>
<%= styled_form_with model: @entry,
url: transaction_path(@entry),
class: "p-3",
data: { controller: "auto-submit-form" } do |f| %>
<%= f.fields_for :entryable do |ef| %>
<%= t(".one_time_title", type: @entry.amount.negative? ? t("transactions.form.income") : t("transactions.form.expense")) %>
<%= t(".one_time_description") %>
<%= ef.toggle :kind, {
checked: @entry.transaction.one_time?,
data: { auto_submit_form_target: "auto" }
}, "one_time", "standard" %>
<% end %>
<% end %>
Transfer or Debt Payment?
Transfers and payments are special types of transactions that indicate money movement between 2 accounts.
<%= render DS::Link.new(
text: "Open matcher",
icon: "arrow-left-right",
variant: "outline",
href: new_transaction_transfer_match_path(@entry),
frame: :modal
) %>
<% if @entry.account.investment? && @entry.entryable.is_a?(Transaction) && !@entry.excluded? %>
Convert to Security Trade
Convert this transaction into a security trade (buy/sell) by providing ticker, shares, and price.
<%= render DS::Button.new(
text: "Convert",
variant: "outline",
icon: "arrow-right-left",
href: convert_to_trade_transaction_path(@entry.transaction),
method: :get,
frame: :modal
) %>
<% end %>
<%= t(".mark_recurring_title") %>
<%= t(".mark_recurring_subtitle") %>
<%= render DS::Button.new(
text: t(".mark_recurring"),
variant: "outline",
icon: "repeat",
href: mark_as_recurring_transaction_path(@entry.transaction),
method: :post,
frame: "_top"
) %>
<%= t(".delete_title") %>
<%= t(".delete_subtitle") %>
<%= render DS::Button.new(
text: t(".delete"),
variant: "outline-destructive",
href: entry_path(@entry),
method: :delete,
confirm: CustomConfirm.for_resource_deletion("transaction"),
frame: "_top"
) %>
<% end %>
<% end %>
<% end %>