foodsoft/app/controllers/finance/financial_links_controller.rb
Patrick Gansterer 53bb096046 Add FinancialLinks
For now this is only usefull for plugins, since there is no UI.
2017-10-28 20:17:16 +02:00

27 lines
845 B
Ruby

class Finance::FinancialLinksController < Finance::BaseController
def show
@financial_link = FinancialLink.find(params[:id])
@items = @financial_link.financial_transactions.map do |ft|
{
date: ft.created_on,
type: t('activerecord.models.financial_transaction'),
description: "#{ft.ordergroup.name}: #{ft.note}",
amount: ft.amount,
link_to: finance_ordergroup_transactions_path(ft.ordergroup)
}
end
@items += @financial_link.invoices.map do |invoice|
{
date: invoice.date || invoice.created_at,
type: t('activerecord.models.invoice'),
description: "#{invoice.supplier.name}: #{invoice.number}",
amount: invoice.amount,
link_to: finance_invoice_path(invoice)
}
end
@items.sort_by! { |item| item[:date] }
end
end