dynaccount 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +36 -0
  4. data/Rakefile +28 -0
  5. data/lib/dynaccount.rb +104 -0
  6. data/lib/dynaccount/account.rb +11 -0
  7. data/lib/dynaccount/accounting.rb +11 -0
  8. data/lib/dynaccount/accounting_bank.rb +11 -0
  9. data/lib/dynaccount/action.rb +15 -0
  10. data/lib/dynaccount/bank.rb +11 -0
  11. data/lib/dynaccount/bank_recon.rb +11 -0
  12. data/lib/dynaccount/contact.rb +11 -0
  13. data/lib/dynaccount/contact_user.rb +11 -0
  14. data/lib/dynaccount/creditor.rb +11 -0
  15. data/lib/dynaccount/creditor_accounting_module.rb +11 -0
  16. data/lib/dynaccount/creditor_group.rb +11 -0
  17. data/lib/dynaccount/creditor_invoice.rb +11 -0
  18. data/lib/dynaccount/creditor_invoice_match.rb +11 -0
  19. data/lib/dynaccount/creditor_invoice_product.rb +11 -0
  20. data/lib/dynaccount/creditor_order.rb +11 -0
  21. data/lib/dynaccount/creditor_order_product.rb +11 -0
  22. data/lib/dynaccount/creditor_order_product_serialno.rb +11 -0
  23. data/lib/dynaccount/currency.rb +11 -0
  24. data/lib/dynaccount/data_voucher.rb +11 -0
  25. data/lib/dynaccount/debtor.rb +11 -0
  26. data/lib/dynaccount/debtor_accounting_module.rb +11 -0
  27. data/lib/dynaccount/debtor_creditnote.rb +11 -0
  28. data/lib/dynaccount/debtor_creditnote_product.rb +11 -0
  29. data/lib/dynaccount/debtor_creditnote_product_list.rb +11 -0
  30. data/lib/dynaccount/debtor_group.rb +11 -0
  31. data/lib/dynaccount/debtor_group_product_discount.rb +11 -0
  32. data/lib/dynaccount/debtor_group_product_group_discount.rb +11 -0
  33. data/lib/dynaccount/debtor_invoice.rb +11 -0
  34. data/lib/dynaccount/debtor_invoice_match.rb +11 -0
  35. data/lib/dynaccount/debtor_invoice_product.rb +11 -0
  36. data/lib/dynaccount/debtor_invoice_product_list.rb +11 -0
  37. data/lib/dynaccount/debtor_order.rb +11 -0
  38. data/lib/dynaccount/debtor_order_product.rb +11 -0
  39. data/lib/dynaccount/debtor_order_product_list.rb +11 -0
  40. data/lib/dynaccount/debtor_order_product_serialno.rb +11 -0
  41. data/lib/dynaccount/debtor_product_discount.rb +11 -0
  42. data/lib/dynaccount/debtor_product_group_discount.rb +11 -0
  43. data/lib/dynaccount/debtor_quote.rb +11 -0
  44. data/lib/dynaccount/debtor_quote_product.rb +11 -0
  45. data/lib/dynaccount/debtor_quote_product_list.rb +11 -0
  46. data/lib/dynaccount/debtor_reminder.rb +11 -0
  47. data/lib/dynaccount/debtor_subscription.rb +11 -0
  48. data/lib/dynaccount/debtor_subscription_group.rb +11 -0
  49. data/lib/dynaccount/debtor_subscription_group_product.rb +11 -0
  50. data/lib/dynaccount/debtor_subscription_group_product_list.rb +11 -0
  51. data/lib/dynaccount/debtor_subscription_product.rb +11 -0
  52. data/lib/dynaccount/debtor_subscription_product_list.rb +11 -0
  53. data/lib/dynaccount/dimension.rb +11 -0
  54. data/lib/dynaccount/draft.rb +11 -0
  55. data/lib/dynaccount/dynaccount_object.rb +53 -0
  56. data/lib/dynaccount/enclosure.rb +11 -0
  57. data/lib/dynaccount/followup.rb +11 -0
  58. data/lib/dynaccount/location.rb +11 -0
  59. data/lib/dynaccount/opportunity.rb +11 -0
  60. data/lib/dynaccount/payment.rb +11 -0
  61. data/lib/dynaccount/product.rb +11 -0
  62. data/lib/dynaccount/product_currency.rb +11 -0
  63. data/lib/dynaccount/product_group.rb +11 -0
  64. data/lib/dynaccount/product_list.rb +11 -0
  65. data/lib/dynaccount/product_list_product.rb +11 -0
  66. data/lib/dynaccount/product_supplier.rb +11 -0
  67. data/lib/dynaccount/stock_adjustment.rb +11 -0
  68. data/lib/dynaccount/unit.rb +11 -0
  69. data/lib/dynaccount/vatcode.rb +11 -0
  70. data/lib/dynaccount/version.rb +3 -0
  71. data/lib/dynaccount/year.rb +11 -0
  72. data/lib/dynaccount/year_period.rb +11 -0
  73. data/lib/tasks/dynaccount_tasks.rake +4 -0
  74. metadata +165 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 8e2e0d81f472fdc491d0ef4ab444f4e12d6a7794
4
+ data.tar.gz: 55e16cb4d1363f9a4763c0b50f6fc1d4f9779395
5
+ SHA512:
6
+ metadata.gz: 4153e16e43d11eeae9d07e96372189b11719c5c37a6a45182a2d6296808afbd4acf7a402ec267d38ca67bd851512b0ac3f390ace9751d4f3cf994857528cc75b
7
+ data.tar.gz: c23cdcbfc6337fb0dae9616c0743bc33038b8765d3b834dff7cdae6d88dcbb9b92e435a0b30e231c88a86edb0fe6a506c921662cfb4ed49a8abbf12a926a7ed7
@@ -0,0 +1,20 @@
1
+ Copyright 2016 Frederik Spang
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,36 @@
1
+ # Dynaccount
2
+ This dynaccount gem is created to create an ActiveRecord-like interaction to [Dynaccount](https://dynaccount.com), accounting system's API.
3
+
4
+ The current API-version is `v5`.
5
+
6
+ ## Usage
7
+
8
+ ### config/initializers/dynaccount.rb
9
+ ```ruby
10
+ Dynaccount.api_id = "key"
11
+ Dynaccount.api_key = "key"
12
+ Dynaccount.api_secret = "key"
13
+ ```
14
+
15
+ ## Installation
16
+ Add this line to your application's Gemfile:
17
+
18
+ ```ruby
19
+ gem 'dynaccount', github: 'prograsdk/dynaccount'
20
+ ```
21
+
22
+ And then execute:
23
+ ```bash
24
+ $ bundle
25
+ ```
26
+
27
+ Or install it yourself as:
28
+ ```bash
29
+ $ gem install dynaccount
30
+ ```
31
+
32
+ ## Todo
33
+ * Support Streaming reports.
34
+
35
+ ## License
36
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
@@ -0,0 +1,28 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'Dynaccount'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.md')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+ require 'bundler/gem_tasks'
18
+
19
+ require 'rake/testtask'
20
+
21
+ Rake::TestTask.new(:test) do |t|
22
+ t.libs << 'lib'
23
+ t.libs << 'test'
24
+ t.pattern = 'test/**/*_test.rb'
25
+ t.verbose = false
26
+ end
27
+
28
+ task default: :test
@@ -0,0 +1,104 @@
1
+ require 'json'
2
+ require 'faraday'
3
+ require 'net/http/persistent'
4
+ require 'logger'
5
+
6
+ require 'dynaccount/dynaccount_object'
7
+
8
+ require 'dynaccount/action'
9
+
10
+ require 'dynaccount/account'
11
+ require 'dynaccount/accounting'
12
+ require 'dynaccount/accounting_bank'
13
+ require 'dynaccount/bank'
14
+ require 'dynaccount/bank_recon'
15
+ require 'dynaccount/contact'
16
+ require 'dynaccount/contact_user'
17
+ require 'dynaccount/creditor'
18
+ require 'dynaccount/creditor_accounting_module'
19
+ require 'dynaccount/creditor_group'
20
+ require 'dynaccount/creditor_invoice'
21
+ require 'dynaccount/creditor_invoice_match'
22
+ require 'dynaccount/creditor_invoice_product'
23
+ require 'dynaccount/creditor_order'
24
+ require 'dynaccount/creditor_order_product'
25
+ require 'dynaccount/creditor_order_product_serialno'
26
+ require 'dynaccount/currency'
27
+ require 'dynaccount/data_voucher'
28
+ require 'dynaccount/debtor'
29
+ require 'dynaccount/debtor_accounting_module'
30
+ require 'dynaccount/debtor_creditnote'
31
+ require 'dynaccount/debtor_creditnote_product'
32
+ require 'dynaccount/debtor_creditnote_product_list'
33
+ require 'dynaccount/debtor_group'
34
+ require 'dynaccount/debtor_group_product_discount'
35
+ require 'dynaccount/debtor_group_product_group_discount'
36
+ require 'dynaccount/debtor_invoice'
37
+ require 'dynaccount/debtor_invoice_match'
38
+ require 'dynaccount/debtor_invoice_product'
39
+ require 'dynaccount/debtor_invoice_product_list'
40
+ require 'dynaccount/debtor_order'
41
+ require 'dynaccount/debtor_order_product'
42
+ require 'dynaccount/debtor_order_product_list'
43
+ require 'dynaccount/debtor_order_product_serialno'
44
+ require 'dynaccount/debtor_product_discount'
45
+ require 'dynaccount/debtor_product_group_discount'
46
+ require 'dynaccount/debtor_reminder'
47
+ require 'dynaccount/debtor_quote'
48
+ require 'dynaccount/debtor_quote_product'
49
+ require 'dynaccount/debtor_quote_product_list'
50
+ require 'dynaccount/debtor_subscription'
51
+ require 'dynaccount/debtor_subscription_group'
52
+ require 'dynaccount/debtor_subscription_group_product'
53
+ require 'dynaccount/debtor_subscription_group_product_list'
54
+ require 'dynaccount/debtor_subscription_product'
55
+ require 'dynaccount/debtor_subscription_product_list'
56
+ require 'dynaccount/dimension'
57
+ require 'dynaccount/draft'
58
+ require 'dynaccount/enclosure'
59
+ require 'dynaccount/followup'
60
+ require 'dynaccount/location'
61
+ require 'dynaccount/opportunity'
62
+ require 'dynaccount/payment'
63
+ require 'dynaccount/product'
64
+ require 'dynaccount/product_currency'
65
+ require 'dynaccount/product_group'
66
+ require 'dynaccount/product_list'
67
+ require 'dynaccount/product_list_product'
68
+ require 'dynaccount/product_supplier'
69
+ require 'dynaccount/stock_adjustment'
70
+ require 'dynaccount/unit'
71
+ require 'dynaccount/vatcode'
72
+ require 'dynaccount/year'
73
+ require 'dynaccount/year_period'
74
+
75
+ module Dynaccount
76
+ @base_url = 'api.dynaccount.com'
77
+
78
+ class << self
79
+ attr_accessor :api_key, :api_base, :api_secret, :api_id
80
+
81
+ def request(url, params = {}, _method = :post)
82
+ @api_connection ||= Faraday.new(url: "https://#{@base_url}") do |faraday|
83
+ faraday.request :url_encoded
84
+ faraday.response :logger, ::Logger.new(STDOUT), bodies: true
85
+ faraday.adapter :net_http_persistent
86
+ end
87
+
88
+ @api_connection.post do |req|
89
+ req.url url
90
+ req.body = "#{URI.encode_www_form(params)}#{'&' unless params.empty?}__api_hash=#{api_hash(request_url(url), params)}"
91
+ end
92
+ end
93
+
94
+ def request_url(url)
95
+ @base_url + url
96
+ end
97
+
98
+ def api_hash(url, params = {})
99
+ # p "#{url}#{URI.encode_www_form(params)}#{api_secret}"
100
+ (Digest::SHA1.new << "#{url}#{URI.encode_www_form(params)}#{api_secret}")
101
+ .to_s
102
+ end
103
+ end
104
+ end
@@ -0,0 +1,11 @@
1
+ module Dynaccount
2
+ class Account < DynaccountObject
3
+ def self.ignore_put
4
+ [:id, :system, :module, :stock, :is_bank]
5
+ end
6
+
7
+ def self.api_path
8
+ 'account'
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ module Dynaccount
2
+ class Accounting < DynaccountObject
3
+ def self.ignore_put
4
+ [:id, :time, :bank_recon_id, :currency_amount, :is_readonly]
5
+ end
6
+
7
+ def self.api_path
8
+ 'accounting'
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ module Dynaccount
2
+ class AccountingBank < DynaccountObject
3
+ def self.ignore_put
4
+ [:id, :account_id, :accounting_id, :time, :is_booked, :recon_id, :amount, :currency_amount]
5
+ end
6
+
7
+ def self.api_path
8
+ 'accounting_bank'
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,15 @@
1
+ module Dynaccount
2
+ class Action
3
+ def self.api_path
4
+ 'accounting_bank'
5
+ end
6
+
7
+ def self.run(action, params = {})
8
+ JSON.parse(Dynaccount.request(url(action), params, :post).body)
9
+ end
10
+
11
+ def self.url(action)
12
+ "/v5/#{Dynaccount.api_id}/#{Dynaccount.api_key}/action/#{action}/json/"
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,11 @@
1
+ module Dynaccount
2
+ class Bank < DynaccountObject
3
+ def self.ignore_put
4
+ [:id, :account_id]
5
+ end
6
+
7
+ def self.api_path
8
+ 'bank'
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ module Dynaccount
2
+ class BankRecon < DynaccountObject
3
+ def self.ignore_put
4
+ [:id, :account_id, :time, :recon_id, :accounting_id, :is_fi_payment, :seq, :amount, :accum_amount, :txt]
5
+ end
6
+
7
+ def self.api_path
8
+ 'bank_recon'
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ module Dynaccount
2
+ class Contact < DynaccountObject
3
+ def self.ignore_put
4
+ [:id, :module_id, :time_last_followup, :time_next_followup, :time_created]
5
+ end
6
+
7
+ def self.api_path
8
+ 'contact'
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ module Dynaccount
2
+ class ContactUser < DynaccountObject
3
+ def self.ignore_put
4
+ [:id, :contact_id]
5
+ end
6
+
7
+ def self.api_path
8
+ 'contact_user'
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ module Dynaccount
2
+ class Creditor < DynaccountObject
3
+ def self.ignore_put
4
+ [:id, :balance, :vatno_validation]
5
+ end
6
+
7
+ def self.api_path
8
+ 'creditor'
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ module Dynaccount
2
+ class CreditorAccountingModule < DynaccountObject
3
+ def self.ignore_put
4
+ [:id, :is_matched, :time, :is_booked, :currency_rate, :amount, :currency_amount]
5
+ end
6
+
7
+ def self.api_path
8
+ 'creditor_accounting_module'
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ module Dynaccount
2
+ class CreditorGroup < DynaccountObject
3
+ def self.ignore_put
4
+ [:id]
5
+ end
6
+
7
+ def self.api_path
8
+ 'creditor_group'
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ module Dynaccount
2
+ class CreditorInvoice < DynaccountObject
3
+ def self.ignore_put
4
+ [:id, :is_booked, :is_system, :is_matched, :time_due, :enc_id_, :currency_rate, :accountoff_id, :vat_amount, :total_amount]
5
+ end
6
+
7
+ def self.api_path
8
+ 'creditor_invoice'
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ module Dynaccount
2
+ class CreditorInvoiceMatch < DynaccountObject
3
+ def self.ignore_put
4
+ [:id, :is_matched, :time, :invoice_id_, :currency_rate, :amount, :currency_amount]
5
+ end
6
+
7
+ def self.api_path
8
+ 'creditor_invoice_match'
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ module Dynaccount
2
+ class CreditorInvoiceProduct < DynaccountObject
3
+ def self.ignore_put
4
+ [:id, :product_id, :vat_amount, :total_amount, :total_weight]
5
+ end
6
+
7
+ def self.api_path
8
+ 'creditor_invoice_product'
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ module Dynaccount
2
+ class CreditorOrder < DynaccountObject
3
+ def self.ignore_put
4
+ [:id, :is_approved, :is_invoiced, :module_id, :order_id_, :is_seen, :vat_amount, :total_amount, :total_weight, :profit_amount]
5
+ end
6
+
7
+ def self.api_path
8
+ 'creditor_order'
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ module Dynaccount
2
+ class CreditorOrderProduct < DynaccountObject
3
+ def self.ignore_put
4
+ [:id, :product_id, :qty_invoiced, :vat_amount, :total_amount, :total_weight]
5
+ end
6
+
7
+ def self.api_path
8
+ 'creditor_order_product'
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ module Dynaccount
2
+ class CreditorOrderProductSerialno < DynaccountObject
3
+ def self.ignore_put
4
+ [:id, :is_booked, :order_id, :order_product_id, :seq]
5
+ end
6
+
7
+ def self.api_path
8
+ 'creditor_order_product_serialno'
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ module Dynaccount
2
+ class Currency < DynaccountObject
3
+ def self.ignore_put
4
+ [:id]
5
+ end
6
+
7
+ def self.api_path
8
+ 'currency'
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ module Dynaccount
2
+ class DataVoucher < DynaccountObject
3
+ def self.ignore_put
4
+ [:id, :client_id, :is_ocr_pending, :is_pdf_broken, :is_attached, :time, :user_id, :is_pdf_scan, :is_pic, :file_sha1, :file_ext, :file_ext_thumb, :file_size, :file_size_original, :file_name, :from_email, :num_pages, :dpi, :ocr_vatno, :ocr_invoice_time, :ocr_invoice_due_time, :ocr_total, :ocr_vat]
5
+ end
6
+
7
+ def self.api_path
8
+ 'data_voucher'
9
+ end
10
+ end
11
+ end