ruconomic 0.9.7 → 0.9.8

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 59dd2113ec86d92bb907b7f464ae480cd4339533
4
- data.tar.gz: 5e190aeabebf004bc23aa80b93dedab9bde9907c
3
+ metadata.gz: 271118522e73b3ba82a8ba62c7cd65459e491802
4
+ data.tar.gz: 4c725caea918b671b1a3ea7d085d815f026a58aa
5
5
  SHA512:
6
- metadata.gz: 7fd730efd1df1656f06d36f10f53f2ba2c831c42f981cc862e26cd615fe874b4eb3140915392e3f673eeb081bd3b093c6f481cc98b68bbdb1b7fd2924857a94a
7
- data.tar.gz: 1be82471bb036f1eb5df59ff9122930bd7b4f653719818d4f080c8f8534c971afc2fe1f9e09eadb60f3d81624dbc91d6b13b7ab573c5a5138daf962812eef8cf
6
+ metadata.gz: 73e4ca801e6c5d4c2bd802b1a49e00188fcf00c730bcca9f4c187aaa3bf24112ecfc7ba3af67de5ebfad17dff66f71e2f6f5c52e3a4b8ad2f3c5d729bb94092c
7
+ data.tar.gz: e6cf323279ed3f659096933a7b7fb406780b79c75f82139371ea3942b4e9b8981248c9b5555d68daf69e78eb87c0136a82d6822c1087666959f1df00b53ad463
data/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # Changelog
2
2
 
3
+ # 0.9.8
4
+
5
+ - Invoice: get all (olepalm)
6
+ - CashBook: get all (olepalm)
7
+ - CurrentInvoice: delete (olepalm)
8
+ - Debtor: get layout (olepalm)
9
+ - CurrentInvoice: book (olepalm)
10
+ - CurrentInvoiceLine: create from data (olepalm)
11
+ - Debtor: get term of payment (olepalm)
12
+ - CurrentInvoice: set due date (olepalm)
13
+ - CurrentInvoice: create (olepalm)
14
+
15
+
16
+ # 0.9.7
17
+
18
+ - Fix missing require (twarberg)
19
+
3
20
  # 0.9.6
4
21
 
5
22
  - Handle nil-response when searching for invoices (twarberg)
data/README.md CHANGED
@@ -84,7 +84,9 @@ You can find the latest API documentation at [http://rdoc.info/github/coherify/r
84
84
 
85
85
  ## Contributors
86
86
 
87
- Open for vacancy
87
+ * @olepalm / Substance Lab
88
+ * @twaberg / Interface
89
+ * @dinesh / QuickPay
88
90
 
89
91
  ## License
90
92
 
@@ -30,13 +30,17 @@ module Ruconomic
30
30
  # Returns a cash book data object for a given cash book.
31
31
  # Parameters: entityHandle: A handle for the cash book.
32
32
  #
33
- # @note TODO: This method was autogenerated from the WSDL - see https://github.com/coherify/ruconomic#contributing"
34
33
  # @see https://api.e-conomic.com/secure/api1/EconomicWebService.asmx?op=CashBook_GetData
35
34
  # @return [Hash] The body content of the SOAP response.
36
- def self.get_data
35
+ def self.get_data(number)
37
36
  response = invoke('CashBook_GetData') do |message|
38
- raise "TODO: This method was autogenerated from the WSDL - see https://github.com/coherify/ruconomic#contributing"
37
+ message.add 'entityHandle' do |handle|
38
+ handle.add 'Number', number
39
+ end
39
40
  end
41
+
42
+ response.to_hash[:cash_book_get_data_response] \
43
+ [:cash_book_get_data_result]
40
44
  end
41
45
 
42
46
  # Returns cash book data objects for a given set of cash book handles.
@@ -53,13 +57,12 @@ module Ruconomic
53
57
 
54
58
  # Return handles for all cash books.
55
59
  #
56
- # @note TODO: This method was autogenerated from the WSDL - see https://github.com/coherify/ruconomic#contributing"
57
60
  # @see https://api.e-conomic.com/secure/api1/EconomicWebService.asmx?op=CashBook_GetAll
58
61
  # @return [Hash] The body content of the SOAP response.
59
62
  def self.get_all
60
- response = invoke('CashBook_GetAll') do |message|
61
- raise "TODO: This method was autogenerated from the WSDL - see https://github.com/coherify/ruconomic#contributing"
62
- end
63
+ response = invoke('CashBook_GetAll')
64
+
65
+ response.to_hash[:cash_book_get_all_response][:cash_book_get_all_result]
63
66
  end
64
67
 
65
68
  # Returns a handle for the cash book with the given number.
@@ -135,13 +138,17 @@ module Ruconomic
135
138
 
136
139
  # Gets the entries in the cashbook.
137
140
  #
138
- # @note TODO: This method was autogenerated from the WSDL - see https://github.com/coherify/ruconomic#contributing"
139
141
  # @see https://api.e-conomic.com/secure/api1/EconomicWebService.asmx?op=CashBook_GetEntries
140
142
  # @return [Hash] The body content of the SOAP response.
141
- def self.get_entries
143
+ def self.get_entries(number)
142
144
  response = invoke('CashBook_GetEntries') do |message|
143
- raise "TODO: This method was autogenerated from the WSDL - see https://github.com/coherify/ruconomic#contributing"
145
+ message.add 'cashBookHandle' do |handle|
146
+ handle.add 'Number', number
147
+ end
144
148
  end
149
+
150
+ response.to_hash[:cash_book_get_entries_response] \
151
+ [:cash_book_get_entries_result]
145
152
  end
146
153
 
147
154
  # Delete all entries from a cash book. Action that cannot be undone.
@@ -234,13 +234,55 @@ module Ruconomic
234
234
  # Creates a new cash book entry from a data object.
235
235
  # Parameters: data: The data object that specifies the properties of the new cash book entry.
236
236
  #
237
- # @note TODO: This method was autogenerated from the WSDL - see https://github.com/coherify/ruconomic#contributing"
238
237
  # @see https://api.e-conomic.com/secure/api1/EconomicWebService.asmx?op=CashBookEntry_CreateFromData
239
238
  # @return [Hash] The body content of the SOAP response.
240
- def self.create_from_data
239
+ def self.create_from_data(entry_data)
241
240
  response = invoke('CashBookEntry_CreateFromData') do |message|
242
- raise "TODO: This method was autogenerated from the WSDL - see https://github.com/coherify/ruconomic#contributing"
243
- end
241
+ message.add 'data' do |data|
242
+ if handle_ids = entry_data.dig(:handle)
243
+ data.add 'Handle' do |handle|
244
+ handle.add 'Id1', handle_ids.dig(:id1)
245
+ handle.add 'Id2', handle_ids.dig(:id2)
246
+ end
247
+ end
248
+ data.add_optional('Id1', entry_data.dig(:id1))
249
+ data.add_optional('Id2', entry_data.dig(:id2))
250
+ data.add_optional('Type', entry_data.dig(:type))
251
+ data.add_handle('CashBookHandle', entry_data.dig(:cash_book_handle, :number))
252
+ data.add_handle('DebtorHandle', entry_data.dig(:debtor_handle, :number))
253
+ data.add_handle('CreditorHandle', entry_data.dig(:creditor_handle, :number))
254
+ data.add_handle('AccountHandle', entry_data.dig(:account_handle, :number))
255
+ data.add_handle('ContraAccountHandle', entry_data.dig(:contra_account_handle, :number))
256
+ data.add('Date', entry_data.dig(:date))
257
+ data.add('VoucherNumber', entry_data.dig(:voucher_number))
258
+ data.add('Text', entry_data.dig(:text))
259
+ data.add('AmountDefaultCurrency', entry_data.dig(:amount_default_currency))
260
+ data.add_handle('CurrencyHandle', entry_data.dig(:currency_handle, :code), 'Code')
261
+ data.add('Amount', entry_data.dig(:amount))
262
+ data.add_handle('VatAccountHandle', entry_data.dig(:vat_account_handle, :vat_code), 'VatCode')
263
+ data.add_handle('ContraVatAccountHandle', entry_data.dig(:contra_vat_account_handle, :vat_code), 'VatCode')
264
+ data.add_optional('DebtorInvoiceNumber', entry_data.dig(:debtor_invoice_number))
265
+ data.add_optional('CreditorInvoiceNumber', entry_data.dig(:creditor_invoice_number))
266
+ data.add('DueDate', entry_data.dig(:due_date))
267
+ data.add_handle('ContraVatAccountHandle', entry_data.dig(:contra_vat_account_handle, :vat_code), 'VatCode')
268
+ data.add_handle('DepartmentHandle', entry_data.dig(:department_handle, :number))
269
+ data.add_handle('DistributionKeyHandle', entry_data.dig(:distribution_key_handle, :number))
270
+ data.add_handle('ProjectHandle', entry_data.dig(:project_handle, :number))
271
+ data.add_handle('CostTypeHandle', entry_data.dig(:cost_type_handle, :number))
272
+ data.add_handle('BankPaymentTypeHandle', entry_data.dig(:bank_payment_type_handle, :number))
273
+ data.add_optional('BankPaymentCreditorId', entry_data.dig(:bank_payment_creditor_id))
274
+ data.add_optional('BankPaymentCreditorInvoiceId', entry_data.dig(:bank_payment_creditor_invoice_id))
275
+ data.add_handle('CapitaliseHandle', entry_data.dig(:capitalise_handle, :number))
276
+ data.add('StartDate', entry_data.dig(:start_date))
277
+ data.add('EndDate', entry_data.dig(:end_date))
278
+ data.add_handle('EmployeeHandle', entry_data.dig(:employee_handle, :number))
279
+ end
280
+ end
281
+
282
+ response.to_hash.dig(
283
+ :cash_book_entry_create_from_data_response,
284
+ :cash_book_entry_create_from_data_result
285
+ )
244
286
  end
245
287
 
246
288
  # Creates new cash book entries from data objects.
@@ -270,25 +270,33 @@ module Ruconomic
270
270
  # Gets the primary line of text of a current invoice.
271
271
  # Parameters: currentInvoiceHandle: Handle for the current invoice.
272
272
  #
273
- # @note TODO: This method was autogenerated from the WSDL - see https://github.com/coherify/ruconomic#contributing"
274
273
  # @see https://api.e-conomic.com/secure/api1/EconomicWebService.asmx?op=CurrentInvoice_GetTextLine1
275
274
  # @return [Hash] The body content of the SOAP response.
276
- def self.get_text_line1
275
+ def self.get_text_line1(id)
277
276
  response = invoke('CurrentInvoice_GetTextLine1') do |message|
278
- raise "TODO: This method was autogenerated from the WSDL - see https://github.com/coherify/ruconomic#contributing"
277
+ message.add 'currentInvoiceHandle' do |handle|
278
+ handle.add 'Id', id
279
+ end
279
280
  end
281
+
282
+ response.to_hash[:current_invoice_get_text_line1_response] \
283
+ [:current_invoice_get_text_line1_result]
280
284
  end
281
285
 
282
286
  # Set the primary line of a current invoice.
283
287
  # Parameters: currentInvoiceHandle: Handle for the current invoice. value: The new primary line of text of the current invoice.
284
288
  #
285
- # @note TODO: This method was autogenerated from the WSDL - see https://github.com/coherify/ruconomic#contributing"
286
289
  # @see https://api.e-conomic.com/secure/api1/EconomicWebService.asmx?op=CurrentInvoice_SetTextLine1
287
290
  # @return [Hash] The body content of the SOAP response.
288
- def self.set_text_line1
291
+ def self.set_text_line1(id, text)
289
292
  response = invoke('CurrentInvoice_SetTextLine1') do |message|
290
- raise "TODO: This method was autogenerated from the WSDL - see https://github.com/coherify/ruconomic#contributing"
293
+ message.add 'currentInvoiceHandle' do |handle|
294
+ handle.add 'Id', id
295
+ end
296
+ message.add 'value', text
291
297
  end
298
+
299
+ response.to_hash[:current_invoice_set_text_line1]
292
300
  end
293
301
 
294
302
  # Gets the secondary line of text of a current invoice.
@@ -306,13 +314,17 @@ module Ruconomic
306
314
  # Set the secondary line of a current invoice.
307
315
  # Parameters: currentInvoiceHandle: Handle for the current invoice. value: The new secondary line of text of the current invoice.
308
316
  #
309
- # @note TODO: This method was autogenerated from the WSDL - see https://github.com/coherify/ruconomic#contributing"
310
317
  # @see https://api.e-conomic.com/secure/api1/EconomicWebService.asmx?op=CurrentInvoice_SetTextLine2
311
318
  # @return [Hash] The body content of the SOAP response.
312
- def self.set_text_line2
319
+ def self.set_text_line2(id, text)
313
320
  response = invoke('CurrentInvoice_SetTextLine2') do |message|
314
- raise "TODO: This method was autogenerated from the WSDL - see https://github.com/coherify/ruconomic#contributing"
321
+ message.add 'currentInvoiceHandle' do |handle|
322
+ handle.add 'Id', id
323
+ end
324
+ message.add 'value', text
315
325
  end
326
+
327
+ response.to_hash[:current_invoice_set_text_line2]
316
328
  end
317
329
 
318
330
  # Gets the other reference of a current invoice.
@@ -473,14 +485,52 @@ module Ruconomic
473
485
 
474
486
  # Creates a new current invoice from a data object.
475
487
  # Parameters: data: The data object that specifies the properties of the new current invoice.
476
- #
477
- # @note TODO: This method was autogenerated from the WSDL - see https://github.com/coherify/ruconomic#contributing"
478
- # @see https://api.e-conomic.com/secure/api1/EconomicWebService.asmx?op=CurrentInvoice_CreateFromData
479
- # @return [Hash] The body content of the SOAP response.
480
- def self.create_from_data
488
+ # returns [String] with the created invoices id
489
+ def self.create_from_data(invoice_data)
481
490
  response = invoke('CurrentInvoice_CreateFromData') do |message|
482
- raise "TODO: This method was autogenerated from the WSDL - see https://github.com/coherify/ruconomic#contributing"
483
- end
491
+ message.add 'data' do |data|
492
+ data.add 'Id', invoice_data.fetch(:id, nil)
493
+ data.add 'DebtorHandle' do |debtor_handle|
494
+ debtor_handle.add 'Number', invoice_data.fetch(:debtor_handle, {}).fetch(:number, nil)
495
+ end
496
+ data.add 'DebtorName', invoice_data.fetch(:debtor_name, nil)
497
+ data.add 'DebtorAddress', invoice_data.fetch(:debtor_address, nil)
498
+ data.add 'DebtorPostalCode', invoice_data.fetch(:debtor_postal_code, nil)
499
+ data.add 'DebtorCity', invoice_data.fetch(:debtor_city, nil)
500
+ data.add 'DebtorCountry', invoice_data.fetch(:debtor_country, nil)
501
+ if attention_id = invoice_data.fetch(:attention_handle, {}).fetch(:id, nil)
502
+ data.add 'AttentionHandle' do |attention_handle|
503
+ attention_handle.add 'Id', attention_id
504
+ end
505
+ end
506
+ data.add 'Date', invoice_data.fetch(:date, nil)
507
+ data.add 'TermOfPaymentHandle' do |term_handle|
508
+ term_handle.add 'Id', invoice_data.fetch(:term_of_payment_handle, {}).fetch(:id, nil)
509
+ end
510
+ data.add 'DueDate', invoice_data.fetch(:due_date, nil)
511
+ data.add "CurrencyHandle" do |currency_handle|
512
+ currency_handle.add 'Code', invoice_data.fetch(:currency_handle, {}).fetch(:code, nil)
513
+ end
514
+ data.add 'ExchangeRate', invoice_data.fetch(:exchange_rate, nil)
515
+ data.add 'IsVatIncluded', invoice_data.fetch(:is_vat_included, nil)
516
+ data.add 'LayoutHandle' do |layout_handle|
517
+ layout_handle.add 'Id', invoice_data.fetch(:layout_handle, {}).fetch(:id, nil)
518
+ end
519
+ data.add 'DeliveryDate', invoice_data.fetch(:delivery_date, nil)
520
+ data.add 'Heading', invoice_data.fetch(:heading, nil)
521
+ data.add 'TextLine1', invoice_data.fetch(:text_line1, nil)
522
+ data.add 'TextLine2', invoice_data.fetch(:text_line2, nil)
523
+ data.add 'NetAmount', invoice_data.fetch(:net_amount, nil)
524
+ data.add 'VatAmount', invoice_data.fetch(:vat_amount, nil)
525
+ data.add 'GrossAmount', invoice_data.fetch(:gross_amount, nil)
526
+ data.add 'Margin', invoice_data.fetch(:margin, nil)
527
+ data.add 'MarginAsPercent', invoice_data.fetch(:margin_as_percent, nil)
528
+ end
529
+ end
530
+
531
+ response.to_hash[:current_invoice_create_from_data_response] \
532
+ [:current_invoice_create_from_data_result] \
533
+ [:id]
484
534
  end
485
535
 
486
536
  # Creates new current invoices from data objects.
@@ -525,10 +575,14 @@ module Ruconomic
525
575
  # @note TODO: This method was autogenerated from the WSDL - see https://github.com/coherify/ruconomic#contributing"
526
576
  # @see https://api.e-conomic.com/secure/api1/EconomicWebService.asmx?op=CurrentInvoice_GetData
527
577
  # @return [Hash] The body content of the SOAP response.
528
- def self.get_data
578
+ def self.get_data(id)
529
579
  response = invoke('CurrentInvoice_GetData') do |message|
530
- raise "TODO: This method was autogenerated from the WSDL - see https://github.com/coherify/ruconomic#contributing"
580
+ message.add 'entityHandle' do |handle|
581
+ handle.add 'Id', id
582
+ end
531
583
  end
584
+
585
+ response.to_hash[:current_invoice_get_data_response][:current_invoice_get_data_result]
532
586
  end
533
587
 
534
588
  # Returns current invoice data objects for a given set of current invoice handles.
@@ -545,14 +599,16 @@ module Ruconomic
545
599
 
546
600
  # Creates a new current invoice.
547
601
  # Parameters: debtor: Handle for a debitor.
548
- #
549
- # @note TODO: This method was autogenerated from the WSDL - see https://github.com/coherify/ruconomic#contributing"
550
- # @see https://api.e-conomic.com/secure/api1/EconomicWebService.asmx?op=CurrentInvoice_Create
551
- # @return [Hash] The body content of the SOAP response.
552
- def self.create
602
+ # @param Number [String] Debtor number
603
+ # @return [String] The created invoice id
604
+ def self.create(number)
553
605
  response = invoke('CurrentInvoice_Create') do |message|
554
- raise "TODO: This method was autogenerated from the WSDL - see https://github.com/coherify/ruconomic#contributing"
606
+ message.add 'debtorHandle' do |handle|
607
+ handle.add 'Number', number
608
+ end
555
609
  end
610
+
611
+ response.to_hash[:current_invoice_create_response][:current_invoice_create_result][:id]
556
612
  end
557
613
 
558
614
  # Returns handles for all current invoices.
@@ -627,14 +683,16 @@ module Ruconomic
627
683
 
628
684
  # Books a current invoice. An invoice number greater than all other invoice numbers will be assigned to the resulting invoice.
629
685
  # Parameters: currentInvoiceHandle: Handle for the current invoice.
630
- #
631
- # @note TODO: This method was autogenerated from the WSDL - see https://github.com/coherify/ruconomic#contributing"
632
686
  # @see https://api.e-conomic.com/secure/api1/EconomicWebService.asmx?op=CurrentInvoice_Book
633
687
  # @return [Hash] The body content of the SOAP response.
634
- def self.book
688
+ def self.book(id)
635
689
  response = invoke('CurrentInvoice_Book') do |message|
636
- raise "TODO: This method was autogenerated from the WSDL - see https://github.com/coherify/ruconomic#contributing"
690
+ message.add 'currentInvoiceHandle' do |handle|
691
+ handle.add 'Id', id
692
+ end
637
693
  end
694
+
695
+ response.to_hash[:current_invoice_book_response][:current_invoice_book_result][:number]
638
696
  end
639
697
 
640
698
  # Books a current invoice.
@@ -652,13 +710,16 @@ module Ruconomic
652
710
  # Deletes a current invoice.
653
711
  # Parameters: currentInvoiceHandle: Handle for the current invoice.
654
712
  #
655
- # @note TODO: This method was autogenerated from the WSDL - see https://github.com/coherify/ruconomic#contributing"
656
713
  # @see https://api.e-conomic.com/secure/api1/EconomicWebService.asmx?op=CurrentInvoice_Delete
657
- # @return [Hash] The body content of the SOAP response.
658
- def self.delete
714
+ # @return [] The body content of the SOAP response.
715
+ def self.delete(id)
659
716
  response = invoke('CurrentInvoice_Delete') do |message|
660
- raise "TODO: This method was autogenerated from the WSDL - see https://github.com/coherify/ruconomic#contributing"
717
+ message.add 'currentInvoiceHandle' do |handle|
718
+ handle.add 'Id', id
719
+ end
661
720
  end
721
+
722
+ response.to_hash[:current_invoice_delete_response]
662
723
  end
663
724
 
664
725
  # Gets handles for the lines of a current invoice.
@@ -1051,10 +1112,15 @@ module Ruconomic
1051
1112
  # @note TODO: This method was autogenerated from the WSDL - see https://github.com/coherify/ruconomic#contributing"
1052
1113
  # @see https://api.e-conomic.com/secure/api1/EconomicWebService.asmx?op=CurrentInvoice_SetDueDate
1053
1114
  # @return [Hash] The body content of the SOAP response.
1054
- def self.set_due_date
1115
+ def self.set_due_date(id, due_date)
1055
1116
  response = invoke('CurrentInvoice_SetDueDate') do |message|
1056
- raise "TODO: This method was autogenerated from the WSDL - see https://github.com/coherify/ruconomic#contributing"
1117
+ message.add 'currentInvoiceHandle' do |handle|
1118
+ handle.add 'Id', id
1119
+ end
1120
+ message.add 'value', due_date
1057
1121
  end
1122
+
1123
+ response.to_hash[:current_invoice_set_due_date_response]
1058
1124
  end
1059
1125
 
1060
1126
  # Gets the currency of a current invoice.
@@ -5,14 +5,33 @@ module Ruconomic
5
5
 
6
6
  # Creates a new current invoice line from a data object.
7
7
  # Parameters: data: The data object that specifies the properties of the new current invoice line.
8
- #
9
- # @note TODO: This method was autogenerated from the WSDL - see https://github.com/coherify/ruconomic#contributing"
10
- # @see https://api.e-conomic.com/secure/api1/EconomicWebService.asmx?op=CurrentInvoiceLine_CreateFromData
11
- # @return [Hash] The body content of the SOAP response.
12
- def self.create_from_data
8
+ # @return [Hash] number and id for the current invoice line
9
+ def self.create_from_data(line_data)
13
10
  response = invoke('CurrentInvoiceLine_CreateFromData') do |message|
14
- raise "TODO: This method was autogenerated from the WSDL - see https://github.com/coherify/ruconomic#contributing"
15
- end
11
+ message.add 'data' do |data|
12
+ data.add 'Number', line_data.fetch(:number, nil)
13
+ data.add 'InvoiceHandle' do |invoice_handle|
14
+ invoice_handle.add 'Id', line_data.fetch(:invoice_handle, {}).fetch(:id, nil)
15
+ end
16
+ data.add 'Description', line_data.fetch(:description, nil)
17
+ data.add 'DeliveryDate', line_data.fetch(:delivery_date, nil)
18
+ data.add 'UnitHandle' do |unit_handle|
19
+ unit_handle.add 'Number', line_data.fetch(:unit_handle, {}).fetch(:number, nil)
20
+ end
21
+ data.add 'ProductHandle' do |product_handle|
22
+ product_handle.add 'Number', line_data.fetch(:product_handle, {}).fetch(:number, nil)
23
+ end
24
+ data.add 'Quantity', line_data.fetch(:quantity, nil)
25
+ data.add 'UnitNetPrice', line_data.fetch(:unit_net_price, nil)
26
+ data.add 'DiscountAsPercent', line_data.fetch(:discount_as_percent, nil)
27
+ data.add 'UnitCostPrice', line_data.fetch(:unit_cost_price, nil)
28
+ data.add 'TotalNetAmount', line_data.fetch(:total_net_amount, nil)
29
+ data.add 'TotalMargin', line_data.fetch(:total_margin, nil)
30
+ data.add 'MarginAsPercent', line_data.fetch(:margin_as_percent, nil)
31
+ end
32
+ end
33
+
34
+ response.to_hash[:current_invoice_line_create_from_data_response][:current_invoice_line_create_from_data_result]
16
35
  end
17
36
 
18
37
  # Creates new current invoice lines from data objects.
@@ -201,13 +201,79 @@ module Ruconomic
201
201
  # Creates a new debtor from a data object.
202
202
  # Parameters: data: The data object that specifies the properties of the new debtor.
203
203
  #
204
- # @note TODO: This method was autogenerated from the WSDL - see https://github.com/coherify/ruconomic#contributing"
205
204
  # @see https://api.e-conomic.com/secure/api1/EconomicWebService.asmx?op=Debtor_CreateFromData
206
205
  # @return [Hash] The body content of the SOAP response.
207
- def self.create_from_data
206
+ def self.create_from_data(debtor_data)
208
207
  response = invoke('Debtor_CreateFromData') do |message|
209
- raise "TODO: This method was autogenerated from the WSDL - see https://github.com/coherify/ruconomic#contributing"
208
+ message.add 'data' do |data|
209
+ data.add 'Handle' do |handle|
210
+ handle.add 'Number', debtor_data.fetch(:handle, {}).fetch(:number, nil)
211
+ end
212
+ data.add 'Number', debtor_data.fetch(:number, nil)
213
+ data.add 'DebtorGroupHandle' do |handle|
214
+ handle.add 'Number', debtor_data.fetch(:debtor_group_handle, {}).fetch(:number, nil)
215
+ end
216
+ data.add 'Name', debtor_data.fetch(:name, nil)
217
+ data.add 'VatZone', debtor_data.fetch(:vat_zone, nil)
218
+ data.add 'ExtendedVatZone' do |handle|
219
+ handle.add 'Number', debtor_data.fetch(:extended_vat_zone, {}).fetch(:number, nil)
220
+ end
221
+ data.add 'CurrencyHandle' do |handle|
222
+ handle.add 'Code', debtor_data.fetch(:currency_handle, {}).fetch(:code, nil)
223
+ end
224
+ if price_group_handle = debtor_data.fetch(:price_group_handle, {}).fetch(:number, nil)
225
+ data.add 'PriceGroupHandle' do |handle|
226
+ handle.add 'Number', price_group_handle
227
+ end
228
+ end
229
+ data.add 'IsAccessible', debtor_data.fetch(:is_accessible, nil)
230
+ data.add 'Ean', debtor_data.fetch(:ean, nil)
231
+ data.add 'PublicEntryNumber', debtor_data.fetch(:public_entry_number, nil)
232
+ data.add 'Email', debtor_data.fetch(:email, nil)
233
+ data.add 'TelephoneAndFaxNumber', debtor_data.fetch(:telephone_and_fax_number, nil)
234
+ data.add 'Website', debtor_data.fetch(:website, nil)
235
+ data.add 'Address', debtor_data.fetch(:address, nil)
236
+ data.add 'PostalCode', debtor_data.fetch(:postal_code, nil)
237
+ data.add 'City', debtor_data.fetch(:city, nil)
238
+ data.add 'Country', debtor_data.fetch(:country, nil)
239
+ if credit_maximum = debtor_data.fetch(:credit_maximum, nil)
240
+ data.add 'CreditMaximum', credit_maximum
241
+ end
242
+ data.add 'VatNumber', debtor_data.fetch(:vat_number, nil)
243
+ data.add 'CINumber', debtor_data.fetch(:ci_number, nil)
244
+ data.add 'TermOfPaymentHandle' do |handle|
245
+ handle.add 'Id', debtor_data.fetch(:term_of_payment_handle, {}).fetch(:id, nil)
246
+ end
247
+ if layout_id = debtor_data.fetch(:layout_handle, {}).fetch(:id, nil)
248
+ data.add 'LayoutHandle' do |handle|
249
+ handle.add 'Id', layout_id
250
+ end
251
+ end
252
+ if attention_id = debtor_data.fetch(:attention_handle, {}).fetch(:id, nil)
253
+ data.add 'AttentionHandle' do |handle|
254
+ handle.add 'Id', attention_id
255
+ end
256
+ end
257
+ if your_reference_id = debtor_data.fetch(:your_reference_handle, {}).fetch(:id, nil)
258
+ data.add 'YourReferenceHandle' do |handle|
259
+ handle.add 'Id', your_reference_id
260
+ end
261
+ end
262
+ if our_reference_handle = debtor_data.fetch(:our_reference_handle, {}).fetch(:number, nil)
263
+ data.add 'OurReferenceHandle' do |handle|
264
+ handle.add 'Number', our_reference_handle
265
+ end
266
+ end
267
+ data.add 'Balance', debtor_data.fetch(:balance, nil)
268
+ if delivery_id = debtor_data.fetch(:default_delivery_location_handle, {}).fetch(:id, nil)
269
+ data.add 'DefaultDeliveryLocationHandle' do |handle|
270
+ handle.add 'Id', delivery_id
271
+ end
272
+ end
273
+ end
210
274
  end
275
+
276
+ response.to_hash[:debtor_create_from_data_response][:debtor_create_from_data_result][:number]
211
277
  end
212
278
 
213
279
  # Creates new debtors from data objects.
@@ -755,14 +821,15 @@ module Ruconomic
755
821
 
756
822
  # Gets a handle for the term of payment of a debtor.
757
823
  # Parameters: debtorHandle: Handle for the debtor.
758
- #
759
- # @note TODO: This method was autogenerated from the WSDL - see https://github.com/coherify/ruconomic#contributing"
760
- # @see https://api.e-conomic.com/secure/api1/EconomicWebService.asmx?op=Debtor_GetTermOfPayment
761
- # @return [Hash] The body content of the SOAP response.
762
- def self.get_term_of_payment
824
+ # @return [String] with the id of the debtor term of payment
825
+ def self.get_term_of_payment(number)
763
826
  response = invoke('Debtor_GetTermOfPayment') do |message|
764
- raise "TODO: This method was autogenerated from the WSDL - see https://github.com/coherify/ruconomic#contributing"
827
+ message.add 'debtorHandle' do |debtor_handle|
828
+ debtor_handle.add 'Number', number
829
+ end
765
830
  end
831
+
832
+ response.to_hash[:debtor_get_term_of_payment_response][:debtor_get_term_of_payment_result][:id]
766
833
  end
767
834
 
768
835
  # Sets the layout of a debtor. The value may be omitted.
@@ -780,13 +847,16 @@ module Ruconomic
780
847
  # Gets a handle for the layout of a debtor.
781
848
  # Parameters: debtorHandle: Handle for the debtor.
782
849
  #
783
- # @note TODO: This method was autogenerated from the WSDL - see https://github.com/coherify/ruconomic#contributing"
784
850
  # @see https://api.e-conomic.com/secure/api1/EconomicWebService.asmx?op=Debtor_GetLayout
785
851
  # @return [Hash] The body content of the SOAP response.
786
- def self.get_layout
852
+ def self.get_layout(handle)
787
853
  response = invoke('Debtor_GetLayout') do |message|
788
- raise "TODO: This method was autogenerated from the WSDL - see https://github.com/coherify/ruconomic#contributing"
854
+ message.add 'debtorHandle' do |debtor_handle|
855
+ debtor_handle.add 'Number', handle
856
+ end
789
857
  end
858
+
859
+ response.to_hash[:debtor_get_layout_response][:debtor_get_layout_result][:id]
790
860
  end
791
861
 
792
862
  # Gets a handle for the attention of a debtor.
@@ -187,13 +187,12 @@ module Ruconomic
187
187
 
188
188
  # Returns handles for all invoices.
189
189
  #
190
- # @note TODO: This method was autogenerated from the WSDL - see https://github.com/coherify/ruconomic#contributing"
191
190
  # @see https://api.e-conomic.com/secure/api1/EconomicWebService.asmx?op=Invoice_GetAll
192
191
  # @return [Hash] The body content of the SOAP response.
193
192
  def self.get_all
194
- response = invoke('Invoice_GetAll') do |message|
195
- raise "TODO: This method was autogenerated from the WSDL - see https://github.com/coherify/ruconomic#contributing"
196
- end
193
+ response = invoke('Invoice_GetAll')
194
+
195
+ response.to_hash[:invoice_get_all_response][:invoice_get_all_result]
197
196
  end
198
197
 
199
198
  # Returns a handle for the invoice with the given number.
@@ -296,13 +295,16 @@ module Ruconomic
296
295
  # Gets an invoice as a PDF-file.
297
296
  # Parameters: invoiceHandle: Handle for the invoice.
298
297
  #
299
- # @note TODO: This method was autogenerated from the WSDL - see https://github.com/coherify/ruconomic#contributing"
300
298
  # @see https://api.e-conomic.com/secure/api1/EconomicWebService.asmx?op=Invoice_GetPdf
301
299
  # @return [Hash] The body content of the SOAP response.
302
- def self.get_pdf
300
+ def self.get_pdf(number)
303
301
  response = invoke('Invoice_GetPdf') do |message|
304
- raise "TODO: This method was autogenerated from the WSDL - see https://github.com/coherify/ruconomic#contributing"
302
+ message.add 'invoiceHandle' do |handle|
303
+ handle.add 'Number', number
304
+ end
305
305
  end
306
+
307
+ response.to_hash[:invoice_get_pdf_response][:invoice_get_pdf_result]
306
308
  end
307
309
 
308
310
  # Gets an OIO XML string representing an invoice.
@@ -1,17 +1,14 @@
1
1
  module Ruconomic
2
2
  class Fault < StandardError
3
- attr_reader :code, :reason, :details
4
-
5
- def initialize(code, reason, details)
6
- super(reason)
7
- @code = code
8
- @reason = reason
9
- @details = details
3
+ attr_reader :fault
4
+
5
+ def initialize(fault)
6
+ super(fault[:code] || fault[:faultcode])
7
+ @fault = fault
10
8
  end
11
-
9
+
12
10
  def to_s
13
- "Ruconomic::Fault { :code => '#{@code}', :reason => '#{@reason}', :details => '#{@details}' }"
14
- end
15
-
11
+ "Ruconomic::Fault #{fault.to_s}"
12
+ end
16
13
  end
17
14
  end
@@ -3,7 +3,6 @@ require "libxml"
3
3
  module Ruconomic
4
4
  module SOAP
5
5
  class Node < LibXML::XML::Node
6
-
7
6
  def initialize(name, value = nil, namespace = nil, prefix = nil)
8
7
  # add prefix to node if namespace (and prefix is given)
9
8
  name = prefix + ':' + name if namespace != nil && prefix != nil
@@ -11,14 +10,31 @@ module Ruconomic
11
10
  # Add namespace (and prefix if given)
12
11
  LibXML::XML::Namespace.new(self, prefix, namespace) if namespace
13
12
  end
14
-
13
+
15
14
  def add(name, value = nil, namespace = nil, prefix = nil)
16
- self << node = Ruconomic::SOAP::Node.new(name, value, namespace, prefix)
15
+ self << node = Ruconomic::SOAP::Node.new(name, value, namespace, prefix)
17
16
  yield node if block_given?
18
17
 
19
18
  node
20
19
  end
21
-
20
+
21
+ def add_handle(handle_node_name, value, value_node_name = 'Number')
22
+ return unless value
23
+ add(handle_node_name) do |handle|
24
+ handle.add(
25
+ value_node_name,
26
+ value
27
+ )
28
+ end
29
+ end
30
+
31
+ def add_optional(handle_node_name, value)
32
+ return unless value
33
+ add(
34
+ handle_node_name,
35
+ value
36
+ )
37
+ end
22
38
  end
23
39
  end
24
40
  end
@@ -1,3 +1,3 @@
1
1
  module Ruconomic
2
- VERSION = "0.9.7"
2
+ VERSION = "0.9.8"
3
3
  end
@@ -39,7 +39,7 @@ module Ruconomic
39
39
  if @@curl.response_code != 200
40
40
  h = response.to_hash || {}
41
41
  fault = h[:fault]
42
- raise Ruconomic::Fault.new(fault[:faultcode],fault[:faultstring],fault[:details]) if fault
42
+ raise Ruconomic::Fault.new(fault) if fault
43
43
  end
44
44
  LibXML::XML::Namespace.new(response.root, nil, "http://e-conomic.com")
45
45
  response.root.namespaces.default_prefix = "dns"
data/lib/ruconomic.rb CHANGED
@@ -1,3 +1,4 @@
1
+ require "ruby_dig"
1
2
  require "ruconomic/version"
2
3
  require "ruconomic/fault"
3
4
  require "ruconomic/web_service"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruconomic
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.7
4
+ version: 0.9.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tonni Tølbøll Lund Aagesen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-31 00:00:00.000000000 Z
11
+ date: 2017-02-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: curb