rconomic 0.4 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.travis.yml +1 -2
- data/Gemfile +1 -1
- data/README.md +1 -1
- data/lib/economic/account.rb +2 -2
- data/lib/economic/cash_book.rb +1 -1
- data/lib/economic/cash_book_entry.rb +33 -36
- data/lib/economic/creditor.rb +2 -2
- data/lib/economic/creditor_contact.rb +3 -3
- data/lib/economic/current_invoice.rb +26 -25
- data/lib/economic/current_invoice_line.rb +17 -17
- data/lib/economic/debtor.rb +3 -3
- data/lib/economic/debtor_contact.rb +4 -4
- data/lib/economic/debtor_entry.rb +1 -2
- data/lib/economic/entity/handle.rb +30 -8
- data/lib/economic/entity.rb +23 -3
- data/lib/economic/entry.rb +1 -2
- data/lib/economic/invoice.rb +2 -2
- data/lib/economic/proxies/actions/find_by_ci_number.rb +25 -0
- data/lib/economic/proxies/actions/find_by_date_interval.rb +27 -0
- data/lib/economic/proxies/actions/find_by_handle_with_number.rb +12 -0
- data/lib/economic/proxies/actions/find_by_number.rb +21 -0
- data/lib/economic/proxies/creditor_contact_proxy.rb +1 -1
- data/lib/economic/proxies/creditor_proxy.rb +6 -53
- data/lib/economic/proxies/current_invoice_line_proxy.rb +1 -1
- data/lib/economic/proxies/current_invoice_proxy.rb +2 -17
- data/lib/economic/proxies/debtor_contact_proxy.rb +2 -2
- data/lib/economic/proxies/debtor_proxy.rb +6 -53
- data/lib/economic/proxies/entity_proxy.rb +27 -11
- data/lib/economic/proxies/invoice_proxy.rb +4 -26
- data/lib/rconomic/version.rb +1 -1
- data/spec/economic/cash_book_entry_spec.rb +8 -0
- data/spec/economic/current_invoice_line_spec.rb +27 -0
- data/spec/economic/current_invoice_spec.rb +24 -1
- data/spec/economic/entity/handle_spec.rb +53 -3
- data/spec/economic/entity_spec.rb +41 -13
- data/spec/economic/proxies/cash_book_entry_proxy_spec.rb +0 -7
- data/spec/economic/proxies/current_invoice_proxy_spec.rb +4 -9
- data/spec/economic/proxies/debtor_proxy_spec.rb +1 -1
- data/spec/economic/proxies/invoice_proxy_spec.rb +4 -9
- data/spec/fixtures/invoice_get_data_array/multiple.xml +143 -0
- data/spec/fixtures/invoice_get_data_array/single.xml +75 -0
- metadata +64 -80
@@ -1,60 +1,13 @@
|
|
1
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'
|
2
5
|
|
3
6
|
module Economic
|
4
7
|
class CreditorProxy < EntityProxy
|
5
|
-
|
6
|
-
|
7
|
-
|
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
|
8
|
+
include FindByCiNumber
|
9
|
+
include FindByHandleWithNumber
|
10
|
+
include FindByNumber
|
58
11
|
|
59
12
|
def create_simple(opts)
|
60
13
|
response = session.request(entity_class.soap_action('Create')) do
|
@@ -11,7 +11,7 @@ module Economic
|
|
11
11
|
|
12
12
|
# Gets data for CurrentInvoiceLine from the API
|
13
13
|
def find(handle)
|
14
|
-
handle = Entity::Handle.
|
14
|
+
handle = Entity::Handle.build(:number => handle) unless handle.is_a?(Entity::Handle)
|
15
15
|
super(handle)
|
16
16
|
end
|
17
17
|
|
@@ -1,7 +1,9 @@
|
|
1
1
|
require 'economic/proxies/entity_proxy'
|
2
|
+
require 'economic/proxies/actions/find_by_date_interval'
|
2
3
|
|
3
4
|
module Economic
|
4
5
|
class CurrentInvoiceProxy < EntityProxy
|
6
|
+
include FindByDateInterval
|
5
7
|
|
6
8
|
# Returns a new, unpersisted Economic::CurrentInvoice
|
7
9
|
def build(properties = {})
|
@@ -10,23 +12,6 @@ module Economic
|
|
10
12
|
invoice
|
11
13
|
end
|
12
14
|
|
13
|
-
# Returns Economic::CurrentInvoice object for a given interval of days.
|
14
|
-
def find_by_date_interval(from, unto)
|
15
|
-
response = session.request entity_class.soap_action("FindByDateInterval") do
|
16
|
-
soap.body = {
|
17
|
-
'first' => from.iso8601,
|
18
|
-
'last' => unto.iso8601,
|
19
|
-
:order! => ['first', 'last']
|
20
|
-
}
|
21
|
-
end
|
22
|
-
|
23
|
-
handles = [ response[:current_invoice_handle] ].flatten.reject(&:blank?)
|
24
|
-
|
25
|
-
handles.collect do |handle|
|
26
|
-
find(handle[:id])
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
15
|
private
|
31
16
|
|
32
17
|
# Initialize properties in invoice with values from owner
|
@@ -12,7 +12,7 @@ module Economic
|
|
12
12
|
|
13
13
|
# Gets data for DebtorContact from the API
|
14
14
|
def find(handle)
|
15
|
-
handle = Entity::Handle.
|
15
|
+
handle = Entity::Handle.build(:id => handle) unless handle.is_a?(Entity::Handle)
|
16
16
|
super(handle)
|
17
17
|
end
|
18
18
|
|
@@ -61,4 +61,4 @@ module Economic
|
|
61
61
|
end
|
62
62
|
|
63
63
|
end
|
64
|
-
end
|
64
|
+
end
|
@@ -1,60 +1,13 @@
|
|
1
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'
|
2
5
|
|
3
6
|
module Economic
|
4
7
|
class DebtorProxy < EntityProxy
|
5
|
-
|
6
|
-
|
7
|
-
|
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 Debtors that have the given ci_number. The Debtor objects will only be partially loaded
|
17
|
-
def find_by_ci_number(ci_number)
|
18
|
-
# Get a list of DebtorHandles 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[:debtor_handle]].flatten.reject(&:blank?)
|
27
|
-
|
28
|
-
# Create partial Debtor entities
|
29
|
-
handles.collect do |handle|
|
30
|
-
debtor = build
|
31
|
-
debtor.partial = true
|
32
|
-
debtor.persisted = true
|
33
|
-
debtor.handle = handle
|
34
|
-
debtor.number = handle[:number]
|
35
|
-
debtor
|
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
|
-
debtor = build
|
51
|
-
debtor.partial = true
|
52
|
-
debtor.persisted = true
|
53
|
-
debtor.handle = response
|
54
|
-
debtor.number = response[:number].to_i
|
55
|
-
debtor
|
56
|
-
end
|
57
|
-
end
|
8
|
+
include FindByCiNumber
|
9
|
+
include FindByHandleWithNumber
|
10
|
+
include FindByNumber
|
58
11
|
|
59
12
|
# Returns the next available debtor number
|
60
13
|
def next_available_number
|
@@ -3,9 +3,12 @@ module Economic
|
|
3
3
|
class << self
|
4
4
|
# Returns the class this Proxy is a proxy for
|
5
5
|
def entity_class
|
6
|
+
Economic.const_get(self.entity_class_name)
|
7
|
+
end
|
8
|
+
|
9
|
+
def entity_class_name
|
6
10
|
proxy_class_name = name.split('::').last
|
7
|
-
|
8
|
-
Economic.const_get(entity_class_name)
|
11
|
+
proxy_class_name.sub(/Proxy$/, '')
|
9
12
|
end
|
10
13
|
end
|
11
14
|
|
@@ -25,21 +28,17 @@ module Economic
|
|
25
28
|
# Fetches all entities from the API.
|
26
29
|
def all
|
27
30
|
response = session.request(entity_class.soap_action(:get_all))
|
28
|
-
handles = response.values.flatten.collect { |handle| Entity::Handle.
|
31
|
+
handles = response.values.flatten.collect { |handle| Entity::Handle.build(handle) }
|
29
32
|
|
30
33
|
if handles.size == 1
|
31
34
|
# Fetch data for single entity
|
32
35
|
find(handles.first)
|
33
36
|
elsif handles.size > 1
|
34
|
-
entity_class_name = entity_class.name.split('::').last
|
35
|
-
|
36
37
|
# Fetch all data for all the entities
|
37
|
-
entity_data =
|
38
|
-
soap.body = {'entityHandles' => {"#{entity_class_name}Handle" => handles.collect(&:to_hash)}}
|
39
|
-
end
|
38
|
+
entity_data = get_data_array(handles)
|
40
39
|
|
41
40
|
# Build Entity objects and add them to the proxy
|
42
|
-
entity_data
|
41
|
+
entity_data.each do |data|
|
43
42
|
entity = build(data)
|
44
43
|
entity.persisted = true
|
45
44
|
end
|
@@ -65,9 +64,14 @@ module Economic
|
|
65
64
|
self.class.entity_class
|
66
65
|
end
|
67
66
|
|
67
|
+
# Returns the name of the class this proxy manages
|
68
|
+
def entity_class_name
|
69
|
+
self.class.entity_class_name
|
70
|
+
end
|
71
|
+
|
68
72
|
# Fetches Entity data from API and returns an Entity initialized with that data added to Proxy
|
69
73
|
def find(handle)
|
70
|
-
handle = Entity::Handle.new(handle)
|
74
|
+
handle = Entity::Handle.new(handle)
|
71
75
|
entity_hash = get_data(handle)
|
72
76
|
entity = build(entity_hash)
|
73
77
|
entity.persisted = true
|
@@ -76,7 +80,7 @@ module Economic
|
|
76
80
|
|
77
81
|
# Gets data for Entity from the API. Returns Hash with the response data
|
78
82
|
def get_data(handle)
|
79
|
-
handle = Entity::Handle.new(handle)
|
83
|
+
handle = Entity::Handle.new(handle)
|
80
84
|
|
81
85
|
entity_hash = session.request(entity_class.soap_action(:get_data)) do
|
82
86
|
soap.body = {
|
@@ -105,5 +109,17 @@ module Economic
|
|
105
109
|
items.size
|
106
110
|
end
|
107
111
|
|
112
|
+
protected
|
113
|
+
|
114
|
+
# Fetches all data for the given handles. Returns Array with hashes of entity data
|
115
|
+
def get_data_array(handles)
|
116
|
+
return [] unless handles && handles.any?
|
117
|
+
|
118
|
+
entity_class_name_for_soap_request = entity_class.name.split('::').last
|
119
|
+
response = session.request(entity_class.soap_action(:get_data_array)) do
|
120
|
+
soap.body = {'entityHandles' => {"#{entity_class_name_for_soap_request}Handle" => handles.collect(&:to_hash)}}
|
121
|
+
end
|
122
|
+
[response["#{entity_class.key}_data".intern]].flatten
|
123
|
+
end
|
108
124
|
end
|
109
125
|
end
|
@@ -1,32 +1,10 @@
|
|
1
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'
|
2
4
|
|
3
5
|
module Economic
|
4
6
|
class InvoiceProxy < EntityProxy
|
5
|
-
|
6
|
-
|
7
|
-
handle = if handle.respond_to?(:to_i)
|
8
|
-
Entity::Handle.new(:number => handle.to_i)
|
9
|
-
else
|
10
|
-
Entity::Handle.new(handle)
|
11
|
-
end
|
12
|
-
super(handle)
|
13
|
-
end
|
14
|
-
|
15
|
-
# Returns Economic::Invoice objects for invoices in a given interval of days.
|
16
|
-
def find_by_date_interval(from, unto)
|
17
|
-
response = session.request entity_class.soap_action("FindByDateInterval") do
|
18
|
-
soap.body = {
|
19
|
-
'first' => from.iso8601,
|
20
|
-
'last' => unto.iso8601,
|
21
|
-
:order! => ['first', 'last']
|
22
|
-
}
|
23
|
-
end
|
24
|
-
|
25
|
-
handles = [ response[:invoice_handle] ].flatten.reject(&:blank?)
|
26
|
-
|
27
|
-
handles.collect do |handle|
|
28
|
-
find(handle[:number])
|
29
|
-
end
|
30
|
-
end
|
7
|
+
include FindByDateInterval
|
8
|
+
include FindByHandleWithNumber
|
31
9
|
end
|
32
10
|
end
|
data/lib/rconomic/version.rb
CHANGED
@@ -8,6 +8,33 @@ describe Economic::CurrentInvoiceLine do
|
|
8
8
|
Economic::CurrentInvoiceLine.ancestors.should include(Economic::Entity)
|
9
9
|
end
|
10
10
|
|
11
|
+
describe "equality" do
|
12
|
+
it "should not be equal when both are newly created" do
|
13
|
+
line1 = Economic::CurrentInvoiceLine.new({})
|
14
|
+
line2 = Economic::CurrentInvoiceLine.new({})
|
15
|
+
|
16
|
+
line1.should_not == line2
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should not be equal when numbers are different" do
|
20
|
+
line1 = Economic::CurrentInvoiceLine.new({:number => 1})
|
21
|
+
line2 = Economic::CurrentInvoiceLine.new({:number => 2})
|
22
|
+
|
23
|
+
line1.should_not == line2
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe "#invoice=" do
|
28
|
+
it "changes the invoice_handle" do
|
29
|
+
invoice = Economic::CurrentInvoice.new(:id => 42)
|
30
|
+
|
31
|
+
subject.invoice = invoice
|
32
|
+
|
33
|
+
subject.invoice.should == invoice
|
34
|
+
subject.invoice_handle.should == invoice.handle
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
11
38
|
describe ".proxy" do
|
12
39
|
it "should return a CurrentInvoiceLineProxy" do
|
13
40
|
subject.proxy.should be_instance_of(Economic::CurrentInvoiceLineProxy)
|
@@ -37,6 +37,23 @@ describe Economic::CurrentInvoice do
|
|
37
37
|
savon.stubs('CurrentInvoice_CreateFromData').returns(:success)
|
38
38
|
end
|
39
39
|
|
40
|
+
it "updates id with the created id" do
|
41
|
+
subject.save
|
42
|
+
subject.id.should == 42
|
43
|
+
end
|
44
|
+
|
45
|
+
it "updates handle with the created id" do
|
46
|
+
invoice = Economic::CurrentInvoice.new({})
|
47
|
+
invoice.session = session
|
48
|
+
|
49
|
+
# This line memoizes the handle with the wrong/old id (0). This is what
|
50
|
+
# we're testing changes
|
51
|
+
invoice.handle.id.should == 0
|
52
|
+
|
53
|
+
invoice.save
|
54
|
+
invoice.handle.should == Economic::Entity::Handle.new(:id => 42)
|
55
|
+
end
|
56
|
+
|
40
57
|
context "when invoice has lines" do
|
41
58
|
before :each do
|
42
59
|
2.times do
|
@@ -105,7 +122,13 @@ describe Economic::CurrentInvoice do
|
|
105
122
|
end
|
106
123
|
|
107
124
|
describe "#attention" do
|
108
|
-
let(:contact) {
|
125
|
+
let(:contact) {
|
126
|
+
c = Economic::DebtorContact.new(
|
127
|
+
:handle => Economic::Entity::Handle.new({:id => 12, :number => 34})
|
128
|
+
)
|
129
|
+
c.session = session
|
130
|
+
c
|
131
|
+
}
|
109
132
|
|
110
133
|
it "should be set- and gettable" do
|
111
134
|
subject.attention = contact
|
@@ -19,6 +19,15 @@ describe Economic::Entity::Handle do
|
|
19
19
|
handle_a.should_not == handle_d
|
20
20
|
end
|
21
21
|
|
22
|
+
it "should not equal if both are empty" do
|
23
|
+
Economic::Entity::Handle.new({}).should_not == Economic::Entity::Handle.new({})
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should be equal if both are the same object" do
|
27
|
+
handle = Economic::Entity::Handle.new({})
|
28
|
+
handle.should == handle
|
29
|
+
end
|
30
|
+
|
22
31
|
describe "CashBookEntry handles" do
|
23
32
|
let(:handle_a) { Economic::Entity::Handle.new(:id1 => 1, :id2 => 2) }
|
24
33
|
|
@@ -38,7 +47,6 @@ describe Economic::Entity::Handle do
|
|
38
47
|
end
|
39
48
|
end
|
40
49
|
end
|
41
|
-
|
42
50
|
end
|
43
51
|
|
44
52
|
describe ".new" do
|
@@ -126,12 +134,54 @@ describe Economic::Entity::Handle do
|
|
126
134
|
end
|
127
135
|
end
|
128
136
|
|
137
|
+
describe ".build" do
|
138
|
+
it "returns nil when given nil" do
|
139
|
+
Economic::Entity::Handle.build(nil).should be_nil
|
140
|
+
end
|
141
|
+
|
142
|
+
it "returns empty handle when hash is empty" do
|
143
|
+
Economic::Entity::Handle.build({}).should be_empty
|
144
|
+
end
|
145
|
+
|
146
|
+
it "returns nil when hash has no values" do
|
147
|
+
Economic::Entity::Handle.build({:id => nil, :number => nil}).should be_empty
|
148
|
+
end
|
149
|
+
|
150
|
+
it "returns handle when hash has values" do
|
151
|
+
Economic::Entity::Handle.build({:id2 => 42}).should == Economic::Entity::Handle.new({:id2 => 42})
|
152
|
+
end
|
153
|
+
|
154
|
+
it "returns a given handle" do
|
155
|
+
handle = Economic::Entity::Handle.new({})
|
156
|
+
Economic::Entity::Handle.build(handle).should === handle
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
describe "#empty?" do
|
161
|
+
it "returns true when handle has no values" do
|
162
|
+
Economic::Entity::Handle.new({}).should be_empty
|
163
|
+
end
|
164
|
+
|
165
|
+
it "returns false when handle has a value" do
|
166
|
+
Economic::Entity::Handle.new({:serial_number => 12}).should_not be_empty
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
129
170
|
describe ".to_hash" do
|
130
|
-
subject { Economic::Entity::Handle.new({:id => 42, :number => 37}) }
|
171
|
+
subject { Economic::Entity::Handle.new({:id => 42, :number => 37, :serial_number => 7}) }
|
131
172
|
|
132
173
|
it "should return a handle for putting into the body of a SOAP request" do
|
133
|
-
subject.to_hash.should == {'Id' => 42, 'Number' => 37}
|
174
|
+
subject.to_hash.should == {'Id' => 42, 'Number' => 37, 'SerialNumber' => 7}
|
175
|
+
end
|
176
|
+
|
177
|
+
it "includes only the named value in the hash" do
|
178
|
+
subject.to_hash(:id).should == {'Id' => 42}
|
179
|
+
end
|
180
|
+
|
181
|
+
it "includes only the named values in the hash" do
|
182
|
+
subject.to_hash([:id, :serial_number]).should == {'Id' => 42, 'SerialNumber' => 7}
|
134
183
|
end
|
135
184
|
end
|
185
|
+
|
136
186
|
end
|
137
187
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require './spec/spec_helper'
|
2
2
|
|
3
3
|
class SpecEntity < Economic::Entity
|
4
|
-
has_properties :foo, :baz
|
4
|
+
has_properties :id, :foo, :baz
|
5
5
|
|
6
6
|
def existing_method; end
|
7
7
|
|
@@ -64,8 +64,8 @@ describe Economic::Entity do
|
|
64
64
|
subject.has_properties :id, :number, :handle
|
65
65
|
end
|
66
66
|
|
67
|
-
it "does
|
68
|
-
subject.expects(:define_method).with('existing_method')
|
67
|
+
it "does clobber existing methods" do
|
68
|
+
subject.expects(:define_method).with('existing_method')
|
69
69
|
subject.has_properties :existing_method
|
70
70
|
end
|
71
71
|
|
@@ -215,33 +215,61 @@ describe Economic::Entity do
|
|
215
215
|
end
|
216
216
|
|
217
217
|
describe "equality" do
|
218
|
+
subject { SpecEntity.new }
|
219
|
+
let(:other) { SpecEntity.new }
|
220
|
+
|
218
221
|
context "when other is nil do" do
|
219
|
-
|
222
|
+
it { should_not == nil }
|
223
|
+
end
|
224
|
+
|
225
|
+
context "when both handles are empty" do
|
226
|
+
it "returns false" do
|
227
|
+
subject.handle = Economic::Entity::Handle.new({})
|
228
|
+
other.handle = Economic::Entity::Handle.new({})
|
229
|
+
|
230
|
+
subject.should_not == other
|
231
|
+
end
|
232
|
+
end
|
233
|
+
|
234
|
+
context "when self handle isn't present" do
|
235
|
+
it "returns false" do
|
236
|
+
subject.handle = nil
|
237
|
+
subject.should_not == other
|
238
|
+
end
|
239
|
+
end
|
220
240
|
|
221
|
-
|
241
|
+
context "when other handle isn't present" do
|
242
|
+
it "returns false" do
|
243
|
+
other.handle = nil
|
222
244
|
subject.should_not == other
|
223
245
|
end
|
224
246
|
end
|
225
247
|
|
226
248
|
context "when other handle is equal" do
|
227
|
-
|
228
|
-
|
249
|
+
let(:handle) { Economic::Entity::Handle.new(:id => 42) }
|
250
|
+
subject { Economic::Debtor.new(:handle => handle) }
|
251
|
+
|
252
|
+
context "when other is another class" do
|
253
|
+
it "should return false" do
|
254
|
+
other = Economic::CashBook.new(:handle => handle)
|
255
|
+
subject.should_not == other
|
256
|
+
end
|
257
|
+
end
|
229
258
|
|
259
|
+
context "when other is same class" do
|
230
260
|
it "should return true" do
|
261
|
+
other = Economic::Debtor.new(:handle => handle)
|
231
262
|
subject.should == other
|
232
263
|
end
|
233
264
|
end
|
234
265
|
|
235
266
|
context "when other is child class" do
|
236
|
-
let(:other) { Economic::Debtor.new(:session => session, :handle => subject.handle) }
|
237
|
-
|
238
267
|
it "should return true" do
|
239
|
-
|
268
|
+
one = Economic::Entity.new(:handle => handle)
|
269
|
+
other = SpecEntity.new(:handle => handle)
|
270
|
+
one.should == other
|
240
271
|
end
|
241
272
|
end
|
242
273
|
end
|
243
|
-
|
244
|
-
|
245
|
-
|
246
274
|
end
|
247
275
|
end
|
@@ -26,13 +26,6 @@ describe Economic::CashBookEntryProxy do
|
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
-
describe "#save" do
|
30
|
-
it 'should save it' do
|
31
|
-
savon.stubs('CashBookEntry_CreateFromData').returns(:success)
|
32
|
-
subject.build.save
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
29
|
describe "#create_finance_voucher" do
|
37
30
|
it 'should create a finance voucher and return the created cash book entry' do
|
38
31
|
savon.stubs('CashBookEntry_CreateFinanceVoucher').returns(:success)
|
@@ -64,31 +64,26 @@ describe Economic::CurrentInvoiceProxy do
|
|
64
64
|
end
|
65
65
|
|
66
66
|
describe ".find_by_date_interval" do
|
67
|
+
let(:from) { Time.now - 60 }
|
68
|
+
let(:unto) { Time.now }
|
67
69
|
|
68
70
|
it "should be able to return a single current invoice" do
|
69
|
-
from = Time.now - 60
|
70
|
-
unto = Time.now
|
71
71
|
savon.expects('CurrentInvoice_FindByDateInterval').with('first' => from.iso8601, 'last' => unto.iso8601, :order! => ['first', 'last']).returns(:single)
|
72
|
-
savon.expects('
|
72
|
+
savon.expects('CurrentInvoice_GetDataArray').returns(:single)
|
73
73
|
results = subject.find_by_date_interval(from, unto)
|
74
74
|
results.size.should == 1
|
75
75
|
results.first.should be_instance_of(Economic::CurrentInvoice)
|
76
76
|
end
|
77
77
|
|
78
78
|
it "should be able to return multiple invoices" do
|
79
|
-
from = Time.now - 60
|
80
|
-
unto = Time.now
|
81
79
|
savon.expects('CurrentInvoice_FindByDateInterval').with('first' => from.iso8601, 'last' => unto.iso8601, :order! => ['first', 'last']).returns(:many)
|
82
|
-
savon.expects('
|
83
|
-
savon.expects('CurrentInvoice_GetData').returns(:success)
|
80
|
+
savon.expects('CurrentInvoice_GetDataArray').returns(:multiple)
|
84
81
|
results = subject.find_by_date_interval(from, unto)
|
85
82
|
results.size.should == 2
|
86
83
|
results.first.should be_instance_of(Economic::CurrentInvoice)
|
87
84
|
end
|
88
85
|
|
89
86
|
it "should be able to return nothing" do
|
90
|
-
from = Time.now - 60
|
91
|
-
unto = Time.now
|
92
87
|
savon.expects('CurrentInvoice_FindByDateInterval').with('first' => from.iso8601, 'last' => unto.iso8601, :order! => ['first', 'last']).returns(:none)
|
93
88
|
results = subject.find_by_date_interval(from, unto)
|
94
89
|
results.size.should == 0
|
@@ -61,7 +61,7 @@ describe Economic::DebtorProxy do
|
|
61
61
|
result.number.should == 1
|
62
62
|
result.partial.should be_true
|
63
63
|
result.persisted.should be_true
|
64
|
-
result.handle.should == Economic::Entity::Handle.new({
|
64
|
+
result.handle.should == Economic::Entity::Handle.new({:number => 1})
|
65
65
|
end
|
66
66
|
|
67
67
|
it "returns nil when there is no debtor" do
|
@@ -41,31 +41,26 @@ describe Economic::InvoiceProxy do
|
|
41
41
|
end
|
42
42
|
|
43
43
|
describe ".find_by_date_interval" do
|
44
|
+
let(:from) { Time.now - 60 }
|
45
|
+
let(:unto) { Time.now }
|
44
46
|
|
45
47
|
it "should be able to return a single current invoice" do
|
46
|
-
from = Time.now - 60
|
47
|
-
unto = Time.now
|
48
48
|
savon.expects('Invoice_FindByDateInterval').with('first' => from.iso8601, 'last' => unto.iso8601, :order! => ['first', 'last']).returns(:single)
|
49
|
-
savon.expects('
|
49
|
+
savon.expects('Invoice_GetDataArray').returns(:single)
|
50
50
|
results = subject.find_by_date_interval(from, unto)
|
51
51
|
results.size.should == 1
|
52
52
|
results.first.should be_instance_of(Economic::Invoice)
|
53
53
|
end
|
54
54
|
|
55
55
|
it "should be able to return multiple invoices" do
|
56
|
-
from = Time.now - 60
|
57
|
-
unto = Time.now
|
58
56
|
savon.expects('Invoice_FindByDateInterval').with('first' => from.iso8601, 'last' => unto.iso8601, :order! => ['first', 'last']).returns(:many)
|
59
|
-
savon.expects('
|
60
|
-
savon.expects('Invoice_GetData').returns(:success)
|
57
|
+
savon.expects('Invoice_GetDataArray').returns(:multiple)
|
61
58
|
results = subject.find_by_date_interval(from, unto)
|
62
59
|
results.size.should == 2
|
63
60
|
results.first.should be_instance_of(Economic::Invoice)
|
64
61
|
end
|
65
62
|
|
66
63
|
it "should be able to return nothing" do
|
67
|
-
from = Time.now - 60
|
68
|
-
unto = Time.now
|
69
64
|
savon.expects('Invoice_FindByDateInterval').with('first' => from.iso8601, 'last' => unto.iso8601, :order! => ['first', 'last']).returns(:none)
|
70
65
|
results = subject.find_by_date_interval(from, unto)
|
71
66
|
results.size.should == 0
|