Add CSV downloads for BankTransaction and Invoice
This commit is contained in:
parent
e0c0834690
commit
9f2e630266
6 changed files with 96 additions and 6 deletions
29
lib/bank_transactions_csv.rb
Normal file
29
lib/bank_transactions_csv.rb
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
require 'csv'
|
||||
|
||||
class BankTransactionsCsv < RenderCSV
|
||||
include ApplicationHelper
|
||||
|
||||
def header
|
||||
[
|
||||
BankTransaction.human_attribute_name(:external_id),
|
||||
BankTransaction.human_attribute_name(:date),
|
||||
BankTransaction.human_attribute_name(:amount),
|
||||
BankTransaction.human_attribute_name(:iban),
|
||||
BankTransaction.human_attribute_name(:reference),
|
||||
BankTransaction.human_attribute_name(:text)
|
||||
]
|
||||
end
|
||||
|
||||
def data
|
||||
@object.each do |t|
|
||||
yield [
|
||||
t.external_id,
|
||||
t.date,
|
||||
t.amount,
|
||||
t.iban,
|
||||
t.reference,
|
||||
t.text
|
||||
]
|
||||
end
|
||||
end
|
||||
end
|
||||
37
lib/invoices_csv.rb
Normal file
37
lib/invoices_csv.rb
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
require 'csv'
|
||||
|
||||
class InvoicesCsv < RenderCSV
|
||||
include ApplicationHelper
|
||||
|
||||
def header
|
||||
[
|
||||
Invoice.human_attribute_name(:created_at),
|
||||
Invoice.human_attribute_name(:created_by),
|
||||
Invoice.human_attribute_name(:date),
|
||||
Invoice.human_attribute_name(:supplier),
|
||||
Invoice.human_attribute_name(:number),
|
||||
Invoice.human_attribute_name(:amount),
|
||||
Invoice.human_attribute_name(:deposit),
|
||||
Invoice.human_attribute_name(:deposit_credit),
|
||||
Invoice.human_attribute_name(:paid_on),
|
||||
Invoice.human_attribute_name(:note)
|
||||
]
|
||||
end
|
||||
|
||||
def data
|
||||
@object.each do |t|
|
||||
yield [
|
||||
t.created_at,
|
||||
show_user(t.created_by),
|
||||
t.date,
|
||||
t.supplier.name,
|
||||
t.number,
|
||||
t.amount,
|
||||
t.deposit,
|
||||
t.deposit_credit,
|
||||
t.paid_on,
|
||||
t.note,
|
||||
]
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue