2024-02-23 21:34:33 -05:00
|
|
|
module TransactionsHelper
|
2024-05-30 20:55:18 -04:00
|
|
|
def transactions_group(date, transactions, transaction_partial_path = "transactions/transaction")
|
|
|
|
header_left = content_tag :span do
|
|
|
|
"#{date.strftime('%b %d, %Y')} · #{transactions.size}".html_safe
|
|
|
|
end
|
2024-04-19 12:03:16 -04:00
|
|
|
|
2024-05-30 20:55:18 -04:00
|
|
|
header_right = content_tag :span do
|
|
|
|
format_money(-transactions.sum(&:amount_money))
|
|
|
|
end
|
2024-04-19 12:03:16 -04:00
|
|
|
|
2024-05-30 20:55:18 -04:00
|
|
|
header = header_left.concat(header_right)
|
|
|
|
|
|
|
|
content = render partial: transaction_partial_path, collection: transactions
|
2024-04-22 22:51:06 +02:00
|
|
|
|
2024-05-30 20:55:18 -04:00
|
|
|
render partial: "shared/list_group", locals: {
|
|
|
|
header: header,
|
|
|
|
content: content
|
|
|
|
}
|
2024-04-22 22:51:06 +02:00
|
|
|
end
|
2024-02-23 21:34:33 -05:00
|
|
|
end
|