rconomic 0.5.2 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (118) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +40 -0
  3. data/.ruby-version +1 -0
  4. data/.travis.yml +14 -3
  5. data/CHANGELOG.md +28 -0
  6. data/Gemfile +5 -4
  7. data/Guardfile +9 -4
  8. data/README.md +23 -4
  9. data/Rakefile +5 -5
  10. data/gemfiles/Gemfile.ruby-2.0 +14 -0
  11. data/lib/economic/account.rb +3 -3
  12. data/lib/economic/cash_book.rb +4 -7
  13. data/lib/economic/cash_book_entry.rb +4 -24
  14. data/lib/economic/company.rb +61 -0
  15. data/lib/economic/creditor.rb +4 -5
  16. data/lib/economic/creditor_contact.rb +5 -6
  17. data/lib/economic/creditor_entry.rb +1 -3
  18. data/lib/economic/current_invoice.rb +14 -21
  19. data/lib/economic/current_invoice_line.rb +4 -13
  20. data/lib/economic/debtor.rb +10 -11
  21. data/lib/economic/debtor_contact.rb +7 -8
  22. data/lib/economic/debtor_entry.rb +1 -3
  23. data/lib/economic/endpoint.rb +36 -6
  24. data/lib/economic/entity/handle.rb +54 -29
  25. data/lib/economic/entity/mapper.rb +1 -1
  26. data/lib/economic/entity.rb +26 -29
  27. data/lib/economic/entry.rb +1 -2
  28. data/lib/economic/invoice.rb +15 -8
  29. data/lib/economic/order.rb +2 -4
  30. data/lib/economic/product.rb +73 -0
  31. data/lib/economic/proxies/account_proxy.rb +2 -4
  32. data/lib/economic/proxies/actions/debtor_contact/all.rb +63 -0
  33. data/lib/economic/proxies/actions/find_by_ci_number.rb +1 -3
  34. data/lib/economic/proxies/actions/find_by_date_interval.rb +3 -6
  35. data/lib/economic/proxies/actions/find_by_handle_with_number.rb +1 -1
  36. data/lib/economic/proxies/actions/find_by_name.rb +1 -1
  37. data/lib/economic/proxies/actions/find_by_number.rb +2 -4
  38. data/lib/economic/proxies/actions/find_by_telephone_and_fax_number.rb +1 -3
  39. data/lib/economic/proxies/cash_book_entry_proxy.rb +19 -22
  40. data/lib/economic/proxies/cash_book_proxy.rb +5 -10
  41. data/lib/economic/proxies/company_proxy.rb +9 -0
  42. data/lib/economic/proxies/creditor_contact_proxy.rb +2 -2
  43. data/lib/economic/proxies/creditor_entry_proxy.rb +8 -14
  44. data/lib/economic/proxies/creditor_proxy.rb +8 -11
  45. data/lib/economic/proxies/current_invoice_line_proxy.rb +2 -2
  46. data/lib/economic/proxies/current_invoice_proxy.rb +3 -3
  47. data/lib/economic/proxies/debtor_contact_proxy.rb +6 -2
  48. data/lib/economic/proxies/debtor_entry_proxy.rb +6 -10
  49. data/lib/economic/proxies/debtor_proxy.rb +40 -55
  50. data/lib/economic/proxies/entity_proxy.rb +15 -15
  51. data/lib/economic/proxies/entry_proxy.rb +10 -16
  52. data/lib/economic/proxies/invoice_proxy.rb +3 -3
  53. data/lib/economic/proxies/order_proxy.rb +3 -3
  54. data/lib/economic/proxies/product_proxy.rb +11 -0
  55. data/lib/economic/session.rb +48 -21
  56. data/lib/economic/support/string.rb +5 -5
  57. data/lib/rconomic/version.rb +1 -1
  58. data/lib/rconomic.rb +39 -34
  59. data/lib/savon_ext/request.rb +17 -0
  60. data/rconomic.gemspec +8 -7
  61. data/spec/economic/account_spec.rb +3 -3
  62. data/spec/economic/cash_book_entry_spec.rb +26 -3
  63. data/spec/economic/cash_book_spec.rb +7 -7
  64. data/spec/economic/company_spec.rb +20 -0
  65. data/spec/economic/creditor_contact_spec.rb +4 -5
  66. data/spec/economic/creditor_entry_spec.rb +20 -0
  67. data/spec/economic/creditor_spec.rb +3 -3
  68. data/spec/economic/current_invoice_line_spec.rb +3 -3
  69. data/spec/economic/current_invoice_spec.rb +19 -19
  70. data/spec/economic/debtor_contact_spec.rb +4 -5
  71. data/spec/economic/debtor_entry_spec.rb +1 -1
  72. data/spec/economic/debtor_spec.rb +13 -13
  73. data/spec/economic/endpoint_spec.rb +27 -11
  74. data/spec/economic/entity/handle_spec.rb +10 -23
  75. data/spec/economic/entity/mapper_spec.rb +26 -30
  76. data/spec/economic/entity_spec.rb +36 -31
  77. data/spec/economic/entry_spec.rb +1 -1
  78. data/spec/economic/invoice_spec.rb +49 -7
  79. data/spec/economic/order_spec.rb +4 -4
  80. data/spec/economic/product_spec.rb +72 -0
  81. data/spec/economic/proxies/account_proxy_spec.rb +74 -0
  82. data/spec/economic/proxies/actions/debtor_contact/all_spec.rb +26 -0
  83. data/spec/economic/proxies/actions/find_by_name_spec.rb +6 -7
  84. data/spec/economic/proxies/cash_book_entry_proxy_spec.rb +27 -29
  85. data/spec/economic/proxies/cash_book_proxy_spec.rb +14 -22
  86. data/spec/economic/proxies/company_proxy_spec.rb +47 -0
  87. data/spec/economic/proxies/creditor_contact_proxy_spec.rb +11 -5
  88. data/spec/economic/proxies/creditor_entry_proxy_spec.rb +12 -12
  89. data/spec/economic/proxies/creditor_proxy_spec.rb +15 -15
  90. data/spec/economic/proxies/current_invoice_line_proxy_spec.rb +10 -4
  91. data/spec/economic/proxies/current_invoice_proxy_spec.rb +37 -19
  92. data/spec/economic/proxies/debtor_contact_proxy_spec.rb +8 -4
  93. data/spec/economic/proxies/debtor_entry_proxy_spec.rb +21 -11
  94. data/spec/economic/proxies/debtor_proxy_spec.rb +81 -40
  95. data/spec/economic/proxies/entry_proxy_spec.rb +17 -14
  96. data/spec/economic/proxies/invoice_proxy_spec.rb +24 -10
  97. data/spec/economic/proxies/order_proxy_spec.rb +20 -10
  98. data/spec/economic/proxies/product_proxy_spec.rb +86 -0
  99. data/spec/economic/session_spec.rb +74 -35
  100. data/spec/fixtures/account_get_all/multiple.xml +15 -0
  101. data/spec/fixtures/account_get_all/none.xml +8 -0
  102. data/spec/fixtures/account_get_all/single.xml +12 -0
  103. data/spec/fixtures/account_get_data_array/multiple.xml +69 -0
  104. data/spec/fixtures/company_get/success.xml +10 -0
  105. data/spec/fixtures/company_get_data/success.xml +32 -0
  106. data/spec/fixtures/current_invoice_line_create_from_data/success.xml +6 -37
  107. data/spec/fixtures/debtor_create_from_data/success.xml +5 -52
  108. data/spec/fixtures/debtor_get_orders/none.xml +9 -0
  109. data/spec/fixtures/product_create_from_data/success.xml +37 -0
  110. data/spec/fixtures/product_find_by_number/found.xml +10 -0
  111. data/spec/fixtures/product_find_by_number/not_found.xml +6 -0
  112. data/spec/fixtures/product_get_all/multiple.xml +15 -0
  113. data/spec/fixtures/product_get_all/single.xml +12 -0
  114. data/spec/fixtures/product_get_data/success.xml +37 -0
  115. data/spec/fixtures/product_get_data_array/multiple.xml +69 -0
  116. data/spec/spec_helper.rb +6 -9
  117. data/spec/support/factories.rb +14 -14
  118. metadata +54 -9
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 88080f5222fecd57d855c891b03926bd416340e2
4
- data.tar.gz: aa89d4fde45914d91730bcff8f26ac867db0852a
3
+ metadata.gz: fa5df738699c252506f1f3acf8370d0e265687a6
4
+ data.tar.gz: c780fb9db1d1fbaf997f20c8a58eb35739be1c41
5
5
  SHA512:
6
- metadata.gz: 223fce8862fd04d5a4540fef0d5c087b77169a8e47c114f3b7db701bab9bf87391587f2ce1bdaa5caa9503dbbea7047462b7783d2f9b4ed6368d6d0475aae704
7
- data.tar.gz: fb814fb6c65aa4cf5a2decc5d0faa88d5a9216dc83a81e121d253454665351cfb9dc694e2e3d86a7a5449cf964d8293b7d8959b0fb8fa9fa300f705eb80da067
6
+ metadata.gz: e13a3d7745b0e2133bca3bb7effc1af8d1dd9df0886bd41d1b4b8f9fb58eccb26fce658cfe1737562775e591f96279f6cd78384d2ef14f15b9f821c3dce21e83
7
+ data.tar.gz: e52198ad2f4475c71e0034a509ca8d277d4c2915beea248bdf00cac9e4dfd85b20a8609028b47270518607338430486cf8cd68c6c8d11f85a9752d01e16c822c
data/.rubocop.yml ADDED
@@ -0,0 +1,40 @@
1
+ AllCops:
2
+ DisplayCopNames: true
3
+ Exclude:
4
+ - 'db/schema.rb'
5
+
6
+ Lint/EndAlignment:
7
+ EnforcedStyleAlignWith: variable
8
+
9
+ Style/AlignParameters:
10
+ EnforcedStyle: with_fixed_indentation
11
+
12
+ Style/BlockDelimiters:
13
+ Enabled: false
14
+
15
+ Style/Documentation:
16
+ Enabled: false
17
+
18
+ Style/DotPosition:
19
+ EnforcedStyle: trailing
20
+
21
+ Style/FileName:
22
+ Enabled: false
23
+
24
+ Style/HashSyntax:
25
+ EnforcedStyle: hash_rockets
26
+
27
+ Style/IfUnlessModifier:
28
+ Enabled: false
29
+
30
+ Style/MultilineOperationIndentation:
31
+ EnforcedStyle: indented
32
+
33
+ Style/SpaceInsideHashLiteralBraces:
34
+ EnforcedStyle: no_space
35
+
36
+ Style/StringLiterals:
37
+ EnforcedStyle: double_quotes
38
+
39
+ Style/WordArray:
40
+ Enabled: false
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ ruby-2.3.0
data/.travis.yml CHANGED
@@ -1,10 +1,21 @@
1
1
  # Specify which ruby versions you wish to run your tests on, each version will be used
2
2
  rvm:
3
- - 1.9.3
4
- - 2.0.0
5
- - jruby
3
+ - 2.1.8
4
+ - 2.2.6
5
+ - 2.3.3
6
+ - 2.4.0
7
+ - jruby-9.1.7.0
6
8
 
7
9
  # Specify the recipients for email notification
8
10
  notifications:
9
11
  recipients:
10
12
  - jakob@mentalized.net
13
+
14
+ addons:
15
+ code_climate:
16
+ repo_token: 6746eb72f5d9759f7d83ea90e8f49e3f01480d3b8f6334eea9e7cd9991c41ea4
17
+
18
+ matrix:
19
+ include:
20
+ - rvm: 2.0.0
21
+ gemfile: gemfiles/Gemfile.ruby-2.0
data/CHANGELOG.md ADDED
@@ -0,0 +1,28 @@
1
+ # Change Log
2
+
3
+ All notable changes to this project will be documented in this file.
4
+ This project adheres to [Semantic Versioning](http://semver.org/).
5
+
6
+ ## 0.6.0 [April 30, 2017]
7
+
8
+ ### Added
9
+
10
+ * Support for getting all contacts for a given debtor (@nielsbuus)
11
+ * Basic implementation of products (@traels)
12
+ * Ability to create CreditorInvoice entries (@prognostikos)
13
+ * Properties for "past due" status of invoices (@skelboe)
14
+ * Support to get company data (@adriacidre)
15
+ * Support X-EconomicAppIdentifier (@prognostikos)
16
+ * Fixed an issue where X-EconomicAppIdentifier wasn't set properly (@olepalm)
17
+
18
+ ### Changes
19
+
20
+ * The source code has a new home at https://github.com/substancelab/rconomic
21
+ * Non-existing methods removed from the documentation (@koppen)
22
+ * Handle Numbers can now be String as well as numbers (@traels)
23
+ * Fixed authentication when using legacy Connect (@koppen)
24
+
25
+ ### Removed
26
+
27
+ * We no longer officially support Ruby 1.9.3. rconomic might still work on
28
+ legacy rubies, but we aren't testing it.
data/Gemfile CHANGED
@@ -3,13 +3,14 @@ source "https://rubygems.org"
3
3
  gemspec
4
4
 
5
5
  group :test do
6
- gem 'coveralls', :require => false
7
- gem 'rake'
6
+ gem "codeclimate-test-reporter", :require => false
7
+ gem "rake"
8
+ gem "simplecov", :require => false
8
9
  end
9
10
 
10
11
  # Not required to develop rconomic, but useful. See file
11
12
  # mappings in Guardfile
12
13
  group :guard do
13
- gem 'guard'
14
- gem 'guard-rspec'
14
+ gem "guard"
15
+ gem "guard-rspec"
15
16
  end
data/Guardfile CHANGED
@@ -1,6 +1,11 @@
1
- guard 'rspec', :version => 2, :cli => "--color", :all_after_pass => false, :all_on_start => false, :keep_failed => false do
2
- watch('spec/spec_helper.rb') { "spec" }
1
+ guard(
2
+ "rspec",
3
+ :cmd => "rspec",
4
+ :all_after_pass => false,
5
+ :all_on_start => false,
6
+ :failed_mode => :keep
7
+ ) do
8
+ watch("spec/spec_helper.rb") { "spec" }
3
9
  watch(%r{^spec/.+_spec\.rb$})
4
- watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
10
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
5
11
  end
6
-
data/README.md CHANGED
@@ -5,14 +5,17 @@ Ruby wrapper for the [e-conomic](http://www.e-conomic.co.uk) SOAP API, that aims
5
5
 
6
6
  E-conomic is a web-based accounting system. For their marketing speak, see [http://www.e-conomic.co.uk/about/](http://www.e-conomic.co.uk/about/). More details about their API at [http://www.e-conomic.com/developer](http://www.e-conomic.com/developer).
7
7
 
8
- [![Build Status](https://secure.travis-ci.org/lokalebasen/rconomic.png?branch=master)](http://travis-ci.org/lokalebasen/rconomic) [![Coverage Status](https://coveralls.io/repos/lokalebasen/rconomic/badge.png?branch=master)](https://coveralls.io/r/lokalebasen/rconomic?branch=master) [![Code Climate](https://codeclimate.com/github/lokalebasen/rconomic.png)](https://codeclimate.com/github/lokalebasen/rconomic)
8
+ [![Build Status](https://travis-ci.org/substancelab/rconomic.svg?branch=master)](https://travis-ci.org/substancelab/rconomic) [![Test Coverage](https://codeclimate.com/github/substancelab/rconomic/badges/coverage.svg)](https://codeclimate.com/github/substancelab/rconomic/coverage) [![Code Climate](https://codeclimate.com/github/substancelab/rconomic/badges/gpa.svg)](https://codeclimate.com/github/substancelab/rconomic)
9
9
 
10
10
 
11
11
  Usage example
12
12
  -------------
13
13
 
14
14
  economic = Economic::Session.new
15
- economic.connect_with_credentials(123456, 'API', 'passw0rd')
15
+
16
+ # After 16 November 2015, you must supply an 'Application ID' with #connect_with_credentials
17
+ # As described here: http://techtalk.e-conomic.com/e-conomic-soap-api-now-requires-you-to-specify-a-custom-x-economicappidentifier-header/
18
+ economic.connect_with_credentials(123456, 'API', 'passw0rd', 'my awesome integration v1.0.0')
16
19
 
17
20
  # Or connect using a Private app ID and an access ID provided by the "Grant Access"
18
21
  # As described here: http://www.e-conomic.com/developer/tutorials
@@ -20,7 +23,7 @@ Usage example
20
23
  economic.connect_with_token 'the_private_app_id', 'the_access_id_you_got_from_the_grant'
21
24
 
22
25
  # Find a debtor:
23
- debtor = economic.debtors.find(101)
26
+ debtor = economic.debtors.find(:id => 101)
24
27
 
25
28
  # Creating a debtor:
26
29
  debtor = economic.debtors.build
@@ -75,6 +78,20 @@ Usage example
75
78
 
76
79
  cash_book.book
77
80
 
81
+ # Find a product:
82
+ product = economic.products.find(1234)
83
+
84
+ # Creating a product:
85
+ product = economic.products.build
86
+ product.number = 'ESC2014-LED-DISPLAY'
87
+ product.product_group_handle = { :number => 1 }
88
+ product.name = '100 meter LED display'
89
+ product.sales_price = 999999
90
+ product.cost_price = 100000
91
+ product.recommended_price = 999999
92
+ product.is_accessible = true
93
+ product.volume = 1
94
+ product.save
78
95
 
79
96
  How to enable e-conomic API access
80
97
  ----------------------------------
@@ -93,7 +110,9 @@ Not even remotely... For now, limited to a small subset of all the [available op
93
110
  -------------------+--------+------+--------+-------
94
111
  CashBook | X | X | X | X
95
112
  CashBookEntry | X | X | X | X
113
+ Company | X | X | X | X
96
114
  Creditor | X | X | X | X
115
+ CreditorEntry | X | X | |
97
116
  CreditorContact | X | X | X | X
98
117
  CreditorEntry | X | X | X | X
99
118
  CurrentInvoice | X | X | X | X
@@ -103,7 +122,7 @@ Not even remotely... For now, limited to a small subset of all the [available op
103
122
  DebtorEntry | X | X | X | X
104
123
  Entry | X | X | X | X
105
124
  Invoice | X | X | |
106
-
125
+ Product | X | X | X | X
107
126
 
108
127
  Credits
109
128
  -------
data/Rakefile CHANGED
@@ -1,13 +1,13 @@
1
- require 'bundler'
1
+ require "bundler"
2
2
  Bundler::GemHelper.install_tasks
3
3
 
4
- require 'rspec/core/rake_task'
4
+ require "rspec/core/rake_task"
5
5
  RSpec::Core::RakeTask.new(:spec)
6
6
 
7
7
  task :console do
8
- require 'irb'
9
- require 'irb/completion'
10
- require 'rconomic' # You know what to do.
8
+ require "irb"
9
+ require "irb/completion"
10
+ require "rconomic" # You know what to do.
11
11
  ARGV.clear
12
12
  IRB.start
13
13
  end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "nokogiri", "< 1.7"
6
+ gem "rack", "< 2.0"
7
+
8
+ gemspec :path => "../"
9
+
10
+ group :test do
11
+ gem "codeclimate-test-reporter", :require => false
12
+ gem "rake"
13
+ gem "simplecov", :require => false
14
+ end
@@ -1,18 +1,18 @@
1
- require 'economic/entity'
1
+ require "economic/entity"
2
2
 
3
3
  module Economic
4
4
  class Account < Entity
5
5
  has_properties :name, :number, :balance, :block_direct_entries, :contra_account, :debit_credit, :department, :distribution_key, :is_accessible, :opening_account, :total_from, :type, :vat_account
6
6
 
7
7
  def handle
8
- Handle.build({:name => @name})
8
+ Handle.build(:name => @name)
9
9
  end
10
10
 
11
11
  protected
12
12
 
13
13
  def fields
14
14
  [
15
- ["Handle", :handle, Proc.new { |handle| handle.to_hash }, :required],
15
+ ["Handle", :handle, proc { |handle| handle.to_hash }, :required],
16
16
  ["Name", :name, nil, :required],
17
17
  ["Number", :number, nil, :required]
18
18
  ]
@@ -1,7 +1,6 @@
1
- require 'economic/entity'
1
+ require "economic/entity"
2
2
 
3
3
  module Economic
4
-
5
4
  # Represents a cash book in E-conomic.
6
5
  #
7
6
  # API documentation: http://www.e-conomic.com/apidocs/Documentation/T_Economic_Api_ICashBook.html
@@ -9,7 +8,7 @@ module Economic
9
8
  has_properties :name, :number
10
9
 
11
10
  def handle
12
- @handle || Handle.new({:number => @number})
11
+ @handle || Handle.new(:number => @number)
13
12
  end
14
13
 
15
14
  def entries
@@ -18,9 +17,7 @@ module Economic
18
17
 
19
18
  # Books all entries in the cashbook. Returns book result.
20
19
  def book
21
- response = request(:book, {
22
- "cashBookHandle" => handle.to_hash
23
- })
20
+ response = request(:book, "cashBookHandle" => handle.to_hash)
24
21
  response[:number].to_i
25
22
  end
26
23
 
@@ -28,7 +25,7 @@ module Economic
28
25
 
29
26
  def fields
30
27
  [
31
- ["Handle", :handle, Proc.new { |h| h.to_hash }, :required],
28
+ ["Handle", :handle, proc { |h| h.to_hash }, :required],
32
29
  ["Name", :name, nil, :required],
33
30
  ["Number", :number, nil, :required]
34
31
  ]
@@ -1,4 +1,4 @@
1
- require 'economic/entity'
1
+ require "economic/entity"
2
2
 
3
3
  module Economic
4
4
  # Represents a cash book in E-conomic.
@@ -37,33 +37,12 @@ module Economic
37
37
  :voucher_number
38
38
 
39
39
  defaults(
40
- :account_handle => nil,
41
40
  :amount => 0,
42
41
  :amount_default_currency => 0,
43
- :bank_payment_creditor_id => nil,
44
- :bank_payment_creditor_invoice_id => nil,
45
- :bank_payment_type_handle => nil,
46
- :capitalise_handle => nil,
47
- :cash_book_handle => nil,
48
- :contra_account_handle => nil,
49
- :contra_vat_account_handle => nil,
50
- :cost_type_handle => nil,
51
- :creditor_handle => nil,
52
- :creditor_invoice_number => nil,
53
- :currency_handle => nil,
54
42
  :date => Time.now,
55
- :debtor_handle => nil,
56
- :debtor_invoice_number => nil,
57
- :department_handle => nil,
58
- :distribution_key_handle => nil,
59
- :due_date => nil,
60
- :employee_handle => nil,
61
- :end_date => nil,
62
- :project_handle => nil,
63
43
  :start_date => Time.now,
64
44
  :text => "",
65
45
  :type => "",
66
- :vat_account_handle => nil,
67
46
  :voucher_number => 0
68
47
  )
69
48
 
@@ -74,14 +53,15 @@ module Economic
74
53
  protected
75
54
 
76
55
  def fields
77
- to_hash = Proc.new { |handle| handle.to_hash }
56
+ to_hash = proc { |handle| handle.to_hash }
78
57
  [
79
- ["Handle", :handle, Proc.new { |v| v.to_hash }],
58
+ ["Handle", :handle, proc { |v| v.to_hash }],
80
59
  ["Id1", :id1],
81
60
  ["Id2", :id2],
82
61
  ["Type", :type],
83
62
  ["CashBookHandle", :cash_book_handle, to_hash],
84
63
  ["DebtorHandle", :debtor_handle, to_hash],
64
+ ["CreditorHandle", :creditor_handle, to_hash],
85
65
  ["AccountHandle", :account_handle, to_hash],
86
66
  ["ContraAccountHandle", :contra_account_handle, to_hash],
87
67
  ["Date", :date, nil, :required],
@@ -0,0 +1,61 @@
1
+ require "economic/entity"
2
+
3
+ module Economic
4
+ # Represents a creditor in E-conomic.
5
+ #
6
+ # API documentation: https://api.e-conomic.com/secure/api1/EconomicWebService.asmx?op=Company_GetData
7
+ #
8
+ # Examples
9
+ #
10
+ # # Get company:
11
+ # creditor = economic.company.get
12
+ #
13
+ class Company < Entity
14
+ has_properties :number,
15
+ :base_currency_handle,
16
+ :name,
17
+ :address_1,
18
+ :address_2,
19
+ :postal_code,
20
+ :city,
21
+ :country,
22
+ :telephone_number,
23
+ :fax_number,
24
+ :mobile_number,
25
+ :contact,
26
+ :website,
27
+ :email,
28
+ :c_i_number,
29
+ :vat_number,
30
+ :sign_up_date
31
+ def handle
32
+ @handle || Handle.build(:number => @number)
33
+ end
34
+
35
+ protected
36
+
37
+ def fields
38
+ to_hash = proc { |h| h.to_hash }
39
+ [
40
+ ["Handle", :handle, to_hash, :required],
41
+ ["Number", :number, nil, :required],
42
+ ["BaseCurrencyHandle", :base_currency_handle, to_hash],
43
+ ["Name", :name],
44
+ ["Address1", :address_1],
45
+ ["Address2", :address_2],
46
+ ["PostalCode", :postal_code],
47
+ ["City", :city],
48
+ ["Country", :country],
49
+ ["TelephoneNumber", :telephone_number],
50
+ ["FaxNumber", :fax_number],
51
+ ["MobileNumber", :mobile_number],
52
+ ["Contact", :contact],
53
+ ["WebSite", :website],
54
+ ["Email", :email],
55
+ ["CINumber", :c_i_number],
56
+ ["VatNumber", :vat_number],
57
+ ["SignUpDate", :sign_up_date]
58
+ ]
59
+ end
60
+ end
61
+ end
@@ -1,7 +1,6 @@
1
- require 'economic/entity'
1
+ require "economic/entity"
2
2
 
3
3
  module Economic
4
-
5
4
  # Represents a creditor in E-conomic.
6
5
  #
7
6
  # API documentation: http://www.e-conomic.com/apidocs/Documentation/T_Economic_Api_ICreditor.html
@@ -13,7 +12,7 @@ module Economic
13
12
  #
14
13
  # # Creating a creditor:
15
14
  # creditor = economic.creditors.build
16
- # creditor.number = economic.creditors.next_available_number
15
+ # creditor.number = 42
17
16
  # creditor.creditor_group_handle = { :number => 1 }
18
17
  # creditor.name = 'Apple Inc'
19
18
  # creditor.vat_zone = 'HomeCountry' # HomeCountry, EU, Abroad
@@ -25,7 +24,7 @@ module Economic
25
24
  has_properties :number, :creditor_group_handle, :name, :vat_zone, :currency_handle, :term_of_payment_handle, :is_accessible, :ci_number, :email, :address, :postal_code, :city, :country, :bank_account, :attention_handle, :your_reference_handle, :our_reference_handle, :default_payment_type_handle, :default_payment_creditor_id, :county, :auto_contra_account_handle
26
25
 
27
26
  def handle
28
- @handle || Handle.build({:number => @number})
27
+ @handle || Handle.build(:number => @number)
29
28
  end
30
29
 
31
30
  # Returns the Creditors contacts
@@ -36,7 +35,7 @@ module Economic
36
35
  protected
37
36
 
38
37
  def fields
39
- to_hash = Proc.new { |h| h.to_hash }
38
+ to_hash = proc { |h| h.to_hash }
40
39
  [
41
40
  ["Handle", :handle, to_hash, :required],
42
41
  ["Number", :number, nil, :required],
@@ -1,7 +1,6 @@
1
- require 'economic/entity'
1
+ require "economic/entity"
2
2
 
3
3
  module Economic
4
-
5
4
  # Represents a creditor contact.
6
5
  #
7
6
  # API documentation: http://www.e-conomic.com/apidocs/Documentation/T_Economic_Api_ICreditorContact.html
@@ -36,20 +35,20 @@ module Economic
36
35
  end
37
36
 
38
37
  def handle
39
- @handle || Handle.build({:id => @id})
38
+ @handle || Handle.build(:id => @id)
40
39
  end
41
40
 
42
41
  protected
43
42
 
44
43
  def fields
45
- to_hash = Proc.new { |handle| handle.to_hash }
44
+ to_hash = proc { |handle| handle.to_hash }
46
45
  # SOAP field, entity method, formatter proc, required?
47
46
  [
48
- ["Handle", :handle, Proc.new { |v| v.to_hash }, :required],
47
+ ["Handle", :handle, proc { |v| v.to_hash }, :required],
49
48
  ["Id", :id, nil],
50
49
  ["CreditorHandle", :creditor_handle, to_hash],
51
50
  ["Name", :name],
52
- ["Number", :handle, Proc.new { |v| v.number }, :required],
51
+ ["Number", :handle, proc { |v| v.number }, :required],
53
52
  ["TelephoneNumber", :telephone_number],
54
53
  ["Email", :email],
55
54
  ["Comments", :comments],
@@ -1,7 +1,6 @@
1
- require 'economic/entity'
1
+ require "economic/entity"
2
2
 
3
3
  module Economic
4
-
5
4
  # Represents a creditor entry in E-conomic.
6
5
  #
7
6
  # API documentation: http://www.e-conomic.com/apidocs/Documentation/T_Economic_Api_ICreditorEntry.html
@@ -21,5 +20,4 @@ module Economic
21
20
  :type,
22
21
  :voucher_number
23
22
  end
24
-
25
23
  end
@@ -1,7 +1,6 @@
1
- require 'economic/entity'
1
+ require "economic/entity"
2
2
 
3
3
  module Economic
4
-
5
4
  # CurrentInvoices are invoices that are not yet booked. They are therefore not
6
5
  # read-only.
7
6
  #
@@ -55,19 +54,12 @@ module Economic
55
54
  defaults(
56
55
  :id => 0,
57
56
  :date => Time.now,
58
- :term_of_payment_handle => nil,
59
- :due_date => nil,
60
- :currency_handle => nil,
61
- :exchange_rate => 100, # Why am _I_ inputting this?
62
- :is_vat_included => nil,
63
- :layout_handle => nil,
64
- :delivery_date => nil,
65
- :heading => nil,
57
+ :exchange_rate => 100,
66
58
  :net_amount => 0,
67
59
  :vat_amount => 0,
68
60
  :gross_amount => 0,
69
61
  :margin => 0,
70
- :margin_as_percent => 0 # Why do I have to input both Margin and MarginAsPercent? Shouldn't powerful Windows machines running ASP.NET be able to compute this?
62
+ :margin_as_percent => 0
71
63
  )
72
64
 
73
65
  def initialize(properties = {})
@@ -94,9 +86,7 @@ module Economic
94
86
  #
95
87
  # Returns the resulting Economic::Invoice object
96
88
  def book
97
- response = request(:book, {
98
- "currentInvoiceHandle" => handle.to_hash
99
- })
89
+ response = request(:book, "currentInvoiceHandle" => handle.to_hash)
100
90
 
101
91
  # Find the created Invoice
102
92
  session.invoices.find(response[:number])
@@ -107,10 +97,11 @@ module Economic
107
97
  #
108
98
  # Returns the resulting Economic::Invoice object
109
99
  def book_with_number(number)
110
- response = request(:book_with_number, {
100
+ response = request(
101
+ :book_with_number,
111
102
  "currentInvoiceHandle" => handle.to_hash,
112
103
  "number" => number
113
- })
104
+ )
114
105
 
115
106
  # Find the created Invoice
116
107
  session.invoices.find(response[:number])
@@ -155,11 +146,13 @@ module Economic
155
146
  protected
156
147
 
157
148
  def fields
158
- date_formatter = Proc.new { |date| date.respond_to?(:iso8601) ? date.iso8601 : nil }
159
- to_hash = Proc.new { |handle| handle.to_hash }
149
+ date_formatter = proc { |date|
150
+ date.respond_to?(:iso8601) ? date.iso8601 : nil
151
+ }
152
+ to_hash = proc { |handle| handle.to_hash }
160
153
  [
161
154
  ["Id", :id, nil, :required],
162
- ["DebtorHandle", :debtor, Proc.new { |d| d.handle.to_hash }],
155
+ ["DebtorHandle", :debtor, proc { |d| d.handle.to_hash }],
163
156
  ["DebtorName", :debtor_name, nil, :required],
164
157
  ["DebtorAddress", :debtor_address],
165
158
  ["DebtorPostalCode", :debtor_postal_code],
@@ -175,8 +168,8 @@ module Economic
175
168
  ["LayoutHandle", :layout_handle, to_hash],
176
169
  ["DeliveryDate", :delivery_date, date_formatter, :required],
177
170
  ["Heading", :heading],
178
- ['TextLine1', :text_line1],
179
- ['TextLine2', :text_line2],
171
+ ["TextLine1", :text_line1],
172
+ ["TextLine2", :text_line2],
180
173
  ["NetAmount", :net_amount, nil, :required],
181
174
  ["VatAmount", :vat_amount, nil, :required],
182
175
  ["GrossAmount", :gross_amount, nil, :required],
@@ -1,8 +1,7 @@
1
- require 'economic/entity'
2
- require 'economic/current_invoice'
1
+ require "economic/entity"
2
+ require "economic/current_invoice"
3
3
 
4
4
  module Economic
5
-
6
5
  # Represents a current invoice line.
7
6
  #
8
7
  # API documentation: http://www.e-conomic.com/apidocs/Documentation/T_Economic_Api_ICurrentInvoiceLine.html
@@ -24,16 +23,8 @@ module Economic
24
23
  :margin_as_percent
25
24
 
26
25
  defaults(
27
- :invoice_handle => nil,
28
- :description => nil,
29
- :delivery_date => nil,
30
- :unit_handle => nil,
31
- :product_handle => nil,
32
- :quantity => nil,
33
- :unit_net_price => nil,
34
26
  :discount_as_percent => 0,
35
27
  :unit_cost_price => 0,
36
- :total_net_amount => nil,
37
28
  :total_margin => 0,
38
29
  :margin_as_percent => 0
39
30
  )
@@ -60,9 +51,9 @@ module Economic
60
51
  protected
61
52
 
62
53
  def fields
63
- to_hash = Proc.new { |h| h.to_hash }
54
+ to_hash = proc { |h| h.to_hash }
64
55
  [
65
- ["Number", :number, Proc.new { 0 }, :required], # Doesn't seem to be used
56
+ ["Number", :number, proc { 0 }, :required], # Doesn't seem to be used
66
57
  ["InvoiceHandle", :invoice_handle, to_hash],
67
58
  ["Description", :description],
68
59
  ["DeliveryDate", :delivery_date, nil, :required],