rconomic 0.7.1 → 0.7.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: caef641910e16033c2e764c9d1f5789c8c75cde339c04528fe0b57bf43edc8ef
4
- data.tar.gz: 8a1152d91d724b54bfd7d4a03abbf5fd00942b034309cf74bde85e8f6f16a157
3
+ metadata.gz: c28c505ccc3c9a6c96ba5f71df0d1405e1fc20b177222e2b878aeb26919125de
4
+ data.tar.gz: 017da352051bacf17271337cbb9ef5aff57d6f9c19f50f7f97ca90cb8c0c8b21
5
5
  SHA512:
6
- metadata.gz: 97860bee85ba9754f5b2707f4599ab96cca1cb236f00f10bc2a2918fcd7b00aa4299e0c975038a93bba61ef1393dcd2595177e03fb43f17b42f8b4efb7aebf5d
7
- data.tar.gz: 4d93f4c950aa88d8fc6a6d41961e68912d652cfb0e486549ee661086da8854dc6fcb02834b1701752e36dcb7e23ebfda67c8ea2ab59f0d62770914668162870b
6
+ metadata.gz: eb77c6883f471d4f77a7aa78fd50defed6290e334a3867f4a8c467e485790a75ef53031a3ed270ddf70b1ca5997d2e9b69cf5225608af63d3f1ae5280e17da7d
7
+ data.tar.gz: 5dafef1962b57e7c8395bd000a1a4fbf6a9f4c925e673a611d26578f333db9bf0d54a5bf9048a7e33600760b90d9b946636564e85fe45fbe2a941c7d1ff160a2
data/CHANGELOG.md CHANGED
@@ -7,7 +7,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
7
7
 
8
8
  ### Added
9
9
 
10
- * Operation to fetch only current orders from the backend.
10
+ *
11
11
 
12
12
  ### Changes
13
13
 
@@ -15,6 +15,34 @@ This project adheres to [Semantic Versioning](http://semver.org/).
15
15
 
16
16
  ### Removed
17
17
 
18
+ *
19
+
20
+ ## 0.7.2 [June 24, 2019]
21
+
22
+ ### Added
23
+
24
+ * Ability to create ManualDebtorInvoice cash book entries (@prognostikos).
25
+
26
+ ### Changes
27
+
28
+ * `Debtor#current_invoices` now only returns invoices for the debtor (@olepalm).
29
+
30
+ ## 0.7.1 [February 21st, 2018]
31
+
32
+ ### Added
33
+
34
+ * Operation to fetch only current orders from the backend.
35
+ * Support for OrderLine objects (@olepalm)
36
+ * Ability to get order lines for a specific order (@olepalm).
37
+ * Orders can now be found by their other_reference field (@olepalm).
38
+ * Ability to toggle Sent-status of orders (@olepalm).
39
+
40
+ ### Changes
41
+
42
+ * The cached E-conomic WSDL has been updated with the most recent version.
43
+
44
+ ### Removed
45
+
18
46
  ## 0.7.0 [July 1st, 2018]
19
47
 
20
48
  This release contains breaking changes as E-conomic has deprecated one of their connection methods. See https://www.e-conomic.com/developer#_ga=2.79896535.1117342868.1530474675-2146547048.1526554784 for details.
data/README.md CHANGED
@@ -118,6 +118,8 @@ Not even remotely... For now, limited to a small subset of all the [available op
118
118
  DebtorEntry | X | X | X | X
119
119
  Entry | X | X | X | X
120
120
  Invoice | X | X | |
121
+ Order | | X | |
122
+ OrderLine | | X | X |
121
123
  Product | X | X | X | X
122
124
 
123
125
  Credits
@@ -63,6 +63,13 @@ module Economic
63
63
  @current_invoices ||= CurrentInvoiceProxy.new(self)
64
64
  end
65
65
 
66
+ # Provides access to the current invoices for Debtor - ie invoices that
67
+ # haven't yet been booked
68
+ def get_current_invoices
69
+ return [] if handle.empty?
70
+ @current_invoices ||= DebtorProxy.new(self).get_current_invoices(handle)
71
+ end
72
+
66
73
  # Returns the Debtors contacts
67
74
  def contacts
68
75
  return [] if handle.empty?
@@ -58,6 +58,16 @@ module Economic
58
58
  create_cash_book_entry_for_handles(handles, "CreateCreditorInvoice")
59
59
  end
60
60
 
61
+ # Creates a manual debtor invoice and returns the cash book entry.
62
+ # Example:
63
+ # cash_book.entries.create_manual_debtor_invoice(
64
+ # :debtor_handle => { :number => 1 },
65
+ # :contra_account_handle => { :number => 1510 }
66
+ # )
67
+ def create_manual_debtor_invoice(handles)
68
+ create_cash_book_entry_for_handles(handles, "CreateManualDebtorInvoice")
69
+ end
70
+
61
71
  def set_due_date(id, date)
62
72
  request("SetDueDate", "cashBookEntryHandle" => {
63
73
  "Id1" => owner.handle[:number], "Id2" => id
@@ -86,7 +96,8 @@ module Economic
86
96
  "CreateFinanceVoucher" => "accountHandle",
87
97
  "CreateDebtorPayment" => "debtorHandle",
88
98
  "CreateCreditorInvoice" => "creditorHandle",
89
- "CreateCreditorPayment" => "creditorHandle"
99
+ "CreateCreditorPayment" => "creditorHandle",
100
+ "CreateManualDebtorInvoice" => "debtorHandle",
90
101
  }[action_name]
91
102
  end
92
103
  end
@@ -7,6 +7,19 @@ module Economic
7
7
  class CurrentInvoiceProxy < EntityProxy
8
8
  include FindByDateInterval
9
9
 
10
+ # Fetches all entities from the API.
11
+ def all
12
+ if owner.is_a?(Economic::Debtor)
13
+ owner.get_current_invoices
14
+ else
15
+ response = request(:get_all)
16
+ handles = response.values.flatten.collect { |handle| Entity::Handle.build(handle) }
17
+ get_data_for_handles(handles)
18
+
19
+ self
20
+ end
21
+ end
22
+
10
23
  private
11
24
 
12
25
  # Initialize properties in invoice with values from owner
@@ -18,6 +18,14 @@ module Economic
18
18
  request :get_next_available_number
19
19
  end
20
20
 
21
+ def get_current_invoices(debtor_handle)
22
+ response = fetch_response(:get_current_invoices, debtor_handle)
23
+ build_entities_from_response(
24
+ Economic::CurrentInvoice,
25
+ response[:current_invoice_handle]
26
+ )
27
+ end
28
+
21
29
  def get_debtor_contacts(debtor_handle)
22
30
  response = fetch_response(:get_debtor_contacts, debtor_handle)
23
31
  build_entities_from_response(
@@ -52,11 +60,21 @@ module Economic
52
60
  entity.partial = true
53
61
  entity.persisted = true
54
62
  entity.handle = handle
55
- entity.number = handle[:id].to_i
63
+ entity = add_id_to_entity(entity, handle[:id].to_i)
56
64
  entity
57
65
  end
58
66
  end
59
67
 
68
+ def add_id_to_entity(entity, id)
69
+ if entity.respond_to?(:number=)
70
+ entity.number = id
71
+ else
72
+ entity.id = id
73
+ end
74
+
75
+ entity
76
+ end
77
+
60
78
  def fetch_response(operation, debtor_handle)
61
79
  request(
62
80
  operation,
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Rconomic
4
- VERSION = "0.7.1"
4
+ VERSION = "0.7.2"
5
5
  end
@@ -58,6 +58,20 @@ describe Economic::Debtor do
58
58
  end
59
59
  end
60
60
 
61
+ describe ".get_current_invoices" do
62
+ it "return nothing if no handle" do
63
+ expect(subject.get_current_invoices).to be_empty
64
+ end
65
+
66
+ it "returns current invoices if there is a handle" do
67
+ mock_request("Debtor_GetCurrentInvoices", {"debtorHandle" => {"Number" => "1"}}, :success)
68
+ subject.handle = Economic::Entity::Handle.new(:number => "1")
69
+ subject.get_current_invoices.each do |i|
70
+ expect(i).to be_instance_of(Economic::CurrentInvoice)
71
+ end
72
+ end
73
+ end
74
+
61
75
  describe ".invoices" do
62
76
  it "return nothing if no handle" do
63
77
  expect(subject.invoices).to be_empty
@@ -46,6 +46,15 @@ describe Economic::CashBookEntryProxy do
46
46
  end
47
47
  end
48
48
 
49
+ describe "#create_manual_debtor_invoice" do
50
+ it "should create a debtor invoice and then return the created cash book entry" do
51
+ stub_request("CashBookEntry_CreateManualDebtorInvoice", nil, :success)
52
+ stub_request("CashBookEntry_GetData", {"entityHandle" => {"Id1" => 13, "Id2" => 14}}, :success)
53
+ cash_book_entry = subject.create_manual_debtor_invoice(:debtor_handle => {:number => 2}, :contra_account_handle => {:number => 3})
54
+ expect(cash_book_entry).to be_instance_of(Economic::CashBookEntry)
55
+ end
56
+ end
57
+
49
58
  describe "#create_creditor_invoice" do
50
59
  it "should create a creditor invoice and then return the created cash book entry" do
51
60
  stub_request("CashBookEntry_CreateCreditorInvoice", nil, :success)
@@ -136,5 +136,16 @@ describe Economic::CurrentInvoiceProxy do
136
136
  expect(current_invoices.first).to be_instance_of(Economic::CurrentInvoice)
137
137
  expect(current_invoices.last).to be_instance_of(Economic::CurrentInvoice)
138
138
  end
139
+
140
+ context "owner is a debtor" do
141
+ let(:debtor) { make_debtor }
142
+ subject { Economic::CurrentInvoiceProxy.new(debtor) }
143
+
144
+ it "asks for the owners current invoices" do
145
+ expect(debtor).to receive(:get_current_invoices) { [] }
146
+
147
+ subject.all
148
+ end
149
+ end
139
150
  end
140
151
  end
@@ -0,0 +1,11 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
3
+ <soap:Body>
4
+ <CashBookEntry_CreateManualDebtorInvoiceResponse xmlns="http://e-conomic.com">
5
+ <CashBookEntry_CreateManualDebtorInvoiceResult>
6
+ <Id1>13</Id1>
7
+ <Id2>14</Id2>
8
+ </CashBookEntry_CreateManualDebtorInvoiceResult>
9
+ </CashBookEntry_CreateManualDebtorInvoiceResponse>
10
+ </soap:Body>
11
+ </soap:Envelope>
@@ -0,0 +1,15 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
3
+ <soap:Body>
4
+ <Debtor_GetCurrentInvoicesResponse xmlns="http://e-conomic.com">
5
+ <Debtor_GetCurrentInvoicesResult>
6
+ <CurrentInvoiceHandle>
7
+ <Id>1</Id>
8
+ </CurrentInvoiceHandle>
9
+ <CurrentInvoiceHandle>
10
+ <Id>2</Id>
11
+ </CurrentInvoiceHandle>
12
+ </Debtor_GetCurrentInvoicesResult>
13
+ </Debtor_GetCurrentInvoicesResponse>
14
+ </soap:Body>
15
+ </soap:Envelope>
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rconomic
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1
4
+ version: 0.7.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jakob Skjerning
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-02-21 00:00:00.000000000 Z
11
+ date: 2019-06-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: savon
@@ -164,6 +164,7 @@ files:
164
164
  - spec/fixtures/cash_book_entry_create_debtor_payment/success.xml
165
165
  - spec/fixtures/cash_book_entry_create_finance_voucher/success.xml
166
166
  - spec/fixtures/cash_book_entry_create_from_data/success.xml
167
+ - spec/fixtures/cash_book_entry_create_manual_debtor_invoice/success.xml
167
168
  - spec/fixtures/cash_book_entry_get_data/success.xml
168
169
  - spec/fixtures/cash_book_entry_set_due_date/success.xml
169
170
  - spec/fixtures/cash_book_get_all/multiple.xml
@@ -220,6 +221,7 @@ files:
220
221
  - spec/fixtures/debtor_find_by_telephone_and_fax_number/not_found.xml
221
222
  - spec/fixtures/debtor_get_all/multiple.xml
222
223
  - spec/fixtures/debtor_get_all/single.xml
224
+ - spec/fixtures/debtor_get_current_invoices/success.xml
223
225
  - spec/fixtures/debtor_get_data/success.xml
224
226
  - spec/fixtures/debtor_get_data_array/multiple.xml
225
227
  - spec/fixtures/debtor_get_debtor_contacts/multiple.xml
@@ -295,7 +297,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
295
297
  version: '0'
296
298
  requirements: []
297
299
  rubyforge_project:
298
- rubygems_version: 2.7.6
300
+ rubygems_version: 2.7.9
299
301
  signing_key:
300
302
  specification_version: 4
301
303
  summary: Wrapper for e-conomic.dk's SOAP API.