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.
- checksums.yaml +4 -4
- data/README.md +418 -136
- data/cashctrl.gemspec +1 -1
- data/lib/cashctrl/client.rb +106 -103
- data/lib/cashctrl/collection.rb +6 -5
- data/lib/cashctrl/configuration.rb +1 -1
- data/lib/cashctrl/error.rb +3 -1
- data/lib/cashctrl/errors.rb +76 -0
- data/lib/cashctrl/localized_string.rb +2 -2
- data/lib/cashctrl/models/account.rb +5 -1
- data/lib/cashctrl/models/article.rb +9 -1
- data/lib/cashctrl/models/asset.rb +6 -1
- data/lib/cashctrl/models/attachment.rb +14 -0
- data/lib/cashctrl/models/bank.rb +3 -1
- data/lib/cashctrl/models/category.rb +1 -1
- data/lib/cashctrl/models/certificate_document.rb +1 -1
- data/lib/cashctrl/models/certificate_template.rb +1 -1
- data/lib/cashctrl/models/cost_center.rb +3 -1
- data/lib/cashctrl/models/currency.rb +1 -1
- data/lib/cashctrl/models/custom_field.rb +1 -1
- data/lib/cashctrl/models/custom_field_group.rb +1 -1
- data/lib/cashctrl/models/file.rb +2 -1
- data/lib/cashctrl/models/fiscal_period.rb +1 -1
- data/lib/cashctrl/models/fiscal_period_task.rb +1 -1
- data/lib/cashctrl/models/history.rb +1 -1
- data/lib/cashctrl/models/insurance_type.rb +1 -1
- data/lib/cashctrl/models/journal.rb +10 -1
- data/lib/cashctrl/models/journal_import.rb +1 -1
- data/lib/cashctrl/models/journal_import_entry.rb +1 -1
- data/lib/cashctrl/models/journal_item.rb +20 -0
- data/lib/cashctrl/models/loader.rb +3 -0
- data/lib/cashctrl/models/location.rb +1 -1
- data/lib/cashctrl/models/order.rb +8 -1
- data/lib/cashctrl/models/order_book_entry.rb +1 -1
- data/lib/cashctrl/models/order_document.rb +1 -1
- data/lib/cashctrl/models/order_item.rb +23 -0
- data/lib/cashctrl/models/order_layout.rb +1 -1
- data/lib/cashctrl/models/order_payment.rb +1 -1
- data/lib/cashctrl/models/person.rb +7 -1
- data/lib/cashctrl/models/report.rb +1 -1
- data/lib/cashctrl/models/report_collection.rb +1 -1
- data/lib/cashctrl/models/report_element.rb +1 -1
- data/lib/cashctrl/models/rounding.rb +2 -1
- data/lib/cashctrl/models/salary_book_entry.rb +1 -1
- data/lib/cashctrl/models/salary_certificate.rb +2 -1
- data/lib/cashctrl/models/salary_document.rb +1 -1
- data/lib/cashctrl/models/salary_field.rb +1 -1
- data/lib/cashctrl/models/salary_layout.rb +1 -1
- data/lib/cashctrl/models/salary_payment.rb +1 -1
- data/lib/cashctrl/models/salary_setting.rb +1 -1
- data/lib/cashctrl/models/salary_statement.rb +3 -1
- data/lib/cashctrl/models/salary_status.rb +1 -1
- data/lib/cashctrl/models/salary_sum.rb +1 -1
- data/lib/cashctrl/models/salary_template.rb +1 -1
- data/lib/cashctrl/models/salary_type.rb +1 -1
- data/lib/cashctrl/models/sequence_number.rb +1 -1
- data/lib/cashctrl/models/setting.rb +1 -1
- data/lib/cashctrl/models/tax.rb +2 -1
- data/lib/cashctrl/models/text.rb +1 -1
- data/lib/cashctrl/models/title.rb +1 -1
- data/lib/cashctrl/models/unit.rb +1 -1
- data/lib/cashctrl/relation.rb +271 -0
- data/lib/cashctrl/resource.rb +300 -57
- data/lib/cashctrl/resources/account/bank.rb +3 -13
- data/lib/cashctrl/resources/account/category.rb +3 -9
- data/lib/cashctrl/resources/account/cost_center/category.rb +3 -9
- data/lib/cashctrl/resources/account/cost_center.rb +3 -25
- data/lib/cashctrl/resources/account.rb +4 -30
- data/lib/cashctrl/resources/attachments.rb +32 -0
- data/lib/cashctrl/resources/base.rb +160 -84
- data/lib/cashctrl/resources/currency.rb +1 -10
- data/lib/cashctrl/resources/custom_field/group.rb +3 -11
- data/lib/cashctrl/resources/custom_field.rb +3 -15
- data/lib/cashctrl/resources/file/category.rb +4 -10
- data/lib/cashctrl/resources/file.rb +44 -28
- data/lib/cashctrl/resources/fiscal_period/task.rb +2 -12
- data/lib/cashctrl/resources/fiscal_period.rb +17 -59
- data/lib/cashctrl/resources/history.rb +3 -21
- data/lib/cashctrl/resources/import_session.rb +43 -0
- data/lib/cashctrl/resources/inventory/article/category.rb +3 -9
- data/lib/cashctrl/resources/inventory/article/import.rb +13 -0
- data/lib/cashctrl/resources/inventory/article.rb +3 -18
- data/lib/cashctrl/resources/inventory/asset/category.rb +3 -9
- data/lib/cashctrl/resources/inventory/asset.rb +3 -18
- data/lib/cashctrl/resources/inventory/unit.rb +1 -1
- data/lib/cashctrl/resources/journal/import/entry.rb +1 -22
- data/lib/cashctrl/resources/journal/import.rb +1 -7
- data/lib/cashctrl/resources/journal.rb +19 -57
- data/lib/cashctrl/resources/location.rb +1 -1
- data/lib/cashctrl/resources/order/book_entry.rb +1 -1
- data/lib/cashctrl/resources/order/category.rb +4 -15
- data/lib/cashctrl/resources/order/document.rb +13 -21
- data/lib/cashctrl/resources/order/layout.rb +1 -1
- data/lib/cashctrl/resources/order/payment.rb +9 -29
- data/lib/cashctrl/resources/order.rb +21 -68
- data/lib/cashctrl/resources/organization.rb +13 -0
- data/lib/cashctrl/resources/person/category.rb +3 -9
- data/lib/cashctrl/resources/person/import.rb +11 -0
- data/lib/cashctrl/resources/person/title.rb +1 -1
- data/lib/cashctrl/resources/person.rb +4 -23
- data/lib/cashctrl/resources/report/collection.rb +10 -42
- data/lib/cashctrl/resources/report/element.rb +14 -46
- data/lib/cashctrl/resources/report.rb +4 -30
- data/lib/cashctrl/resources/rounding.rb +1 -1
- data/lib/cashctrl/resources/salary/book_entry.rb +1 -1
- data/lib/cashctrl/resources/salary/category.rb +3 -9
- data/lib/cashctrl/resources/salary/certificate/document.rb +14 -39
- data/lib/cashctrl/resources/salary/certificate/template.rb +2 -8
- data/lib/cashctrl/resources/salary/certificate.rb +2 -12
- data/lib/cashctrl/resources/salary/document.rb +14 -34
- data/lib/cashctrl/resources/salary/field.rb +3 -17
- data/lib/cashctrl/resources/salary/insurance/type.rb +1 -1
- data/lib/cashctrl/resources/salary/layout.rb +1 -1
- data/lib/cashctrl/resources/salary/payment.rb +9 -29
- data/lib/cashctrl/resources/salary/setting.rb +1 -1
- data/lib/cashctrl/resources/salary/statement.rb +19 -54
- data/lib/cashctrl/resources/salary/status.rb +3 -11
- data/lib/cashctrl/resources/salary/sum.rb +1 -1
- data/lib/cashctrl/resources/salary/template.rb +2 -8
- data/lib/cashctrl/resources/salary/type.rb +1 -8
- data/lib/cashctrl/resources/sequence_number.rb +1 -7
- data/lib/cashctrl/resources/setting.rb +6 -24
- data/lib/cashctrl/resources/tax.rb +1 -1
- data/lib/cashctrl/resources/text.rb +1 -1
- data/lib/cashctrl/schema.yml +111 -0
- data/lib/cashctrl/version.rb +2 -2
- data/lib/cashctrl.rb +35 -25
- data/lib/generators/model_generator.rb +19 -7
- data/sig/cashctrl.rbs +1 -1
- metadata +12 -2
|
@@ -1,46 +1,62 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
module
|
|
3
|
+
module CashCtrl
|
|
4
4
|
module Resources
|
|
5
|
-
class
|
|
5
|
+
class File < Base
|
|
6
6
|
api_path "file"
|
|
7
7
|
model_class Models::File
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
MIME_TYPES = {
|
|
10
|
+
".csv" => "text/csv",
|
|
11
|
+
".gif" => "image/gif",
|
|
12
|
+
".heic" => "image/heic",
|
|
13
|
+
".jpeg" => "image/jpeg",
|
|
14
|
+
".jpg" => "image/jpeg",
|
|
15
|
+
".pdf" => "application/pdf",
|
|
16
|
+
".png" => "image/png",
|
|
17
|
+
".txt" => "text/plain",
|
|
18
|
+
".vcf" => "text/vcard",
|
|
19
|
+
".xls" => "application/vnd.ms-excel",
|
|
20
|
+
".xlsx" => "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
21
|
+
".xml" => "application/xml",
|
|
22
|
+
".zip" => "application/zip",
|
|
23
|
+
}.freeze
|
|
13
24
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
25
|
+
def self.mime_type_for(name)
|
|
26
|
+
MIME_TYPES.fetch(::File.extname(name.to_s).downcase, "application/octet-stream")
|
|
27
|
+
end
|
|
17
28
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
end
|
|
29
|
+
def get(id:)
|
|
30
|
+
client.get_raw("#{api_path}/get", id: id)
|
|
31
|
+
end
|
|
22
32
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
client.post("#{api_path}/categorize.json", ids: ids_param, target: target)
|
|
26
|
-
end
|
|
33
|
+
def prepare(files: nil, name: nil, mime_type: nil, category_id: nil, size: nil)
|
|
34
|
+
files ||= [{ name: name, mime_type: mime_type, category_id: category_id, size: size }]
|
|
27
35
|
|
|
28
|
-
|
|
29
|
-
|
|
36
|
+
payload = files.map do |file|
|
|
37
|
+
{
|
|
38
|
+
name: file[:name],
|
|
39
|
+
mimeType: file[:mime_type] || self.class.mime_type_for(file[:name]),
|
|
40
|
+
categoryId: file[:category_id],
|
|
41
|
+
size: file[:size],
|
|
42
|
+
}.compact
|
|
30
43
|
end
|
|
31
44
|
|
|
32
|
-
|
|
33
|
-
ids_param = Array(ids).join(",")
|
|
34
|
-
client.post("#{api_path}/restore.json", ids: ids_param)
|
|
35
|
-
end
|
|
45
|
+
client.post("#{api_path}/prepare.json", files: payload)
|
|
36
46
|
end
|
|
37
47
|
|
|
38
|
-
def
|
|
39
|
-
|
|
40
|
-
|
|
48
|
+
def upload(file, name: nil, mime_type: nil, category_id: nil, persist: true)
|
|
49
|
+
content = file.respond_to?(:read) ? file.read : ::File.binread(file)
|
|
50
|
+
name ||= file.respond_to?(:path) ? ::File.basename(file.path) : ::File.basename(file.to_s)
|
|
51
|
+
mime_type ||= self.class.mime_type_for(name)
|
|
52
|
+
|
|
53
|
+
prepared = prepare(name: name, mime_type: mime_type, category_id: category_id, size: content.bytesize)
|
|
54
|
+
entry = Array(prepared["data"]).first || raise(Error, "CashCtrl did not return an upload URL")
|
|
55
|
+
|
|
56
|
+
client.put_raw(entry["writeUrl"], content, content_type: mime_type)
|
|
57
|
+
persist(ids: entry["fileId"]) if persist
|
|
41
58
|
|
|
42
|
-
|
|
43
|
-
client.post("#{api_path}/prepare.json", mimeType: mime_type, name: name)
|
|
59
|
+
entry["fileId"]
|
|
44
60
|
end
|
|
45
61
|
|
|
46
62
|
def persist(ids:)
|
|
@@ -1,27 +1,17 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
module
|
|
3
|
+
module CashCtrl
|
|
4
4
|
module Resources
|
|
5
5
|
class FiscalPeriod
|
|
6
6
|
class Task < Base
|
|
7
7
|
api_path "fiscalperiod/task"
|
|
8
8
|
model_class Models::FiscalPeriodTask
|
|
9
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
10
|
def read(id:)
|
|
21
11
|
raise NotImplementedError, "FiscalPeriod::Task does not support read"
|
|
22
12
|
end
|
|
23
13
|
|
|
24
|
-
def update(
|
|
14
|
+
def update(*, **)
|
|
25
15
|
raise NotImplementedError, "FiscalPeriod::Task does not support update"
|
|
26
16
|
end
|
|
27
17
|
end
|
|
@@ -1,53 +1,13 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
module
|
|
3
|
+
module CashCtrl
|
|
4
4
|
module Resources
|
|
5
5
|
class FiscalPeriod < Base
|
|
6
6
|
api_path "fiscalperiod"
|
|
7
7
|
model_class Models::FiscalPeriod
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
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
|
|
9
|
+
def current
|
|
10
|
+
list.find(&:is_current)
|
|
51
11
|
end
|
|
52
12
|
|
|
53
13
|
def result(id:)
|
|
@@ -58,38 +18,36 @@ module Cashctrl
|
|
|
58
18
|
client.get("#{api_path}/depreciations.json", id: id)
|
|
59
19
|
end
|
|
60
20
|
|
|
61
|
-
def exchangediff(id:)
|
|
62
|
-
client.get("#{api_path}/exchangediff.json", id: id)
|
|
21
|
+
def exchangediff(id: nil, date: nil)
|
|
22
|
+
client.get("#{api_path}/exchangediff.json", api_params(id: id, date: date))
|
|
63
23
|
end
|
|
64
24
|
|
|
65
25
|
def switch(id:)
|
|
66
26
|
client.post("#{api_path}/switch.json", id: id)
|
|
67
27
|
end
|
|
68
28
|
|
|
69
|
-
def book_depreciations(id:)
|
|
70
|
-
client.post("#{api_path}/bookdepreciations.json", id: id)
|
|
29
|
+
def book_depreciations(id:, depreciation:)
|
|
30
|
+
client.post("#{api_path}/bookdepreciations.json", id: id, depreciation: csv(depreciation))
|
|
71
31
|
end
|
|
72
32
|
|
|
73
|
-
def book_exchangediff(id:)
|
|
74
|
-
client.post("#{api_path}/bookexchangediff.json", id: id)
|
|
33
|
+
def book_exchangediff(exchange_diff:, id: nil, date: nil)
|
|
34
|
+
client.post("#{api_path}/bookexchangediff.json", api_params(exchange_diff: exchange_diff, id: id, date: date))
|
|
75
35
|
end
|
|
76
36
|
|
|
77
|
-
def complete(id:)
|
|
78
|
-
client.post("#{api_path}/complete.json", id: id)
|
|
37
|
+
def complete(id:, is_salary: nil)
|
|
38
|
+
client.post("#{api_path}/complete.json", api_params(id: id, is_salary: is_salary))
|
|
79
39
|
end
|
|
80
40
|
|
|
81
|
-
def reopen(id:)
|
|
82
|
-
client.post("#{api_path}/reopen.json", id: id)
|
|
41
|
+
def reopen(id:, is_salary: nil)
|
|
42
|
+
client.post("#{api_path}/reopen.json", api_params(id: id, is_salary: is_salary))
|
|
83
43
|
end
|
|
84
44
|
|
|
85
|
-
def complete_months(id:, months:)
|
|
86
|
-
|
|
87
|
-
client.post("#{api_path}/complete_months.json", id: id, months: months_param)
|
|
45
|
+
def complete_months(id:, months: nil, is_salary: nil)
|
|
46
|
+
client.post("#{api_path}/complete_months.json", api_params(id: id, months: months, is_salary: is_salary))
|
|
88
47
|
end
|
|
89
48
|
|
|
90
|
-
def reopen_months(id:, months:)
|
|
91
|
-
|
|
92
|
-
client.post("#{api_path}/reopen_months.json", id: id, months: months_param)
|
|
49
|
+
def reopen_months(id:, months: nil, is_salary: nil)
|
|
50
|
+
client.get("#{api_path}/reopen_months.json", api_params(id: id, months: months, is_salary: is_salary))
|
|
93
51
|
end
|
|
94
52
|
end
|
|
95
53
|
end
|
|
@@ -1,38 +1,20 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
module
|
|
3
|
+
module CashCtrl
|
|
4
4
|
module Resources
|
|
5
5
|
class History < Base
|
|
6
6
|
api_path "history"
|
|
7
7
|
model_class Models::History
|
|
8
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
9
|
def create(**params)
|
|
28
10
|
raise NotImplementedError, "History does not support create"
|
|
29
11
|
end
|
|
30
12
|
|
|
31
|
-
def update(
|
|
13
|
+
def update(*, **)
|
|
32
14
|
raise NotImplementedError, "History does not support update"
|
|
33
15
|
end
|
|
34
16
|
|
|
35
|
-
def delete(
|
|
17
|
+
def delete(*)
|
|
36
18
|
raise NotImplementedError, "History does not support delete"
|
|
37
19
|
end
|
|
38
20
|
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module CashCtrl
|
|
4
|
+
module Resources
|
|
5
|
+
class ImportSession < Base
|
|
6
|
+
def list
|
|
7
|
+
raise NotImplementedError, "#{self.class.name} does not support list"
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def read(id:)
|
|
11
|
+
raise NotImplementedError, "#{self.class.name} does not support read"
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def update(*, **)
|
|
15
|
+
raise NotImplementedError, "#{self.class.name} does not support update"
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def delete(*)
|
|
19
|
+
raise NotImplementedError, "#{self.class.name} does not support delete"
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def create(file_id:, category_id: nil)
|
|
23
|
+
client.post("#{api_path}/create.json", api_params(file_id: file_id, category_id: category_id))
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def mapping(id:, mapping:)
|
|
27
|
+
client.post("#{api_path}/mapping.json", id: id, mapping: mapping)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def mapping_combo
|
|
31
|
+
client.get("#{api_path}/mapping_combo.json")
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def preview(id:)
|
|
35
|
+
client.get("#{api_path}/preview.json", id: id)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def execute(id:, indexes: nil)
|
|
39
|
+
client.post("#{api_path}/execute.json", api_params(id: id, indexes: indexes && csv(indexes)))
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
module
|
|
3
|
+
module CashCtrl
|
|
4
4
|
module Resources
|
|
5
5
|
module Inventory
|
|
6
6
|
class Article
|
|
@@ -8,14 +8,8 @@ module Cashctrl
|
|
|
8
8
|
api_path "inventory/article/category"
|
|
9
9
|
model_class Models::Category
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
client.get("#{api_path}/tree.json")
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
def tree
|
|
18
|
-
client.get("#{api_path}/tree.json")
|
|
11
|
+
def tree(id = nil)
|
|
12
|
+
tree_collection(client.get("#{api_path}/tree.json", api_params(id: id)))
|
|
19
13
|
end
|
|
20
14
|
end
|
|
21
15
|
end
|
|
@@ -1,33 +1,18 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
module
|
|
3
|
+
module CashCtrl
|
|
4
4
|
module Resources
|
|
5
5
|
module Inventory
|
|
6
6
|
class Article < Base
|
|
7
|
+
include Attachments
|
|
8
|
+
|
|
7
9
|
api_path "inventory/article"
|
|
8
10
|
model_class Models::Article
|
|
9
11
|
|
|
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
12
|
def categorize(ids:, target:)
|
|
23
13
|
ids_param = Array(ids).join(",")
|
|
24
14
|
client.post("#{api_path}/categorize.json", ids: ids_param, target: target)
|
|
25
15
|
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
16
|
end
|
|
32
17
|
end
|
|
33
18
|
end
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
module
|
|
3
|
+
module CashCtrl
|
|
4
4
|
module Resources
|
|
5
5
|
module Inventory
|
|
6
6
|
class Asset
|
|
@@ -8,14 +8,8 @@ module Cashctrl
|
|
|
8
8
|
api_path "inventory/asset/category"
|
|
9
9
|
model_class Models::Category
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
client.get("#{api_path}/tree.json")
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
def tree
|
|
18
|
-
client.get("#{api_path}/tree.json")
|
|
11
|
+
def tree(id = nil)
|
|
12
|
+
tree_collection(client.get("#{api_path}/tree.json", api_params(id: id)))
|
|
19
13
|
end
|
|
20
14
|
end
|
|
21
15
|
end
|
|
@@ -1,33 +1,18 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
module
|
|
3
|
+
module CashCtrl
|
|
4
4
|
module Resources
|
|
5
5
|
module Inventory
|
|
6
6
|
class Asset < Base
|
|
7
|
+
include Attachments
|
|
8
|
+
|
|
7
9
|
api_path "inventory/asset"
|
|
8
10
|
model_class Models::Asset
|
|
9
11
|
|
|
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
12
|
def categorize(ids:, target:)
|
|
23
13
|
ids_param = Array(ids).join(",")
|
|
24
14
|
client.post("#{api_path}/categorize.json", ids: ids_param, target: target)
|
|
25
15
|
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
16
|
end
|
|
32
17
|
end
|
|
33
18
|
end
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
module
|
|
3
|
+
module CashCtrl
|
|
4
4
|
module Resources
|
|
5
5
|
class Journal
|
|
6
6
|
class Import
|
|
@@ -8,27 +8,6 @@ module Cashctrl
|
|
|
8
8
|
api_path "journal/import/entry"
|
|
9
9
|
model_class Models::JournalImportEntry
|
|
10
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
11
|
def create(**params)
|
|
33
12
|
raise NotImplementedError, "Journal::Import::Entry does not support create"
|
|
34
13
|
end
|
|
@@ -1,18 +1,12 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
module
|
|
3
|
+
module CashCtrl
|
|
4
4
|
module Resources
|
|
5
5
|
class Journal
|
|
6
6
|
class Import < Base
|
|
7
7
|
api_path "journal/import"
|
|
8
8
|
model_class Models::JournalImport
|
|
9
9
|
|
|
10
|
-
class << self
|
|
11
|
-
def execute(id:)
|
|
12
|
-
client.post("#{api_path}/execute.json", id: id)
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
|
|
16
10
|
def execute(id:)
|
|
17
11
|
client.post("#{api_path}/execute.json", id: id)
|
|
18
12
|
end
|
|
@@ -1,66 +1,13 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
module
|
|
3
|
+
module CashCtrl
|
|
4
4
|
module Resources
|
|
5
5
|
class Journal < Base
|
|
6
|
+
include Attachments
|
|
7
|
+
|
|
6
8
|
api_path "journal"
|
|
7
9
|
model_class Models::Journal
|
|
8
10
|
|
|
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
11
|
def update_recurrence(id:, recurrence: nil, start_date: nil, end_date: nil, days_before: nil,
|
|
65
12
|
notify_type: nil, notify_person_id: nil, notify_user_id: nil, notify_email: nil)
|
|
66
13
|
params = { id: id }
|
|
@@ -77,6 +24,21 @@ module Cashctrl
|
|
|
77
24
|
|
|
78
25
|
private
|
|
79
26
|
|
|
27
|
+
def record_attributes(record)
|
|
28
|
+
attributes = super
|
|
29
|
+
attributes.delete("items") if Array(record.items).empty?
|
|
30
|
+
attributes
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def normalize_attributes(attributes)
|
|
34
|
+
attributes = attributes.transform_keys(&:to_sym)
|
|
35
|
+
debit = attributes.delete(:debit)
|
|
36
|
+
credit = attributes.delete(:credit)
|
|
37
|
+
attributes[:debit_id] = resolve_account_id(debit) if debit
|
|
38
|
+
attributes[:credit_id] = resolve_account_id(credit) if credit
|
|
39
|
+
super
|
|
40
|
+
end
|
|
41
|
+
|
|
80
42
|
def resolve_account_id(account)
|
|
81
43
|
case account
|
|
82
44
|
when Integer
|
|
@@ -84,7 +46,7 @@ module Cashctrl
|
|
|
84
46
|
when Models::Account
|
|
85
47
|
account.id
|
|
86
48
|
when String
|
|
87
|
-
Account.
|
|
49
|
+
Account.with_client(client).find_by_number(account)&.id || raise(ArgumentError, "Account not found: #{account}")
|
|
88
50
|
else
|
|
89
51
|
raise ArgumentError, "Invalid account: #{account.inspect}. Expected Integer, Account, or account number String."
|
|
90
52
|
end
|
|
@@ -1,30 +1,19 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
module
|
|
3
|
+
module CashCtrl
|
|
4
4
|
module Resources
|
|
5
5
|
class Order
|
|
6
6
|
class Category < Base
|
|
7
7
|
api_path "order/category"
|
|
8
8
|
model_class Models::Category
|
|
9
|
-
|
|
10
|
-
class << self
|
|
11
|
-
def read_status(id:)
|
|
12
|
-
client.get("#{api_path}/read_status.json", id: id)
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def reorder(ids:)
|
|
16
|
-
ids_param = Array(ids).join(",")
|
|
17
|
-
client.post("#{api_path}/reorder.json", ids: ids_param)
|
|
18
|
-
end
|
|
19
|
-
end
|
|
9
|
+
list_params :type
|
|
20
10
|
|
|
21
11
|
def read_status(id:)
|
|
22
12
|
client.get("#{api_path}/read_status.json", id: id)
|
|
23
13
|
end
|
|
24
14
|
|
|
25
|
-
def reorder(ids:)
|
|
26
|
-
|
|
27
|
-
client.post("#{api_path}/reorder.json", ids: ids_param)
|
|
15
|
+
def reorder(ids:, target:, before: nil, type: nil)
|
|
16
|
+
client.post("#{api_path}/reorder.json", api_params(ids: csv(ids), target: target, before: before, type: type))
|
|
28
17
|
end
|
|
29
18
|
end
|
|
30
19
|
end
|