cashctrl 0.1.0 → 0.2.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 (130) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +418 -136
  3. data/cashctrl.gemspec +1 -1
  4. data/lib/cashctrl/client.rb +106 -103
  5. data/lib/cashctrl/collection.rb +6 -5
  6. data/lib/cashctrl/configuration.rb +1 -1
  7. data/lib/cashctrl/error.rb +3 -1
  8. data/lib/cashctrl/errors.rb +76 -0
  9. data/lib/cashctrl/localized_string.rb +2 -2
  10. data/lib/cashctrl/models/account.rb +5 -1
  11. data/lib/cashctrl/models/article.rb +9 -1
  12. data/lib/cashctrl/models/asset.rb +6 -1
  13. data/lib/cashctrl/models/attachment.rb +14 -0
  14. data/lib/cashctrl/models/bank.rb +3 -1
  15. data/lib/cashctrl/models/category.rb +1 -1
  16. data/lib/cashctrl/models/certificate_document.rb +1 -1
  17. data/lib/cashctrl/models/certificate_template.rb +1 -1
  18. data/lib/cashctrl/models/cost_center.rb +3 -1
  19. data/lib/cashctrl/models/currency.rb +1 -1
  20. data/lib/cashctrl/models/custom_field.rb +1 -1
  21. data/lib/cashctrl/models/custom_field_group.rb +1 -1
  22. data/lib/cashctrl/models/file.rb +2 -1
  23. data/lib/cashctrl/models/fiscal_period.rb +1 -1
  24. data/lib/cashctrl/models/fiscal_period_task.rb +1 -1
  25. data/lib/cashctrl/models/history.rb +1 -1
  26. data/lib/cashctrl/models/insurance_type.rb +1 -1
  27. data/lib/cashctrl/models/journal.rb +10 -1
  28. data/lib/cashctrl/models/journal_import.rb +1 -1
  29. data/lib/cashctrl/models/journal_import_entry.rb +1 -1
  30. data/lib/cashctrl/models/journal_item.rb +20 -0
  31. data/lib/cashctrl/models/loader.rb +3 -0
  32. data/lib/cashctrl/models/location.rb +1 -1
  33. data/lib/cashctrl/models/order.rb +8 -1
  34. data/lib/cashctrl/models/order_book_entry.rb +1 -1
  35. data/lib/cashctrl/models/order_document.rb +1 -1
  36. data/lib/cashctrl/models/order_item.rb +23 -0
  37. data/lib/cashctrl/models/order_layout.rb +1 -1
  38. data/lib/cashctrl/models/order_payment.rb +1 -1
  39. data/lib/cashctrl/models/person.rb +7 -1
  40. data/lib/cashctrl/models/report.rb +1 -1
  41. data/lib/cashctrl/models/report_collection.rb +1 -1
  42. data/lib/cashctrl/models/report_element.rb +1 -1
  43. data/lib/cashctrl/models/rounding.rb +2 -1
  44. data/lib/cashctrl/models/salary_book_entry.rb +1 -1
  45. data/lib/cashctrl/models/salary_certificate.rb +2 -1
  46. data/lib/cashctrl/models/salary_document.rb +1 -1
  47. data/lib/cashctrl/models/salary_field.rb +1 -1
  48. data/lib/cashctrl/models/salary_layout.rb +1 -1
  49. data/lib/cashctrl/models/salary_payment.rb +1 -1
  50. data/lib/cashctrl/models/salary_setting.rb +1 -1
  51. data/lib/cashctrl/models/salary_statement.rb +3 -1
  52. data/lib/cashctrl/models/salary_status.rb +1 -1
  53. data/lib/cashctrl/models/salary_sum.rb +1 -1
  54. data/lib/cashctrl/models/salary_template.rb +1 -1
  55. data/lib/cashctrl/models/salary_type.rb +1 -1
  56. data/lib/cashctrl/models/sequence_number.rb +1 -1
  57. data/lib/cashctrl/models/setting.rb +1 -1
  58. data/lib/cashctrl/models/tax.rb +2 -1
  59. data/lib/cashctrl/models/text.rb +1 -1
  60. data/lib/cashctrl/models/title.rb +1 -1
  61. data/lib/cashctrl/models/unit.rb +1 -1
  62. data/lib/cashctrl/relation.rb +271 -0
  63. data/lib/cashctrl/resource.rb +300 -57
  64. data/lib/cashctrl/resources/account/bank.rb +3 -13
  65. data/lib/cashctrl/resources/account/category.rb +3 -9
  66. data/lib/cashctrl/resources/account/cost_center/category.rb +3 -9
  67. data/lib/cashctrl/resources/account/cost_center.rb +3 -25
  68. data/lib/cashctrl/resources/account.rb +4 -30
  69. data/lib/cashctrl/resources/attachments.rb +32 -0
  70. data/lib/cashctrl/resources/base.rb +160 -84
  71. data/lib/cashctrl/resources/currency.rb +1 -10
  72. data/lib/cashctrl/resources/custom_field/group.rb +3 -11
  73. data/lib/cashctrl/resources/custom_field.rb +3 -15
  74. data/lib/cashctrl/resources/file/category.rb +4 -10
  75. data/lib/cashctrl/resources/file.rb +44 -28
  76. data/lib/cashctrl/resources/fiscal_period/task.rb +2 -12
  77. data/lib/cashctrl/resources/fiscal_period.rb +17 -59
  78. data/lib/cashctrl/resources/history.rb +3 -21
  79. data/lib/cashctrl/resources/import_session.rb +43 -0
  80. data/lib/cashctrl/resources/inventory/article/category.rb +3 -9
  81. data/lib/cashctrl/resources/inventory/article/import.rb +13 -0
  82. data/lib/cashctrl/resources/inventory/article.rb +3 -18
  83. data/lib/cashctrl/resources/inventory/asset/category.rb +3 -9
  84. data/lib/cashctrl/resources/inventory/asset.rb +3 -18
  85. data/lib/cashctrl/resources/inventory/unit.rb +1 -1
  86. data/lib/cashctrl/resources/journal/import/entry.rb +1 -22
  87. data/lib/cashctrl/resources/journal/import.rb +1 -7
  88. data/lib/cashctrl/resources/journal.rb +19 -57
  89. data/lib/cashctrl/resources/location.rb +1 -1
  90. data/lib/cashctrl/resources/order/book_entry.rb +1 -1
  91. data/lib/cashctrl/resources/order/category.rb +4 -15
  92. data/lib/cashctrl/resources/order/document.rb +13 -21
  93. data/lib/cashctrl/resources/order/layout.rb +1 -1
  94. data/lib/cashctrl/resources/order/payment.rb +9 -29
  95. data/lib/cashctrl/resources/order.rb +21 -68
  96. data/lib/cashctrl/resources/organization.rb +13 -0
  97. data/lib/cashctrl/resources/person/category.rb +3 -9
  98. data/lib/cashctrl/resources/person/import.rb +11 -0
  99. data/lib/cashctrl/resources/person/title.rb +1 -1
  100. data/lib/cashctrl/resources/person.rb +4 -23
  101. data/lib/cashctrl/resources/report/collection.rb +10 -42
  102. data/lib/cashctrl/resources/report/element.rb +14 -46
  103. data/lib/cashctrl/resources/report.rb +4 -30
  104. data/lib/cashctrl/resources/rounding.rb +1 -1
  105. data/lib/cashctrl/resources/salary/book_entry.rb +1 -1
  106. data/lib/cashctrl/resources/salary/category.rb +3 -9
  107. data/lib/cashctrl/resources/salary/certificate/document.rb +14 -39
  108. data/lib/cashctrl/resources/salary/certificate/template.rb +2 -8
  109. data/lib/cashctrl/resources/salary/certificate.rb +2 -12
  110. data/lib/cashctrl/resources/salary/document.rb +14 -34
  111. data/lib/cashctrl/resources/salary/field.rb +3 -17
  112. data/lib/cashctrl/resources/salary/insurance/type.rb +1 -1
  113. data/lib/cashctrl/resources/salary/layout.rb +1 -1
  114. data/lib/cashctrl/resources/salary/payment.rb +9 -29
  115. data/lib/cashctrl/resources/salary/setting.rb +1 -1
  116. data/lib/cashctrl/resources/salary/statement.rb +19 -54
  117. data/lib/cashctrl/resources/salary/status.rb +3 -11
  118. data/lib/cashctrl/resources/salary/sum.rb +1 -1
  119. data/lib/cashctrl/resources/salary/template.rb +2 -8
  120. data/lib/cashctrl/resources/salary/type.rb +1 -8
  121. data/lib/cashctrl/resources/sequence_number.rb +1 -7
  122. data/lib/cashctrl/resources/setting.rb +6 -24
  123. data/lib/cashctrl/resources/tax.rb +1 -1
  124. data/lib/cashctrl/resources/text.rb +1 -1
  125. data/lib/cashctrl/schema.yml +111 -0
  126. data/lib/cashctrl/version.rb +2 -2
  127. data/lib/cashctrl.rb +35 -25
  128. data/lib/generators/model_generator.rb +19 -7
  129. data/sig/cashctrl.rbs +1 -1
  130. metadata +12 -2
data/cashctrl.gemspec CHANGED
@@ -4,7 +4,7 @@ require_relative "lib/cashctrl/version"
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "cashctrl"
7
- spec.version = Cashctrl::VERSION
7
+ spec.version = CashCtrl::VERSION
8
8
  spec.authors = ["Marco Roth"]
9
9
  spec.email = ["marco.roth@intergga.ch"]
10
10
 
@@ -1,9 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "bigdecimal"
4
+ require "date"
3
5
  require "faraday"
4
6
  require "json"
5
7
 
6
- module Cashctrl
8
+ module CashCtrl
7
9
  class Client
8
10
  attr_reader :config
9
11
 
@@ -18,130 +20,126 @@ module Cashctrl
18
20
  @connection ||= build_connection
19
21
  end
20
22
 
23
+ MAX_REDIRECTS = 5
24
+
21
25
  def get(path, params = {})
22
- params = params.merge(lang: config.language) if config.language
23
- response = connection.get(path, params)
26
+ response = connection.get(path, prepare_params(params))
24
27
  handle_response(response)
25
28
  end
26
29
 
27
30
  def post(path, params = {})
28
- params = params.merge(lang: config.language) if config.language
29
- response = connection.post(path, params)
31
+ response = connection.post(path, prepare_params(params))
30
32
  handle_response(response)
31
33
  end
32
34
 
33
35
  def get_raw(path, params = {})
34
- params = params.merge(lang: config.language) if config.language
35
- response = raw_connection.get(path, params)
36
+ response = raw_connection.get(path, prepare_params(params))
37
+ response = follow_redirects(response)
36
38
  handle_raw_response(response)
37
39
  end
38
40
 
39
- def accounts
40
- Resources::Account.new(self)
41
- end
42
-
43
- def account_categories
44
- Resources::Account::Category.new(self)
45
- end
46
-
47
- def account_cost_centers
48
- Resources::Account::CostCenter.new(self)
49
- end
50
-
51
- def bank_accounts
52
- Resources::Account::Bank.new(self)
53
- end
54
-
55
- def currencies
56
- Resources::Currency.new(self)
57
- end
58
-
59
- def custom_fields
60
- Resources::CustomField.new(self)
61
- end
62
-
63
- def files
64
- Resources::CashctrlFile.new(self)
65
- end
66
-
67
- def file_categories
68
- Resources::CashctrlFile::Category.new(self)
69
- end
70
-
71
- def fiscal_periods
72
- Resources::FiscalPeriod.new(self)
73
- end
74
-
75
- def inventory_articles
76
- Resources::Inventory::Article.new(self)
77
- end
78
-
79
- def inventory_assets
80
- Resources::Inventory::Asset.new(self)
81
- end
82
-
83
- def inventory_units
84
- Resources::Inventory::Unit.new(self)
85
- end
86
-
87
- def journal_entries
88
- Resources::Journal.new(self)
89
- end
90
-
91
- def locations
92
- Resources::Location.new(self)
93
- end
94
-
95
- def orders
96
- Resources::Order.new(self)
97
- end
98
-
99
- def order_categories
100
- Resources::Order::Category.new(self)
101
- end
102
-
103
- def order_documents
104
- Resources::Order::Document.new(self)
105
- end
106
-
107
- def persons
108
- Resources::Person.new(self)
109
- end
110
-
111
- def person_categories
112
- Resources::Person::Category.new(self)
113
- end
114
-
115
- def person_titles
116
- Resources::Person::Title.new(self)
41
+ def put_raw(url, body, content_type: "application/octet-stream")
42
+ response = Faraday.put(url, body, "Content-Type" => content_type)
43
+ return response if response.success?
44
+
45
+ raise Error.new("Upload failed: #{response.status}", response: response)
46
+ end
47
+
48
+ RESOURCES = {
49
+ accounts: "Account",
50
+ account_banks: "Account::Bank",
51
+ account_categories: "Account::Category",
52
+ account_cost_centers: "Account::CostCenter",
53
+ account_cost_center_categories: "Account::CostCenter::Category",
54
+ currencies: "Currency",
55
+ custom_fields: "CustomField",
56
+ custom_field_groups: "CustomField::Group",
57
+ files: "File",
58
+ file_categories: "File::Category",
59
+ fiscal_periods: "FiscalPeriod",
60
+ fiscal_period_tasks: "FiscalPeriod::Task",
61
+ history: "History",
62
+ inventory_articles: "Inventory::Article",
63
+ inventory_article_categories: "Inventory::Article::Category",
64
+ inventory_article_imports: "Inventory::Article::Import",
65
+ inventory_assets: "Inventory::Asset",
66
+ inventory_asset_categories: "Inventory::Asset::Category",
67
+ inventory_units: "Inventory::Unit",
68
+ journals: "Journal",
69
+ journal_imports: "Journal::Import",
70
+ journal_import_entries: "Journal::Import::Entry",
71
+ locations: "Location",
72
+ orders: "Order",
73
+ order_book_entries: "Order::BookEntry",
74
+ order_categories: "Order::Category",
75
+ order_documents: "Order::Document",
76
+ order_layouts: "Order::Layout",
77
+ order_payments: "Order::Payment",
78
+ organization: "Organization",
79
+ people: "Person",
80
+ person_categories: "Person::Category",
81
+ person_imports: "Person::Import",
82
+ person_titles: "Person::Title",
83
+ reports: "Report",
84
+ report_collections: "Report::Collection",
85
+ report_elements: "Report::Element",
86
+ roundings: "Rounding",
87
+ salary_book_entries: "Salary::BookEntry",
88
+ salary_categories: "Salary::Category",
89
+ salary_certificates: "Salary::Certificate",
90
+ salary_certificate_documents: "Salary::Certificate::Document",
91
+ salary_certificate_templates: "Salary::Certificate::Template",
92
+ salary_documents: "Salary::Document",
93
+ salary_fields: "Salary::Field",
94
+ salary_insurance_types: "Salary::Insurance::Type",
95
+ salary_layouts: "Salary::Layout",
96
+ salary_payments: "Salary::Payment",
97
+ salary_settings: "Salary::Setting",
98
+ salary_statements: "Salary::Statement",
99
+ salary_statuses: "Salary::Status",
100
+ salary_sums: "Salary::Sum",
101
+ salary_templates: "Salary::Template",
102
+ salary_types: "Salary::Type",
103
+ sequence_numbers: "SequenceNumber",
104
+ settings: "Setting",
105
+ taxes: "Tax",
106
+ texts: "Text",
107
+ }.freeze
108
+
109
+ RESOURCES.each do |name, resource|
110
+ define_method(name) do
111
+ Resources.const_get(resource).with_client(self)
112
+ end
117
113
  end
118
114
 
119
- def reports
120
- Resources::Report.new(self)
121
- end
115
+ private
122
116
 
123
- def roundings
124
- Resources::Rounding.new(self)
117
+ def prepare_params(params)
118
+ params = params.transform_values { |value| encode_param(value) }
119
+ params = params.merge(lang: config.language) if config.language
120
+ params
125
121
  end
126
122
 
127
- def sequence_numbers
128
- Resources::SequenceNumber.new(self)
123
+ def encode_param(value)
124
+ case value
125
+ when Array, Hash then value.to_json
126
+ when BigDecimal then value.to_s("F")
127
+ when DateTime, Time then value.strftime("%Y-%m-%d %H:%M:%S")
128
+ when Date then value.iso8601
129
+ else value
130
+ end
129
131
  end
130
132
 
131
- def settings
132
- Resources::Setting.new(self)
133
- end
133
+ def follow_redirects(response)
134
+ MAX_REDIRECTS.times do
135
+ break unless [301, 302, 303, 307, 308].include?(response.status) && response.headers["location"]
134
136
 
135
- def taxes
136
- Resources::Tax.new(self)
137
- end
137
+ response = Faraday.get(response.headers["location"])
138
+ end
138
139
 
139
- def texts
140
- Resources::Text.new(self)
140
+ response
141
141
  end
142
142
 
143
- private
144
-
145
143
  def build_connection
146
144
  config.validate!
147
145
 
@@ -171,6 +169,8 @@ module Cashctrl
171
169
  handle_success_response(response)
172
170
  when 401
173
171
  raise AuthenticationError.new("Invalid API key", response: response)
172
+ when 403
173
+ raise PermissionError.new("API key lacks permission for this request", response: response)
174
174
  when 404
175
175
  raise NotFoundError.new("Resource not found", response: response)
176
176
  when 429
@@ -189,7 +189,8 @@ module Cashctrl
189
189
 
190
190
  if body["success"] == false
191
191
  errors = body["errors"] || []
192
- message = body["message"] || errors.map { |e| e["message"] }.join(", ")
192
+ message = body["message"] || body["errorMessage"] ||
193
+ errors.map { |e| [e["field"], e["message"]].compact.join(": ") }.join(", ")
193
194
  raise ValidationError.new(message, errors: errors, response: response)
194
195
  end
195
196
 
@@ -202,6 +203,8 @@ module Cashctrl
202
203
  response.body
203
204
  when 401
204
205
  raise AuthenticationError.new("Invalid API key", response: response)
206
+ when 403
207
+ raise PermissionError.new("API key lacks permission for this request", response: response)
205
208
  when 404
206
209
  raise NotFoundError.new("Resource not found", response: response)
207
210
  when 429
@@ -1,12 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Cashctrl
3
+ module CashCtrl
4
4
  class Collection
5
5
  include Enumerable
6
6
 
7
7
  attr_reader :data, :total, :summary, :properties, :resource_class
8
8
 
9
- def self.from_response(response, resource_class: Resource)
9
+ def self.from_response(response, resource_class: Resource, resource: nil)
10
10
  data = response.is_a?(Array) ? response : (response["data"] || [])
11
11
 
12
12
  new(
@@ -14,13 +14,14 @@ module Cashctrl
14
14
  total: response.is_a?(Hash) ? response["total"] : nil,
15
15
  summary: response.is_a?(Hash) ? response["summary"] : nil,
16
16
  properties: response.is_a?(Hash) ? response["properties"] : nil,
17
- resource_class: resource_class
17
+ resource_class: resource_class,
18
+ resource: resource
18
19
  )
19
20
  end
20
21
 
21
- def initialize(data:, total: nil, summary: nil, properties: nil, resource_class: Resource)
22
+ def initialize(data:, total: nil, summary: nil, properties: nil, resource_class: Resource, resource: nil)
22
23
  @resource_class = resource_class
23
- @data = data.map { |item| resource_class.from_response(item) }
24
+ @data = data.map { |item| resource_class.from_response(item, resource: resource) }
24
25
  @total = total || @data.size
25
26
  @summary = summary
26
27
  @properties = properties
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Cashctrl
3
+ module CashCtrl
4
4
  class Configuration
5
5
  attr_accessor :org, :api_key, :language
6
6
 
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Cashctrl
3
+ module CashCtrl
4
4
  class Error < StandardError
5
5
  attr_reader :response
6
6
 
@@ -12,12 +12,14 @@ module Cashctrl
12
12
 
13
13
  class ConfigurationError < Error; end
14
14
  class AuthenticationError < Error; end
15
+ class PermissionError < Error; end
15
16
  class NotFoundError < Error; end
16
17
  class RateLimitError < Error; end
17
18
  class ServerError < Error; end
18
19
 
19
20
  class ValidationError < Error
20
21
  attr_reader :errors
22
+ attr_accessor :record
21
23
 
22
24
  def initialize(message = nil, errors: [], response: nil)
23
25
  @errors = errors
@@ -0,0 +1,76 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CashCtrl
4
+ class Errors
5
+ include Enumerable
6
+
7
+ def initialize
8
+ @messages = {}
9
+ end
10
+
11
+ def add(attribute, message)
12
+ (@messages[attribute.to_sym] ||= []) << message
13
+ end
14
+
15
+ def add_api_errors(error)
16
+ error.errors.each do |entry|
17
+ field = entry["field"].to_s.gsub(/([A-Z])/) { "_#{Regexp.last_match(1).downcase}" }
18
+ add(field.empty? ? :base : field, entry["message"])
19
+ end
20
+
21
+ add(:base, error.message) if error.errors.empty? && error.message
22
+ end
23
+
24
+ def [](attribute)
25
+ @messages.fetch(attribute.to_sym, [])
26
+ end
27
+
28
+ def messages
29
+ @messages.transform_values(&:dup)
30
+ end
31
+
32
+ alias to_h messages
33
+
34
+ def include?(attribute)
35
+ @messages.key?(attribute.to_sym)
36
+ end
37
+
38
+ def each(&)
39
+ @messages.each { |attribute, messages| messages.each { |message| yield attribute, message } }
40
+ end
41
+
42
+ def full_messages
43
+ map { |attribute, message| full_message(attribute, message) }
44
+ end
45
+
46
+ def full_messages_for(attribute)
47
+ self[attribute].map { |message| full_message(attribute.to_sym, message) }
48
+ end
49
+
50
+ def size
51
+ @messages.values.sum(&:size)
52
+ end
53
+
54
+ alias count size
55
+
56
+ def empty?
57
+ @messages.empty?
58
+ end
59
+
60
+ def clear
61
+ @messages.clear
62
+ end
63
+
64
+ def inspect
65
+ "#<#{self.class.name} #{@messages.inspect}>"
66
+ end
67
+
68
+ private
69
+
70
+ def full_message(attribute, message)
71
+ return message if attribute == :base
72
+
73
+ "#{attribute.to_s.tr("_", " ").capitalize} #{message}"
74
+ end
75
+ end
76
+ end
@@ -2,7 +2,7 @@
2
2
 
3
3
  require "rexml/document"
4
4
 
5
- module Cashctrl
5
+ module CashCtrl
6
6
  class LocalizedString
7
7
  LOCALIZED_PATTERN = %r{<values>.*?</values>}m
8
8
 
@@ -39,7 +39,7 @@ module Cashctrl
39
39
  current_locale = if defined?(I18n) && I18n.respond_to?(:locale)
40
40
  I18n.locale.to_s.downcase
41
41
  else
42
- Cashctrl.configuration&.language&.downcase || "en"
42
+ CashCtrl.configuration&.language&.downcase || "en"
43
43
  end
44
44
 
45
45
  value = @translations[current_locale] || @translations["en"] || @translations.values.first
@@ -2,7 +2,7 @@
2
2
 
3
3
  # This file is auto-generated from schema.yml. Do not edit manually.
4
4
 
5
- module Cashctrl
5
+ module CashCtrl
6
6
  module Models
7
7
  class Account < Resource
8
8
  attribute :category_id, type: :integer
@@ -30,6 +30,10 @@ module Cashctrl
30
30
  attribute :is_inactive, type: :boolean
31
31
  attribute :is_in_salary_type, type: :boolean, readonly: true
32
32
  attribute :is_bank_account, type: :boolean, readonly: true
33
+ belongs_to :category, resource: "Account::Category"
34
+ belongs_to :tax, resource: "Tax"
35
+ belongs_to :currency, resource: "Currency"
36
+ nested :attachments, model: "Attachment"
33
37
  end
34
38
  end
35
39
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  # This file is auto-generated from schema.yml. Do not edit manually.
4
4
 
5
- module Cashctrl
5
+ module CashCtrl
6
6
  module Models
7
7
  class Article < Resource
8
8
  attribute :category_id, type: :integer
@@ -35,6 +35,14 @@ module Cashctrl
35
35
  attribute :is_purchase_price_gross, type: :boolean
36
36
  attribute :is_sales_price_gross, type: :boolean
37
37
  attribute :is_inactive, type: :boolean
38
+ belongs_to :category, resource: "Inventory::Article::Category"
39
+ belongs_to :unit, resource: "Inventory::Unit"
40
+ belongs_to :sales_account, resource: "Account"
41
+ belongs_to :purchase_account, resource: "Account"
42
+ belongs_to :sales_tax, resource: "Tax"
43
+ belongs_to :purchase_tax, resource: "Tax"
44
+ belongs_to :currency, resource: "Currency"
45
+ nested :attachments, model: "Attachment"
38
46
  end
39
47
  end
40
48
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  # This file is auto-generated from schema.yml. Do not edit manually.
4
4
 
5
- module Cashctrl
5
+ module CashCtrl
6
6
  module Models
7
7
  class Asset < Resource
8
8
  attribute :category_id, type: :integer
@@ -27,6 +27,11 @@ module Cashctrl
27
27
  attribute :notes, type: :string
28
28
  attribute :attachment_count, type: :integer, readonly: true
29
29
  attribute :is_inactive, type: :boolean
30
+ belongs_to :category, resource: "Inventory::Asset::Category"
31
+ belongs_to :account_asset, resource: "Account"
32
+ belongs_to :account_depreciation, resource: "Account"
33
+ belongs_to :account_expense, resource: "Account"
34
+ nested :attachments, model: "Attachment"
30
35
  end
31
36
  end
32
37
  end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This file is auto-generated from schema.yml. Do not edit manually.
4
+
5
+ module CashCtrl
6
+ module Models
7
+ class Attachment < Resource
8
+ attribute :file_id, type: :integer
9
+ attribute :name, type: :string
10
+ attribute :mime_type, type: :string
11
+ belongs_to :file, resource: "File"
12
+ end
13
+ end
14
+ end
@@ -2,7 +2,7 @@
2
2
 
3
3
  # This file is auto-generated from schema.yml. Do not edit manually.
4
4
 
5
- module Cashctrl
5
+ module CashCtrl
6
6
  module Models
7
7
  class Bank < Resource
8
8
  attribute :account_id, type: :integer
@@ -11,6 +11,8 @@ module Cashctrl
11
11
  attribute :iban, type: :string
12
12
  attribute :bic, type: :string
13
13
  attribute :qr_iban, type: :string
14
+ belongs_to :account, resource: "Account"
15
+ nested :attachments, model: "Attachment"
14
16
  end
15
17
  end
16
18
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  # This file is auto-generated from schema.yml. Do not edit manually.
4
4
 
5
- module Cashctrl
5
+ module CashCtrl
6
6
  module Models
7
7
  class Category < Resource
8
8
  attribute :parent_id, type: :integer
@@ -2,7 +2,7 @@
2
2
 
3
3
  # This file is auto-generated from schema.yml. Do not edit manually.
4
4
 
5
- module Cashctrl
5
+ module CashCtrl
6
6
  module Models
7
7
  class CertificateDocument < Resource
8
8
  attribute :certificate_id, type: :integer
@@ -2,7 +2,7 @@
2
2
 
3
3
  # This file is auto-generated from schema.yml. Do not edit manually.
4
4
 
5
- module Cashctrl
5
+ module CashCtrl
6
6
  module Models
7
7
  class CertificateTemplate < Resource
8
8
  attribute :name, type: :string
@@ -2,7 +2,7 @@
2
2
 
3
3
  # This file is auto-generated from schema.yml. Do not edit manually.
4
4
 
5
- module Cashctrl
5
+ module CashCtrl
6
6
  module Models
7
7
  class CostCenter < Resource
8
8
  attribute :category_id, type: :integer
@@ -10,6 +10,8 @@ module Cashctrl
10
10
  attribute :number, type: :string
11
11
  attribute :name, type: :string
12
12
  attribute :notes, type: :string
13
+ belongs_to :category, resource: "Account::CostCenter::Category"
14
+ nested :attachments, model: "Attachment"
13
15
  end
14
16
  end
15
17
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  # This file is auto-generated from schema.yml. Do not edit manually.
4
4
 
5
- module Cashctrl
5
+ module CashCtrl
6
6
  module Models
7
7
  class Currency < Resource
8
8
  attribute :code, type: :string
@@ -2,7 +2,7 @@
2
2
 
3
3
  # This file is auto-generated from schema.yml. Do not edit manually.
4
4
 
5
- module Cashctrl
5
+ module CashCtrl
6
6
  module Models
7
7
  class CustomField < Resource
8
8
  attribute :type, type: :string
@@ -2,7 +2,7 @@
2
2
 
3
3
  # This file is auto-generated from schema.yml. Do not edit manually.
4
4
 
5
- module Cashctrl
5
+ module CashCtrl
6
6
  module Models
7
7
  class CustomFieldGroup < Resource
8
8
  attribute :type, type: :string
@@ -2,7 +2,7 @@
2
2
 
3
3
  # This file is auto-generated from schema.yml. Do not edit manually.
4
4
 
5
- module Cashctrl
5
+ module CashCtrl
6
6
  module Models
7
7
  class File < Resource
8
8
  attribute :category_id, type: :integer
@@ -14,6 +14,7 @@ module Cashctrl
14
14
  attribute :height, type: :integer, readonly: true
15
15
  attribute :notes, type: :string
16
16
  attribute :is_archived, type: :boolean, readonly: true
17
+ belongs_to :category, resource: "File::Category"
17
18
  end
18
19
  end
19
20
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  # This file is auto-generated from schema.yml. Do not edit manually.
4
4
 
5
- module Cashctrl
5
+ module CashCtrl
6
6
  module Models
7
7
  class FiscalPeriod < Resource
8
8
  attribute :name, type: :string
@@ -2,7 +2,7 @@
2
2
 
3
3
  # This file is auto-generated from schema.yml. Do not edit manually.
4
4
 
5
- module Cashctrl
5
+ module CashCtrl
6
6
  module Models
7
7
  class FiscalPeriodTask < Resource
8
8
  attribute :fiscal_period_id, type: :integer
@@ -2,7 +2,7 @@
2
2
 
3
3
  # This file is auto-generated from schema.yml. Do not edit manually.
4
4
 
5
- module Cashctrl
5
+ module CashCtrl
6
6
  module Models
7
7
  class History < Resource
8
8
  attribute :type, type: :string