twinfieldrb 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. checksums.yaml +7 -0
  2. data/.github/workflows/codeql-analysis.yml +70 -0
  3. data/.github/workflows/rspec.yml +33 -0
  4. data/.gitignore +6 -0
  5. data/.rspec +1 -0
  6. data/CHANGELOG.md +15 -0
  7. data/Gemfile +4 -0
  8. data/README.md +120 -0
  9. data/Rakefile +1 -0
  10. data/lib/twinfield/abstract_model.rb +7 -0
  11. data/lib/twinfield/api/base_api.rb +50 -0
  12. data/lib/twinfield/api/finder.rb +45 -0
  13. data/lib/twinfield/api/o_auth_session.rb +58 -0
  14. data/lib/twinfield/api/process.rb +44 -0
  15. data/lib/twinfield/api/session.rb +170 -0
  16. data/lib/twinfield/browse/transaction/cost_center.rb +145 -0
  17. data/lib/twinfield/browse/transaction/customer.rb +413 -0
  18. data/lib/twinfield/browse/transaction/general_ledger.rb +144 -0
  19. data/lib/twinfield/configuration.rb +49 -0
  20. data/lib/twinfield/create/cost_center.rb +39 -0
  21. data/lib/twinfield/create/creditor.rb +88 -0
  22. data/lib/twinfield/create/debtor.rb +88 -0
  23. data/lib/twinfield/create/error.rb +30 -0
  24. data/lib/twinfield/create/general_ledger.rb +39 -0
  25. data/lib/twinfield/create/transaction.rb +97 -0
  26. data/lib/twinfield/customer.rb +612 -0
  27. data/lib/twinfield/helpers/parsers.rb +23 -0
  28. data/lib/twinfield/helpers/transaction_match.rb +40 -0
  29. data/lib/twinfield/request/find.rb +149 -0
  30. data/lib/twinfield/request/list.rb +66 -0
  31. data/lib/twinfield/request/read.rb +111 -0
  32. data/lib/twinfield/sales_invoice.rb +409 -0
  33. data/lib/twinfield/transaction.rb +112 -0
  34. data/lib/twinfield/version.rb +5 -0
  35. data/lib/twinfield.rb +89 -0
  36. data/script/boot.rb +58 -0
  37. data/script/console +2 -0
  38. data/spec/fixtures/cluster/finder/ivt.xml +1 -0
  39. data/spec/fixtures/cluster/processxml/columns/sales_transactions.xml +312 -0
  40. data/spec/fixtures/cluster/processxml/customer/create_success.xml +100 -0
  41. data/spec/fixtures/cluster/processxml/customer/read_success.xml +93 -0
  42. data/spec/fixtures/cluster/processxml/customer/update_success.xml +1 -0
  43. data/spec/fixtures/cluster/processxml/invoice/create_error.xml +8 -0
  44. data/spec/fixtures/cluster/processxml/invoice/create_final_error.xml +67 -0
  45. data/spec/fixtures/cluster/processxml/invoice/create_success.xml +64 -0
  46. data/spec/fixtures/cluster/processxml/invoice/read_not_found.xml +1 -0
  47. data/spec/fixtures/cluster/processxml/invoice/read_success.xml +106 -0
  48. data/spec/fixtures/cluster/processxml/read/deb.xml +12 -0
  49. data/spec/fixtures/cluster/processxml/response.xml +8 -0
  50. data/spec/fixtures/login/session/wsdl.xml +210 -0
  51. data/spec/spec_helper.rb +17 -0
  52. data/spec/stubs/finder_stubs.rb +19 -0
  53. data/spec/stubs/processxml_stubs.rb +41 -0
  54. data/spec/stubs/session_stubs.rb +28 -0
  55. data/spec/twinfield/api/oauth_session_spec.rb +37 -0
  56. data/spec/twinfield/api/process_spec.rb +7 -0
  57. data/spec/twinfield/browse/transaction/cost_center_spec.rb +60 -0
  58. data/spec/twinfield/browse/transaction/general_ledger_spec.rb +60 -0
  59. data/spec/twinfield/browse/transaction/transaction_spec.rb +72 -0
  60. data/spec/twinfield/config_spec.rb +60 -0
  61. data/spec/twinfield/customer_spec.rb +326 -0
  62. data/spec/twinfield/request/find_spec.rb +24 -0
  63. data/spec/twinfield/request/list_spec.rb +58 -0
  64. data/spec/twinfield/request/read_spec.rb +26 -0
  65. data/spec/twinfield/sales_invoice_spec.rb +253 -0
  66. data/spec/twinfield/session_spec.rb +77 -0
  67. data/spec/twinfield/transaction_spec.rb +149 -0
  68. data/twinfieldrb.gemspec +24 -0
  69. data/wsdls/accounting/finder.wsdl +157 -0
  70. data/wsdls/accounting/process.wsdl +199 -0
  71. data/wsdls/accounting/session.wsdl +452 -0
  72. data/wsdls/accounting2/finder.wsdl +157 -0
  73. data/wsdls/accounting2/process.wsdl +199 -0
  74. data/wsdls/api.accounting/finder.wsdl +157 -0
  75. data/wsdls/api.accounting/process.wsdl +199 -0
  76. data/wsdls/session.wsdl +210 -0
  77. data/wsdls/update +10 -0
  78. metadata +196 -0
@@ -0,0 +1,145 @@
1
+ module Twinfield
2
+ module Browse
3
+ module Transaction
4
+ class CostCenter < Twinfield::AbstractModel
5
+ extend Twinfield::Helpers::Parsers
6
+ include Twinfield::Helpers::TransactionMatch
7
+
8
+ attr_accessor :number, :yearperiod, :currency, :value, :status, :dim1, :dim2, :key, :code
9
+
10
+ class << self
11
+ def initialize_from_columns_response_row(transaction_xml)
12
+ new(
13
+ number: transaction_xml.css("td[field='fin.trs.head.number']").text,
14
+ yearperiod: transaction_xml.css("td[field='fin.trs.head.yearperiod']").text,
15
+ currency: transaction_xml.css("td[field='fin.trs.head.curcode']").text,
16
+ value: transaction_xml.css("td[field='fin.trs.line.valuesigned']").text&.to_f,
17
+ status: transaction_xml.css("td[field='fin.trs.head.status']").text,
18
+ dim1: transaction_xml.css("td[field='fin.trs.line.dim1']").text,
19
+ dim2: transaction_xml.css("td[field='fin.trs.line.dim2']").text,
20
+ key: transaction_xml.css("key").text.gsub(/\s/, ""),
21
+ code: transaction_xml.css("td[field='fin.trs.head.code']").text
22
+ )
23
+ end
24
+
25
+ def find(customer_code: nil, invoice_number: nil, code: nil, number: nil)
26
+ where(customer_code: customer_code, invoice_number: invoice_number, code: code, number: number).first
27
+ end
28
+
29
+ # @param years: range
30
+ #
31
+ def where(years: ((Date.today.year - 30)..Date.today.year), dim1: nil, dim2: nil)
32
+ build_request = %(
33
+ <column>
34
+ <field>fin.trs.head.yearperiod</field>
35
+ <label>Periode</label>
36
+ <visible>true</visible>
37
+ <ask>false</ask>
38
+ <operator>between</operator>
39
+ <from>#{years.first}/01</from>
40
+ <to>#{years.last}/12</to>
41
+ <finderparam/>
42
+ </column>
43
+ <column>
44
+ <field>fin.trs.line.dim1</field>
45
+ <label>Grootboek</label>
46
+ <visible>true</visible>
47
+ <ask>false</ask>
48
+ <operator>between</operator>
49
+ <from>#{dim1}</from>
50
+ <to>#{dim1}</to>
51
+ <finderparam/>
52
+ </column>
53
+ <column>
54
+ <field>fin.trs.line.dim2</field>
55
+ <label>Kostenplaats</label>
56
+ <visible>true</visible>
57
+ <ask>false</ask>
58
+ <operator>between</operator>
59
+ <from>#{dim2}</from>
60
+ <to>#{dim2}</to>
61
+ <finderparam>dimtype=KPL</finderparam>
62
+ </column>
63
+ <column>
64
+ <field>fin.trs.head.code</field>
65
+ <label>Dagboek</label>
66
+ <visible>true</visible>
67
+ <ask>false</ask>
68
+ <operator>equal</operator>
69
+ <from/>
70
+ <to/>
71
+ <finderparam>hidden=1</finderparam>
72
+ </column>
73
+ <column>
74
+ <field>fin.trs.head.number</field>
75
+ <label>Boekst.nr.</label>
76
+ <visible>true</visible>
77
+ <ask>false</ask>
78
+ <operator>between</operator>
79
+ <from/>
80
+ <to/>
81
+ <finderparam/>
82
+ </column>
83
+ <column>
84
+ <field>fin.trs.head.curcode</field>
85
+ <label>Valuta</label>
86
+ <visible>true</visible>
87
+ <ask>false</ask>
88
+ <operator>none</operator>
89
+ <from/>
90
+ <to/>
91
+ <finderparam/>
92
+ </column>
93
+ <column>
94
+ <field>fin.trs.line.valuesigned</field>
95
+ <label>Bedrag</label>
96
+ <visible>true</visible>
97
+ <ask>false</ask>
98
+ <operator>between</operator>
99
+ <from/>
100
+ <to/>
101
+ <finderparam/>
102
+ </column>
103
+ <column>
104
+ <field>fin.trs.head.status</field>
105
+ <label>Status</label>
106
+ <visible>true</visible>
107
+ <ask>false</ask>
108
+ <operator>equal</operator>
109
+ <from>normal</from>
110
+ <to/>
111
+ <finderparam/>
112
+ </column>
113
+ )
114
+
115
+ response = Twinfield::Api::Process.request(:process_xml_string) do
116
+ %(
117
+ <columns code="900">
118
+ #{build_request}
119
+ </columns>
120
+ )
121
+ end
122
+
123
+ xml = Nokogiri::XML(response.body[:process_xml_string_response][:process_xml_string_result])
124
+
125
+ xml.css("tr").map do |transaction_xml|
126
+ Twinfield::Browse::Transaction::CostCenter.initialize_from_columns_response_row(transaction_xml)
127
+ end
128
+ end
129
+ end
130
+
131
+ def initialize(number: nil, yearperiod: nil, currency: "EUR", value: nil, status: nil, dim1: nil, dim2: nil, key: nil, code: nil)
132
+ self.number = number
133
+ self.yearperiod = yearperiod
134
+ self.currency = currency
135
+ self.value = value
136
+ self.status = status
137
+ self.dim1 = dim1
138
+ self.dim2 = dim2
139
+ self.key = key
140
+ self.code = code
141
+ end
142
+ end
143
+ end
144
+ end
145
+ end
@@ -0,0 +1,413 @@
1
+ # These models are the result of a browse response; and sadly do not map 1 on 1 on a e.g. Transaction; and reconstruction isn't possible with just the results from the browse response.
2
+
3
+ module Twinfield
4
+ module Browse
5
+ module Transaction
6
+ class Customer < Twinfield::AbstractModel
7
+ extend Twinfield::Helpers::Parsers
8
+ include Twinfield::Helpers::TransactionMatch
9
+
10
+ attr_accessor :invoice_number, :customer_code, :key, :currency, :value, :open_value, :available_for_payruns, :status, :number, :date, :code
11
+
12
+ class << self
13
+ def initialize_from_columns_response_row(transaction_xml)
14
+ # "<tr>
15
+ # <td field=\"fin.trs.head.number\" hideforuser=\"false\" type=\"Decimal\">202000011</td>
16
+ # <td field=\"fin.trs.line.invnumber\" hideforuser=\"false\" type=\"String\">20200198</td>
17
+ # <td field=\"fin.trs.head.curcode\" hideforuser=\"false\" type=\"String\">EUR</td>
18
+ # <td field=\"fin.trs.line.valuesigned\" hideforuser=\"false\" type=\"Value\">2200.00</td>
19
+ # <td field=\"fin.trs.line.openvaluesigned\" hideforuser=\"false\" type=\"Value\">2200.00</td>
20
+ # <td field=\"fin.trs.line.availableforpayruns\" hideforuser=\"false\" type=\"String\" name=\"Ja\">true</td>
21
+ # <td field=\"fin.trs.line.matchstatus\" hideforuser=\"false\" type=\"String\" name=\"Beschikbaar\">available</td>
22
+ # <td field=\"fin.trs.line.dim2\" hideforuser=\"false\" type=\"String\">1003</td>
23
+ # <key> <office>NLA002058</office> <code>VRK</code> <number>202000011</number> <line>1</line> </key>
24
+ # </tr>"
25
+ # p
26
+ new(
27
+ number: transaction_xml.css("td[field='fin.trs.head.number']").text,
28
+ invoice_number: transaction_xml.css("td[field='fin.trs.line.invnumber']").text,
29
+ currency: transaction_xml.css("td[field='fin.trs.head.curcode']").text,
30
+ value: transaction_xml.css("td[field='fin.trs.line.valuesigned']").text&.to_f,
31
+ open_value: transaction_xml.css("td[field='fin.trs.line.openvaluesigned']").text&.to_f,
32
+ available_for_payruns: transaction_xml.css("td[field='fin.trs.line.availableforpayruns']").text&.to_f,
33
+ status: transaction_xml.css("td[field='fin.trs.line.matchstatus']").text,
34
+ customer_code: transaction_xml.css("td[field='fin.trs.line.dim2']").text,
35
+ key: transaction_xml.css("key").text.gsub(/\s/, ""),
36
+ date: parse_date(transaction_xml.css("td[field='fin.trs.head.date']").text),
37
+ code: transaction_xml.css("td[field='fin.trs.head.code']").text
38
+ )
39
+ end
40
+
41
+ def find(customer_code: nil, invoice_number: nil, code: nil, number: nil)
42
+ where(customer_code: customer_code, invoice_number: invoice_number, code: code, number: number).first
43
+ end
44
+
45
+ def where(customer_code: nil, invoice_number: nil, code: nil, number: nil, years: ((Date.today.year - 30)..Date.today.year))
46
+ # <?xml version="1.0"?>
47
+ # <browse result="1">
48
+ # <office name="Heden" shortname="">NLA002058</office>
49
+ # <code>100</code>
50
+ # <name>Debiteurenkaart</name>
51
+ # <shortname>Debiteurenkaart</shortname>
52
+ # <visible>true</visible>
53
+ # <columns code="100">
54
+ # <column id="2">
55
+ # <field>fin.trs.head.code</field>
56
+ # <label>Dagboek</label>
57
+ # <visible>true</visible>
58
+ # <ask>true</ask>
59
+ # <operator>equal</operator>
60
+ # <from/>
61
+ # <to/>
62
+ # <finderparam>hidden=1</finderparam>
63
+ # </column>
64
+ # <column id="3">
65
+ # <field>fin.trs.head.shortname</field>
66
+ # <label>Naam</label>
67
+ # <visible>true</visible>
68
+ # <ask>false</ask>
69
+ # <operator>none</operator>
70
+ # <from/>
71
+ # <to/>
72
+ # <finderparam/>
73
+ # </column>
74
+ # <column id="4">
75
+ # <field>fin.trs.head.number</field>
76
+ # <label>Boekst.nr.</label>
77
+ # <visible>true</visible>
78
+ # <ask>true</ask>
79
+ # <operator>between</operator>
80
+ # <from/>
81
+ # <to/>
82
+ # <finderparam/>
83
+ # </column>
84
+ # <column id="5">
85
+ # <field>fin.trs.head.status</field>
86
+ # <label>Status</label>
87
+ # <visible>true</visible>
88
+ # <ask>true</ask>
89
+ # <operator>equal</operator>
90
+ # <from>normal</from>
91
+ # <to/>
92
+ # <finderparam/>
93
+ # </column>
94
+ # <column id="6">
95
+ # <field>fin.trs.head.date</field>
96
+ # <label>Boekdatum</label>
97
+ # <visible>true</visible>
98
+ # <ask>false</ask>
99
+ # <operator>none</operator>
100
+ # <from/>
101
+ # <to/>
102
+ # <finderparam/>
103
+ # </column>
104
+ # <column id="7">
105
+ # <field>fin.trs.line.dim2</field>
106
+ # <label>Debiteur</label>
107
+ # <visible>true</visible>
108
+ # <ask>true</ask>
109
+ # <operator>between</operator>
110
+ # <from/>
111
+ # <to/>
112
+ # <finderparam>dimtype=DEB</finderparam>
113
+ # </column>
114
+ # <column id="8">
115
+ # <field>fin.trs.line.dim2name</field>
116
+ # <label>Naam</label>
117
+ # <visible>true</visible>
118
+ # <ask>false</ask>
119
+ # <operator>none</operator>
120
+ # <from/>
121
+ # <to/>
122
+ # <finderparam/>
123
+ # </column>
124
+ # <column id="9">
125
+ # <field>fin.trs.head.curcode</field>
126
+ # <label>Valuta</label>
127
+ # <visible>false</visible>
128
+ # <ask>false</ask>
129
+ # <operator>equal</operator>
130
+ # <from/>
131
+ # <to/>
132
+ # <finderparam/>
133
+ # </column>
134
+ # <column id="10">
135
+ # <field>fin.trs.line.valuesigned</field>
136
+ # <label>Bedrag</label>
137
+ # <visible>false</visible>
138
+ # <ask>false</ask>
139
+ # <operator>between</operator>
140
+ # <from/>
141
+ # <to/>
142
+ # <finderparam/>
143
+ # </column>
144
+ # <column id="11">
145
+ # <field>fin.trs.line.basevaluesigned</field>
146
+ # <label>Euro</label>
147
+ # <visible>true</visible>
148
+ # <ask>true</ask>
149
+ # <operator>between</operator>
150
+ # <from/>
151
+ # <to/>
152
+ # <finderparam/>
153
+ # </column>
154
+ # <column id="12">
155
+ # <field>fin.trs.line.repvaluesigned</field>
156
+ # <label/>
157
+ # <visible>false</visible>
158
+ # <ask>false</ask>
159
+ # <operator>between</operator>
160
+ # <from/>
161
+ # <to/>
162
+ # <finderparam/>
163
+ # </column>
164
+ # <column id="13">
165
+ # <field>fin.trs.line.openbasevaluesigned</field>
166
+ # <label>Openstaand bedrag</label>
167
+ # <visible>true</visible>
168
+ # <ask>false</ask>
169
+ # <operator>none</operator>
170
+ # <from/>
171
+ # <to/>
172
+ # <finderparam/>
173
+ # </column>
174
+ # <column id="14">
175
+ # <field>fin.trs.line.invnumber</field>
176
+ # <label>Factuurnr.</label>
177
+ # <visible>true</visible>
178
+ # <ask>true</ask>
179
+ # <operator>equal</operator>
180
+ # <from/>
181
+ # <to/>
182
+ # <finderparam/>
183
+ # </column>
184
+ # <column id="15">
185
+ # <field>fin.trs.line.datedue</field>
186
+ # <label>Vervaldatum</label>
187
+ # <visible>true</visible>
188
+ # <ask>false</ask>
189
+ # <operator>none</operator>
190
+ # <from/>
191
+ # <to/>
192
+ # <finderparam/>
193
+ # </column>
194
+ # <column id="16">
195
+ # <field>fin.trs.line.matchstatus</field>
196
+ # <label>Betaalstatus</label>
197
+ # <visible>true</visible>
198
+ # <ask>true</ask>
199
+ # <operator>equal</operator>
200
+ # <from/>
201
+ # <to/>
202
+ # <finderparam/>
203
+ # </column>
204
+ # <column id="17">
205
+ # <field>fin.trs.line.matchnumber</field>
206
+ # <label>Betaalnr.</label>
207
+ # <visible>true</visible>
208
+ # <ask>false</ask>
209
+ # <operator>none</operator>
210
+ # <from/>
211
+ # <to/>
212
+ # <finderparam/>
213
+ # </column>
214
+ # <column id="18">
215
+ # <field>fin.trs.line.matchdate</field>
216
+ # <label>Betaaldatum</label>
217
+ # <visible>true</visible>
218
+ # <ask>true</ask>
219
+ # <operator>between</operator>
220
+ # <from/>
221
+ # <to/>
222
+ # <finderparam/>
223
+ # </column>
224
+ # <column id="19">
225
+ # <field>fin.trs.line.openvaluesigned</field>
226
+ # <label>Openstaand bedrag transactievaluta</label>
227
+ # <visible>false</visible>
228
+ # <ask>false</ask>
229
+ # <operator>none</operator>
230
+ # <from/>
231
+ # <to/>
232
+ # <finderparam/>
233
+ # </column>
234
+ # <column id="20">
235
+ # <field>fin.trs.line.availableforpayruns</field>
236
+ # <label>Beschikbaar voor betaalrun</label>
237
+ # <visible>false</visible>
238
+ # <ask>false</ask>
239
+ # <operator>none</operator>
240
+ # <from/>
241
+ # <to/>
242
+ # <finderparam/>
243
+ # </column>
244
+ # <column id="21">
245
+ # <field>fin.trs.line.modified</field>
246
+ # <label>Wijzigingsdatum</label>
247
+ # <visible>true</visible>
248
+ # <ask>true</ask>
249
+ # <operator>between</operator>
250
+ # <from/>
251
+ # <to/>
252
+ # <finderparam/>
253
+ # </column>
254
+ # </columns>
255
+ # </browse>
256
+
257
+ build_request = %(
258
+ <sort>
259
+ <field>fin.trs.head.code</field>
260
+ </sort>
261
+ <column>
262
+ <field>fin.trs.head.yearperiod</field>
263
+ <label>Periode</label>
264
+ <visible>true</visible>
265
+ <ask>false</ask>
266
+ <operator>between</operator>
267
+ <from>#{years.first}/01</from>
268
+ <to>#{years.last}/12</to>
269
+ <finderparam/>
270
+ </column>
271
+ <column>
272
+ <field>fin.trs.head.shortname</field>
273
+ <label>Naam</label>
274
+ <visible>true</visible>
275
+ </column>
276
+ <column>
277
+ <field>fin.trs.head.date</field>
278
+ <label>Boekdatum</label>
279
+ <visible>true</visible>
280
+ </column>
281
+ <column>
282
+ <field>fin.trs.head.curcode</field>
283
+ <label>currency</label>
284
+ <visible>true</visible>
285
+ </column>
286
+ <column>
287
+ <field>fin.trs.line.valuesigned</field>
288
+ <label>value</label>
289
+ <visible>true</visible>
290
+ </column>
291
+ <column>
292
+ <field>fin.trs.line.openvaluesigned</field>
293
+ <label>open_value</label>
294
+ <visible>true</visible>
295
+ </column>
296
+ <column>
297
+ <field>fin.trs.line.availableforpayruns</field>
298
+ <label>available_for_payruns</label>
299
+ <visible>true</visible>
300
+ </column>
301
+ <column>
302
+ <field>fin.trs.line.matchstatus</field>
303
+ <label>status</label>
304
+ <visible>true</visible>
305
+ </column>
306
+ <column>
307
+ <field>fin.trs.line.dim2</field>
308
+ <label>customer_code</label>
309
+ <visible>true</visible>
310
+ <from>#{customer_code}</from>
311
+ <to>#{customer_code}</to>
312
+ <operator>between</operator>
313
+ </column>
314
+ )
315
+
316
+ build_request += if code
317
+ "<column>
318
+ <field>fin.trs.head.code</field>
319
+ <label>Code</label>
320
+ <visible>true</visible>
321
+ <ask>true</ask>
322
+ <operator>equal</operator>
323
+ <from>#{code}</from>
324
+ <to>#{code}</to>
325
+
326
+ <finderparam>#{code}</finderparam>
327
+ </column>
328
+ "
329
+ else
330
+ "<column>
331
+ <field>fin.trs.head.code</field>
332
+ <label>Code</label>
333
+ <visible>true</visible>
334
+ </column>"
335
+ end
336
+
337
+ build_request += if invoice_number
338
+ "<column>
339
+ <field>fin.trs.line.invnumber</field>
340
+ <label>invoice_number</label>
341
+ <visible>true</visible>
342
+ <ask>true</ask>
343
+ <operator>equal</operator>
344
+ <from>#{invoice_number}</from>
345
+ <to>#{invoice_number}</to>
346
+ <finderparam>#{invoice_number}</finderparam>
347
+ </column>
348
+ "
349
+ else
350
+ "<column>
351
+ <field>fin.trs.line.invnumber</field>
352
+ <label>invoice_number</label>
353
+ <visible>true</visible>
354
+ </column>"
355
+ end
356
+
357
+ build_request += if number
358
+ "<column>
359
+ <field>fin.trs.head.number</field>
360
+ <label>Boekst.nr.</label>
361
+ <visible>true</visible>
362
+ <ask>true</ask>
363
+ <operator>between</operator>
364
+ <from>#{number}</from>
365
+ <to>#{number}</to>
366
+ </column>
367
+ "
368
+ else
369
+ "<column>
370
+ <field>fin.trs.head.number</field>
371
+ <label>number</label>
372
+ <visible>true</visible>
373
+ </column>"
374
+ end
375
+
376
+ response = Twinfield::Api::Process.request(:process_xml_string) do
377
+ %(
378
+ <columns code="100">
379
+ #{build_request}
380
+ </columns>
381
+ )
382
+ end
383
+
384
+ xml = Nokogiri::XML(response.body[:process_xml_string_response][:process_xml_string_result])
385
+
386
+ transactions_xml = xml.css("tr")
387
+
388
+ transactions = []
389
+ transactions_xml.each do |transaction_xml|
390
+ transactions << Twinfield::Browse::Transaction::Customer.initialize_from_columns_response_row(transaction_xml)
391
+ end
392
+
393
+ transactions
394
+ end
395
+ end
396
+
397
+ def initialize(code:, invoice_number: nil, customer_code: nil, key: nil, currency: "EUR", value: nil, open_value: nil, available_for_payruns: nil, status: nil, number: nil, date: nil)
398
+ self.invoice_number = invoice_number
399
+ self.customer_code = customer_code
400
+ self.key = key
401
+ self.currency = currency
402
+ self.value = value
403
+ self.open_value = open_value
404
+ self.available_for_payruns = available_for_payruns
405
+ self.status = status
406
+ self.number = number
407
+ self.date = date
408
+ self.code = code
409
+ end
410
+ end
411
+ end
412
+ end
413
+ end