cashctrl 0.0.1 → 0.1.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 (119) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE.txt +21 -0
  3. data/README.md +549 -14
  4. data/lib/cashctrl/client.rb +216 -0
  5. data/lib/cashctrl/collection.rb +77 -0
  6. data/lib/cashctrl/configuration.rb +30 -0
  7. data/lib/cashctrl/error.rb +27 -0
  8. data/lib/cashctrl/localized_string.rb +115 -0
  9. data/lib/cashctrl/models/account.rb +35 -0
  10. data/lib/cashctrl/models/article.rb +40 -0
  11. data/lib/cashctrl/models/asset.rb +32 -0
  12. data/lib/cashctrl/models/bank.rb +16 -0
  13. data/lib/cashctrl/models/category.rb +13 -0
  14. data/lib/cashctrl/models/certificate_document.rb +14 -0
  15. data/lib/cashctrl/models/certificate_template.rb +13 -0
  16. data/lib/cashctrl/models/cost_center.rb +15 -0
  17. data/lib/cashctrl/models/currency.rb +18 -0
  18. data/lib/cashctrl/models/custom_field.rb +18 -0
  19. data/lib/cashctrl/models/custom_field_group.rb +12 -0
  20. data/lib/cashctrl/models/file.rb +19 -0
  21. data/lib/cashctrl/models/fiscal_period.rb +16 -0
  22. data/lib/cashctrl/models/fiscal_period_task.rb +14 -0
  23. data/lib/cashctrl/models/history.rb +19 -0
  24. data/lib/cashctrl/models/insurance_type.rb +13 -0
  25. data/lib/cashctrl/models/journal.rb +56 -0
  26. data/lib/cashctrl/models/journal_import.rb +18 -0
  27. data/lib/cashctrl/models/journal_import_entry.rb +20 -0
  28. data/lib/cashctrl/models/loader.rb +52 -0
  29. data/lib/cashctrl/models/location.rb +22 -0
  30. data/lib/cashctrl/models/order.rb +46 -0
  31. data/lib/cashctrl/models/order_book_entry.rb +17 -0
  32. data/lib/cashctrl/models/order_document.rb +15 -0
  33. data/lib/cashctrl/models/order_layout.rb +18 -0
  34. data/lib/cashctrl/models/order_payment.rb +16 -0
  35. data/lib/cashctrl/models/person.rb +72 -0
  36. data/lib/cashctrl/models/report.rb +15 -0
  37. data/lib/cashctrl/models/report_collection.rb +13 -0
  38. data/lib/cashctrl/models/report_element.rb +16 -0
  39. data/lib/cashctrl/models/rounding.rb +15 -0
  40. data/lib/cashctrl/models/salary_book_entry.rb +16 -0
  41. data/lib/cashctrl/models/salary_certificate.rb +15 -0
  42. data/lib/cashctrl/models/salary_document.rb +15 -0
  43. data/lib/cashctrl/models/salary_field.rb +16 -0
  44. data/lib/cashctrl/models/salary_layout.rb +13 -0
  45. data/lib/cashctrl/models/salary_payment.rb +16 -0
  46. data/lib/cashctrl/models/salary_setting.rb +12 -0
  47. data/lib/cashctrl/models/salary_statement.rb +17 -0
  48. data/lib/cashctrl/models/salary_status.rb +12 -0
  49. data/lib/cashctrl/models/salary_sum.rb +14 -0
  50. data/lib/cashctrl/models/salary_template.rb +12 -0
  51. data/lib/cashctrl/models/salary_type.rb +14 -0
  52. data/lib/cashctrl/models/sequence_number.rb +13 -0
  53. data/lib/cashctrl/models/setting.rb +33 -0
  54. data/lib/cashctrl/models/tax.rb +17 -0
  55. data/lib/cashctrl/models/text.rb +13 -0
  56. data/lib/cashctrl/models/title.rb +13 -0
  57. data/lib/cashctrl/models/unit.rb +11 -0
  58. data/lib/cashctrl/resource.rb +190 -0
  59. data/lib/cashctrl/resources/account/bank.rb +24 -0
  60. data/lib/cashctrl/resources/account/category.rb +22 -0
  61. data/lib/cashctrl/resources/account/cost_center/category.rb +24 -0
  62. data/lib/cashctrl/resources/account/cost_center.rb +48 -0
  63. data/lib/cashctrl/resources/account.rb +54 -0
  64. data/lib/cashctrl/resources/base.rb +161 -0
  65. data/lib/cashctrl/resources/currency.rb +26 -0
  66. data/lib/cashctrl/resources/custom_field/group.rb +24 -0
  67. data/lib/cashctrl/resources/custom_field.rb +30 -0
  68. data/lib/cashctrl/resources/file/category.rb +22 -0
  69. data/lib/cashctrl/resources/file.rb +66 -0
  70. data/lib/cashctrl/resources/fiscal_period/task.rb +30 -0
  71. data/lib/cashctrl/resources/fiscal_period.rb +96 -0
  72. data/lib/cashctrl/resources/history.rb +44 -0
  73. data/lib/cashctrl/resources/inventory/article/category.rb +24 -0
  74. data/lib/cashctrl/resources/inventory/article.rb +34 -0
  75. data/lib/cashctrl/resources/inventory/asset/category.rb +24 -0
  76. data/lib/cashctrl/resources/inventory/asset.rb +34 -0
  77. data/lib/cashctrl/resources/inventory/unit.rb +12 -0
  78. data/lib/cashctrl/resources/journal/import/entry.rb +54 -0
  79. data/lib/cashctrl/resources/journal/import.rb +22 -0
  80. data/lib/cashctrl/resources/journal.rb +94 -0
  81. data/lib/cashctrl/resources/location.rb +10 -0
  82. data/lib/cashctrl/resources/order/book_entry.rb +12 -0
  83. data/lib/cashctrl/resources/order/category.rb +32 -0
  84. data/lib/cashctrl/resources/order/document.rb +38 -0
  85. data/lib/cashctrl/resources/order/layout.rb +12 -0
  86. data/lib/cashctrl/resources/order/payment.rb +56 -0
  87. data/lib/cashctrl/resources/order.rb +94 -0
  88. data/lib/cashctrl/resources/person/category.rb +22 -0
  89. data/lib/cashctrl/resources/person/title.rb +12 -0
  90. data/lib/cashctrl/resources/person.rb +40 -0
  91. data/lib/cashctrl/resources/report/collection.rb +72 -0
  92. data/lib/cashctrl/resources/report/element.rb +80 -0
  93. data/lib/cashctrl/resources/report.rb +60 -0
  94. data/lib/cashctrl/resources/rounding.rb +10 -0
  95. data/lib/cashctrl/resources/salary/book_entry.rb +12 -0
  96. data/lib/cashctrl/resources/salary/category.rb +22 -0
  97. data/lib/cashctrl/resources/salary/certificate/document.rb +72 -0
  98. data/lib/cashctrl/resources/salary/certificate/template.rb +24 -0
  99. data/lib/cashctrl/resources/salary/certificate.rb +30 -0
  100. data/lib/cashctrl/resources/salary/document.rb +62 -0
  101. data/lib/cashctrl/resources/salary/field.rb +38 -0
  102. data/lib/cashctrl/resources/salary/insurance/type.rb +14 -0
  103. data/lib/cashctrl/resources/salary/layout.rb +12 -0
  104. data/lib/cashctrl/resources/salary/payment.rb +56 -0
  105. data/lib/cashctrl/resources/salary/setting.rb +12 -0
  106. data/lib/cashctrl/resources/salary/statement.rb +77 -0
  107. data/lib/cashctrl/resources/salary/status.rb +24 -0
  108. data/lib/cashctrl/resources/salary/sum.rb +12 -0
  109. data/lib/cashctrl/resources/salary/template.rb +22 -0
  110. data/lib/cashctrl/resources/salary/type.rb +24 -0
  111. data/lib/cashctrl/resources/sequence_number.rb +20 -0
  112. data/lib/cashctrl/resources/setting.rb +52 -0
  113. data/lib/cashctrl/resources/tax.rb +10 -0
  114. data/lib/cashctrl/resources/text.rb +10 -0
  115. data/lib/cashctrl/schema.yml +601 -0
  116. data/lib/cashctrl/version.rb +1 -1
  117. data/lib/cashctrl.rb +114 -2
  118. data/lib/generators/model_generator.rb +92 -0
  119. metadata +115 -1
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cashctrl
4
+ module Resources
5
+ class Currency < Base
6
+ api_path "currency"
7
+ model_class Models::Currency
8
+
9
+ class << self
10
+ def exchange_rate(from:, to:, date: nil)
11
+ params = { from: from, to: to }
12
+ params[:date] = date if date
13
+ result = client.get_raw("#{api_path}/exchangerate", params)
14
+ BigDecimal(result.to_s)
15
+ end
16
+ end
17
+
18
+ def exchange_rate(from:, to:, date: nil)
19
+ params = { from: from, to: to }
20
+ params[:date] = date if date
21
+ result = client.get_raw("#{api_path}/exchangerate", params)
22
+ BigDecimal(result.to_s)
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cashctrl
4
+ module Resources
5
+ class CustomField
6
+ class Group < Base
7
+ api_path "customfield/group"
8
+ model_class Models::CustomFieldGroup
9
+
10
+ class << self
11
+ def reorder(ids:)
12
+ ids_param = Array(ids).join(",")
13
+ client.post("#{api_path}/reorder.json", ids: ids_param)
14
+ end
15
+ end
16
+
17
+ def reorder(ids:)
18
+ ids_param = Array(ids).join(",")
19
+ client.post("#{api_path}/reorder.json", ids: ids_param)
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cashctrl
4
+ module Resources
5
+ class CustomField < Base
6
+ api_path "customfield"
7
+ model_class Models::CustomField
8
+
9
+ class << self
10
+ def types
11
+ client.get("#{api_path}/types.json")
12
+ end
13
+
14
+ def reorder(ids:)
15
+ ids_param = Array(ids).join(",")
16
+ client.post("#{api_path}/reorder.json", ids: ids_param)
17
+ end
18
+ end
19
+
20
+ def types
21
+ client.get("#{api_path}/types.json")
22
+ end
23
+
24
+ def reorder(ids:)
25
+ ids_param = Array(ids).join(",")
26
+ client.post("#{api_path}/reorder.json", ids: ids_param)
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cashctrl
4
+ module Resources
5
+ class CashctrlFile
6
+ class Category < Base
7
+ api_path "file/category"
8
+ model_class Models::Category
9
+
10
+ class << self
11
+ def tree
12
+ client.get("#{api_path}/tree.json")
13
+ end
14
+ end
15
+
16
+ def tree
17
+ client.get("#{api_path}/tree.json")
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,66 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cashctrl
4
+ module Resources
5
+ class CashctrlFile < Base
6
+ api_path "file"
7
+ model_class Models::File
8
+
9
+ class << self
10
+ def get(id:)
11
+ client.get_raw("#{api_path}/get", id: id)
12
+ end
13
+
14
+ def prepare(mime_type:, name:)
15
+ client.post("#{api_path}/prepare.json", mimeType: mime_type, name: name)
16
+ end
17
+
18
+ def persist(ids:)
19
+ ids_param = Array(ids).join(",")
20
+ client.post("#{api_path}/persist.json", ids: ids_param)
21
+ end
22
+
23
+ def categorize(ids:, target:)
24
+ ids_param = Array(ids).join(",")
25
+ client.post("#{api_path}/categorize.json", ids: ids_param, target: target)
26
+ end
27
+
28
+ def empty_archive
29
+ client.post("#{api_path}/empty_archive.json")
30
+ end
31
+
32
+ def restore(ids:)
33
+ ids_param = Array(ids).join(",")
34
+ client.post("#{api_path}/restore.json", ids: ids_param)
35
+ end
36
+ end
37
+
38
+ def get(id:)
39
+ client.get_raw("#{api_path}/get", id: id)
40
+ end
41
+
42
+ def prepare(mime_type:, name:)
43
+ client.post("#{api_path}/prepare.json", mimeType: mime_type, name: name)
44
+ end
45
+
46
+ def persist(ids:)
47
+ ids_param = Array(ids).join(",")
48
+ client.post("#{api_path}/persist.json", ids: ids_param)
49
+ end
50
+
51
+ def categorize(ids:, target:)
52
+ ids_param = Array(ids).join(",")
53
+ client.post("#{api_path}/categorize.json", ids: ids_param, target: target)
54
+ end
55
+
56
+ def empty_archive
57
+ client.post("#{api_path}/empty_archive.json")
58
+ end
59
+
60
+ def restore(ids:)
61
+ ids_param = Array(ids).join(",")
62
+ client.post("#{api_path}/restore.json", ids: ids_param)
63
+ end
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cashctrl
4
+ module Resources
5
+ class FiscalPeriod
6
+ class Task < Base
7
+ api_path "fiscalperiod/task"
8
+ model_class Models::FiscalPeriodTask
9
+
10
+ class << self
11
+ def read(id:)
12
+ raise NotImplementedError, "FiscalPeriod::Task does not support read"
13
+ end
14
+
15
+ def update(id:, **params)
16
+ raise NotImplementedError, "FiscalPeriod::Task does not support update"
17
+ end
18
+ end
19
+
20
+ def read(id:)
21
+ raise NotImplementedError, "FiscalPeriod::Task does not support read"
22
+ end
23
+
24
+ def update(id:, **params)
25
+ raise NotImplementedError, "FiscalPeriod::Task does not support update"
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,96 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cashctrl
4
+ module Resources
5
+ class FiscalPeriod < Base
6
+ api_path "fiscalperiod"
7
+ model_class Models::FiscalPeriod
8
+
9
+ class << self
10
+ def result(id:)
11
+ client.get("#{api_path}/result", id: id)
12
+ end
13
+
14
+ def depreciations(id:)
15
+ client.get("#{api_path}/depreciations.json", id: id)
16
+ end
17
+
18
+ def exchangediff(id:)
19
+ client.get("#{api_path}/exchangediff.json", id: id)
20
+ end
21
+
22
+ def switch(id:)
23
+ client.post("#{api_path}/switch.json", id: id)
24
+ end
25
+
26
+ def book_depreciations(id:)
27
+ client.post("#{api_path}/bookdepreciations.json", id: id)
28
+ end
29
+
30
+ def book_exchangediff(id:)
31
+ client.post("#{api_path}/bookexchangediff.json", id: id)
32
+ end
33
+
34
+ def complete(id:)
35
+ client.post("#{api_path}/complete.json", id: id)
36
+ end
37
+
38
+ def reopen(id:)
39
+ client.post("#{api_path}/reopen.json", id: id)
40
+ end
41
+
42
+ def complete_months(id:, months:)
43
+ months_param = Array(months).join(",")
44
+ client.post("#{api_path}/complete_months.json", id: id, months: months_param)
45
+ end
46
+
47
+ def reopen_months(id:, months:)
48
+ months_param = Array(months).join(",")
49
+ client.post("#{api_path}/reopen_months.json", id: id, months: months_param)
50
+ end
51
+ end
52
+
53
+ def result(id:)
54
+ client.get("#{api_path}/result", id: id)
55
+ end
56
+
57
+ def depreciations(id:)
58
+ client.get("#{api_path}/depreciations.json", id: id)
59
+ end
60
+
61
+ def exchangediff(id:)
62
+ client.get("#{api_path}/exchangediff.json", id: id)
63
+ end
64
+
65
+ def switch(id:)
66
+ client.post("#{api_path}/switch.json", id: id)
67
+ end
68
+
69
+ def book_depreciations(id:)
70
+ client.post("#{api_path}/bookdepreciations.json", id: id)
71
+ end
72
+
73
+ def book_exchangediff(id:)
74
+ client.post("#{api_path}/bookexchangediff.json", id: id)
75
+ end
76
+
77
+ def complete(id:)
78
+ client.post("#{api_path}/complete.json", id: id)
79
+ end
80
+
81
+ def reopen(id:)
82
+ client.post("#{api_path}/reopen.json", id: id)
83
+ end
84
+
85
+ def complete_months(id:, months:)
86
+ months_param = Array(months).join(",")
87
+ client.post("#{api_path}/complete_months.json", id: id, months: months_param)
88
+ end
89
+
90
+ def reopen_months(id:, months:)
91
+ months_param = Array(months).join(",")
92
+ client.post("#{api_path}/reopen_months.json", id: id, months: months_param)
93
+ end
94
+ end
95
+ end
96
+ end
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cashctrl
4
+ module Resources
5
+ class History < Base
6
+ api_path "history"
7
+ model_class Models::History
8
+
9
+ class << self
10
+ def create(**params)
11
+ raise NotImplementedError, "History does not support create"
12
+ end
13
+
14
+ def update(id:, **params)
15
+ raise NotImplementedError, "History does not support update"
16
+ end
17
+
18
+ def delete(ids:)
19
+ raise NotImplementedError, "History does not support delete"
20
+ end
21
+
22
+ def read(id:)
23
+ raise NotImplementedError, "History does not support read"
24
+ end
25
+ end
26
+
27
+ def create(**params)
28
+ raise NotImplementedError, "History does not support create"
29
+ end
30
+
31
+ def update(id:, **params)
32
+ raise NotImplementedError, "History does not support update"
33
+ end
34
+
35
+ def delete(ids:)
36
+ raise NotImplementedError, "History does not support delete"
37
+ end
38
+
39
+ def read(id:)
40
+ raise NotImplementedError, "History does not support read"
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cashctrl
4
+ module Resources
5
+ module Inventory
6
+ class Article
7
+ class Category < Base
8
+ api_path "inventory/article/category"
9
+ model_class Models::Category
10
+
11
+ class << self
12
+ def tree
13
+ client.get("#{api_path}/tree.json")
14
+ end
15
+ end
16
+
17
+ def tree
18
+ client.get("#{api_path}/tree.json")
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cashctrl
4
+ module Resources
5
+ module Inventory
6
+ class Article < Base
7
+ api_path "inventory/article"
8
+ model_class Models::Article
9
+
10
+ class << self
11
+ def categorize(ids:, target:)
12
+ ids_param = Array(ids).join(",")
13
+ client.post("#{api_path}/categorize.json", ids: ids_param, target: target)
14
+ end
15
+
16
+ def update_attachments(id:, file_ids:)
17
+ file_ids_param = Array(file_ids).join(",")
18
+ client.post("#{api_path}/update_attachments.json", id: id, fileIds: file_ids_param)
19
+ end
20
+ end
21
+
22
+ def categorize(ids:, target:)
23
+ ids_param = Array(ids).join(",")
24
+ client.post("#{api_path}/categorize.json", ids: ids_param, target: target)
25
+ end
26
+
27
+ def update_attachments(id:, file_ids:)
28
+ file_ids_param = Array(file_ids).join(",")
29
+ client.post("#{api_path}/update_attachments.json", id: id, fileIds: file_ids_param)
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cashctrl
4
+ module Resources
5
+ module Inventory
6
+ class Asset
7
+ class Category < Base
8
+ api_path "inventory/asset/category"
9
+ model_class Models::Category
10
+
11
+ class << self
12
+ def tree
13
+ client.get("#{api_path}/tree.json")
14
+ end
15
+ end
16
+
17
+ def tree
18
+ client.get("#{api_path}/tree.json")
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cashctrl
4
+ module Resources
5
+ module Inventory
6
+ class Asset < Base
7
+ api_path "inventory/asset"
8
+ model_class Models::Asset
9
+
10
+ class << self
11
+ def categorize(ids:, target:)
12
+ ids_param = Array(ids).join(",")
13
+ client.post("#{api_path}/categorize.json", ids: ids_param, target: target)
14
+ end
15
+
16
+ def update_attachments(id:, file_ids:)
17
+ file_ids_param = Array(file_ids).join(",")
18
+ client.post("#{api_path}/update_attachments.json", id: id, fileIds: file_ids_param)
19
+ end
20
+ end
21
+
22
+ def categorize(ids:, target:)
23
+ ids_param = Array(ids).join(",")
24
+ client.post("#{api_path}/categorize.json", ids: ids_param, target: target)
25
+ end
26
+
27
+ def update_attachments(id:, file_ids:)
28
+ file_ids_param = Array(file_ids).join(",")
29
+ client.post("#{api_path}/update_attachments.json", id: id, fileIds: file_ids_param)
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cashctrl
4
+ module Resources
5
+ module Inventory
6
+ class Unit < Base
7
+ api_path "inventory/unit"
8
+ model_class Models::Unit
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cashctrl
4
+ module Resources
5
+ class Journal
6
+ class Import
7
+ class Entry < Base
8
+ api_path "journal/import/entry"
9
+ model_class Models::JournalImportEntry
10
+
11
+ class << self
12
+ def create(**params)
13
+ raise NotImplementedError, "Journal::Import::Entry does not support create"
14
+ end
15
+
16
+ def restore(ids:)
17
+ ids_param = Array(ids).join(",")
18
+ client.post("#{api_path}/restore.json", ids: ids_param)
19
+ end
20
+
21
+ def confirm(ids:)
22
+ ids_param = Array(ids).join(",")
23
+ client.post("#{api_path}/confirm.json", ids: ids_param)
24
+ end
25
+
26
+ def unconfirm(ids:)
27
+ ids_param = Array(ids).join(",")
28
+ client.post("#{api_path}/unconfirm.json", ids: ids_param)
29
+ end
30
+ end
31
+
32
+ def create(**params)
33
+ raise NotImplementedError, "Journal::Import::Entry does not support create"
34
+ end
35
+
36
+ def restore(ids:)
37
+ ids_param = Array(ids).join(",")
38
+ client.post("#{api_path}/restore.json", ids: ids_param)
39
+ end
40
+
41
+ def confirm(ids:)
42
+ ids_param = Array(ids).join(",")
43
+ client.post("#{api_path}/confirm.json", ids: ids_param)
44
+ end
45
+
46
+ def unconfirm(ids:)
47
+ ids_param = Array(ids).join(",")
48
+ client.post("#{api_path}/unconfirm.json", ids: ids_param)
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cashctrl
4
+ module Resources
5
+ class Journal
6
+ class Import < Base
7
+ api_path "journal/import"
8
+ model_class Models::JournalImport
9
+
10
+ class << self
11
+ def execute(id:)
12
+ client.post("#{api_path}/execute.json", id: id)
13
+ end
14
+ end
15
+
16
+ def execute(id:)
17
+ client.post("#{api_path}/execute.json", id: id)
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,94 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cashctrl
4
+ module Resources
5
+ class Journal < Base
6
+ api_path "journal"
7
+ model_class Models::Journal
8
+
9
+ class << self
10
+ def create(debit: nil, credit: nil, **params)
11
+ params[:debitId] = resolve_account_id(debit) if debit
12
+ params[:creditId] = resolve_account_id(credit) if credit
13
+
14
+ super(**params)
15
+ end
16
+
17
+ def update_attachments(id:, file_ids:)
18
+ file_ids_param = Array(file_ids).join(",")
19
+ client.post("#{api_path}/update_attachments.json", id: id, fileIds: file_ids_param)
20
+ end
21
+
22
+ def update_recurrence(id:, recurrence: nil, start_date: nil, end_date: nil, days_before: nil,
23
+ notify_type: nil, notify_person_id: nil, notify_user_id: nil, notify_email: nil)
24
+ params = { id: id }
25
+ params[:recurrence] = recurrence if recurrence
26
+ params[:startDate] = start_date if start_date
27
+ params[:endDate] = end_date if end_date
28
+ params[:daysBefore] = days_before if days_before
29
+ params[:notifyType] = notify_type if notify_type
30
+ params[:notifyPersonId] = notify_person_id if notify_person_id
31
+ params[:notifyUserId] = notify_user_id if notify_user_id
32
+ params[:notifyEmail] = notify_email if notify_email
33
+ client.post("#{api_path}/update_recurrence.json", params)
34
+ end
35
+
36
+ private
37
+
38
+ def resolve_account_id(account)
39
+ case account
40
+ when Integer
41
+ account
42
+ when Models::Account
43
+ account.id
44
+ when String
45
+ Account.find_by_number(account)&.id || raise(ArgumentError, "Account not found: #{account}")
46
+ else
47
+ raise ArgumentError, "Invalid account: #{account.inspect}. Expected Integer, Account, or account number String."
48
+ end
49
+ end
50
+ end
51
+
52
+ def create(debit: nil, credit: nil, **params)
53
+ params[:debitId] = resolve_account_id(debit) if debit
54
+ params[:creditId] = resolve_account_id(credit) if credit
55
+
56
+ super(**params)
57
+ end
58
+
59
+ def update_attachments(id:, file_ids:)
60
+ file_ids_param = Array(file_ids).join(",")
61
+ client.post("#{api_path}/update_attachments.json", id: id, fileIds: file_ids_param)
62
+ end
63
+
64
+ def update_recurrence(id:, recurrence: nil, start_date: nil, end_date: nil, days_before: nil,
65
+ notify_type: nil, notify_person_id: nil, notify_user_id: nil, notify_email: nil)
66
+ params = { id: id }
67
+ params[:recurrence] = recurrence if recurrence
68
+ params[:startDate] = start_date if start_date
69
+ params[:endDate] = end_date if end_date
70
+ params[:daysBefore] = days_before if days_before
71
+ params[:notifyType] = notify_type if notify_type
72
+ params[:notifyPersonId] = notify_person_id if notify_person_id
73
+ params[:notifyUserId] = notify_user_id if notify_user_id
74
+ params[:notifyEmail] = notify_email if notify_email
75
+ client.post("#{api_path}/update_recurrence.json", params)
76
+ end
77
+
78
+ private
79
+
80
+ def resolve_account_id(account)
81
+ case account
82
+ when Integer
83
+ account
84
+ when Models::Account
85
+ account.id
86
+ when String
87
+ Account.new(client).find_by_number(account)&.id || raise(ArgumentError, "Account not found: #{account}")
88
+ else
89
+ raise ArgumentError, "Invalid account: #{account.inspect}. Expected Integer, Account, or account number String."
90
+ end
91
+ end
92
+ end
93
+ end
94
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cashctrl
4
+ module Resources
5
+ class Location < Base
6
+ api_path "location"
7
+ model_class Models::Location
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cashctrl
4
+ module Resources
5
+ class Order
6
+ class BookEntry < Base
7
+ api_path "order/bookentry"
8
+ model_class Models::OrderBookEntry
9
+ end
10
+ end
11
+ end
12
+ end