The personal finance app for everyone (by everyone)
Ruby
<%# locals: (account:) %>
<div class="grid grid-cols-3 gap-2">
<%= summary_card title: t(".market_value") do %>
<%= format_money(account.balance_money) %>
<% end %>
<%= summary_card title: t(".purchase_price") do %>
<%= account.property.purchase_price ? format_money(account.property.purchase_price) : t(".unknown") %>
<% end %>
<%= summary_card title: t(".trend") do %>
<div class="flex items-center gap-1" style="color: <%= account.property.trend.color %>">
<p class="text-xl font-medium">
<%= account.property.trend.value %>
</p>
<p>(<%= account.property.trend.percent %>%)</p>
</div>
<% end %>
<% if account.property.family_currency_trend_applicable? %>
<div data-testid="family-currency-trend">
<%= render "properties/currency_trend_card",
title: t(".trend_in_currency", currency: account.family.currency),
trend: account.property.family_currency_trend %>
</div>
<% end %>
<% if (cost_tag = account.property.cost_tag) %>
<%# The costs are summed in the family currency, the currency stored rates convert into. %>
<% foreign = account.currency != account.family.currency %>
<div class="contents" data-testid="purchase-costs">
<% costs = account.property.purchase_costs_for(Current.user) %>
<% cost_link = link_to t(".cost_transactions", count: account.property.cost_entries_for(Current.user).count, tag: cost_tag.name),
transactions_path(q: { tags: [ cost_tag.name ], types: %w[expense income], status: %w[confirmed], active_accounts_only: false }),
class: "block text-sm text-secondary hover:underline",
data: { turbo_frame: "_top" } %>
<%= summary_card title: t(foreign ? ".purchase_costs_in_currency" : ".purchase_costs", currency: account.family.currency), footer: cost_link do %>
<%= costs ? format_money(costs) : t(".rate_unavailable") %>
<% end %>
<%= summary_card title: t(foreign ? ".cost_basis_in_currency" : ".cost_basis", currency: account.family.currency) do %>
<% cost_basis = account.property.cost_basis_for(Current.user) %>
<%= cost_basis ? format_money(cost_basis) : t(".rate_unavailable") %>
<% end %>
<%= render "properties/currency_trend_card",
title: t(foreign ? ".gain_after_costs_in_currency" : ".gain_after_costs", currency: account.family.currency),
trend: account.property.cost_adjusted_trend_for(Current.user) %>
</div>
<% end %>
<%= summary_card title: t(".year_built") do %>
<%= account.property.year_built || t(".unknown") %>
<% end %>
<%= summary_card title: t(".living_area") do %>
<%= account.property.area || t(".unknown") %>
<% end %>
</div>
<% if account.property.avm_provider.present? %>
<div class="flex flex-col items-center gap-2 pt-8">
<% if account.property.avm_last_synced_on.present? %>
<p class="text-sm text-secondary">
<%= t(".valuation_source",
provider: t("properties.avm_providers.#{account.property.avm_provider}"),
date: l(account.property.avm_last_synced_on, format: :long)) %>
</p>
<% end %>
<%= render DS::Button.new(
text: t(".refresh_valuation"),
href: refresh_valuation_property_path(account),
variant: "outline",
icon: "refresh-cw",
data: { turbo_frame: "_top" }
) %>
</div>
<% elsif (linkable_providers = account.property.linkable_avm_providers).any? %>
<div class="flex flex-col items-center gap-2 pt-8">
<p class="text-sm text-secondary"><%= t(".link_valuation_description") %></p>
<% linkable_providers.each do |provider_key| %>
<%= render DS::Button.new(
text: t(".link_valuation", provider: t("properties.avm_providers.#{provider_key}")),
href: link_valuation_property_path(account, avm_provider: provider_key),
variant: "outline",
icon: "link",
data: { turbo_frame: "_top" }
) %>
<% end %>
</div>
<% end %>
<div class="flex justify-center py-8">
<%= render DS::Link.new(
text: t(".edit_account_details"),
href: edit_property_path(account),
variant: "ghost",
frame: :modal
) %>
</div>