dynaccount 0.9.0

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.
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,11 @@
1
+ module Dynaccount
2
+ class Debtor < DynaccountObject
3
+ def self.ignore_put
4
+ [:id, :contact_id, :balance, :vatno_validation, :time_vatno_validation, :due]
5
+ end
6
+
7
+ def self.api_path
8
+ 'debtor'
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ module Dynaccount
2
+ class DebtorAccountingModule < 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
+ 'debtor_accounting_module'
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ module Dynaccount
2
+ class DebtorCreditnote < DynaccountObject
3
+ def self.ignore_put
4
+ [:id, :is_booked, :module_id, :invoice_id_, :credit_invoice_id_, :sha1_ref, :lang, :vat_amount, :total_amount, :total_weight, :profit_amount, :attention, :address, :zip, :city, :txt]
5
+ end
6
+
7
+ def self.api_path
8
+ 'debtor_creditnote'
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ module Dynaccount
2
+ class DebtorCreditnoteProduct < DynaccountObject
3
+ def self.ignore_put
4
+ [:id, :product_id, :qty_credited, :is_list_listing, :is_list_pricing, :vat_amount, :total_amount, :total_weight, :profit_amount]
5
+ end
6
+
7
+ def self.api_path
8
+ 'debtor_creditnote_product'
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ module Dynaccount
2
+ class DebtorCreditnoteProductList < DynaccountObject
3
+ def self.ignore_put
4
+ [:id, :invoice_product_id, :product_id, :qty, :price, :discount_percent, :vat_amount, :total_amount, :total_weight, :profit_amount, :name, :list_qty]
5
+ end
6
+
7
+ def self.api_path
8
+ 'debtor_creditnote_product_list'
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ module Dynaccount
2
+ class DebtorGroup < DynaccountObject
3
+ def self.ignore_put
4
+ [:id]
5
+ end
6
+
7
+ def self.api_path
8
+ 'debtor_group'
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ module Dynaccount
2
+ class DebtorGroupProductDiscount < DynaccountObject
3
+ def self.ignore_put
4
+ [:id, :product_id]
5
+ end
6
+
7
+ def self.api_path
8
+ 'debtor_group_product_discount'
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ module Dynaccount
2
+ class DebtorGroupProductGroupDiscount < DynaccountObject
3
+ def self.ignore_put
4
+ [:id, :product_group_id]
5
+ end
6
+
7
+ def self.api_path
8
+ 'debtor_group_product_group_discount'
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ module Dynaccount
2
+ class DebtorInvoice < DynaccountObject
3
+ def self.ignore_put
4
+ [:id, :is_booked, :is_system, :is_matched, :is_reminder, :is_credited, :is_credited_complete, :is_subscription, :module_id, :time_due, :invoice_id_, :currency_rate, :sha1_ref, :is_seen, :fi_payment_id_, :accountoff_id, :vat_amount, :total_amount, :total_weight, :profit_amount]
5
+ end
6
+
7
+ def self.api_path
8
+ 'debtor_invoice'
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ module Dynaccount
2
+ class DebtorInvoiceMatch < DynaccountObject
3
+ def self.ignore_put
4
+ [:id, :is_matched, :is_creditnote, :time, :invoice_id_, :currency_rate, :amount, :currency_amount]
5
+ end
6
+
7
+ def self.api_path
8
+ 'debtor_invoice_match'
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ module Dynaccount
2
+ class DebtorInvoiceProduct < DynaccountObject
3
+ def self.ignore_put
4
+ [:id, :product_id, :qty_credited, :is_list_listing, :is_list_pricing, :vat_amount, :total_amount, :total_weight, :profit_amount]
5
+ end
6
+
7
+ def self.api_path
8
+ 'debtor_invoice_product'
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ module Dynaccount
2
+ class DebtorInvoiceProductList < DynaccountObject
3
+ def self.ignore_put
4
+ [:id, :invoice_product_id, :product_id, :qty, :price, :discount_percent, :vat_amount, :total_amount, :total_weight, :profit_amount, :name, :list_qty]
5
+ end
6
+
7
+ def self.api_path
8
+ 'debtor_invoice_product_list'
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ module Dynaccount
2
+ class DebtorOrder < 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
+ 'debtor_order'
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ module Dynaccount
2
+ class DebtorOrderProduct < DynaccountObject
3
+ def self.ignore_put
4
+ [:id, :product_id, :qty_invoiced, :is_list_listing, :is_list_pricing, :vat_amount, :total_amount, :total_weight, :profit_amount]
5
+ end
6
+
7
+ def self.api_path
8
+ 'debtor_order_product'
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ module Dynaccount
2
+ class DebtorOrderProductList < DynaccountObject
3
+ def self.ignore_put
4
+ [:id, :order_product_id, :product_id, :qty, :price, :discount_percent, :vat_amount, :total_amount, :total_weight, :profit_amount, :name, :list_qty]
5
+ end
6
+
7
+ def self.api_path
8
+ 'debtor_order_product_list'
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ module Dynaccount
2
+ class DebtorOrderProductSerialno < 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
+ 'debtor_order_product_serialno'
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ module Dynaccount
2
+ class DebtorProductDiscount < DynaccountObject
3
+ def self.ignore_put
4
+ [:id, :product_id]
5
+ end
6
+
7
+ def self.api_path
8
+ 'debtor_product_discount'
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ module Dynaccount
2
+ class DebtorProductGroupDiscount < DynaccountObject
3
+ def self.ignore_put
4
+ [:id, :product_group_id]
5
+ end
6
+
7
+ def self.api_path
8
+ 'debtor_product_group_discount'
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ module Dynaccount
2
+ class DebtorQuote < DynaccountObject
3
+ def self.ignore_put
4
+ [:id, :module_id, :quote_id_, :is_seen, :is_transferred_time, :vat_amount, :total_amount, :total_weight, :profit_amount]
5
+ end
6
+
7
+ def self.api_path
8
+ 'debtor_quote'
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ module Dynaccount
2
+ class DebtorQuoteProduct < DynaccountObject
3
+ def self.ignore_put
4
+ [:id, :product_id, :is_list_listing, :is_list_pricing, :vat_amount, :total_amount, :total_weight, :profit_amount]
5
+ end
6
+
7
+ def self.api_path
8
+ 'debtor_quote_product'
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ module Dynaccount
2
+ class DebtorQuoteProductList < DynaccountObject
3
+ def self.ignore_put
4
+ [:id, :quote_product_id, :product_id, :qty, :price, :discount_percent, :vat_amount, :total_amount, :total_weight, :profit_amount, :name, :list_qty]
5
+ end
6
+
7
+ def self.api_path
8
+ 'debtor_quote_product_list'
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ module Dynaccount
2
+ class DebtorReminder < DynaccountObject
3
+ def self.ignore_put
4
+ [:id, :module_id_, :reminder_time, :reminder_time_due, :reminder_level, :balance, :name, :is_fi_payment]
5
+ end
6
+
7
+ def self.api_path
8
+ 'debtor_reminder'
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ module Dynaccount
2
+ class DebtorSubscription < DynaccountObject
3
+ def self.ignore_put
4
+ [:id, :is_active, :module_id, :time_next_charge, :vat_amount, :total_amount, :total_weight, :profit_amount]
5
+ end
6
+
7
+ def self.api_path
8
+ 'debtor_subscription'
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ module Dynaccount
2
+ class DebtorSubscriptionGroup < DynaccountObject
3
+ def self.ignore_put
4
+ [:id, :is_active, :time_next_charge, :vat_amount, :total_amount, :total_weight, :profit_amount]
5
+ end
6
+
7
+ def self.api_path
8
+ 'debtor_subscription_group'
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ module Dynaccount
2
+ class DebtorSubscriptionGroupProduct < DynaccountObject
3
+ def self.ignore_put
4
+ [:id, :product_id, :is_list_listing, :is_list_pricing, :vat_amount, :total_amount, :total_weight, :profit_amount]
5
+ end
6
+
7
+ def self.api_path
8
+ 'debtor_subscription_group_product'
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ module Dynaccount
2
+ class DebtorSubscriptionGroupProductList < DynaccountObject
3
+ def self.ignore_put
4
+ [:id, :product_id, :qty, :price, :discount_percent, :vat_amount, :total_amount, :total_weight, :profit_amount, :name, :list_qty]
5
+ end
6
+
7
+ def self.api_path
8
+ 'debtor_subscription_group_product_list'
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ module Dynaccount
2
+ class DebtorSubscriptionProduct < DynaccountObject
3
+ def self.ignore_put
4
+ [:id, :product_id, :is_list_listing, :is_list_pricing, :vat_amount, :total_amount, :total_weight, :profit_amount]
5
+ end
6
+
7
+ def self.api_path
8
+ 'debtor_subscription_product'
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ module Dynaccount
2
+ class DebtorSubscriptionProductList < DynaccountObject
3
+ def self.ignore_put
4
+ [:id, :product_id, :qty, :price, :discount_percent, :vat_amount, :total_amount, :total_weight, :profit_amount, :name, :list_qty]
5
+ end
6
+
7
+ def self.api_path
8
+ 'debtor_subscription_product_list'
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ module Dynaccount
2
+ class Dimension < DynaccountObject
3
+ def self.ignore_put
4
+ [:id]
5
+ end
6
+
7
+ def self.api_path
8
+ 'dimension'
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ module Dynaccount
2
+ class Draft < DynaccountObject
3
+ def self.ignore_put
4
+ [:id]
5
+ end
6
+
7
+ def self.api_path
8
+ 'draft'
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,53 @@
1
+ module Dynaccount
2
+ class DynaccountObject
3
+ def initialize(attributes)
4
+ @keys = attributes.keys
5
+ attributes.each do |k, v|
6
+ singleton_class.send(:attr_accessor, k.to_sym)
7
+ send("#{k}=", v)
8
+ end
9
+ end
10
+
11
+ def update(attributes = {})
12
+ return true if attributes.empty?
13
+ updt = @keys.select { |k| !self.class.ignore_put.include?(k.to_sym) }
14
+ .map { |k| [k, send(k)] }
15
+ .to_h
16
+ attributes.merge!(updt)
17
+ Dynaccount.request(self.class.url(id, 'put'), attributes, :post).body
18
+ end
19
+
20
+ def save
21
+ updt = @keys.select { |k| !self.class.ignore_put.include?(k.to_sym) }
22
+ .map { |k| [k, send(k)] }
23
+ .to_h
24
+ Dynaccount.request(self.class.url(id, 'put'), updt, :post).body
25
+ end
26
+
27
+ def self.create(attributes = {})
28
+ Dynaccount.request(url(nil, 'put'), attributes, :post).body
29
+ end
30
+
31
+ def self.all
32
+ find(nil)
33
+ end
34
+
35
+ def self.find(id)
36
+ req = JSON.parse(Dynaccount.request(url(id, 'get'), {}, :post).body)['result'].map { |res| new(res) }
37
+ return req[0] if req.size == 1
38
+ req
39
+ end
40
+
41
+ def self.find_by(params = {})
42
+ req = JSON.parse(Dynaccount.request(url(nil, 'get', params), {}, :post).body)['result'].map { |res| new(res) }
43
+ return req[0] if req.size == 1
44
+ req
45
+ end
46
+
47
+ def self.url(id, action, params = {})
48
+ url = "/v5/#{Dynaccount.api_id}/#{Dynaccount.api_key}/#{action}/#{api_path}/json/#{"#{id}/" unless id.nil?}"
49
+ url += "?" + params.map { |k,v| "#{k}=#{v}" }.join('&') if params.any?
50
+ url
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,11 @@
1
+ module Dynaccount
2
+ class Enclosure < DynaccountObject
3
+ def self.ignore_put
4
+ [:id, :is_booked, :system, :dimension_id, :balance_amount, :vat_amount, :profit_amount]
5
+ end
6
+
7
+ def self.api_path
8
+ 'enclosure'
9
+ end
10
+ end
11
+ end