From e21058c5d885fceacf2d8db4893dd49cd98aa4e1 Mon Sep 17 00:00:00 2001 From: Paul van Tilburg Date: Sun, 6 Mar 2016 14:58:24 +0100 Subject: [PATCH] Add a button to trigger GnuCash CSV generation to the invoice_form view This button is only there if information has been filled in for the company and customer. --- stoptime.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/stoptime.rb b/stoptime.rb index ae13f5e..90b63dc 100644 --- a/stoptime.rb +++ b/stoptime.rb @@ -1388,6 +1388,8 @@ module StopTime::Controllers tex_file = PUBLIC_DIR + "invoices/#{@number}.tex" pdf_file = PUBLIC_DIR + "invoices/#{@number}.pdf" csv_file = PUBLIC_DIR + "invoices/#{@number}.csv" + @csv_enabled = @company.gnucash_revenues_account_name.present? && + @customer.gnucash_customer_owner_id.present? if @format == "html" @input = @invoice.attributes @invoice_file_present = tex_file.exist? || csv_file.exist? @@ -2652,6 +2654,14 @@ module StopTime::Views _icon("download") span "Download LaTeX" end + if @csv_enabled + a.btn.btn_default role: "button", + href: R(CustomersNInvoicesX, + @customer.id, "#{@invoice.number}.csv") do + _icon("download") + span "Download GnuCash CSV" + end + end a.btn.btn_default role: "button", href: R(Company, revision: @company.revision) do _icon("briefcase")