clearbooks 0.16.3
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 +7 -0
- data/AUTHORS.md +31 -0
- data/CHANGELOG.md +0 -0
- data/COPYING.md +12 -0
- data/FAQ.md +8 -0
- data/Gemfile +105 -0
- data/LICENSE.md +14 -0
- data/MAINTAINERS.md +40 -0
- data/README.md +549 -0
- data/Rakefile +94 -0
- data/Thorfile +80 -0
- data/bin/clearbooks +28 -0
- data/clearbooks.gemspec +119 -0
- data/examples/demo.rb +8 -0
- data/lib/clearbooks.rb +92 -0
- data/lib/clearbooks/core_ext.rb +8 -0
- data/lib/clearbooks/core_ext/array.rb +51 -0
- data/lib/clearbooks/core_ext/hash.rb +47 -0
- data/lib/clearbooks/core_ext/io_binary_read.rb +20 -0
- data/lib/clearbooks/core_ext/string.rb +21 -0
- data/lib/clearbooks/error.rb +8 -0
- data/lib/clearbooks/error/errors.rb +228 -0
- data/lib/clearbooks/interface/rake/cucumber.rb +36 -0
- data/lib/clearbooks/interface/rake/default.rb +28 -0
- data/lib/clearbooks/interface/rake/documentation.rb +45 -0
- data/lib/clearbooks/interface/rake/guard.rb +13 -0
- data/lib/clearbooks/interface/rake/helpers.rb +27 -0
- data/lib/clearbooks/interface/rake/library.rb +126 -0
- data/lib/clearbooks/interface/rake/metric.rb +15 -0
- data/lib/clearbooks/interface/rake/rspec.rb +31 -0
- data/lib/clearbooks/interface/thor/info.thor +292 -0
- data/lib/clearbooks/interface/thor/mixin/config_choice.rb +27 -0
- data/lib/clearbooks/interface/thor/mixin/configuration.rb +28 -0
- data/lib/clearbooks/interface/thor/mixin/default.rb +30 -0
- data/lib/clearbooks/interface/thor/mixin/default_config.rb +31 -0
- data/lib/clearbooks/interface/thor/mixin/guess.rb +57 -0
- data/lib/clearbooks/interface/thor/mixin/shell.rb +225 -0
- data/lib/clearbooks/interface/thor/version.thor +34 -0
- data/lib/clearbooks/library/client.rb +257 -0
- data/lib/clearbooks/library/configuration.rb +34 -0
- data/lib/clearbooks/model/account_code.rb +65 -0
- data/lib/clearbooks/model/base.rb +67 -0
- data/lib/clearbooks/model/entity.rb +225 -0
- data/lib/clearbooks/model/invoice.rb +163 -0
- data/lib/clearbooks/model/item.rb +78 -0
- data/lib/clearbooks/model/journal.rb +74 -0
- data/lib/clearbooks/model/ledger.rb +52 -0
- data/lib/clearbooks/model/payment.rb +113 -0
- data/lib/clearbooks/model/project.rb +58 -0
- data/lib/clearbooks/version.rb +12 -0
- data/spec/clearbooks/clearbooks_spec.rb +27 -0
- data/spec/clearbooks/model/account_code_spec.rb +52 -0
- data/spec/clearbooks/model/entity_spec.rb +107 -0
- data/spec/clearbooks/model/invoice_spec.rb +109 -0
- data/spec/clearbooks/model/journal_spec.rb +77 -0
- data/spec/clearbooks/model/payment_spec.rb +103 -0
- data/spec/clearbooks/model/project_spec.rb +72 -0
- data/spec/fixtures/response/allocate_payment.xml +12 -0
- data/spec/fixtures/response/create_entity.xml +12 -0
- data/spec/fixtures/response/create_invoice.xml +11 -0
- data/spec/fixtures/response/create_journal.xml +12 -0
- data/spec/fixtures/response/create_payment.xml +12 -0
- data/spec/fixtures/response/create_project.xml +12 -0
- data/spec/fixtures/response/delete_entity.xml +12 -0
- data/spec/fixtures/response/delete_journal.xml +12 -0
- data/spec/fixtures/response/list_account_codes.xml +168 -0
- data/spec/fixtures/response/list_entities.xml +45 -0
- data/spec/fixtures/response/list_invoices.xml +56 -0
- data/spec/fixtures/response/list_projects.xml +16 -0
- data/spec/fixtures/response/no_api_key_fault.xml +8 -0
- data/spec/fixtures/response/well_formed_request.xml +10 -0
- data/spec/fixtures/response/wrong_api_key_fault.xml +8 -0
- data/spec/spec_helper.rb +26 -0
- metadata +212 -0
@@ -0,0 +1,78 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
|
4
|
+
# @module Clearbooks
|
5
|
+
# @brief Handles Ruby idomatic expression of Clear Books SOAP API
|
6
|
+
module Clearbooks
|
7
|
+
|
8
|
+
# @class Clearbooks Item model
|
9
|
+
# @brief Single item from an invoice
|
10
|
+
#
|
11
|
+
# @see https://www.clearbooks.co.uk/support/api/docs/soap/createinvoice/
|
12
|
+
class Item < Base
|
13
|
+
|
14
|
+
attr_reader :description, :unit_price, :quantity, :type, :vat, :vat_rate
|
15
|
+
|
16
|
+
# @!attribute [r] description
|
17
|
+
# Required.
|
18
|
+
# @return [String]
|
19
|
+
# @see https://www.clearbooks.co.uk/support/api/docs/soap/createinvoice/
|
20
|
+
|
21
|
+
# @!attribute [r] unit_price
|
22
|
+
# Required.
|
23
|
+
# @return [BigDecimal] The unit price of an item in pounds.
|
24
|
+
# @see https://www.clearbooks.co.uk/support/api/docs/soap/createinvoice/
|
25
|
+
|
26
|
+
# @!attribute [r] quantity
|
27
|
+
# Required.
|
28
|
+
# @return [Fixnum]
|
29
|
+
# @see https://www.clearbooks.co.uk/support/api/docs/soap/createinvoice/
|
30
|
+
|
31
|
+
# @!attribute [r] type
|
32
|
+
# Required. The account code identifying the revenue stream.
|
33
|
+
# @return [String]
|
34
|
+
# @see https://www.clearbooks.co.uk/support/api/docs/soap/createinvoice/
|
35
|
+
|
36
|
+
# @!attribute [r] vat
|
37
|
+
# Required. The total amount of VAT in pounds. Use either this field or vat_rate.
|
38
|
+
# @return [String]
|
39
|
+
# @see https://www.clearbooks.co.uk/support/api/docs/soap/createinvoice/
|
40
|
+
|
41
|
+
# @!attribute [r] vat_rate
|
42
|
+
# Required. The percentage VAT as a decimal number. Use either this field or vat.
|
43
|
+
# @return [String]
|
44
|
+
# @see https://www.clearbooks.co.uk/support/api/docs/soap/createinvoice/
|
45
|
+
|
46
|
+
# @fn def initialize data {{{
|
47
|
+
# @brief Constructor for Item model
|
48
|
+
#
|
49
|
+
# @param [Hash] data Item attributes. For the list of available options see https://www.clearbooks.co.uk/support/api/docs/soap/createinvoice/
|
50
|
+
def initialize data
|
51
|
+
@description = data.savon :description
|
52
|
+
@unit_price = BigDecimal.new data.savon(:unit_price), 2
|
53
|
+
@quantity = data.savon(:quantity).to_i
|
54
|
+
@type = data.savon :type
|
55
|
+
@vat = data.savon :vat
|
56
|
+
@vat_rate = data.savon :vat_rate
|
57
|
+
end # }}}
|
58
|
+
|
59
|
+
# @fn def to_savon {{{
|
60
|
+
# @brief Converts given Item (self) to savon readable format
|
61
|
+
#
|
62
|
+
# @return [Hash] Returns self as Savon readable Hash
|
63
|
+
def to_savon
|
64
|
+
{
|
65
|
+
:@unitPrice => @unit_price.to_f,
|
66
|
+
:@quantity => @quantity,
|
67
|
+
:@type => @type,
|
68
|
+
:@vat => @vat,
|
69
|
+
:@vat_rate => @vat_rate,
|
70
|
+
:description => @description
|
71
|
+
}
|
72
|
+
end # }}}
|
73
|
+
|
74
|
+
end # of class Item
|
75
|
+
|
76
|
+
end # of module Clearbooks
|
77
|
+
|
78
|
+
# vim:ts=2:tw=100:wm=100:syntax=ruby
|
@@ -0,0 +1,74 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
|
4
|
+
# @module Clearbooks
|
5
|
+
# @brief Handles Ruby idomatic expression of Clear Books SOAP API
|
6
|
+
module Clearbooks
|
7
|
+
|
8
|
+
# @class Clearbooks Journal model
|
9
|
+
# @brief Used to create a new journal via Clearbooks API.
|
10
|
+
#
|
11
|
+
# @see https://www.clearbooks.co.uk/support/api/docs/soap/listaccountcodes/
|
12
|
+
class Journal < Base
|
13
|
+
|
14
|
+
attr_reader :description, :accounting_date, :entity, :project, :ledgers
|
15
|
+
|
16
|
+
# @!attribute [r] description
|
17
|
+
# Required. The description of the journal.
|
18
|
+
# return [String]
|
19
|
+
# @see https://www.clearbooks.co.uk/support/api/docs/soap/createjournal/
|
20
|
+
|
21
|
+
# @!attribute [r] accounting_date
|
22
|
+
# Optional. The accounting date of the journal.
|
23
|
+
# return [Date]
|
24
|
+
# @see https://www.clearbooks.co.uk/support/api/docs/soap/createjournal/
|
25
|
+
|
26
|
+
# @!attribute [r] entity
|
27
|
+
# Optional. The ID of an entity attached to the journal.
|
28
|
+
# return [Fixnum]
|
29
|
+
# @see https://www.clearbooks.co.uk/support/api/docs/soap/createjournal/
|
30
|
+
|
31
|
+
# @!attribute [r] project
|
32
|
+
# Optional. The ID of a project attached to the journal.
|
33
|
+
# return [Fixnum]
|
34
|
+
# @see https://www.clearbooks.co.uk/support/api/docs/soap/createjournal/
|
35
|
+
|
36
|
+
# @!attribute [r] ledgers
|
37
|
+
# Optional. An array of transactions added to the journal. Two items required.
|
38
|
+
# return [Array, Ledger]
|
39
|
+
# @see https://www.clearbooks.co.uk/support/api/docs/soap/createjournal/
|
40
|
+
|
41
|
+
|
42
|
+
# @fn def initialize data {{{
|
43
|
+
# @brief Constructor for Journal model
|
44
|
+
#
|
45
|
+
# @param [Hash] data Journal attributes. For the list of available options see https://www.clearbooks.co.uk/support/api/docs/soap/createjournal/
|
46
|
+
def initialize data
|
47
|
+
@description = data.savon :description
|
48
|
+
@accounting_date = parse_date data.savon :accounting_date
|
49
|
+
@entity = data.savon :entity
|
50
|
+
@project = data.savon :project
|
51
|
+
@ledgers = Ledger.build data.savon :ledgers
|
52
|
+
end # }}}
|
53
|
+
|
54
|
+
# @fn def to_savon {{{
|
55
|
+
# @brief Converts given Journal (self) to savon readable format
|
56
|
+
#
|
57
|
+
# @return [Hash] Returns self as Savon readable Hash
|
58
|
+
def to_savon
|
59
|
+
{
|
60
|
+
journal: {
|
61
|
+
:@description => @description,
|
62
|
+
:@accountingDate => @accounting_date.strftime('%F'),
|
63
|
+
:@entity => @entity,
|
64
|
+
:@project => @project,
|
65
|
+
:ledgers => @ledgers.map(&:to_savon)
|
66
|
+
}.compact
|
67
|
+
}
|
68
|
+
end # }}}
|
69
|
+
|
70
|
+
end # of class Journal
|
71
|
+
|
72
|
+
end # of module Clearbooks
|
73
|
+
|
74
|
+
# vim:ts=2:tw=100:wm=100:syntax=ruby
|
@@ -0,0 +1,52 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
|
4
|
+
# @module Clearbooks
|
5
|
+
# @brief Handles Ruby idomatic expression of Clear Books SOAP API
|
6
|
+
module Clearbooks
|
7
|
+
|
8
|
+
# @class Clearbooks Ledger model
|
9
|
+
# @brief Represents a transaction item in a Journal
|
10
|
+
#
|
11
|
+
# @see https://www.clearbooks.co.uk/support/api/docs/soap/createjournal/
|
12
|
+
class Ledger < Base
|
13
|
+
|
14
|
+
attr_reader :account, :amount
|
15
|
+
|
16
|
+
# @!attribute [r] account
|
17
|
+
# Optional. Account code for associated transaction.
|
18
|
+
# @return [String]
|
19
|
+
# @see https://www.clearbooks.co.uk/support/api/docs/soap/createjournal/
|
20
|
+
|
21
|
+
# @!attribute [r] amount
|
22
|
+
# Optional. Amount for associated transaction in the journal.
|
23
|
+
# @return [BigDecimal]
|
24
|
+
# @see https://www.clearbooks.co.uk/support/api/docs/soap/createjournal/
|
25
|
+
|
26
|
+
# @fn def initialize data {{{
|
27
|
+
# @brief Constructor for Ledger model
|
28
|
+
#
|
29
|
+
# @param [Hash] data Ledger attributes. For the list of available options see https://www.clearbooks.co.uk/support/api/docs/soap/createjournal/
|
30
|
+
def initialize data
|
31
|
+
@account = data.savon :account
|
32
|
+
@amount = BigDecimal.new data.savon :amount
|
33
|
+
end # }}}
|
34
|
+
|
35
|
+
# @fn def to_savon {{{
|
36
|
+
# @brief Converts given Ledger (self) to savon readable format
|
37
|
+
#
|
38
|
+
# @return [Hash] Returns self as Savon readable Hash
|
39
|
+
def to_savon
|
40
|
+
{
|
41
|
+
ledger: {
|
42
|
+
:@account => @account,
|
43
|
+
:@amount => @amount.to_f
|
44
|
+
}.compact
|
45
|
+
}
|
46
|
+
end # }}}
|
47
|
+
|
48
|
+
end # of class Ledger
|
49
|
+
|
50
|
+
end # of module Clearbooks
|
51
|
+
|
52
|
+
# vim:ts=2:tw=100:wm=100:syntax=ruby
|
@@ -0,0 +1,113 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
|
4
|
+
# @module Clearbooks
|
5
|
+
# @brief Handles Ruby idomatic expression of Clear Books SOAP API
|
6
|
+
module Clearbooks
|
7
|
+
|
8
|
+
# @class Clearbooks Payment model
|
9
|
+
# @brief Used to create payments in Clearbooks API
|
10
|
+
#
|
11
|
+
# @see https://www.clearbooks.co.uk/support/api/docs/soap/createpayment/
|
12
|
+
class Payment < Base
|
13
|
+
|
14
|
+
attr_reader :accounting_date,
|
15
|
+
:type,
|
16
|
+
:description,
|
17
|
+
:amount,
|
18
|
+
:entity_id,
|
19
|
+
:payment_method,
|
20
|
+
:bank_account,
|
21
|
+
:invoices
|
22
|
+
|
23
|
+
|
24
|
+
# @!attribute [r] accounting_date
|
25
|
+
# Optional. Date the payment was made.
|
26
|
+
# @return [DateTime]
|
27
|
+
# @see https://www.clearbooks.co.uk/support/api/docs/soap/createpayment/
|
28
|
+
|
29
|
+
# @!attribute [r] type
|
30
|
+
# Optional. String identifying the type of the payment. Value one of: purchases, sales.
|
31
|
+
# @return [String]
|
32
|
+
# @see https://www.clearbooks.co.uk/support/api/docs/soap/createpayment/
|
33
|
+
|
34
|
+
# @!attribute [r] description
|
35
|
+
# Optional.
|
36
|
+
# @return [String]
|
37
|
+
# @see https://www.clearbooks.co.uk/support/api/docs/soap/createpayment/
|
38
|
+
|
39
|
+
# @!attribute [r] amount
|
40
|
+
# Optional. The total amount paid in pounds.
|
41
|
+
# @return [BigDecimal]
|
42
|
+
# @see https://www.clearbooks.co.uk/support/api/docs/soap/createpayment/
|
43
|
+
|
44
|
+
# @!attribute [r] entity_id
|
45
|
+
# Optional. The id of the customer or supplier.
|
46
|
+
# @return [Fixnum]
|
47
|
+
# @see https://www.clearbooks.co.uk/support/api/docs/soap/createpayment/
|
48
|
+
|
49
|
+
# @!attribute [r] payment_method
|
50
|
+
# Optional. The id of the payment method.
|
51
|
+
# @return [Fixnum]
|
52
|
+
# @see https://www.clearbooks.co.uk/support/api/docs/soap/createpayment/
|
53
|
+
|
54
|
+
# @!attribute [r] bank_account
|
55
|
+
# Optional. The account code of the bank account being paid into.
|
56
|
+
# @return [String]
|
57
|
+
# @see https://www.clearbooks.co.uk/support/api/docs/soap/createpayment/
|
58
|
+
|
59
|
+
# @!attribute [r] invoices
|
60
|
+
# Optional. An array of invoice elements.
|
61
|
+
# @return [Array]
|
62
|
+
# @see https://www.clearbooks.co.uk/support/api/docs/soap/createpayment/
|
63
|
+
|
64
|
+
# @fn def initialize data {{{
|
65
|
+
# @brief Constructor for Payment model
|
66
|
+
#
|
67
|
+
# @param [Hash] data Payment attributes. For the list of available options see https://www.clearbooks.co.uk/support/api/docs/soap/createpayment/
|
68
|
+
def initialize data
|
69
|
+
@accounting_date = parse_date data.savon :accounting_date
|
70
|
+
@type = data.savon :type
|
71
|
+
@description = data.savon :description
|
72
|
+
@amount = BigDecimal.new data.savon :amount
|
73
|
+
@entity_id = data.savon(:entity_id).to_i
|
74
|
+
@payment_method = data.savon(:payment_method).to_i
|
75
|
+
@bank_account = data.savon :bank_account
|
76
|
+
@invoices = data.savon :invoices
|
77
|
+
end # }}}
|
78
|
+
|
79
|
+
# @fn def to_savon {{{
|
80
|
+
# @brief Converts given Payment (self) to savon readable format
|
81
|
+
#
|
82
|
+
# @return [Hash] Returns self as Savon readable Hash
|
83
|
+
def to_savon
|
84
|
+
{
|
85
|
+
payment: {
|
86
|
+
:@accountingDate => @accounting_date.strftime('%F'),
|
87
|
+
:@type => @type,
|
88
|
+
:@amount => @amount.to_f,
|
89
|
+
:@entityId => @entity_id,
|
90
|
+
:@paymentMethod => @payment_method,
|
91
|
+
:@bankAccount => @bank_account,
|
92
|
+
:description => @description,
|
93
|
+
:invoices => { invoice: savon_invoices }
|
94
|
+
}
|
95
|
+
}
|
96
|
+
end # }}}
|
97
|
+
|
98
|
+
private
|
99
|
+
|
100
|
+
def savon_invoices
|
101
|
+
@invoices.map do |i|
|
102
|
+
{
|
103
|
+
:@id => i[:id],
|
104
|
+
:@amount => i[:amount]
|
105
|
+
}
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
end # of class Payment
|
110
|
+
|
111
|
+
end # of module Clearbooks
|
112
|
+
|
113
|
+
# vim:ts=2:tw=100:wm=100:syntax=ruby
|
@@ -0,0 +1,58 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
|
4
|
+
# @module Clearbooks
|
5
|
+
# @brief Handles Ruby idomatic expression of Clear Books SOAP API
|
6
|
+
module Clearbooks
|
7
|
+
|
8
|
+
# @class Clearbooks Project model
|
9
|
+
# @brief Used to list existing projects or create new.
|
10
|
+
#
|
11
|
+
# @see https://www.clearbooks.co.uk/support/api/docs/soap/createproject/
|
12
|
+
class Project < Base
|
13
|
+
|
14
|
+
attr_reader :id, :description, :project_name, :status
|
15
|
+
|
16
|
+
# @!attribute [r] description
|
17
|
+
# Required. The description of the project.
|
18
|
+
# @see https://www.clearbooks.co.uk/support/api/docs/soap/createproject/
|
19
|
+
|
20
|
+
# @!attribute [r] project_name
|
21
|
+
# Optional. The name of the project.
|
22
|
+
# @see https://www.clearbooks.co.uk/support/api/docs/soap/createproject/
|
23
|
+
|
24
|
+
# @!attribute [r] status
|
25
|
+
# Optional. String identifying the project status. Use one of the following values: "open", "closed" or "deleted".
|
26
|
+
# @see https://www.clearbooks.co.uk/support/api/docs/soap/createproject/
|
27
|
+
|
28
|
+
# @fn def initialize data {{{
|
29
|
+
# @brief Constructor for Project model
|
30
|
+
#
|
31
|
+
# @param [Hash] data Project attributes. For the list of available options see https://www.clearbooks.co.uk/support/api/docs/soap/createproject/
|
32
|
+
def initialize data
|
33
|
+
@id = data.savon(:id).to_i
|
34
|
+
@description = data.savon :description
|
35
|
+
@project_name = data.savon :project_name
|
36
|
+
@status = data.savon :status
|
37
|
+
end # }}}
|
38
|
+
|
39
|
+
# @fn def to_savon {{{
|
40
|
+
# @brief Converts given Project (self) to savon readable format
|
41
|
+
#
|
42
|
+
# @return [Hash] Returns self as Savon readable Hash
|
43
|
+
def to_savon
|
44
|
+
{
|
45
|
+
project: {
|
46
|
+
:@projectName => @project_name,
|
47
|
+
:@status => @status,
|
48
|
+
:@description => @description
|
49
|
+
}
|
50
|
+
}
|
51
|
+
end # }}}
|
52
|
+
|
53
|
+
|
54
|
+
end # of class Project
|
55
|
+
|
56
|
+
end # of module Clearbooks
|
57
|
+
|
58
|
+
# vim:ts=2:tw=100:wm=100:syntax=ruby
|
@@ -0,0 +1,12 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
|
4
|
+
# @module Clearbooks Module
|
5
|
+
# @brief Implements the Clearbooks module wrapper around the Clearbooks API
|
6
|
+
module Clearbooks
|
7
|
+
|
8
|
+
VERSION = `git describe --tags`.split("-").first || "0.1.0-wrong-version"
|
9
|
+
|
10
|
+
end
|
11
|
+
|
12
|
+
# vim:ts=2:tw=100:wm=100:syntax=ruby
|
@@ -0,0 +1,27 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# System include
|
4
|
+
require 'savon'
|
5
|
+
|
6
|
+
# Custom include
|
7
|
+
require 'spec_helper'
|
8
|
+
|
9
|
+
|
10
|
+
module Clearbooks
|
11
|
+
|
12
|
+
describe Clearbooks do
|
13
|
+
|
14
|
+
describe :config do
|
15
|
+
it 'has default WSDL url' do
|
16
|
+
expect(Clearbooks.config.wsdl).to eq 'https://secure.clearbooks.co.uk/api/wsdl/'
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'has API key' do
|
20
|
+
expect(Clearbooks.config.api_key).not_to be_nil
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
end # of describe Clearbooks
|
25
|
+
|
26
|
+
end # of module Clearbooks
|
27
|
+
|
@@ -0,0 +1,52 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
|
4
|
+
# System include
|
5
|
+
require 'savon'
|
6
|
+
|
7
|
+
# Custom include
|
8
|
+
require 'spec_helper'
|
9
|
+
|
10
|
+
|
11
|
+
module Clearbooks
|
12
|
+
|
13
|
+
describe Clearbooks do
|
14
|
+
|
15
|
+
before(:all) { savon.mock! }
|
16
|
+
after(:all) { savon.unmock! }
|
17
|
+
|
18
|
+
let(:message) { :any }
|
19
|
+
|
20
|
+
describe '::list_account_codes' do
|
21
|
+
let(:xml) { File.read('spec/fixtures/response/list_account_codes.xml') }
|
22
|
+
|
23
|
+
let(:account_codes) do
|
24
|
+
savon.expects(:list_account_codes).with(message: message).returns(xml)
|
25
|
+
Clearbooks.list_account_codes
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'returns list of account_codes' do
|
29
|
+
expect(account_codes).to be_an Array
|
30
|
+
expect(account_codes.length).to eq 77
|
31
|
+
end
|
32
|
+
|
33
|
+
describe AccountCode do
|
34
|
+
let(:account_code) {account_codes.last}
|
35
|
+
|
36
|
+
it 'has proper attribute values' do
|
37
|
+
expect(account_code.id).to eq 6501001
|
38
|
+
expect(account_code.account_name).to eq 'Corporation tax'
|
39
|
+
expect(account_code.group_name).to eq 'Tax expense'
|
40
|
+
expect(account_code.default_vat_rate).to eq '0.00:Out'
|
41
|
+
expect(account_code.show_sales).to eq false
|
42
|
+
expect(account_code.show_purchases).to eq true
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
end # of describe '::list_account_codes
|
48
|
+
|
49
|
+
end # of describe Clearbooks
|
50
|
+
|
51
|
+
end # of module Clearbooks
|
52
|
+
|