rconomic 0.5.2 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +40 -0
- data/.ruby-version +1 -0
- data/.travis.yml +14 -3
- data/CHANGELOG.md +28 -0
- data/Gemfile +5 -4
- data/Guardfile +9 -4
- data/README.md +23 -4
- data/Rakefile +5 -5
- data/gemfiles/Gemfile.ruby-2.0 +14 -0
- data/lib/economic/account.rb +3 -3
- data/lib/economic/cash_book.rb +4 -7
- data/lib/economic/cash_book_entry.rb +4 -24
- data/lib/economic/company.rb +61 -0
- data/lib/economic/creditor.rb +4 -5
- data/lib/economic/creditor_contact.rb +5 -6
- data/lib/economic/creditor_entry.rb +1 -3
- data/lib/economic/current_invoice.rb +14 -21
- data/lib/economic/current_invoice_line.rb +4 -13
- data/lib/economic/debtor.rb +10 -11
- data/lib/economic/debtor_contact.rb +7 -8
- data/lib/economic/debtor_entry.rb +1 -3
- data/lib/economic/endpoint.rb +36 -6
- data/lib/economic/entity/handle.rb +54 -29
- data/lib/economic/entity/mapper.rb +1 -1
- data/lib/economic/entity.rb +26 -29
- data/lib/economic/entry.rb +1 -2
- data/lib/economic/invoice.rb +15 -8
- data/lib/economic/order.rb +2 -4
- data/lib/economic/product.rb +73 -0
- data/lib/economic/proxies/account_proxy.rb +2 -4
- data/lib/economic/proxies/actions/debtor_contact/all.rb +63 -0
- data/lib/economic/proxies/actions/find_by_ci_number.rb +1 -3
- data/lib/economic/proxies/actions/find_by_date_interval.rb +3 -6
- data/lib/economic/proxies/actions/find_by_handle_with_number.rb +1 -1
- data/lib/economic/proxies/actions/find_by_name.rb +1 -1
- data/lib/economic/proxies/actions/find_by_number.rb +2 -4
- data/lib/economic/proxies/actions/find_by_telephone_and_fax_number.rb +1 -3
- data/lib/economic/proxies/cash_book_entry_proxy.rb +19 -22
- data/lib/economic/proxies/cash_book_proxy.rb +5 -10
- data/lib/economic/proxies/company_proxy.rb +9 -0
- data/lib/economic/proxies/creditor_contact_proxy.rb +2 -2
- data/lib/economic/proxies/creditor_entry_proxy.rb +8 -14
- data/lib/economic/proxies/creditor_proxy.rb +8 -11
- data/lib/economic/proxies/current_invoice_line_proxy.rb +2 -2
- data/lib/economic/proxies/current_invoice_proxy.rb +3 -3
- data/lib/economic/proxies/debtor_contact_proxy.rb +6 -2
- data/lib/economic/proxies/debtor_entry_proxy.rb +6 -10
- data/lib/economic/proxies/debtor_proxy.rb +40 -55
- data/lib/economic/proxies/entity_proxy.rb +15 -15
- data/lib/economic/proxies/entry_proxy.rb +10 -16
- data/lib/economic/proxies/invoice_proxy.rb +3 -3
- data/lib/economic/proxies/order_proxy.rb +3 -3
- data/lib/economic/proxies/product_proxy.rb +11 -0
- data/lib/economic/session.rb +48 -21
- data/lib/economic/support/string.rb +5 -5
- data/lib/rconomic/version.rb +1 -1
- data/lib/rconomic.rb +39 -34
- data/lib/savon_ext/request.rb +17 -0
- data/rconomic.gemspec +8 -7
- data/spec/economic/account_spec.rb +3 -3
- data/spec/economic/cash_book_entry_spec.rb +26 -3
- data/spec/economic/cash_book_spec.rb +7 -7
- data/spec/economic/company_spec.rb +20 -0
- data/spec/economic/creditor_contact_spec.rb +4 -5
- data/spec/economic/creditor_entry_spec.rb +20 -0
- data/spec/economic/creditor_spec.rb +3 -3
- data/spec/economic/current_invoice_line_spec.rb +3 -3
- data/spec/economic/current_invoice_spec.rb +19 -19
- data/spec/economic/debtor_contact_spec.rb +4 -5
- data/spec/economic/debtor_entry_spec.rb +1 -1
- data/spec/economic/debtor_spec.rb +13 -13
- data/spec/economic/endpoint_spec.rb +27 -11
- data/spec/economic/entity/handle_spec.rb +10 -23
- data/spec/economic/entity/mapper_spec.rb +26 -30
- data/spec/economic/entity_spec.rb +36 -31
- data/spec/economic/entry_spec.rb +1 -1
- data/spec/economic/invoice_spec.rb +49 -7
- data/spec/economic/order_spec.rb +4 -4
- data/spec/economic/product_spec.rb +72 -0
- data/spec/economic/proxies/account_proxy_spec.rb +74 -0
- data/spec/economic/proxies/actions/debtor_contact/all_spec.rb +26 -0
- data/spec/economic/proxies/actions/find_by_name_spec.rb +6 -7
- data/spec/economic/proxies/cash_book_entry_proxy_spec.rb +27 -29
- data/spec/economic/proxies/cash_book_proxy_spec.rb +14 -22
- data/spec/economic/proxies/company_proxy_spec.rb +47 -0
- data/spec/economic/proxies/creditor_contact_proxy_spec.rb +11 -5
- data/spec/economic/proxies/creditor_entry_proxy_spec.rb +12 -12
- data/spec/economic/proxies/creditor_proxy_spec.rb +15 -15
- data/spec/economic/proxies/current_invoice_line_proxy_spec.rb +10 -4
- data/spec/economic/proxies/current_invoice_proxy_spec.rb +37 -19
- data/spec/economic/proxies/debtor_contact_proxy_spec.rb +8 -4
- data/spec/economic/proxies/debtor_entry_proxy_spec.rb +21 -11
- data/spec/economic/proxies/debtor_proxy_spec.rb +81 -40
- data/spec/economic/proxies/entry_proxy_spec.rb +17 -14
- data/spec/economic/proxies/invoice_proxy_spec.rb +24 -10
- data/spec/economic/proxies/order_proxy_spec.rb +20 -10
- data/spec/economic/proxies/product_proxy_spec.rb +86 -0
- data/spec/economic/session_spec.rb +74 -35
- data/spec/fixtures/account_get_all/multiple.xml +15 -0
- data/spec/fixtures/account_get_all/none.xml +8 -0
- data/spec/fixtures/account_get_all/single.xml +12 -0
- data/spec/fixtures/account_get_data_array/multiple.xml +69 -0
- data/spec/fixtures/company_get/success.xml +10 -0
- data/spec/fixtures/company_get_data/success.xml +32 -0
- data/spec/fixtures/current_invoice_line_create_from_data/success.xml +6 -37
- data/spec/fixtures/debtor_create_from_data/success.xml +5 -52
- data/spec/fixtures/debtor_get_orders/none.xml +9 -0
- data/spec/fixtures/product_create_from_data/success.xml +37 -0
- data/spec/fixtures/product_find_by_number/found.xml +10 -0
- data/spec/fixtures/product_find_by_number/not_found.xml +6 -0
- data/spec/fixtures/product_get_all/multiple.xml +15 -0
- data/spec/fixtures/product_get_all/single.xml +12 -0
- data/spec/fixtures/product_get_data/success.xml +37 -0
- data/spec/fixtures/product_get_data_array/multiple.xml +69 -0
- data/spec/spec_helper.rb +6 -9
- data/spec/support/factories.rb +14 -14
- metadata +54 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fa5df738699c252506f1f3acf8370d0e265687a6
|
4
|
+
data.tar.gz: c780fb9db1d1fbaf997f20c8a58eb35739be1c41
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
4
|
-
- 2.
|
5
|
-
-
|
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
|
7
|
-
gem
|
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
|
14
|
-
gem
|
14
|
+
gem "guard"
|
15
|
+
gem "guard-rspec"
|
15
16
|
end
|
data/Guardfile
CHANGED
@@ -1,6 +1,11 @@
|
|
1
|
-
guard
|
2
|
-
|
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$})
|
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://
|
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
|
-
|
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
|
1
|
+
require "bundler"
|
2
2
|
Bundler::GemHelper.install_tasks
|
3
3
|
|
4
|
-
require
|
4
|
+
require "rspec/core/rake_task"
|
5
5
|
RSpec::Core::RakeTask.new(:spec)
|
6
6
|
|
7
7
|
task :console do
|
8
|
-
require
|
9
|
-
require
|
10
|
-
require
|
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
|
data/lib/economic/account.rb
CHANGED
@@ -1,18 +1,18 @@
|
|
1
|
-
require
|
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(
|
8
|
+
Handle.build(:name => @name)
|
9
9
|
end
|
10
10
|
|
11
11
|
protected
|
12
12
|
|
13
13
|
def fields
|
14
14
|
[
|
15
|
-
["Handle", :handle,
|
15
|
+
["Handle", :handle, proc { |handle| handle.to_hash }, :required],
|
16
16
|
["Name", :name, nil, :required],
|
17
17
|
["Number", :number, nil, :required]
|
18
18
|
]
|
data/lib/economic/cash_book.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
|
-
require
|
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(
|
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,
|
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
|
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 =
|
56
|
+
to_hash = proc { |handle| handle.to_hash }
|
78
57
|
[
|
79
|
-
["Handle", :handle,
|
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
|
data/lib/economic/creditor.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
|
-
require
|
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 =
|
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(
|
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 =
|
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
|
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(
|
38
|
+
@handle || Handle.build(:id => @id)
|
40
39
|
end
|
41
40
|
|
42
41
|
protected
|
43
42
|
|
44
43
|
def fields
|
45
|
-
to_hash =
|
44
|
+
to_hash = proc { |handle| handle.to_hash }
|
46
45
|
# SOAP field, entity method, formatter proc, required?
|
47
46
|
[
|
48
|
-
["Handle", :handle,
|
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,
|
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
|
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
|
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
|
-
:
|
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
|
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(
|
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 =
|
159
|
-
|
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,
|
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
|
-
[
|
179
|
-
[
|
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
|
2
|
-
require
|
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 =
|
54
|
+
to_hash = proc { |h| h.to_hash }
|
64
55
|
[
|
65
|
-
["Number", :number,
|
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],
|