rconomic 0.3 → 0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +2 -1
- data/lib/economic/cash_book_entry.rb +42 -36
- data/lib/economic/creditor.rb +67 -0
- data/lib/economic/creditor_contact.rb +62 -0
- data/lib/economic/creditor_entry.rb +26 -0
- data/lib/economic/current_invoice.rb +30 -10
- data/lib/economic/current_invoice_line.rb +2 -0
- data/lib/economic/debtor_entry.rb +27 -0
- data/lib/economic/economic.wsdl +23134 -17255
- data/lib/economic/entity/handle.rb +1 -1
- data/lib/economic/entity.rb +8 -4
- data/lib/economic/entry.rb +26 -0
- data/lib/economic/proxies/cash_book_entry_proxy.rb +53 -15
- data/lib/economic/proxies/creditor_contact_proxy.rb +64 -0
- data/lib/economic/proxies/creditor_entry_proxy.rb +42 -0
- data/lib/economic/proxies/creditor_proxy.rb +73 -0
- data/lib/economic/proxies/current_invoice_proxy.rb +2 -1
- data/lib/economic/proxies/debtor_entry_proxy.rb +32 -0
- data/lib/economic/proxies/entity_proxy.rb +2 -2
- data/lib/economic/proxies/entry_proxy.rb +63 -0
- data/lib/economic/proxies/invoice_proxy.rb +2 -1
- data/lib/economic/session.rb +21 -4
- data/lib/economic/support/string.rb +5 -0
- data/lib/rconomic/version.rb +1 -1
- data/lib/rconomic.rb +10 -0
- data/rconomic.gemspec +6 -1
- data/spec/economic/creditor_contact_spec.rb +106 -0
- data/spec/economic/creditor_spec.rb +52 -0
- data/spec/economic/current_invoice_spec.rb +14 -0
- data/spec/economic/debtor_entry_spec.rb +20 -0
- data/spec/economic/debtor_spec.rb +12 -0
- data/spec/economic/entity/handle_spec.rb +21 -0
- data/spec/economic/entity_spec.rb +31 -0
- data/spec/economic/entry_spec.rb +20 -0
- data/spec/economic/proxies/cash_book_entry_proxy_spec.rb +35 -2
- data/spec/economic/proxies/creditor_contact_proxy_spec.rb +55 -0
- data/spec/economic/proxies/creditor_entry_proxy_spec.rb +49 -0
- data/spec/economic/proxies/creditor_proxy_spec.rb +81 -0
- data/spec/economic/proxies/current_invoice_line_proxy_spec.rb +1 -1
- data/spec/economic/proxies/current_invoice_proxy_spec.rb +3 -3
- data/spec/economic/proxies/debtor_entry_proxy_spec.rb +47 -0
- data/spec/economic/proxies/entry_proxy_spec.rb +73 -0
- data/spec/economic/proxies/invoice_proxy_spec.rb +3 -3
- data/spec/fixtures/cash_book_entry_create_creditor_invoice/success.xml +11 -0
- data/spec/fixtures/cash_book_entry_create_creditor_payment/success.xml +11 -0
- data/spec/fixtures/cash_book_entry_get_data/success.xml +4 -4
- data/spec/fixtures/cash_book_entry_set_due_date/success.xml +6 -0
- data/spec/fixtures/cash_book_get_all/multiple.xml +2 -2
- data/spec/fixtures/cash_book_get_entries/success.xml +4 -4
- data/spec/fixtures/creditor_contact_get_data/success.xml +22 -0
- data/spec/fixtures/creditor_entry_find_by_invoice_number/many.xml +15 -0
- data/spec/fixtures/creditor_entry_find_by_invoice_number/single.xml +12 -0
- data/spec/fixtures/creditor_entry_get_data/success.xml +32 -0
- data/spec/fixtures/creditor_entry_match_entries/success.xml +5 -0
- data/spec/fixtures/creditor_find_by_number/found.xml +10 -0
- data/spec/fixtures/creditor_find_by_number/not_found.xml +7 -0
- data/spec/fixtures/creditor_get_all/multiple.xml +15 -0
- data/spec/fixtures/creditor_get_all/single.xml +12 -0
- data/spec/fixtures/creditor_get_data/success.xml +49 -0
- data/spec/fixtures/creditor_get_data_array/multiple.xml +93 -0
- data/spec/fixtures/current_invoice_book_with_number/success.xml +10 -0
- data/spec/fixtures/current_invoice_get_data_array/multiple.xml +4 -4
- data/spec/fixtures/debtor_entry_find_by_invoice_number/many.xml +15 -0
- data/spec/fixtures/debtor_entry_find_by_invoice_number/single.xml +12 -0
- data/spec/fixtures/debtor_entry_match_entries/success.xml +6 -0
- data/spec/fixtures/debtor_get_data_array/multiple.xml +4 -4
- data/spec/fixtures/entry_find_by_date_interval/many.xml +15 -0
- data/spec/fixtures/entry_find_by_date_interval/none.xml +9 -0
- data/spec/fixtures/entry_find_by_date_interval/single.xml +12 -0
- data/spec/fixtures/entry_find_by_serial_number_interval/many.xml +15 -0
- data/spec/fixtures/entry_find_by_serial_number_interval/none.xml +9 -0
- data/spec/fixtures/entry_find_by_serial_number_interval/single.xml +12 -0
- data/spec/fixtures/entry_get_data/success.xml +40 -0
- data/spec/fixtures/entry_get_last_used_serial_number/success.xml +8 -0
- data/spec/spec_helper.rb +22 -2
- metadata +68 -11
- data/Gemfile.lock +0 -61
- data/spec/fixtures/wsdl.xml +0 -56596
@@ -28,7 +28,7 @@ class Economic::Entity
|
|
28
28
|
def ==(other)
|
29
29
|
return false if other.nil?
|
30
30
|
return false unless other.respond_to?(:id) && other.respond_to?(:number)
|
31
|
-
self.id == other.id && self.number == other.number
|
31
|
+
self.id == other.id && self.number == other.number && self.id1 == other.id1 && self.id2 == other.id2
|
32
32
|
end
|
33
33
|
|
34
34
|
private
|
data/lib/economic/entity.rb
CHANGED
@@ -71,10 +71,6 @@ module Economic
|
|
71
71
|
@partial = true
|
72
72
|
end
|
73
73
|
|
74
|
-
def initialize_defaults
|
75
|
-
nil
|
76
|
-
end
|
77
|
-
|
78
74
|
# Updates Entity with its data from the API
|
79
75
|
def get_data
|
80
76
|
response = proxy.get_data(handle)
|
@@ -144,6 +140,11 @@ module Economic
|
|
144
140
|
end
|
145
141
|
end
|
146
142
|
|
143
|
+
def ==(other)
|
144
|
+
return false if other.nil?
|
145
|
+
self.handle == other.handle && other.is_a?(self.class)
|
146
|
+
end
|
147
|
+
|
147
148
|
protected
|
148
149
|
|
149
150
|
def create_or_update
|
@@ -199,6 +200,9 @@ module Economic
|
|
199
200
|
name[0,1].downcase + name[1..-1]
|
200
201
|
end
|
201
202
|
|
203
|
+
def initialize_defaults
|
204
|
+
nil
|
205
|
+
end
|
202
206
|
end
|
203
207
|
|
204
208
|
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'economic/entity'
|
2
|
+
|
3
|
+
module Economic
|
4
|
+
|
5
|
+
# Represents an entry in E-conomic.
|
6
|
+
#
|
7
|
+
# API documentation: http://www.e-conomic.com/apidocs/Documentation/T_Economic_Api_IEntry.html
|
8
|
+
|
9
|
+
class Entry < Entity
|
10
|
+
has_properties :handle,
|
11
|
+
:serial_number,
|
12
|
+
:account_handle,
|
13
|
+
:amount,
|
14
|
+
:amount_default_currency,
|
15
|
+
:currency_handle,
|
16
|
+
:date,
|
17
|
+
:text,
|
18
|
+
:type,
|
19
|
+
:department_handle,
|
20
|
+
:distribution_key_handle,
|
21
|
+
:vat_account_handle,
|
22
|
+
:voucher_number,
|
23
|
+
:project_handle,
|
24
|
+
:document_handle
|
25
|
+
end
|
26
|
+
end
|
@@ -6,6 +6,7 @@ module Economic
|
|
6
6
|
entity_hash = session.request(CashBookProxy.entity_class.soap_action(:get_entries)) do
|
7
7
|
soap.body = { "cashBookHandle" => owner.handle.to_hash }
|
8
8
|
end
|
9
|
+
|
9
10
|
if entity_hash != {}
|
10
11
|
[ entity_hash.values.first ].flatten.each do |id_hash|
|
11
12
|
find(id_hash)
|
@@ -21,15 +22,7 @@ module Economic
|
|
21
22
|
# :contra_account_handle => { :number => 1011 }
|
22
23
|
# )
|
23
24
|
def create_finance_voucher(handles)
|
24
|
-
|
25
|
-
soap.body = {
|
26
|
-
'cashBookHandle' => { 'Number' => owner.handle[:number] },
|
27
|
-
'accountHandle' => { 'Number' => handles[:account_handle][:number] },
|
28
|
-
'contraAccountHandle' => { 'Number' => handles[:contra_account_handle][:number] }
|
29
|
-
}
|
30
|
-
end
|
31
|
-
|
32
|
-
find(response)
|
25
|
+
create_cash_book_entry_for_handles(handles, 'CreateFinanceVoucher')
|
33
26
|
end
|
34
27
|
|
35
28
|
# Creates a debtor payment and returns the cash book entry.
|
@@ -39,15 +32,60 @@ module Economic
|
|
39
32
|
# :contra_account_handle => { :number => 1510 }
|
40
33
|
# )
|
41
34
|
def create_debtor_payment(handles)
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
35
|
+
create_cash_book_entry_for_handles(handles, 'CreateDebtorPayment')
|
36
|
+
end
|
37
|
+
|
38
|
+
# Creates a creditor payment and returns the cash book entry.
|
39
|
+
# Example:
|
40
|
+
# cash_book.entries.create_creditor_payment(
|
41
|
+
# :creditor_handle => { :number => 1 },
|
42
|
+
# :contra_account_handle => { :number => 1510 }
|
43
|
+
# )
|
44
|
+
def create_creditor_payment(handles)
|
45
|
+
create_cash_book_entry_for_handles(handles, 'CreateCreditorPayment')
|
46
|
+
end
|
47
|
+
|
48
|
+
# Creates a creditor invoice and returns the cash book entry.
|
49
|
+
# Example:
|
50
|
+
# cash_book.entries.create_creditor_invoice(
|
51
|
+
# :creditor_handle => { :number => 1 },
|
52
|
+
# :contra_account_handle => { :number => 1510 }
|
53
|
+
# )
|
54
|
+
def create_creditor_invoice(handles)
|
55
|
+
create_cash_book_entry_for_handles(handles, 'CreateCreditorInvoice')
|
56
|
+
end
|
57
|
+
|
58
|
+
def set_due_date(id, date)
|
59
|
+
session.request(entity_class.soap_action("SetDueDate")) do
|
60
|
+
soap.body = { 'cashBookEntryHandle' => { 'Id1' => owner.handle[:number], 'Id2' => id }, :value => date }
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
protected
|
65
|
+
|
66
|
+
def create_cash_book_entry_for_handles(handles, action, foobar = nil)
|
67
|
+
handle_name = handle_name_for_action(action)
|
68
|
+
handle_key = Economic::Support::String.underscore(handle_name).intern
|
69
|
+
|
70
|
+
response = session.request(entity_class.soap_action(action)) do
|
71
|
+
data = ActiveSupport::OrderedHash.new
|
72
|
+
data["cashBookHandle"] = { 'Number' => owner.handle[:number] }
|
73
|
+
data[handle_name] = { 'Number' => handles[handle_key][:number] } if handles[handle_key]
|
74
|
+
data["contraAccountHandle"] = { 'Number' => handles[:contra_account_handle][:number] } if handles[:contra_account_handle]
|
75
|
+
soap.body = data
|
48
76
|
end
|
49
77
|
|
50
78
|
find(response)
|
51
79
|
end
|
80
|
+
|
81
|
+
def handle_name_for_action(action_name)
|
82
|
+
{
|
83
|
+
'CreateFinanceVoucher' => 'accountHandle',
|
84
|
+
'CreateDebtorPayment' => 'debtorHandle',
|
85
|
+
'CreateCreditorInvoice' => 'creditorHandle',
|
86
|
+
'CreateCreditorPayment' => 'creditorHandle'
|
87
|
+
}[action_name]
|
88
|
+
end
|
89
|
+
|
52
90
|
end
|
53
91
|
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'economic/proxies/entity_proxy'
|
2
|
+
|
3
|
+
module Economic
|
4
|
+
class CreditorContactProxy < EntityProxy
|
5
|
+
|
6
|
+
# Returns a new, unpersisted Economic::CreditorContact
|
7
|
+
def build(properties = {})
|
8
|
+
contact = super
|
9
|
+
initialize_properties_with_values_from_owner(contact) if owner.is_a?(Creditor)
|
10
|
+
contact
|
11
|
+
end
|
12
|
+
|
13
|
+
# Gets data for CreditorContact from the API
|
14
|
+
def find(handle)
|
15
|
+
handle = Entity::Handle.new(:id => handle) unless handle.is_a?(Entity::Handle)
|
16
|
+
super(handle)
|
17
|
+
end
|
18
|
+
|
19
|
+
# Returns CreditorContact that have the given name. The objects will only be partially loaded
|
20
|
+
def find_by_name(name)
|
21
|
+
# Get a list of CreditorContactHandles from e-conomic
|
22
|
+
response = session.request entity_class.soap_action('FindByName') do
|
23
|
+
soap.body = {
|
24
|
+
'name' => name
|
25
|
+
}
|
26
|
+
end
|
27
|
+
|
28
|
+
# Make sure we always have an array of handles even if the result only contains one
|
29
|
+
handles = [response[:creditor_contact_handle]].flatten.reject(&:blank?)
|
30
|
+
|
31
|
+
# Create partial CreditorContact entities
|
32
|
+
contacts = handles.collect do |handle|
|
33
|
+
creditor_contact = build
|
34
|
+
creditor_contact.partial = true
|
35
|
+
creditor_contact.persisted = true
|
36
|
+
creditor_contact.handle = handle
|
37
|
+
creditor_contact.id = handle[:id]
|
38
|
+
creditor_contact.number = handle[:number]
|
39
|
+
creditor_contact
|
40
|
+
end
|
41
|
+
|
42
|
+
if owner.is_a?(Creditor)
|
43
|
+
# Scope to the owner
|
44
|
+
contacts.select do |creditor_contact|
|
45
|
+
creditor_contact.get_data
|
46
|
+
creditor_contact.creditor.handle == owner.handle
|
47
|
+
end
|
48
|
+
else
|
49
|
+
contacts
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
|
55
|
+
private
|
56
|
+
|
57
|
+
# Initialize properties in contact with values from owner. Returns contact.
|
58
|
+
def initialize_properties_with_values_from_owner(contact)
|
59
|
+
contact.creditor = owner
|
60
|
+
contact
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'economic/proxies/entity_proxy'
|
2
|
+
|
3
|
+
module Economic
|
4
|
+
class CreditorEntryProxy < EntityProxy
|
5
|
+
def find_by_invoice_number(invoice_number)
|
6
|
+
response = session.request(entity_class.soap_action('FindByInvoiceNumber')) do
|
7
|
+
soap.body = {
|
8
|
+
'invoiceNumber' => invoice_number
|
9
|
+
}
|
10
|
+
end
|
11
|
+
|
12
|
+
response[:creditor_entry_handle].map do |creditor_entry_handle|
|
13
|
+
# Kinda ugly, but we get an array instead of a hash when there's only one result. :)
|
14
|
+
Hash[*creditor_entry_handle.to_a.flatten][:serial_number].to_i
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def find(serial_number)
|
19
|
+
response = session.request(entity_class.soap_action('GetData')) do
|
20
|
+
soap.body = {
|
21
|
+
'entityHandle' => {
|
22
|
+
'SerialNumber' => serial_number
|
23
|
+
}
|
24
|
+
}
|
25
|
+
end
|
26
|
+
|
27
|
+
build(response)
|
28
|
+
end
|
29
|
+
|
30
|
+
def match(*serial_numbers)
|
31
|
+
response = session.request(entity_class.soap_action('MatchEntries')) do
|
32
|
+
soap.body = {
|
33
|
+
:entries => {
|
34
|
+
"CreditorEntryHandle" => serial_numbers.map { |serial_number|
|
35
|
+
{ "SerialNumber" => serial_number }
|
36
|
+
}
|
37
|
+
}
|
38
|
+
}
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
require 'economic/proxies/entity_proxy'
|
2
|
+
|
3
|
+
module Economic
|
4
|
+
class CreditorProxy < EntityProxy
|
5
|
+
|
6
|
+
# Fetches Creditor from API
|
7
|
+
def find(handle)
|
8
|
+
handle = if handle.respond_to?(:to_i)
|
9
|
+
Entity::Handle.new(:number => handle.to_i)
|
10
|
+
else
|
11
|
+
Entity::Handle.new(handle)
|
12
|
+
end
|
13
|
+
super(handle)
|
14
|
+
end
|
15
|
+
|
16
|
+
# Returns Creditors that have the given ci_number. The Creditor objects will only be partially loaded
|
17
|
+
def find_by_ci_number(ci_number)
|
18
|
+
# Get a list of CreditorHandles from e-conomic
|
19
|
+
response = session.request(entity_class.soap_action('FindByCINumber')) do
|
20
|
+
soap.body = {
|
21
|
+
'ciNumber' => ci_number
|
22
|
+
}
|
23
|
+
end
|
24
|
+
|
25
|
+
# Make sure we always have an array of handles even if the result only contains one
|
26
|
+
handles = [response[:creditor_handle]].flatten.reject(&:blank?)
|
27
|
+
|
28
|
+
# Create partial Creditor entities
|
29
|
+
handles.collect do |handle|
|
30
|
+
creditor = build
|
31
|
+
creditor.partial = true
|
32
|
+
creditor.persisted = true
|
33
|
+
creditor.handle = handle
|
34
|
+
creditor.number = handle[:number]
|
35
|
+
creditor
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
# Returns handle with a given number.
|
40
|
+
def find_by_number(number)
|
41
|
+
response = session.request(entity_class.soap_action('FindByNumber')) do
|
42
|
+
soap.body = {
|
43
|
+
'number' => number
|
44
|
+
}
|
45
|
+
end
|
46
|
+
|
47
|
+
if response == {}
|
48
|
+
nil
|
49
|
+
else
|
50
|
+
creditor = build
|
51
|
+
creditor.partial = true
|
52
|
+
creditor.persisted = true
|
53
|
+
creditor.handle = response
|
54
|
+
creditor.number = response[:number].to_i
|
55
|
+
creditor
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def create_simple(opts)
|
60
|
+
response = session.request(entity_class.soap_action('Create')) do
|
61
|
+
soap.body = {
|
62
|
+
'number' => opts[:number],
|
63
|
+
'creditorGroupHandle' => { 'Number' => opts[:creditor_group_handle][:number] },
|
64
|
+
:name => opts[:name],
|
65
|
+
:vatZone => opts[:vat_zone]
|
66
|
+
}
|
67
|
+
end
|
68
|
+
|
69
|
+
find(response)
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'economic/proxies/entity_proxy'
|
2
|
+
|
3
|
+
module Economic
|
4
|
+
class DebtorEntryProxy < EntityProxy
|
5
|
+
def find_by_invoice_number(from, to = from)
|
6
|
+
response = session.request(entity_class.soap_action('FindByInvoiceNumber')) do
|
7
|
+
soap.body = {
|
8
|
+
'from' => from,
|
9
|
+
'to' => to,
|
10
|
+
:order! => [ 'from', 'to' ]
|
11
|
+
}
|
12
|
+
end
|
13
|
+
|
14
|
+
response[:debtor_entry_handle].map do |debtor_entry_handle|
|
15
|
+
# Kinda ugly, but we get an array instead of a hash when there's only one result. :)
|
16
|
+
Hash[*debtor_entry_handle.to_a.flatten][:serial_number].to_i
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def match(*serial_numbers)
|
21
|
+
response = session.request(entity_class.soap_action('MatchEntries')) do
|
22
|
+
soap.body = {
|
23
|
+
:entries => {
|
24
|
+
"DebtorEntryHandle" => serial_numbers.map { |serial_number|
|
25
|
+
{ "SerialNumber" => serial_number }
|
26
|
+
}
|
27
|
+
}
|
28
|
+
}
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -48,7 +48,7 @@ module Economic
|
|
48
48
|
self
|
49
49
|
end
|
50
50
|
|
51
|
-
# Returns a new, unpersisted Economic::Entity
|
51
|
+
# Returns a new, unpersisted Economic::Entity that has been added to Proxy
|
52
52
|
def build(properties = {})
|
53
53
|
entity = self.class.entity_class.new(:session => session)
|
54
54
|
|
@@ -65,7 +65,7 @@ module Economic
|
|
65
65
|
self.class.entity_class
|
66
66
|
end
|
67
67
|
|
68
|
-
# Fetches Entity data from API and returns an Entity initialized with that data
|
68
|
+
# Fetches Entity data from API and returns an Entity initialized with that data added to Proxy
|
69
69
|
def find(handle)
|
70
70
|
handle = Entity::Handle.new(handle) unless handle.is_a?(Entity::Handle)
|
71
71
|
entity_hash = get_data(handle)
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'economic/proxies/entity_proxy'
|
2
|
+
|
3
|
+
module Economic
|
4
|
+
class EntryProxy < EntityProxy
|
5
|
+
def find_by_date_interval(from_date, to_date)
|
6
|
+
response = session.request(entity_class.soap_action('FindByDateInterval')) do
|
7
|
+
soap.body = {
|
8
|
+
'fromDate' => from_date,
|
9
|
+
'toDate' => to_date
|
10
|
+
}
|
11
|
+
end
|
12
|
+
|
13
|
+
build_array(response)
|
14
|
+
end
|
15
|
+
|
16
|
+
# Undocumented tip: if you only care about the min_number, pass in the maximum
|
17
|
+
# possible value as max_number so you don't have to call `get_last_used_serial_number`:
|
18
|
+
#
|
19
|
+
# max_number = 2**31 - 1 # Maximum int32.
|
20
|
+
#
|
21
|
+
def find_by_serial_number_interval(min_number, max_number)
|
22
|
+
response = session.request(entity_class.soap_action('FindBySerialNumberInterval')) do
|
23
|
+
soap.body = {
|
24
|
+
'minNumber' => min_number,
|
25
|
+
'maxNumber' => max_number
|
26
|
+
}
|
27
|
+
end
|
28
|
+
|
29
|
+
build_array(response)
|
30
|
+
end
|
31
|
+
|
32
|
+
def get_last_used_serial_number
|
33
|
+
response = session.request(entity_class.soap_action('GetLastUsedSerialNumber'))
|
34
|
+
response.to_i
|
35
|
+
end
|
36
|
+
|
37
|
+
def find(serial_number)
|
38
|
+
response = session.request(entity_class.soap_action('GetData')) do
|
39
|
+
soap.body = {
|
40
|
+
'entityHandle' => {
|
41
|
+
'SerialNumber' => serial_number
|
42
|
+
}
|
43
|
+
}
|
44
|
+
end
|
45
|
+
|
46
|
+
build(response)
|
47
|
+
end
|
48
|
+
|
49
|
+
private
|
50
|
+
|
51
|
+
def build_array(response)
|
52
|
+
# The response[:entry_handle] format may be any of
|
53
|
+
# [{:serial_number=>"1"}, {:serial_number=>"2"}] # Many results.
|
54
|
+
# {:serial_number=>"1"} # One result.
|
55
|
+
# nil # No results.
|
56
|
+
entry_handles = [ response[:entry_handle] ].flatten.compact
|
57
|
+
|
58
|
+
entry_handles.map do |entry_handle|
|
59
|
+
entry_handle[:serial_number].to_i
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
data/lib/economic/session.rb
CHANGED
@@ -37,7 +37,7 @@ module Economic
|
|
37
37
|
def current_invoices
|
38
38
|
@current_invoices ||= CurrentInvoiceProxy.new(self)
|
39
39
|
end
|
40
|
-
|
40
|
+
|
41
41
|
# Provides access to the invoices
|
42
42
|
def invoices
|
43
43
|
@invoices ||= InvoiceProxy.new(self)
|
@@ -47,19 +47,36 @@ module Economic
|
|
47
47
|
def debtors
|
48
48
|
@debtors ||= DebtorProxy.new(self)
|
49
49
|
end
|
50
|
-
|
50
|
+
|
51
|
+
# Provides access to creditors
|
52
|
+
def creditors
|
53
|
+
@creditors ||= CreditorProxy.new(self)
|
54
|
+
end
|
55
|
+
|
51
56
|
def cash_books
|
52
57
|
@cash_books ||= CashBookProxy.new(self)
|
53
58
|
end
|
54
|
-
|
59
|
+
|
55
60
|
def cash_book_entries
|
56
61
|
@cash_book_entries ||= CashBookEntryProxy.new(self)
|
57
62
|
end
|
58
|
-
|
63
|
+
|
59
64
|
def accounts
|
60
65
|
@accounts ||= AccountProxy.new(self)
|
61
66
|
end
|
62
67
|
|
68
|
+
def debtor_entries
|
69
|
+
@debtor_entries ||= DebtorEntryProxy.new(self)
|
70
|
+
end
|
71
|
+
|
72
|
+
def creditor_entries
|
73
|
+
@creditor_entries ||= CreditorEntryProxy.new(self)
|
74
|
+
end
|
75
|
+
|
76
|
+
def entries
|
77
|
+
@entries ||= EntryProxy.new(self)
|
78
|
+
end
|
79
|
+
|
63
80
|
def request(action, &block)
|
64
81
|
response = client.request :economic, action, &block
|
65
82
|
response_hash = response.to_hash
|
data/lib/rconomic/version.rb
CHANGED
data/lib/rconomic.rb
CHANGED
@@ -8,21 +8,31 @@ require 'economic/session'
|
|
8
8
|
|
9
9
|
require 'economic/debtor'
|
10
10
|
require 'economic/debtor_contact'
|
11
|
+
require 'economic/creditor'
|
12
|
+
require 'economic/creditor_contact'
|
11
13
|
require 'economic/current_invoice'
|
12
14
|
require 'economic/current_invoice_line'
|
13
15
|
require 'economic/invoice'
|
14
16
|
require 'economic/cash_book'
|
15
17
|
require 'economic/cash_book_entry'
|
16
18
|
require 'economic/account'
|
19
|
+
require 'economic/debtor_entry'
|
20
|
+
require 'economic/creditor_entry'
|
21
|
+
require 'economic/entry'
|
17
22
|
|
18
23
|
require 'economic/proxies/current_invoice_proxy'
|
19
24
|
require 'economic/proxies/current_invoice_line_proxy'
|
20
25
|
require 'economic/proxies/debtor_proxy'
|
21
26
|
require 'economic/proxies/debtor_contact_proxy'
|
27
|
+
require 'economic/proxies/creditor_proxy'
|
28
|
+
require 'economic/proxies/creditor_contact_proxy'
|
22
29
|
require 'economic/proxies/invoice_proxy'
|
23
30
|
require 'economic/proxies/cash_book_proxy'
|
24
31
|
require 'economic/proxies/cash_book_entry_proxy'
|
25
32
|
require 'economic/proxies/account_proxy'
|
33
|
+
require 'economic/proxies/debtor_entry_proxy'
|
34
|
+
require 'economic/proxies/creditor_entry_proxy'
|
35
|
+
require 'economic/proxies/entry_proxy'
|
26
36
|
|
27
37
|
# http://www.e-conomic.com/apidocs/Documentation/index.html
|
28
38
|
# https://www.e-conomic.com/secure/api1/EconomicWebService.asmx
|
data/rconomic.gemspec
CHANGED
@@ -17,10 +17,15 @@ Gem::Specification.new do |s|
|
|
17
17
|
s.version = Rconomic::VERSION
|
18
18
|
s.platform = Gem::Platform::RUBY
|
19
19
|
|
20
|
+
# As long as we use Savon 0.9.5, we need to tie down the max version
|
21
|
+
# of gyoku as 0.4.5 is not backwards compatible. If we update Savon,
|
22
|
+
# we should remove the gyoku constraint.
|
20
23
|
s.add_runtime_dependency "savon", "0.9.5"
|
24
|
+
s.add_runtime_dependency "gyoku", "0.4.4"
|
25
|
+
|
21
26
|
s.add_runtime_dependency "activesupport", "~> 3.0"
|
22
27
|
|
23
28
|
s.files = `git ls-files`.split("\n").reject { |filename| ['.gitignore'].include?(filename) }
|
24
29
|
s.test_files = `git ls-files -- {spec}/*`.split("\n")
|
25
30
|
s.require_paths = ["lib"]
|
26
|
-
end
|
31
|
+
end
|