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
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Cashctrl
3
+ module CashCtrl
4
4
  module Resources
5
5
  module Salary
6
6
  class Certificate
@@ -8,36 +8,6 @@ module Cashctrl
8
8
  api_path "salary/certificate/document"
9
9
  model_class Models::CertificateDocument
10
10
 
11
- class << self
12
- def list
13
- raise NotImplementedError, "Salary::Certificate::Document does not support list"
14
- end
15
-
16
- def create(**params)
17
- raise NotImplementedError, "Salary::Certificate::Document does not support create"
18
- end
19
-
20
- def update(id:, **params)
21
- raise NotImplementedError, "Salary::Certificate::Document does not support update"
22
- end
23
-
24
- def delete(ids:)
25
- raise NotImplementedError, "Salary::Certificate::Document does not support delete"
26
- end
27
-
28
- def read_pdf(id:)
29
- client.get_raw("#{api_path}/read.pdf", id: id)
30
- end
31
-
32
- def read_zip(id:)
33
- client.get_raw("#{api_path}/read.zip", id: id)
34
- end
35
-
36
- def mail(id:, recipient_email:, **params)
37
- client.post("#{api_path}/mail.json", { id: id, recipientEmail: recipient_email, **params })
38
- end
39
- end
40
-
41
11
  def list
42
12
  raise NotImplementedError, "Salary::Certificate::Document does not support list"
43
13
  end
@@ -46,24 +16,29 @@ module Cashctrl
46
16
  raise NotImplementedError, "Salary::Certificate::Document does not support create"
47
17
  end
48
18
 
49
- def update(id:, **params)
19
+ def update(*, **)
50
20
  raise NotImplementedError, "Salary::Certificate::Document does not support update"
51
21
  end
52
22
 
53
- def delete(ids:)
23
+ def delete(*)
54
24
  raise NotImplementedError, "Salary::Certificate::Document does not support delete"
55
25
  end
56
26
 
57
- def read_pdf(id:)
58
- client.get_raw("#{api_path}/read.pdf", id: id)
27
+ def read_pdf(ids:)
28
+ client.get_raw("#{api_path}/read.pdf", ids: csv(ids))
59
29
  end
60
30
 
61
- def read_zip(id:)
62
- client.get_raw("#{api_path}/read.zip", id: id)
31
+ def read_zip(ids:)
32
+ client.get_raw("#{api_path}/read.zip", ids: csv(ids))
63
33
  end
64
34
 
65
- def mail(id:, recipient_email:, **params)
66
- client.post("#{api_path}/mail.json", { id: id, recipientEmail: recipient_email, **params })
35
+ def mail(certificate_ids:, mail_from:, mail_subject:, mail_text:, mail_to: nil, mail_cc: nil, mail_bcc: nil,
36
+ is_copy_to_me: nil)
37
+ params = api_params(
38
+ certificate_ids: csv(certificate_ids), mail_from: mail_from, mail_subject: mail_subject, mail_text: mail_text,
39
+ mail_to: mail_to, mail_cc: mail_cc, mail_bcc: mail_bcc, is_copy_to_me: is_copy_to_me
40
+ )
41
+ client.post("#{api_path}/mail.json", params)
67
42
  end
68
43
  end
69
44
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Cashctrl
3
+ module CashCtrl
4
4
  module Resources
5
5
  module Salary
6
6
  class Certificate
@@ -8,14 +8,8 @@ module Cashctrl
8
8
  api_path "salary/certificate/template"
9
9
  model_class Models::CertificateTemplate
10
10
 
11
- class << self
12
- def tree
13
- client.get("#{api_path}/tree.json")
14
- end
15
- end
16
-
17
11
  def tree
18
- client.get("#{api_path}/tree.json")
12
+ tree_collection(client.get("#{api_path}/tree.json"))
19
13
  end
20
14
  end
21
15
  end
@@ -1,27 +1,17 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Cashctrl
3
+ module CashCtrl
4
4
  module Resources
5
5
  module Salary
6
6
  class Certificate < Base
7
7
  api_path "salary/certificate"
8
8
  model_class Models::SalaryCertificate
9
9
 
10
- class << self
11
- def create(**params)
12
- raise NotImplementedError, "Salary::Certificate does not support create"
13
- end
14
-
15
- def delete(ids:)
16
- raise NotImplementedError, "Salary::Certificate does not support delete"
17
- end
18
- end
19
-
20
10
  def create(**params)
21
11
  raise NotImplementedError, "Salary::Certificate does not support create"
22
12
  end
23
13
 
24
- def delete(ids:)
14
+ def delete(*)
25
15
  raise NotImplementedError, "Salary::Certificate does not support delete"
26
16
  end
27
17
  end
@@ -1,38 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Cashctrl
3
+ module CashCtrl
4
4
  module Resources
5
5
  module Salary
6
6
  class Document < Base
7
7
  api_path "salary/document"
8
8
  model_class Models::SalaryDocument
9
9
 
10
- class << self
11
- def list
12
- raise NotImplementedError, "Salary::Document does not support list"
13
- end
14
-
15
- def create(**params)
16
- raise NotImplementedError, "Salary::Document does not support create"
17
- end
18
-
19
- def delete(ids:)
20
- raise NotImplementedError, "Salary::Document does not support delete"
21
- end
22
-
23
- def read_pdf(id:)
24
- client.get_raw("#{api_path}/read.pdf", id: id)
25
- end
26
-
27
- def read_zip(id:)
28
- client.get_raw("#{api_path}/read.zip", id: id)
29
- end
30
-
31
- def mail(id:, recipient_email:, **params)
32
- client.post("#{api_path}/mail.json", { id: id, recipientEmail: recipient_email, **params })
33
- end
34
- end
35
-
36
10
  def list
37
11
  raise NotImplementedError, "Salary::Document does not support list"
38
12
  end
@@ -41,20 +15,26 @@ module Cashctrl
41
15
  raise NotImplementedError, "Salary::Document does not support create"
42
16
  end
43
17
 
44
- def delete(ids:)
18
+ def delete(*)
45
19
  raise NotImplementedError, "Salary::Document does not support delete"
46
20
  end
47
21
 
48
- def read_pdf(id:)
49
- client.get_raw("#{api_path}/read.pdf", id: id)
22
+ def read_pdf(ids:)
23
+ client.get_raw("#{api_path}/read.pdf", ids: csv(ids))
50
24
  end
51
25
 
52
- def read_zip(id:)
53
- client.get_raw("#{api_path}/read.zip", id: id)
26
+ def read_zip(ids:)
27
+ client.get_raw("#{api_path}/read.zip", ids: csv(ids))
54
28
  end
55
29
 
56
- def mail(id:, recipient_email:, **params)
57
- client.post("#{api_path}/mail.json", { id: id, recipientEmail: recipient_email, **params })
30
+ def mail(statement_ids:, mail_from:, mail_subject:, mail_text:, mail_to: nil, mail_cc: nil, mail_bcc: nil,
31
+ is_copy_to_me: nil, sent_status_id: nil)
32
+ params = api_params(
33
+ statement_ids: csv(statement_ids), mail_from: mail_from, mail_subject: mail_subject, mail_text: mail_text,
34
+ mail_to: mail_to, mail_cc: mail_cc, mail_bcc: mail_bcc, is_copy_to_me: is_copy_to_me,
35
+ sent_status_id: sent_status_id
36
+ )
37
+ client.post("#{api_path}/mail.json", params)
58
38
  end
59
39
  end
60
40
  end
@@ -1,35 +1,21 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Cashctrl
3
+ module CashCtrl
4
4
  module Resources
5
5
  module Salary
6
6
  class Field < Base
7
7
  api_path "salary/field"
8
8
  model_class Models::SalaryField
9
9
 
10
- class << self
11
- def create(**params)
12
- raise NotImplementedError, "Salary::Field does not support create"
13
- end
14
-
15
- def update(id:, **params)
16
- raise NotImplementedError, "Salary::Field does not support update"
17
- end
18
-
19
- def delete(ids:)
20
- raise NotImplementedError, "Salary::Field does not support delete"
21
- end
22
- end
23
-
24
10
  def create(**params)
25
11
  raise NotImplementedError, "Salary::Field does not support create"
26
12
  end
27
13
 
28
- def update(id:, **params)
14
+ def update(*, **)
29
15
  raise NotImplementedError, "Salary::Field does not support update"
30
16
  end
31
17
 
32
- def delete(ids:)
18
+ def delete(*)
33
19
  raise NotImplementedError, "Salary::Field does not support delete"
34
20
  end
35
21
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Cashctrl
3
+ module CashCtrl
4
4
  module Resources
5
5
  module Salary
6
6
  module Insurance
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Cashctrl
3
+ module CashCtrl
4
4
  module Resources
5
5
  module Salary
6
6
  class Layout < Base
@@ -1,35 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Cashctrl
3
+ module CashCtrl
4
4
  module Resources
5
5
  module Salary
6
6
  class Payment < Base
7
7
  api_path "salary/payment"
8
8
  model_class Models::SalaryPayment
9
9
 
10
- class << self
11
- def list
12
- raise NotImplementedError, "Salary::Payment does not support list"
13
- end
14
-
15
- def read(id:)
16
- raise NotImplementedError, "Salary::Payment does not support read"
17
- end
18
-
19
- def update(id:, **params)
20
- raise NotImplementedError, "Salary::Payment does not support update"
21
- end
22
-
23
- def delete(ids:)
24
- raise NotImplementedError, "Salary::Payment does not support delete"
25
- end
26
-
27
- def download(ids:)
28
- ids_param = Array(ids).join(",")
29
- client.get_raw("#{api_path}/download", ids: ids_param)
30
- end
31
- end
32
-
33
10
  def list
34
11
  raise NotImplementedError, "Salary::Payment does not support list"
35
12
  end
@@ -38,17 +15,20 @@ module Cashctrl
38
15
  raise NotImplementedError, "Salary::Payment does not support read"
39
16
  end
40
17
 
41
- def update(id:, **params)
18
+ def update(*, **)
42
19
  raise NotImplementedError, "Salary::Payment does not support update"
43
20
  end
44
21
 
45
- def delete(ids:)
22
+ def delete(*)
46
23
  raise NotImplementedError, "Salary::Payment does not support delete"
47
24
  end
48
25
 
49
- def download(ids:)
50
- ids_param = Array(ids).join(",")
51
- client.get_raw("#{api_path}/download", ids: ids_param)
26
+ def download(statement_ids:, date:, amount: nil, is_combine: nil, status_id: nil, type: nil)
27
+ params = api_params(
28
+ statement_ids: csv(statement_ids), date: date, amount: amount, is_combine: is_combine,
29
+ status_id: status_id, type: type
30
+ )
31
+ client.get_raw("#{api_path}/download", params)
52
32
  end
53
33
  end
54
34
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Cashctrl
3
+ module CashCtrl
4
4
  module Resources
5
5
  module Salary
6
6
  class Setting < Base
@@ -1,75 +1,40 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Cashctrl
3
+ module CashCtrl
4
4
  module Resources
5
5
  module Salary
6
6
  class Statement < Base
7
+ include Attachments
8
+
7
9
  api_path "salary/statement"
8
10
  model_class Models::SalaryStatement
9
11
 
10
- class << self
11
- def update_multiple(ids:, **params)
12
- ids_param = Array(ids).join(",")
13
- client.post("#{api_path}/update_multiple.json", { ids: ids_param, **params })
14
- end
15
-
16
- def update_status(id:, status:)
17
- client.post("#{api_path}/update_status.json", id: id, status: status)
18
- end
19
-
20
- def update_recurrence(id:, recurrence: nil, start_date: nil, end_date: nil, days_before: nil, notify_type: nil, notify_person_id: nil, notify_user_id: nil, notify_email: nil)
21
- params = { id: id }
22
- params[:recurrence] = recurrence if recurrence
23
- params[:startDate] = start_date if start_date
24
- params[:endDate] = end_date if end_date
25
- params[:daysBefore] = days_before if days_before
26
- params[:notifyType] = notify_type if notify_type
27
- params[:notifyPersonId] = notify_person_id if notify_person_id
28
- params[:notifyUserId] = notify_user_id if notify_user_id
29
- params[:notifyEmail] = notify_email if notify_email
30
- client.post("#{api_path}/update_recurrence.json", params)
31
- end
32
-
33
- def calculate(id:)
34
- client.post("#{api_path}/calculate.json", id: id)
35
- end
36
-
37
- def update_attachments(id:, file_ids:)
38
- file_ids_param = Array(file_ids).join(",")
39
- client.post("#{api_path}/update_attachments.json", id: id, fileIds: file_ids_param)
40
- end
41
- end
42
-
43
12
  def update_multiple(ids:, **params)
44
- ids_param = Array(ids).join(",")
45
- client.post("#{api_path}/update_multiple.json", { ids: ids_param, **params })
13
+ client.post("#{api_path}/update_multiple.json", api_params(ids: csv(ids), **params))
46
14
  end
47
15
 
48
- def update_status(id:, status:)
49
- client.post("#{api_path}/update_status.json", id: id, status: status)
16
+ def update_status(ids:, status_id:)
17
+ client.post("#{api_path}/update_status.json", ids: csv(ids), statusId: status_id)
50
18
  end
51
19
 
52
20
  def update_recurrence(id:, recurrence: nil, start_date: nil, end_date: nil, days_before: nil,
53
21
  notify_type: nil, notify_person_id: nil, notify_user_id: nil, notify_email: nil)
54
- params = { id: id }
55
- params[:recurrence] = recurrence if recurrence
56
- params[:startDate] = start_date if start_date
57
- params[:endDate] = end_date if end_date
58
- params[:daysBefore] = days_before if days_before
59
- params[:notifyType] = notify_type if notify_type
60
- params[:notifyPersonId] = notify_person_id if notify_person_id
61
- params[:notifyUserId] = notify_user_id if notify_user_id
62
- params[:notifyEmail] = notify_email if notify_email
22
+ params = api_params(
23
+ id: id, recurrence: recurrence, start_date: start_date, end_date: end_date, days_before: days_before,
24
+ notify_type: notify_type, notify_person_id: notify_person_id, notify_user_id: notify_user_id,
25
+ notify_email: notify_email
26
+ )
63
27
  client.post("#{api_path}/update_recurrence.json", params)
64
28
  end
65
29
 
66
- def calculate(id:)
67
- client.post("#{api_path}/calculate.json", id: id)
68
- end
69
-
70
- def update_attachments(id:, file_ids:)
71
- file_ids_param = Array(file_ids).join(",")
72
- client.post("#{api_path}/update_attachments.json", id: id, fileIds: file_ids_param)
30
+ def calculate(person_id: nil, id: nil, template_id: nil, date: nil, date_payment: nil, currency_id: nil,
31
+ types: nil, values_local: nil, custom: nil, recalculate: nil)
32
+ params = api_params(
33
+ person_id: person_id, id: id, template_id: template_id, date: date, date_payment: date_payment,
34
+ currency_id: currency_id, types: types, values_local: values_local, custom: custom,
35
+ recalculate: recalculate
36
+ )
37
+ client.post("#{api_path}/calculate.json", params)
73
38
  end
74
39
  end
75
40
  end
@@ -1,22 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Cashctrl
3
+ module CashCtrl
4
4
  module Resources
5
5
  module Salary
6
6
  class Status < Base
7
7
  api_path "salary/status"
8
8
  model_class Models::SalaryStatus
9
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)
10
+ def reorder(ids:, target:, before: nil)
11
+ client.post("#{api_path}/reorder.json", api_params(ids: csv(ids), target: target, before: before))
20
12
  end
21
13
  end
22
14
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Cashctrl
3
+ module CashCtrl
4
4
  module Resources
5
5
  module Salary
6
6
  class Sum < Base
@@ -1,20 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Cashctrl
3
+ module CashCtrl
4
4
  module Resources
5
5
  module Salary
6
6
  class Template < Base
7
7
  api_path "salary/template"
8
8
  model_class Models::SalaryTemplate
9
9
 
10
- class << self
11
- def tree
12
- client.get("#{api_path}/tree.json")
13
- end
14
- end
15
-
16
10
  def tree
17
- client.get("#{api_path}/tree.json")
11
+ tree_collection(client.get("#{api_path}/tree.json"))
18
12
  end
19
13
  end
20
14
  end
@@ -1,19 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Cashctrl
3
+ module CashCtrl
4
4
  module Resources
5
5
  module Salary
6
6
  class Type < Base
7
7
  api_path "salary/type"
8
8
  model_class Models::SalaryType
9
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
- end
16
-
17
10
  def categorize(ids:, target:)
18
11
  ids_param = Array(ids).join(",")
19
12
  client.post("#{api_path}/categorize.json", ids: ids_param, target: target)
@@ -1,17 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Cashctrl
3
+ module CashCtrl
4
4
  module Resources
5
5
  class SequenceNumber < Base
6
6
  api_path "sequencenumber"
7
7
  model_class Models::SequenceNumber
8
8
 
9
- class << self
10
- def get(id:)
11
- client.get("#{api_path}/get", id: id)
12
- end
13
- end
14
-
15
9
  def get(id:)
16
10
  client.get("#{api_path}/get", id: id)
17
11
  end
@@ -1,33 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Cashctrl
3
+ module CashCtrl
4
4
  module Resources
5
5
  class Setting < Base
6
6
  api_path "setting"
7
7
  model_class Models::Setting
8
8
 
9
- class << self
10
- def list
11
- raise NotImplementedError, "Setting does not support list, use read instead"
12
- end
13
-
14
- def read
15
- client.get("#{api_path}/read.json")
16
- end
17
-
18
- def get(name:)
19
- client.get("#{api_path}/get", name: name)
20
- end
21
-
22
- def create(**params)
23
- raise NotImplementedError, "Setting does not support create, use update instead"
24
- end
25
-
26
- def delete(ids:)
27
- raise NotImplementedError, "Setting does not support delete"
28
- end
29
- end
30
-
31
9
  def list
32
10
  raise NotImplementedError, "Setting does not support list, use read instead"
33
11
  end
@@ -40,11 +18,15 @@ module Cashctrl
40
18
  client.get("#{api_path}/get", name: name)
41
19
  end
42
20
 
21
+ def update(**settings)
22
+ client.post("#{api_path}/update.json", settings)
23
+ end
24
+
43
25
  def create(**params)
44
26
  raise NotImplementedError, "Setting does not support create, use update instead"
45
27
  end
46
28
 
47
- def delete(ids:)
29
+ def delete(*)
48
30
  raise NotImplementedError, "Setting does not support delete"
49
31
  end
50
32
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Cashctrl
3
+ module CashCtrl
4
4
  module Resources
5
5
  class Tax < Base
6
6
  api_path "tax"
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Cashctrl
3
+ module CashCtrl
4
4
  module Resources
5
5
  class Text < Base
6
6
  api_path "text"