A simple DSL to generate IIF file.
Add this line to your application's Gemfile:
gem 'riif'
And then execute:
$ bundle
Or install it yourself as:
$ gem install riif
You have to use klass
for class
and _1099
for 1099
With a custom template handler, it works with Rails.
# invoices_controller.rb
class InvoicesController < ApplicationController
def show
respond_to do |format|
format.iif { render iif: render_to_string, filename: 'batman'}
format.html
end
end
end
# show.iif.riif
iif.trns do
row do
trnsid 123
trnstype 'INVOICE'
date '8/31/1988'
accnt 'Accounts Receivable'
name 'Customer'
amount 20
docnum invoice.id
clear 'N'
toprint 'N'
addr1 'Baker'
addr2 'Customer'
end
spl do
row do
splid '777'
trnstype 'INVOICE'
date '8/31/1988'
accnt 'Income Account'
amount '-20'
clear 'N'
qnty '-2'
price 10
invitem 'Sales Item'
taxable 'N'
end
end
spl do
row do
splid '888'
end
end
end
Riif::IIF.new do
trns do
row do
trnsid 123
trnstype 'INVOICE'
date '8/31/1988'
accnt 'Accounts Receivable'
name 'Customer'
amount 20
docnum 1
clear 'N'
toprint 'N'
addr1 'Baker'
addr2 'Customer'
end
spl do
row do
splid '777'
trnstype 'INVOICE'
date '8/31/1988'
accnt 'Income Account'
amount '-20'
clear 'N'
qnty '-2'
price 10
invitem 'Sales Item'
taxable 'N'
end
end
spl do
row do
splid '888'
end
end
end
end
Result:
!TRNS TRNSID TRNSTYPE DATE ACCNT NAME CLASS AMOUNT DOCNUM MEMO CLEAR TOPRINT ADDR1 ADDR2 ADDR3 ADDR4 ADDR5 DUEDATE TERMS PAID SHIPDATE
!SPL SPLID TRNSTYPE DATE ACCNT NAME CLASS AMOUNT DOCNUM MEMO CLEAR QNTY PRICE INVITEM PAYMETH TAXABLE REIMBEXP EXTRA
!ENDTRNS
TRNS 123 INVOICE 8/31/1988 Accounts Receivable Customer 20 1 N N Baker Customer
SPL 777 INVOICE 8/31/1988 Income Account -20 N -2 10 Sales Item N
SPL 888
ENDTRNS
If you prefer, you can pass an argument along with your block:
Riif::IIF.new do |riif|
riif.trns do |trns|
trns.row do |row|
row.trnsid 123
row.trnstype 'INVOICE'
row.date '8/31/1988'
row.accnt 'Accounts Receivable'
row.name 'Customer'
end
end
end
au BufWinEnter,BufRead,BufNewFile *.riif set filetype=ruby
Export or import Intuit Interchange Format (.IIF) files
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
🍻
https://github.com/linjunpop/riif/graphs/contributors
See CHANGELOG.md