qb_iif 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (84) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +17 -0
  3. data/.rspec +3 -0
  4. data/CHANGELOG.md +18 -0
  5. data/Gemfile +4 -0
  6. data/LICENSE +20 -0
  7. data/LICENSE.txt +22 -0
  8. data/README.md +188 -0
  9. data/Rakefile +7 -0
  10. data/lib/qb_iif/dsl/accnt.rb +15 -0
  11. data/lib/qb_iif/dsl/base.rb +54 -0
  12. data/lib/qb_iif/dsl/bud.rb +14 -0
  13. data/lib/qb_iif/dsl/class.rb +9 -0
  14. data/lib/qb_iif/dsl/ctype.rb +9 -0
  15. data/lib/qb_iif/dsl/cust.rb +51 -0
  16. data/lib/qb_iif/dsl/emp.rb +31 -0
  17. data/lib/qb_iif/dsl/invitem.rb +32 -0
  18. data/lib/qb_iif/dsl/invmemo.rb +9 -0
  19. data/lib/qb_iif/dsl/othername.rb +25 -0
  20. data/lib/qb_iif/dsl/paymeth.rb +9 -0
  21. data/lib/qb_iif/dsl/shipmeth.rb +10 -0
  22. data/lib/qb_iif/dsl/spl.rb +29 -0
  23. data/lib/qb_iif/dsl/terms.rb +13 -0
  24. data/lib/qb_iif/dsl/timeact.rb +17 -0
  25. data/lib/qb_iif/dsl/timerhdr.rb +14 -0
  26. data/lib/qb_iif/dsl/todo.rb +12 -0
  27. data/lib/qb_iif/dsl/trns.rb +56 -0
  28. data/lib/qb_iif/dsl/vend.rb +39 -0
  29. data/lib/qb_iif/dsl/vtype.rb +9 -0
  30. data/lib/qb_iif/iif.rb +64 -0
  31. data/lib/qb_iif/keywords.rb +12 -0
  32. data/lib/qb_iif/rails/renderer.rb +15 -0
  33. data/lib/qb_iif/rails/template_handler.rb +20 -0
  34. data/lib/qb_iif/railtie.rb +17 -0
  35. data/lib/qb_iif/version.rb +3 -0
  36. data/lib/qb_iif.rb +7 -0
  37. data/qb_iif.gemspec +28 -0
  38. data/spec/controllers/invoices_controller_spec.rb +26 -0
  39. data/spec/fixtures/accnt.iif +2 -0
  40. data/spec/fixtures/bud.iif +2 -0
  41. data/spec/fixtures/class.iif +2 -0
  42. data/spec/fixtures/ctype.iif +2 -0
  43. data/spec/fixtures/cust.iif +2 -0
  44. data/spec/fixtures/emp.iif +2 -0
  45. data/spec/fixtures/invitem.iif +2 -0
  46. data/spec/fixtures/invmemo.iif +2 -0
  47. data/spec/fixtures/mixed.iif +13 -0
  48. data/spec/fixtures/othername.iif +2 -0
  49. data/spec/fixtures/paymeth.iif +2 -0
  50. data/spec/fixtures/rails/invoices.iif +6 -0
  51. data/spec/fixtures/shipmeth.iif +2 -0
  52. data/spec/fixtures/terms.iif +2 -0
  53. data/spec/fixtures/timeact.iif +4 -0
  54. data/spec/fixtures/todo.iif +2 -0
  55. data/spec/fixtures/trns.iif +7 -0
  56. data/spec/fixtures/vend.iif +2 -0
  57. data/spec/fixtures/vtype.iif +2 -0
  58. data/spec/internal/app/controllers/invoices_controller.rb +7 -0
  59. data/spec/internal/app/views/invoices/index.iif.riif +27 -0
  60. data/spec/internal/config/database.yml +3 -0
  61. data/spec/internal/config/routes.rb +3 -0
  62. data/spec/internal/db/schema.rb +3 -0
  63. data/spec/internal/log/.gitignore +1 -0
  64. data/spec/internal/public/favicon.ico +0 -0
  65. data/spec/qb_iif/dsl/accnt_spec.rb +22 -0
  66. data/spec/qb_iif/dsl/bud_spec.rb +28 -0
  67. data/spec/qb_iif/dsl/class_spec.rb +20 -0
  68. data/spec/qb_iif/dsl/ctype_spec.rb +19 -0
  69. data/spec/qb_iif/dsl/cust_spec.rb +20 -0
  70. data/spec/qb_iif/dsl/emp_spec.rb +24 -0
  71. data/spec/qb_iif/dsl/invitem_spec.rb +21 -0
  72. data/spec/qb_iif/dsl/invmemo_spec.rb +19 -0
  73. data/spec/qb_iif/dsl/othername_spec.rb +23 -0
  74. data/spec/qb_iif/dsl/paymeth_spec.rb +19 -0
  75. data/spec/qb_iif/dsl/shipmeth_spec.rb +19 -0
  76. data/spec/qb_iif/dsl/terms_spec.rb +23 -0
  77. data/spec/qb_iif/dsl/timeact_spec.rb +35 -0
  78. data/spec/qb_iif/dsl/todo_spec.rb +22 -0
  79. data/spec/qb_iif/dsl/trns_spec.rb +55 -0
  80. data/spec/qb_iif/dsl/vend_spec.rb +21 -0
  81. data/spec/qb_iif/dsl/vtype_spec.rb +19 -0
  82. data/spec/qb_iif/iif_spec.rb +61 -0
  83. data/spec/spec_helper.rb +19 -0
  84. metadata +283 -0
@@ -0,0 +1,56 @@
1
+ module QbIif::DSL
2
+ class Trns < Base
3
+ HEADER_COLUMNS = [
4
+ :trnsid,
5
+ :trnstype,
6
+ :date,
7
+ :accnt,
8
+ :name,
9
+ :class,
10
+ :amount,
11
+ :docnum,
12
+ :memo,
13
+ :clear,
14
+ :toprint,
15
+ :addr1,
16
+ :addr2,
17
+ :addr3,
18
+ :addr4,
19
+ :addr5,
20
+ :saddr1,
21
+ :saddr2,
22
+ :saddr3,
23
+ :saddr4,
24
+ :saddr5,
25
+ :duedate,
26
+ :terms,
27
+ :paid,
28
+ :paymeth,
29
+ :shipdate,
30
+ :rep,
31
+ :ponum,
32
+ :invtitle,
33
+ :invmemo
34
+ ]
35
+ START_COLUMN = 'TRNS'
36
+ END_COLUMN = 'ENDTRNS'
37
+
38
+ def headers
39
+ [
40
+ ["!#{START_COLUMN}"].concat(HEADER_COLUMNS.map(&:upcase)),
41
+ ["!SPL"].concat(Spl::HEADER_COLUMNS.map(&:upcase)),
42
+ ["!#{END_COLUMN}"]
43
+ ]
44
+ end
45
+
46
+ def rows
47
+ @rows << [END_COLUMN]
48
+ end
49
+
50
+ def spl(&block)
51
+ Spl.new.build(&block)[:rows].each do |row|
52
+ @rows << row
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,39 @@
1
+ module QbIif::DSL
2
+ class Vend < Base
3
+ HEADER_COLUMNS = [
4
+ :name,
5
+ :printas,
6
+ :addr1,
7
+ :addr2,
8
+ :addr3,
9
+ :addr4,
10
+ :addr5,
11
+ :vtype,
12
+ :cont1,
13
+ :phone1,
14
+ :phone2,
15
+ :faxnum,
16
+ :note,
17
+ :taxid,
18
+ :limit,
19
+ :terms,
20
+ :notepad,
21
+ :salutation,
22
+ :companyname,
23
+ :firstname,
24
+ :midinit,
25
+ :lastname,
26
+ :custfld1,
27
+ :custfld2,
28
+ :custfld3,
29
+ :custfld4,
30
+ :custfld5,
31
+ :custfld6,
32
+ :custfld7,
33
+ :"1099",
34
+ :note
35
+ ]
36
+ START_COLUMN = 'VEND'
37
+ END_COLUMN = ''
38
+ end
39
+ end
@@ -0,0 +1,9 @@
1
+ module QbIif::DSL
2
+ class Vtype < Base
3
+ HEADER_COLUMNS = [
4
+ :name
5
+ ]
6
+ START_COLUMN = 'VTYPE'
7
+ END_COLUMN = ''
8
+ end
9
+ end
data/lib/qb_iif/iif.rb ADDED
@@ -0,0 +1,64 @@
1
+ require 'csv'
2
+
3
+ require 'qb_iif/keywords'
4
+ require 'qb_iif/dsl/base'
5
+
6
+ require 'qb_iif/dsl/accnt'
7
+ require 'qb_iif/dsl/bud'
8
+ require 'qb_iif/dsl/ctype'
9
+ require 'qb_iif/dsl/cust'
10
+ require 'qb_iif/dsl/emp'
11
+ require 'qb_iif/dsl/invitem'
12
+ require 'qb_iif/dsl/invmemo'
13
+ require 'qb_iif/dsl/class'
14
+ require 'qb_iif/dsl/othername'
15
+ require 'qb_iif/dsl/paymeth'
16
+ require 'qb_iif/dsl/shipmeth'
17
+ require 'qb_iif/dsl/spl'
18
+ require 'qb_iif/dsl/terms'
19
+ require 'qb_iif/dsl/timeact'
20
+ require 'qb_iif/dsl/timerhdr'
21
+ require 'qb_iif/dsl/todo'
22
+ require 'qb_iif/dsl/trns'
23
+ require 'qb_iif/dsl/vend'
24
+ require 'qb_iif/dsl/vtype'
25
+
26
+ module QbIif
27
+ class IIF
28
+ include QbIif::Keywords
29
+
30
+ def initialize(&block)
31
+ @output = {}
32
+ if block_given?
33
+ if block.arity == 1
34
+ yield(self)
35
+ else
36
+ instance_eval(&block)
37
+ end
38
+ end
39
+ end
40
+
41
+ def output
42
+ CSV.generate(col_sep: "\t") do |tsv|
43
+
44
+ @output.each do |_, list|
45
+ list[:headers].uniq.each do |header|
46
+ tsv << header
47
+ end
48
+ list[:rows].each do |row|
49
+ tsv << row
50
+ end
51
+ end
52
+ end
53
+ end
54
+
55
+ def method_missing(method_name, *args, &block)
56
+ class_name = escaped(method_name).to_s.split('_').map(&:capitalize).join('')
57
+ result = QbIif::DSL.const_get(class_name).new.build(&block)
58
+
59
+ @output[method_name] ||= { headers: [], rows: [] }
60
+ @output[method_name][:headers].concat(result[:headers])
61
+ @output[method_name][:rows].concat(result[:rows])
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,12 @@
1
+ module QbIif
2
+ module Keywords
3
+ ESCAPED_KEYWORDS = {
4
+ _class: :class,
5
+ _1099: :"1099"
6
+ }
7
+
8
+ def escaped(symbol)
9
+ ESCAPED_KEYWORDS[symbol] || symbol
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,15 @@
1
+ module QbIif
2
+ module Rails
3
+ class Renderer
4
+ ActionController::Renderers.add :iif do |iif_string, options|
5
+ filename = options[:filename] || options[:template]
6
+ send_data(
7
+ iif_string,
8
+ filename: "#{filename}.iif",
9
+ type: Mime::IIF,
10
+ disposition: 'attachment'
11
+ )
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,20 @@
1
+ module QbIif
2
+ module Rails
3
+ class TemplateHandler
4
+ cattr_accessor :default_format
5
+ self.default_format = Mime::IIF
6
+
7
+ def self.call(template)
8
+ <<-RUBY
9
+ iif = ::QbIif::IIF.new
10
+
11
+ #{template.source}
12
+
13
+ iif.output
14
+ RUBY
15
+ end
16
+
17
+ ActionView::Template.register_template_handler :riif, self
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,17 @@
1
+ require 'rails'
2
+
3
+ module QbIif
4
+ class Railtie < ::Rails::Railtie
5
+ initializer 'qb_iif' do
6
+ ::ActiveSupport.on_load(:action_view) do
7
+ unless ::Mime::Type.lookup_by_extension(:iif)
8
+ ::Mime::Type.register "application/qbooks", :iif,
9
+ %w(application/qbookspro text/iif)
10
+ end
11
+
12
+ require 'qb_iif/rails/template_handler'
13
+ require 'qb_iif/rails/renderer'
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,3 @@
1
+ module QbIif
2
+ VERSION = "0.1.0"
3
+ end
data/lib/qb_iif.rb ADDED
@@ -0,0 +1,7 @@
1
+ require 'qb_iif/version'
2
+ require 'qb_iif/iif'
3
+ require 'qb_iif/railtie' if defined?(Rails)
4
+
5
+ module QbIif
6
+ # Your code goes here...
7
+ end
data/qb_iif.gemspec ADDED
@@ -0,0 +1,28 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'qb_iif/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "qb_iif"
8
+ gem.version = QbIif::VERSION
9
+ gem.authors = ["Pracstrat"]
10
+ gem.email = ["xinlangzi@gmail.com"]
11
+ gem.description = "A simple DSL to generate QuickBooks IIF file"
12
+ gem.summary = "A simple DSL to generate QuickBooks IIF file"
13
+ gem.homepage = "https://github.com/pracstrat/qb-iif"
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+
20
+ gem.add_development_dependency 'pry'
21
+ gem.add_development_dependency 'rails'
22
+ gem.add_development_dependency 'rspec'
23
+ gem.add_development_dependency 'rspec-rails'
24
+ gem.add_development_dependency 'awesome_print'
25
+ gem.add_development_dependency 'combustion', '~> 0.3.1'
26
+ gem.add_development_dependency 'fuubar'
27
+ gem.add_development_dependency 'coveralls'
28
+ end
@@ -0,0 +1,26 @@
1
+ require 'spec_helper'
2
+
3
+ describe InvoicesController do
4
+ render_views
5
+
6
+ let(:expected) { File.read('spec/fixtures/rails/invoices.iif') }
7
+
8
+ describe '#index' do
9
+
10
+ before do
11
+ get :index, format: 'iif'
12
+ end
13
+
14
+ it 'respond with rendered iif' do
15
+ response.body.should eq expected
16
+ end
17
+
18
+ it 'respond with QuickBooks content type' do
19
+ response.header['Content-Type'].should eq 'application/qbooks'
20
+ end
21
+
22
+ it 'respond with filename: batman.iif' do
23
+ response.header['Content-Disposition'].should =~ /filename="batman\.iif"/
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,2 @@
1
+ !ACCNT NAME ACCNTTYPE OBAMOUNT DESC SCD ACCNUM EXTRA
2
+ ACCNT Jun Lin AR 47
@@ -0,0 +1,2 @@
1
+ !BUD ACCNT PERIOD AMOUNT STARTDATE CLASS CUSTOMER
2
+ BUD Accounts Receivable MONTH foo 3/14/12
@@ -0,0 +1,2 @@
1
+ !CLASS NAME
2
+ CLASS Foo
@@ -0,0 +1,2 @@
1
+ !CTYPE NAME
2
+ CTYPE Bar
@@ -0,0 +1,2 @@
1
+ !CUST NAME BADDR1 BADDR2 BADDR3 BADDR4 BADDR5 SADDR1 SADDR2 SADDR3 SADDR4 SADDR5 PHONE1 PHONE2 FAXNUM CONT1 CONT2 CTYPE TERMS TAXABLE LIMIT RESALENUM REP TAXITEM NOTEPAD SALUTATION COMPANYNAME FIRSTNAME MIDINIT LASTNAME CUSTFLD1 CUSTFLD2 CUSTFLD3 CUSTFLD4 CUSTFLD5 CUSTFLD6 CUSTFLD7 JOBDESC JOBTYPE JOBSTATUS JOBSTART JOBPROJEND JOBEND NOTE
2
+ CUST Jun Lin 12312323242
@@ -0,0 +1,2 @@
1
+ !EMP NAME INIT ADDR1 ADDR2 ADDR3 ADDR4 ADDR5 SSNO PHONE1 PHONE2 NOTEPAD FIRSTNAME MIDINIT LASTNAME SALUTATION CUSTFLD1 CUSTFLD2 CUSTFLD3 CUSTFLD4 CUSTFLD5 CUSTFLD6 CUSTFLD7 NOTE
2
+ EMP Alfred Master Backer 37 Doctor
@@ -0,0 +1,2 @@
1
+ !INVITEM NAME INVITEMTYPE DESC PURCHASEDESC ACCNT ASSETACCNT COGSACCNT PRICE COST TAXABLE PAYMETH TAXVEND TAXDIST TOPRINT PREFVEND REORDERPOINT EXTRA CUSTFLD1 CUSTFLD2 CUSTFLD3 CUSTFLD4 CUSTFLD5 DEP_TYPE ISPASSEDTHRU
2
+ INVITEM invitem 1 INVENTORY 1
@@ -0,0 +1,2 @@
1
+ !INVMEMO NAME
2
+ INVMEMO invmemo 1
@@ -0,0 +1,13 @@
1
+ !CUST NAME BADDR1 BADDR2 BADDR3 BADDR4 BADDR5 SADDR1 SADDR2 SADDR3 SADDR4 SADDR5 PHONE1 PHONE2 FAXNUM CONT1 CONT2 CTYPE TERMS TAXABLE LIMIT RESALENUM REP TAXITEM NOTEPAD SALUTATION COMPANYNAME FIRSTNAME MIDINIT LASTNAME CUSTFLD1 CUSTFLD2 CUSTFLD3 CUSTFLD4 CUSTFLD5 CUSTFLD6 CUSTFLD7 JOBDESC JOBTYPE JOBSTATUS JOBSTART JOBPROJEND JOBEND NOTE
2
+ CUST Batman Amoy
3
+ CUST Joker Amoy
4
+ !BUD ACCNT PERIOD AMOUNT STARTDATE CLASS CUSTOMER
5
+ BUD Accounts Receivable MONTH foo 3/14/12
6
+ BUD Accounts Payable MONTH 123 3/15/12
7
+ !TRNS TRNSID TRNSTYPE DATE ACCNT NAME CLASS AMOUNT DOCNUM MEMO CLEAR TOPRINT ADDR1 ADDR2 ADDR3 ADDR4 ADDR5 SADDR1 SADDR2 SADDR3 SADDR4 SADDR5 DUEDATE TERMS PAID PAYMETH SHIPDATE REP PONUM INVTITLE INVMEMO
8
+ !SPL SPLID TRNSTYPE DATE ACCNT NAME CLASS AMOUNT DOCNUM MEMO CLEAR QNTY PRICE INVITEM PAYMETH TAXABLE REIMBEXP EXTRA
9
+ !ENDTRNS
10
+ TRNS foo
11
+ SPL joker
12
+ SPL foobar
13
+ ENDTRNS
@@ -0,0 +1,2 @@
1
+ !OTHERNAME NAME BADDR1 BADDR2 BADDR3 BADDR4 BADDR5 PHONE1 PHONE2 FAXNUM CONT1 NOTEPAD SALUTATION COMPANYNAME FIRSTNAME MIDINIT LASTNAME NOTE
2
+ OTHERNAME Alfred Backer 37 123
@@ -0,0 +1,2 @@
1
+ !PAYMETH NAME
2
+ PAYMETH paymeth 1
@@ -0,0 +1,6 @@
1
+ !TRNS TRNSID TRNSTYPE DATE ACCNT NAME CLASS AMOUNT DOCNUM MEMO CLEAR TOPRINT ADDR1 ADDR2 ADDR3 ADDR4 ADDR5 SADDR1 SADDR2 SADDR3 SADDR4 SADDR5 DUEDATE TERMS PAID PAYMETH SHIPDATE REP PONUM INVTITLE INVMEMO
2
+ !SPL SPLID TRNSTYPE DATE ACCNT NAME CLASS AMOUNT DOCNUM MEMO CLEAR QNTY PRICE INVITEM PAYMETH TAXABLE REIMBEXP EXTRA
3
+ !ENDTRNS
4
+ TRNS 12345 BILL 3/14/1984 Accounts Payable EZ -300 12345 N
5
+ SPL 1 BILL 3/14/1984 Payable CMA 300 foo 3 150 Base Rate
6
+ ENDTRNS
@@ -0,0 +1,2 @@
1
+ !SHIPMETH NAME
2
+ SHIPMETH shipmeth 1
@@ -0,0 +1,2 @@
1
+ !TERMS NAME DUEDAYS DISCPER DISCDAYS TERMSTYPE
2
+ TERMS terms 1 10 0.3 1 0
@@ -0,0 +1,4 @@
1
+ !TIMERHDR VER REL COMPANYNAME IMPORTEDBEFORE FROMTIMER COMPANYCREATETIME
2
+ TIMERHDR 8 0 Import Test Company N Y 1208544781
3
+ !TIMEACT DATE JOB EMP ITEM PITEM DURATION PROJ NOTE BILLINGSTATUS
4
+ TIMEACT 06/21/97 job 1 Jun item 1 13:40 klass 1 0
@@ -0,0 +1,2 @@
1
+ !TODO REFNUM ISDONE DATE DESC
2
+ TODO 1234234 Y 7/11/2013 Pickup
@@ -0,0 +1,7 @@
1
+ !TRNS TRNSID TRNSTYPE DATE ACCNT NAME CLASS AMOUNT DOCNUM MEMO CLEAR TOPRINT ADDR1 ADDR2 ADDR3 ADDR4 ADDR5 SADDR1 SADDR2 SADDR3 SADDR4 SADDR5 DUEDATE TERMS PAID PAYMETH SHIPDATE REP PONUM INVTITLE INVMEMO
2
+ !SPL SPLID TRNSTYPE DATE ACCNT NAME CLASS AMOUNT DOCNUM MEMO CLEAR QNTY PRICE INVITEM PAYMETH TAXABLE REIMBEXP EXTRA
3
+ !ENDTRNS
4
+ TRNS 123 INVOICE 8/31/1988 Accounts Receivable Customer tires:deeptread 20 1 N N Baker Customer Watson Recipient BOB
5
+ SPL 777 INVOICE 8/31/1988 Income Account -20 N -2 10 Sales Item N
6
+ SPL 888
7
+ ENDTRNS
@@ -0,0 +1,2 @@
1
+ !VEND NAME PRINTAS ADDR1 ADDR2 ADDR3 ADDR4 ADDR5 VTYPE CONT1 PHONE1 PHONE2 FAXNUM NOTE TAXID LIMIT TERMS NOTEPAD SALUTATION COMPANYNAME FIRSTNAME MIDINIT LASTNAME CUSTFLD1 CUSTFLD2 CUSTFLD3 CUSTFLD4 CUSTFLD5 CUSTFLD6 CUSTFLD7 1099 NOTE
2
+ VEND Jun Lin 12312323242 Y
@@ -0,0 +1,2 @@
1
+ !VTYPE NAME
2
+ VTYPE vtype 1
@@ -0,0 +1,7 @@
1
+ class InvoicesController < ActionController::Base
2
+ def index
3
+ respond_to do |format|
4
+ format.iif { render iif: render_to_string, filename: 'batman'}
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,27 @@
1
+ iif.trns do
2
+ row do
3
+ trnsid 12345
4
+ trnstype 'BILL'
5
+ date '3/14/1984'
6
+ accnt 'Accounts Payable'
7
+ name 'EZ'
8
+ amount -300
9
+ docnum 12345
10
+ clear 'N'
11
+ end
12
+
13
+ spl do
14
+ row do
15
+ splid 001
16
+ trnstype 'BILL'
17
+ date '3/14/1984'
18
+ accnt 'Payable'
19
+ invitem 'Base Rate'
20
+ name 'CMA'
21
+ amount 300
22
+ memo "foo"
23
+ qnty 3
24
+ price 150
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,3 @@
1
+ test:
2
+ adapter: sqlite3
3
+ database: db/combustion_test.sqlite
@@ -0,0 +1,3 @@
1
+ Rails.application.routes.draw do
2
+ resources :invoices
3
+ end
@@ -0,0 +1,3 @@
1
+ ActiveRecord::Schema.define do
2
+ #
3
+ end
@@ -0,0 +1 @@
1
+ *.log
File without changes
@@ -0,0 +1,22 @@
1
+ require 'spec_helper'
2
+
3
+ describe QbIif::DSL::Accnt do
4
+
5
+ let(:expected) { File.read('spec/fixtures/accnt.iif') }
6
+
7
+ let(:accnt) {
8
+ QbIif::IIF.new do
9
+ accnt do
10
+ row do
11
+ name 'Jun Lin'
12
+ accnttype 'AR'
13
+ accnum 47
14
+ end
15
+ end
16
+ end
17
+ }
18
+
19
+ subject { accnt }
20
+
21
+ its(:output) { should eq expected }
22
+ end
@@ -0,0 +1,28 @@
1
+ require 'spec_helper'
2
+ class Invoice
3
+ attr_accessor :name
4
+ def initialize(n)
5
+ @name = n
6
+ end
7
+ end
8
+ describe QbIif::DSL::Bud do
9
+
10
+ let(:expected) { File.read('spec/fixtures/bud.iif') }
11
+
12
+ let(:bud) {
13
+ QbIif::IIF.new do
14
+ bud do
15
+ row do
16
+ accnt 'Accounts Receivable'
17
+ period 'MONTH'
18
+ amount 'foo'
19
+ startdate '3/14/12'
20
+ end
21
+ end
22
+ end
23
+ }
24
+
25
+ subject { bud }
26
+
27
+ its(:output) { should eq expected }
28
+ end
@@ -0,0 +1,20 @@
1
+ require 'spec_helper'
2
+
3
+ describe QbIif::DSL::Class do
4
+
5
+ let(:expected) { File.read('spec/fixtures/class.iif') }
6
+
7
+ let(:klass) {
8
+ QbIif::IIF.new do
9
+ _class do
10
+ row do
11
+ name 'Foo'
12
+ end
13
+ end
14
+ end
15
+ }
16
+
17
+ subject { klass }
18
+
19
+ its(:output) { should eq expected }
20
+ end
@@ -0,0 +1,19 @@
1
+ require 'spec_helper'
2
+
3
+ describe QbIif::DSL::Ctype do
4
+ let(:expected) { File.read('spec/fixtures/ctype.iif') }
5
+
6
+ let(:ctype) {
7
+ QbIif::IIF.new do
8
+ ctype do
9
+ row do
10
+ name 'Bar'
11
+ end
12
+ end
13
+ end
14
+ }
15
+
16
+ subject { ctype }
17
+
18
+ its(:output) { should eq expected }
19
+ end
@@ -0,0 +1,20 @@
1
+ require 'spec_helper'
2
+
3
+ describe QbIif::DSL::Cust do
4
+ let(:expected) { File.read('spec/fixtures/cust.iif') }
5
+
6
+ let(:cust) {
7
+ QbIif::IIF.new do
8
+ cust do
9
+ row do
10
+ name 'Jun Lin'
11
+ phone1 '12312323242'
12
+ end
13
+ end
14
+ end
15
+ }
16
+
17
+ subject { cust }
18
+
19
+ its(:output) { should eq expected }
20
+ end
@@ -0,0 +1,24 @@
1
+ require 'spec_helper'
2
+
3
+ describe QbIif::DSL::Emp do
4
+
5
+ let(:expected) { File.read('spec/fixtures/emp.iif') }
6
+
7
+ let(:emp) {
8
+ QbIif::IIF.new do
9
+ emp do
10
+ row do
11
+ name 'Alfred'
12
+ init 'Master'
13
+ addr1 'Backer'
14
+ addr2 '37'
15
+ salutation 'Doctor'
16
+ end
17
+ end
18
+ end
19
+ }
20
+
21
+ subject { emp }
22
+
23
+ its(:output) { should eq expected }
24
+ end
@@ -0,0 +1,21 @@
1
+ require 'spec_helper'
2
+
3
+ describe QbIif::DSL::Invitem do
4
+ let(:expected) { File.read('spec/fixtures/invitem.iif') }
5
+
6
+ let(:invitem) {
7
+ QbIif::IIF.new do
8
+ invitem do
9
+ row do
10
+ name 'invitem 1'
11
+ invitemtype 'INVENTORY'
12
+ dep_type 1
13
+ end
14
+ end
15
+ end
16
+ }
17
+
18
+ subject { invitem }
19
+
20
+ its(:output) { should eq expected }
21
+ end
@@ -0,0 +1,19 @@
1
+ require 'spec_helper'
2
+
3
+ describe QbIif::DSL::Invmemo do
4
+ let(:expected) { File.read('spec/fixtures/invmemo.iif') }
5
+
6
+ let(:invmemo) {
7
+ QbIif::IIF.new do
8
+ invmemo do
9
+ row do
10
+ name 'invmemo 1'
11
+ end
12
+ end
13
+ end
14
+ }
15
+
16
+ subject { invmemo }
17
+
18
+ its(:output) { should eq expected }
19
+ end