rconomic 0.5.2 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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
@@ -1,12 +1,10 @@
|
|
1
|
-
require
|
1
|
+
require "economic/proxies/entity_proxy"
|
2
2
|
|
3
3
|
module Economic
|
4
4
|
class EntryProxy < EntityProxy
|
5
5
|
def find_by_date_interval(from_date, to_date)
|
6
|
-
response = request(
|
7
|
-
|
8
|
-
'toDate' => to_date
|
9
|
-
})
|
6
|
+
response = request("FindByDateInterval", "fromDate" => from_date,
|
7
|
+
"toDate" => to_date)
|
10
8
|
|
11
9
|
build_array(response)
|
12
10
|
end
|
@@ -17,25 +15,21 @@ module Economic
|
|
17
15
|
# max_number = 2**31 - 1 # Maximum int32.
|
18
16
|
#
|
19
17
|
def find_by_serial_number_interval(min_number, max_number)
|
20
|
-
response = request(
|
21
|
-
|
22
|
-
'maxNumber' => max_number
|
23
|
-
})
|
18
|
+
response = request("FindBySerialNumberInterval", "minNumber" => min_number,
|
19
|
+
"maxNumber" => max_number)
|
24
20
|
|
25
21
|
build_array(response)
|
26
22
|
end
|
27
23
|
|
28
24
|
def get_last_used_serial_number
|
29
|
-
response = request(
|
25
|
+
response = request("GetLastUsedSerialNumber")
|
30
26
|
response.to_i
|
31
27
|
end
|
32
28
|
|
33
29
|
def find(serial_number)
|
34
|
-
response = request(
|
35
|
-
|
36
|
-
|
37
|
-
}
|
38
|
-
})
|
30
|
+
response = request("GetData", "entityHandle" => {
|
31
|
+
"SerialNumber" => serial_number
|
32
|
+
})
|
39
33
|
|
40
34
|
build(response)
|
41
35
|
end
|
@@ -47,7 +41,7 @@ module Economic
|
|
47
41
|
# [{:serial_number=>"1"}, {:serial_number=>"2"}] # Many results.
|
48
42
|
# {:serial_number=>"1"} # One result.
|
49
43
|
# nil # No results.
|
50
|
-
entry_handles = [
|
44
|
+
entry_handles = [response[:entry_handle]].flatten.compact
|
51
45
|
|
52
46
|
entry_handles.map do |entry_handle|
|
53
47
|
entry_handle[:serial_number].to_i
|
@@ -1,6 +1,6 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
1
|
+
require "economic/proxies/entity_proxy"
|
2
|
+
require "economic/proxies/actions/find_by_date_interval"
|
3
|
+
require "economic/proxies/actions/find_by_handle_with_number"
|
4
4
|
|
5
5
|
module Economic
|
6
6
|
class InvoiceProxy < EntityProxy
|
@@ -1,6 +1,6 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
1
|
+
require "economic/proxies/entity_proxy"
|
2
|
+
require "economic/proxies/actions/find_by_date_interval"
|
3
|
+
require "economic/proxies/actions/find_by_handle_with_number"
|
4
4
|
|
5
5
|
module Economic
|
6
6
|
class OrderProxy < EntityProxy
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require "economic/proxies/entity_proxy"
|
2
|
+
require "economic/proxies/actions/find_by_ci_number"
|
3
|
+
require "economic/proxies/actions/find_by_handle_with_number"
|
4
|
+
require "economic/proxies/actions/find_by_number"
|
5
|
+
|
6
|
+
module Economic
|
7
|
+
class ProductProxy < EntityProxy
|
8
|
+
include FindByHandleWithNumber
|
9
|
+
include FindByNumber
|
10
|
+
end
|
11
|
+
end
|
data/lib/economic/session.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "forwardable"
|
2
2
|
|
3
3
|
module Economic
|
4
4
|
# The Economic::Session contains details and behaviors for a current
|
@@ -8,45 +8,62 @@ module Economic
|
|
8
8
|
|
9
9
|
def_delegators :endpoint, :logger=, :log_level=, :log=
|
10
10
|
|
11
|
-
attr_accessor :agreement_number, :user_name, :password
|
12
|
-
attr_reader :
|
11
|
+
attr_accessor :agreement_number, :user_name, :password, :app_identifier
|
12
|
+
attr_reader :authentication_cookies
|
13
13
|
|
14
|
-
def initialize(agreement_number = nil, user_name = nil, password = nil)
|
14
|
+
def initialize(agreement_number = nil, user_name = nil, password = nil, app_identifier = nil)
|
15
15
|
self.agreement_number = agreement_number
|
16
16
|
self.user_name = user_name
|
17
17
|
self.password = password
|
18
|
+
self.app_identifier = app_identifier
|
18
19
|
yield endpoint if block_given?
|
19
20
|
end
|
20
21
|
|
22
|
+
# Connect/authenticate with an API token and app id
|
23
|
+
#
|
24
|
+
# Reference: http://techtalk.e-conomic.com/why-were-implementing-a-new-api-connection-model/
|
25
|
+
#
|
26
|
+
# ==== Attributes
|
27
|
+
#
|
28
|
+
# * +private_app_id+ - The App ID created in your developer agreement
|
29
|
+
# * +access_id+ - The Access ID or token for your App ID
|
30
|
+
#
|
21
31
|
def connect_with_token(private_app_id, access_id)
|
22
32
|
endpoint.call(
|
23
33
|
:connect_with_token,
|
24
|
-
|
25
|
-
|
26
|
-
:appToken => private_app_id
|
27
|
-
}
|
34
|
+
:token => access_id,
|
35
|
+
:appToken => private_app_id
|
28
36
|
) do |response|
|
29
|
-
|
37
|
+
store_authentication_cookies(response)
|
30
38
|
end
|
31
39
|
end
|
32
40
|
|
33
|
-
|
41
|
+
# Connect/authenticate with credentials
|
42
|
+
#
|
43
|
+
# ==== Attributes
|
44
|
+
#
|
45
|
+
# * +agreement_number+ - your economic agreement number
|
46
|
+
# * +user_name+ - your username
|
47
|
+
# * +password+ - your passsword
|
48
|
+
# * +app_identifier+ - A string identifiying your application, as described in http://techtalk.e-conomic.com/e-conomic-soap-api-now-requires-you-to-specify-a-custom-x-economicappidentifier-header/
|
49
|
+
#
|
50
|
+
def connect_with_credentials(agreement_number, user_name, password, app_identifier = nil)
|
51
|
+
self.app_identifier = app_identifier if app_identifier
|
52
|
+
|
34
53
|
endpoint.call(
|
35
54
|
:connect,
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
:password => password
|
40
|
-
}
|
55
|
+
:agreementNumber => agreement_number,
|
56
|
+
:userName => user_name,
|
57
|
+
:password => password
|
41
58
|
) do |response|
|
42
|
-
|
59
|
+
store_authentication_cookies(response)
|
43
60
|
end
|
44
61
|
end
|
45
62
|
|
46
63
|
# Authenticates with E-conomic using credentials
|
47
64
|
# Assumes ::new was called with credentials as arguments.
|
48
65
|
def connect
|
49
|
-
connect_with_credentials(
|
66
|
+
connect_with_credentials(agreement_number, user_name, password, app_identifier)
|
50
67
|
end
|
51
68
|
|
52
69
|
# Provides access to the DebtorContacts
|
@@ -104,9 +121,18 @@ module Economic
|
|
104
121
|
@entries ||= EntryProxy.new(self)
|
105
122
|
end
|
106
123
|
|
124
|
+
# Provides access to products
|
125
|
+
def products
|
126
|
+
@products ||= ProductProxy.new(self)
|
127
|
+
end
|
128
|
+
|
129
|
+
def company
|
130
|
+
@company ||= CompanyProxy.new(self)
|
131
|
+
end
|
132
|
+
|
107
133
|
# Requests an action from the API endpoint
|
108
134
|
def request(soap_action, data = nil)
|
109
|
-
endpoint.call(soap_action, data,
|
135
|
+
endpoint.call(soap_action, data, authentication_cookies)
|
110
136
|
end
|
111
137
|
|
112
138
|
# Returns self - used by proxies to access the session of their owner
|
@@ -116,13 +142,14 @@ module Economic
|
|
116
142
|
|
117
143
|
# Returns the SOAP endpoint to connect to
|
118
144
|
def endpoint
|
119
|
-
@endpoint ||= Economic::Endpoint.new
|
145
|
+
@endpoint ||= Economic::Endpoint.new(app_identifier)
|
120
146
|
end
|
121
147
|
|
122
148
|
private
|
123
149
|
|
124
|
-
def
|
125
|
-
|
150
|
+
def store_authentication_cookies(response)
|
151
|
+
cookies = response.http.cookies
|
152
|
+
@authentication_cookies = cookies
|
126
153
|
end
|
127
154
|
end
|
128
155
|
end
|
@@ -2,18 +2,18 @@ module Economic
|
|
2
2
|
module Support
|
3
3
|
module String
|
4
4
|
def self.camel_back(name)
|
5
|
-
name[0,1].downcase + name[1..-1]
|
5
|
+
name[0, 1].downcase + name[1..-1]
|
6
6
|
end
|
7
7
|
|
8
8
|
def self.demodulize(class_name_in_module)
|
9
|
-
class_name_in_module.to_s.gsub(/^.*::/,
|
9
|
+
class_name_in_module.to_s.gsub(/^.*::/, "")
|
10
10
|
end
|
11
11
|
|
12
12
|
def self.underscore(camel_cased_word)
|
13
13
|
word = camel_cased_word.to_s.dup
|
14
|
-
word.gsub!(/::/,
|
15
|
-
word.gsub!(/([A-Z]+)([A-Z][a-z])/,'\1_\2')
|
16
|
-
word.gsub!(/([a-z\d])([A-Z])/,'\1_\2')
|
14
|
+
word.gsub!(/::/, "/")
|
15
|
+
word.gsub!(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
|
16
|
+
word.gsub!(/([a-z\d])([A-Z])/, '\1_\2')
|
17
17
|
word.tr!("-", "_")
|
18
18
|
word.downcase!
|
19
19
|
word
|
data/lib/rconomic/version.rb
CHANGED
data/lib/rconomic.rb
CHANGED
@@ -1,41 +1,47 @@
|
|
1
1
|
# Dependencies
|
2
|
-
require
|
3
|
-
require
|
2
|
+
require "time"
|
3
|
+
require "savon"
|
4
|
+
require "savon_ext/request"
|
4
5
|
|
5
|
-
require
|
6
|
-
require
|
6
|
+
require "economic/support/string"
|
7
|
+
require "economic/session"
|
7
8
|
|
8
|
-
require
|
9
|
-
require
|
10
|
-
require
|
11
|
-
require
|
12
|
-
require
|
13
|
-
require
|
14
|
-
require
|
15
|
-
require
|
16
|
-
require
|
17
|
-
require
|
18
|
-
require
|
19
|
-
require
|
20
|
-
require
|
21
|
-
require
|
9
|
+
require "economic/debtor"
|
10
|
+
require "economic/debtor_contact"
|
11
|
+
require "economic/creditor"
|
12
|
+
require "economic/creditor_contact"
|
13
|
+
require "economic/current_invoice"
|
14
|
+
require "economic/current_invoice_line"
|
15
|
+
require "economic/invoice"
|
16
|
+
require "economic/order"
|
17
|
+
require "economic/cash_book"
|
18
|
+
require "economic/cash_book_entry"
|
19
|
+
require "economic/account"
|
20
|
+
require "economic/debtor_entry"
|
21
|
+
require "economic/creditor_entry"
|
22
|
+
require "economic/entry"
|
23
|
+
require "economic/product"
|
24
|
+
require "economic/company"
|
22
25
|
|
23
|
-
require
|
24
|
-
require
|
25
|
-
require
|
26
|
-
require
|
27
|
-
require
|
28
|
-
require
|
29
|
-
require
|
30
|
-
require
|
31
|
-
require
|
32
|
-
require
|
33
|
-
require
|
34
|
-
require
|
35
|
-
require
|
36
|
-
require
|
26
|
+
require "economic/proxies/current_invoice_proxy"
|
27
|
+
require "economic/proxies/current_invoice_line_proxy"
|
28
|
+
require "economic/proxies/debtor_proxy"
|
29
|
+
require "economic/proxies/debtor_contact_proxy"
|
30
|
+
require "economic/proxies/creditor_proxy"
|
31
|
+
require "economic/proxies/creditor_contact_proxy"
|
32
|
+
require "economic/proxies/invoice_proxy"
|
33
|
+
require "economic/proxies/order_proxy"
|
34
|
+
require "economic/proxies/cash_book_proxy"
|
35
|
+
require "economic/proxies/cash_book_entry_proxy"
|
36
|
+
require "economic/proxies/account_proxy"
|
37
|
+
require "economic/proxies/debtor_entry_proxy"
|
38
|
+
require "economic/proxies/creditor_entry_proxy"
|
39
|
+
require "economic/proxies/entry_proxy"
|
40
|
+
require "economic/proxies/product_proxy"
|
41
|
+
require "economic/proxies/company_proxy"
|
37
42
|
|
38
|
-
require
|
43
|
+
require "economic/proxies/actions/debtor_contact/all"
|
44
|
+
require "economic/proxies/actions/find_by_name"
|
39
45
|
|
40
46
|
# http://www.e-conomic.com/apidocs/Documentation/index.html
|
41
47
|
# https://www.e-conomic.com/secure/api1/EconomicWebService.asmx
|
@@ -46,4 +52,3 @@ require 'economic/proxies/actions/find_by_name'
|
|
46
52
|
|
47
53
|
module Economic
|
48
54
|
end
|
49
|
-
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Savon
|
4
|
+
class SOAPRequest < HTTPRequest
|
5
|
+
def build(options = {})
|
6
|
+
configure_proxy
|
7
|
+
configure_timeouts
|
8
|
+
configure_headers options[:soap_action]
|
9
|
+
configure_cookies options[:cookies]
|
10
|
+
configure_ssl
|
11
|
+
configure_auth
|
12
|
+
configure_redirect_handling
|
13
|
+
|
14
|
+
@http_request
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/rconomic.gemspec
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
|
3
|
-
require
|
2
|
+
$LOAD_PATH.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "rconomic/version"
|
4
4
|
|
5
5
|
Gem::Specification.new do |s|
|
6
|
-
s.name =
|
6
|
+
s.name = "rconomic"
|
7
7
|
s.summary = "Wrapper for e-conomic.dk's SOAP API."
|
8
8
|
s.description = <<-EOS
|
9
9
|
Ruby wrapper for the e-conomic SOAP API, that aims at making working with the API bearable.
|
@@ -11,15 +11,16 @@ Gem::Specification.new do |s|
|
|
11
11
|
E-conomic is a web-based accounting system. For their marketing speak, see http://www.e-conomic.co.uk/about/. More details about their API at http://www.e-conomic.co.uk/integration/integration-partner/.
|
12
12
|
EOS
|
13
13
|
s.authors = ["Jakob Skjerning"]
|
14
|
-
s.email =
|
15
|
-
s.homepage =
|
16
|
-
s.license =
|
14
|
+
s.email = "jakob@mentalized.net"
|
15
|
+
s.homepage = "https://github.com/substancelab/rconomic"
|
16
|
+
s.license = "MIT"
|
17
17
|
s.version = Rconomic::VERSION
|
18
18
|
s.platform = Gem::Platform::RUBY
|
19
19
|
|
20
20
|
s.add_runtime_dependency "savon", "~> 2.2"
|
21
|
+
s.add_development_dependency "rspec", "> 3.0"
|
21
22
|
|
22
|
-
s.files = `git ls-files`.split("\n").reject { |filename| [
|
23
|
+
s.files = `git ls-files`.split("\n").reject { |filename| [".gitignore"].include?(filename) }
|
23
24
|
s.test_files = `git ls-files -- {spec}/*`.split("\n")
|
24
25
|
s.require_paths = ["lib"]
|
25
26
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "./spec/spec_helper"
|
2
2
|
|
3
3
|
describe Economic::Account do
|
4
4
|
let(:session) { make_session }
|
@@ -9,8 +9,8 @@ describe Economic::Account do
|
|
9
9
|
end
|
10
10
|
|
11
11
|
describe "#save" do
|
12
|
-
it
|
13
|
-
stub_request(
|
12
|
+
it "should save it" do
|
13
|
+
stub_request("Account_CreateFromData", nil, :success)
|
14
14
|
subject.save
|
15
15
|
end
|
16
16
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "./spec/spec_helper"
|
2
2
|
|
3
3
|
describe Economic::CashBookEntry do
|
4
4
|
let(:session) { make_session }
|
@@ -19,8 +19,8 @@ describe Economic::CashBookEntry do
|
|
19
19
|
end
|
20
20
|
|
21
21
|
describe "#save" do
|
22
|
-
it
|
23
|
-
stub_request(
|
22
|
+
it "should save it" do
|
23
|
+
stub_request("CashBookEntry_CreateFromData", nil, :success)
|
24
24
|
subject.save
|
25
25
|
end
|
26
26
|
|
@@ -46,5 +46,28 @@ describe Economic::CashBookEntry do
|
|
46
46
|
)
|
47
47
|
subject.save
|
48
48
|
end
|
49
|
+
|
50
|
+
it "can build a CashBookEntry with a CreditorHandle" do
|
51
|
+
time = Time.now
|
52
|
+
subject.date = subject.start_date = time
|
53
|
+
subject.creditor_handle = Economic::Entity::Handle.new(:number => 12)
|
54
|
+
mock_request(
|
55
|
+
:cash_book_entry_create_from_data, {
|
56
|
+
"data" => {
|
57
|
+
"CreditorHandle" => {"Number" => 12},
|
58
|
+
"Date" => time,
|
59
|
+
"VoucherNumber" => 0,
|
60
|
+
"Text" => "",
|
61
|
+
"AmountDefaultCurrency" => 0,
|
62
|
+
"Amount" => 0,
|
63
|
+
"DueDate" => nil,
|
64
|
+
"StartDate" => time,
|
65
|
+
"EndDate" => nil
|
66
|
+
}
|
67
|
+
},
|
68
|
+
:success
|
69
|
+
)
|
70
|
+
subject.save
|
71
|
+
end
|
49
72
|
end
|
50
73
|
end
|
@@ -1,8 +1,8 @@
|
|
1
|
-
require
|
1
|
+
require "./spec/spec_helper"
|
2
2
|
|
3
3
|
describe Economic::CashBook do
|
4
4
|
let(:session) { make_session }
|
5
|
-
subject { (i = Economic::CashBook.new(
|
5
|
+
subject { (i = Economic::CashBook.new(:id => 512, :number => 32)).tap { i.session = session } }
|
6
6
|
|
7
7
|
it "inherits from Economic::Entity" do
|
8
8
|
expect(Economic::CashBook.superclass).to eq(Economic::Entity)
|
@@ -19,15 +19,15 @@ describe Economic::CashBook do
|
|
19
19
|
end
|
20
20
|
|
21
21
|
describe "#entries" do
|
22
|
-
it
|
22
|
+
it "should return a cash book entry proxy" do
|
23
23
|
expect(subject.entries).to be_a(Economic::CashBookEntryProxy)
|
24
24
|
expect(subject.entries.owner).to eq(subject)
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
28
|
describe "#book" do
|
29
|
-
it
|
30
|
-
mock_request("CashBook_Book", {
|
29
|
+
it "should book the cash book and return an invoice number" do
|
30
|
+
mock_request("CashBook_Book", {"cashBookHandle" => {"Number" => 32}}, :success)
|
31
31
|
expect(subject.book).to eq(832)
|
32
32
|
end
|
33
33
|
end
|
@@ -37,8 +37,8 @@ describe Economic::CashBook do
|
|
37
37
|
subject.persisted = true
|
38
38
|
end
|
39
39
|
|
40
|
-
it
|
41
|
-
stub_request(
|
40
|
+
it "should save it" do
|
41
|
+
stub_request("CashBook_UpdateFromData", nil, :success)
|
42
42
|
subject.save
|
43
43
|
end
|
44
44
|
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require "./spec/spec_helper"
|
2
|
+
|
3
|
+
describe Economic::Company do
|
4
|
+
let(:session) { make_session }
|
5
|
+
subject { Economic::Company.new(:session => session) }
|
6
|
+
|
7
|
+
it "inherits from Economic::Entity" do
|
8
|
+
expect(Economic::Company.ancestors).to include(Economic::Entity)
|
9
|
+
end
|
10
|
+
|
11
|
+
describe ".proxy" do
|
12
|
+
it "should return a CompanyProxy" do
|
13
|
+
expect(subject.proxy).to be_instance_of(Economic::CompanyProxy)
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should return a proxy owned by session" do
|
17
|
+
expect(subject.proxy.session).to eq(session)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "./spec/spec_helper"
|
2
2
|
|
3
3
|
describe Economic::CreditorContact do
|
4
4
|
let(:session) { make_session }
|
@@ -42,7 +42,7 @@ describe Economic::CreditorContact do
|
|
42
42
|
end
|
43
43
|
|
44
44
|
context "when creditor_handle is set" do
|
45
|
-
let(:handle) { Economic::CreditorContact::Handle.new(
|
45
|
+
let(:handle) { Economic::CreditorContact::Handle.new(:number => 42) }
|
46
46
|
|
47
47
|
before :each do
|
48
48
|
subject.creditor_handle = handle
|
@@ -83,8 +83,8 @@ describe Economic::CreditorContact do
|
|
83
83
|
end
|
84
84
|
|
85
85
|
it "should clear cached creditor and fetch the new creditor from API" do
|
86
|
-
stub_request(
|
87
|
-
subject.creditor_handle = Economic::Creditor::Handle.new(
|
86
|
+
stub_request("Creditor_GetData", nil, :success)
|
87
|
+
subject.creditor_handle = Economic::Creditor::Handle.new(:number => 1234)
|
88
88
|
expect(subject.creditor).to be_instance_of(Economic::Creditor)
|
89
89
|
end
|
90
90
|
end
|
@@ -111,5 +111,4 @@ describe Economic::CreditorContact do
|
|
111
111
|
expect(subject.proxy.session).to eq(session)
|
112
112
|
end
|
113
113
|
end
|
114
|
-
|
115
114
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require "./spec/spec_helper"
|
2
|
+
|
3
|
+
describe Economic::CreditorEntry do
|
4
|
+
let(:session) { make_session }
|
5
|
+
subject { Economic::CreditorEntry.new(:session => session) }
|
6
|
+
|
7
|
+
it "inherits from Economic::Entity" do
|
8
|
+
expect(subject).to be_a(Economic::Entity)
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "#proxy" do
|
12
|
+
it "should return a CreditorEntryProxy" do
|
13
|
+
expect(subject.proxy).to be_instance_of(Economic::CreditorEntryProxy)
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should return a proxy owned by session" do
|
17
|
+
expect(subject.proxy.session).to eq(session)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "./spec/spec_helper"
|
2
2
|
|
3
3
|
describe Economic::Creditor do
|
4
4
|
let(:session) { make_session }
|
@@ -50,8 +50,8 @@ describe Economic::Creditor do
|
|
50
50
|
end
|
51
51
|
|
52
52
|
describe "#save" do
|
53
|
-
it
|
54
|
-
stub_request(
|
53
|
+
it "should save it" do
|
54
|
+
stub_request("Creditor_CreateFromData", nil, :success)
|
55
55
|
subject.save
|
56
56
|
end
|
57
57
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "./spec/spec_helper"
|
2
2
|
|
3
3
|
describe Economic::CurrentInvoiceLine do
|
4
4
|
let(:session) { make_session }
|
@@ -17,8 +17,8 @@ describe Economic::CurrentInvoiceLine do
|
|
17
17
|
end
|
18
18
|
|
19
19
|
it "should not be equal when numbers are different" do
|
20
|
-
line1 = Economic::CurrentInvoiceLine.new(
|
21
|
-
line2 = Economic::CurrentInvoiceLine.new(
|
20
|
+
line1 = Economic::CurrentInvoiceLine.new(:number => 1)
|
21
|
+
line2 = Economic::CurrentInvoiceLine.new(:number => 2)
|
22
22
|
|
23
23
|
expect(line1).not_to eq(line2)
|
24
24
|
end
|