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
data/lib/cashctrl/schema.yml
CHANGED
|
@@ -25,6 +25,12 @@ account:
|
|
|
25
25
|
is_inactive: { type: boolean }
|
|
26
26
|
is_in_salary_type: { type: boolean, readonly: true }
|
|
27
27
|
is_bank_account: { type: boolean, readonly: true }
|
|
28
|
+
belongs_to:
|
|
29
|
+
category: { resource: Account::Category }
|
|
30
|
+
tax: { resource: Tax }
|
|
31
|
+
currency: { resource: Currency }
|
|
32
|
+
nested:
|
|
33
|
+
attachments: { model: attachment }
|
|
28
34
|
|
|
29
35
|
person:
|
|
30
36
|
attributes:
|
|
@@ -90,6 +96,15 @@ person:
|
|
|
90
96
|
is_family: { type: boolean }
|
|
91
97
|
is_auto_fill_responsible_person: { type: boolean }
|
|
92
98
|
is_inactive: { type: boolean }
|
|
99
|
+
belongs_to:
|
|
100
|
+
category: { resource: Person::Category }
|
|
101
|
+
superior: { resource: Person }
|
|
102
|
+
location: { resource: Location }
|
|
103
|
+
has_many:
|
|
104
|
+
orders: { resource: Order, foreign_key: associate_id }
|
|
105
|
+
journals: { resource: Journal, foreign_key: associate_id }
|
|
106
|
+
nested:
|
|
107
|
+
attachments: { model: attachment }
|
|
93
108
|
|
|
94
109
|
currency:
|
|
95
110
|
attributes:
|
|
@@ -111,6 +126,8 @@ tax:
|
|
|
111
126
|
account_id: { type: integer }
|
|
112
127
|
account_name: { type: string, readonly: true }
|
|
113
128
|
is_inactive: { type: boolean }
|
|
129
|
+
belongs_to:
|
|
130
|
+
account: { resource: Account }
|
|
114
131
|
|
|
115
132
|
journal:
|
|
116
133
|
attributes:
|
|
@@ -135,6 +152,7 @@ journal:
|
|
|
135
152
|
notes: { type: string }
|
|
136
153
|
reference: { type: string }
|
|
137
154
|
amount: { type: decimal }
|
|
155
|
+
items: { type: json }
|
|
138
156
|
currency_id: { type: integer }
|
|
139
157
|
currency_rate: { type: decimal }
|
|
140
158
|
currency_code: { type: string, readonly: true }
|
|
@@ -160,6 +178,16 @@ journal:
|
|
|
160
178
|
imported: { type: datetime, readonly: true }
|
|
161
179
|
imported_by: { type: string, readonly: true }
|
|
162
180
|
is_recurring: { type: boolean, readonly: true }
|
|
181
|
+
belongs_to:
|
|
182
|
+
debit: { resource: Account }
|
|
183
|
+
credit: { resource: Account }
|
|
184
|
+
associate: { resource: Person }
|
|
185
|
+
tax: { resource: Tax }
|
|
186
|
+
currency: { resource: Currency }
|
|
187
|
+
order: { resource: Order }
|
|
188
|
+
nested:
|
|
189
|
+
items: { model: journal_item }
|
|
190
|
+
attachments: { model: attachment }
|
|
163
191
|
|
|
164
192
|
order:
|
|
165
193
|
attributes:
|
|
@@ -199,6 +227,15 @@ order:
|
|
|
199
227
|
notify_user_id: { type: integer }
|
|
200
228
|
notify_email: { type: string }
|
|
201
229
|
is_recurring: { type: boolean, readonly: true }
|
|
230
|
+
belongs_to:
|
|
231
|
+
category: { resource: Order::Category }
|
|
232
|
+
associate: { resource: Person }
|
|
233
|
+
responsible_person: { resource: Person }
|
|
234
|
+
currency: { resource: Currency }
|
|
235
|
+
rounding: { resource: Rounding }
|
|
236
|
+
nested:
|
|
237
|
+
items: { model: order_item }
|
|
238
|
+
attachments: { model: attachment }
|
|
202
239
|
|
|
203
240
|
fiscal_period:
|
|
204
241
|
attributes:
|
|
@@ -231,6 +268,8 @@ rounding:
|
|
|
231
268
|
account_name: { type: string, readonly: true }
|
|
232
269
|
mode: { type: string }
|
|
233
270
|
value: { type: decimal }
|
|
271
|
+
belongs_to:
|
|
272
|
+
account: { resource: Account }
|
|
234
273
|
|
|
235
274
|
sequence_number:
|
|
236
275
|
attributes:
|
|
@@ -260,6 +299,8 @@ file:
|
|
|
260
299
|
height: { type: integer, readonly: true }
|
|
261
300
|
notes: { type: string }
|
|
262
301
|
is_archived: { type: boolean, readonly: true }
|
|
302
|
+
belongs_to:
|
|
303
|
+
category: { resource: File::Category }
|
|
263
304
|
|
|
264
305
|
article:
|
|
265
306
|
attributes:
|
|
@@ -293,6 +334,16 @@ article:
|
|
|
293
334
|
is_purchase_price_gross: { type: boolean }
|
|
294
335
|
is_sales_price_gross: { type: boolean }
|
|
295
336
|
is_inactive: { type: boolean }
|
|
337
|
+
belongs_to:
|
|
338
|
+
category: { resource: Inventory::Article::Category }
|
|
339
|
+
unit: { resource: Inventory::Unit }
|
|
340
|
+
sales_account: { resource: Account }
|
|
341
|
+
purchase_account: { resource: Account }
|
|
342
|
+
sales_tax: { resource: Tax }
|
|
343
|
+
purchase_tax: { resource: Tax }
|
|
344
|
+
currency: { resource: Currency }
|
|
345
|
+
nested:
|
|
346
|
+
attachments: { model: attachment }
|
|
296
347
|
|
|
297
348
|
asset:
|
|
298
349
|
attributes:
|
|
@@ -318,6 +369,13 @@ asset:
|
|
|
318
369
|
notes: { type: string }
|
|
319
370
|
attachment_count: { type: integer, readonly: true }
|
|
320
371
|
is_inactive: { type: boolean }
|
|
372
|
+
belongs_to:
|
|
373
|
+
category: { resource: Inventory::Asset::Category }
|
|
374
|
+
account_asset: { resource: Account }
|
|
375
|
+
account_depreciation: { resource: Account }
|
|
376
|
+
account_expense: { resource: Account }
|
|
377
|
+
nested:
|
|
378
|
+
attachments: { model: attachment }
|
|
321
379
|
|
|
322
380
|
unit:
|
|
323
381
|
attributes:
|
|
@@ -389,6 +447,10 @@ bank:
|
|
|
389
447
|
iban: { type: string }
|
|
390
448
|
bic: { type: string }
|
|
391
449
|
qr_iban: { type: string }
|
|
450
|
+
belongs_to:
|
|
451
|
+
account: { resource: Account }
|
|
452
|
+
nested:
|
|
453
|
+
attachments: { model: attachment }
|
|
392
454
|
|
|
393
455
|
cost_center:
|
|
394
456
|
attributes:
|
|
@@ -397,6 +459,10 @@ cost_center:
|
|
|
397
459
|
number: { type: string }
|
|
398
460
|
name: { type: string }
|
|
399
461
|
notes: { type: string }
|
|
462
|
+
belongs_to:
|
|
463
|
+
category: { resource: Account::CostCenter::Category }
|
|
464
|
+
nested:
|
|
465
|
+
attachments: { model: attachment }
|
|
400
466
|
|
|
401
467
|
title:
|
|
402
468
|
attributes:
|
|
@@ -509,6 +575,8 @@ salary_certificate:
|
|
|
509
575
|
template_id: { type: integer }
|
|
510
576
|
year: { type: integer }
|
|
511
577
|
values: { type: json }
|
|
578
|
+
belongs_to:
|
|
579
|
+
person: { resource: Person }
|
|
512
580
|
|
|
513
581
|
salary_document:
|
|
514
582
|
attributes:
|
|
@@ -556,6 +624,10 @@ salary_statement:
|
|
|
556
624
|
status: { type: string }
|
|
557
625
|
total_gross: { type: decimal, readonly: true }
|
|
558
626
|
total_net: { type: decimal, readonly: true }
|
|
627
|
+
belongs_to:
|
|
628
|
+
person: { resource: Person }
|
|
629
|
+
nested:
|
|
630
|
+
attachments: { model: attachment }
|
|
559
631
|
|
|
560
632
|
salary_status:
|
|
561
633
|
attributes:
|
|
@@ -599,3 +671,42 @@ certificate_template:
|
|
|
599
671
|
name: { type: string }
|
|
600
672
|
year: { type: integer }
|
|
601
673
|
fields: { type: json }
|
|
674
|
+
|
|
675
|
+
journal_item:
|
|
676
|
+
attributes:
|
|
677
|
+
account_id: { type: integer }
|
|
678
|
+
debit: { type: decimal }
|
|
679
|
+
credit: { type: decimal }
|
|
680
|
+
description: { type: string }
|
|
681
|
+
tax_id: { type: integer }
|
|
682
|
+
associate_id: { type: integer }
|
|
683
|
+
amount: { type: decimal, readonly: true }
|
|
684
|
+
belongs_to:
|
|
685
|
+
account: { resource: Account }
|
|
686
|
+
tax: { resource: Tax }
|
|
687
|
+
associate: { resource: Person }
|
|
688
|
+
|
|
689
|
+
order_item:
|
|
690
|
+
attributes:
|
|
691
|
+
account_id: { type: integer }
|
|
692
|
+
tax_id: { type: integer }
|
|
693
|
+
unit_id: { type: integer }
|
|
694
|
+
name: { type: string }
|
|
695
|
+
description: { type: string }
|
|
696
|
+
article_nr: { type: string }
|
|
697
|
+
quantity: { type: decimal }
|
|
698
|
+
unit_price: { type: decimal }
|
|
699
|
+
discount_percentage: { type: decimal }
|
|
700
|
+
type: { type: string }
|
|
701
|
+
belongs_to:
|
|
702
|
+
account: { resource: Account }
|
|
703
|
+
tax: { resource: Tax }
|
|
704
|
+
unit: { resource: Inventory::Unit }
|
|
705
|
+
|
|
706
|
+
attachment:
|
|
707
|
+
attributes:
|
|
708
|
+
file_id: { type: integer }
|
|
709
|
+
name: { type: string }
|
|
710
|
+
mime_type: { type: string }
|
|
711
|
+
belongs_to:
|
|
712
|
+
file: { resource: File }
|
data/lib/cashctrl/version.rb
CHANGED
data/lib/cashctrl.rb
CHANGED
|
@@ -3,13 +3,17 @@
|
|
|
3
3
|
require_relative "cashctrl/version"
|
|
4
4
|
require_relative "cashctrl/configuration"
|
|
5
5
|
require_relative "cashctrl/error"
|
|
6
|
+
require_relative "cashctrl/errors"
|
|
6
7
|
require_relative "cashctrl/client"
|
|
7
8
|
require_relative "cashctrl/localized_string"
|
|
8
9
|
require_relative "cashctrl/resource"
|
|
9
10
|
require_relative "cashctrl/collection"
|
|
11
|
+
require_relative "cashctrl/relation"
|
|
10
12
|
require_relative "cashctrl/models/loader"
|
|
11
13
|
|
|
12
14
|
require_relative "cashctrl/resources/base"
|
|
15
|
+
require_relative "cashctrl/resources/attachments"
|
|
16
|
+
require_relative "cashctrl/resources/import_session"
|
|
13
17
|
|
|
14
18
|
require_relative "cashctrl/resources/account"
|
|
15
19
|
require_relative "cashctrl/resources/account/bank"
|
|
@@ -22,6 +26,7 @@ require_relative "cashctrl/resources/custom_field"
|
|
|
22
26
|
require_relative "cashctrl/resources/custom_field/group"
|
|
23
27
|
require_relative "cashctrl/resources/history"
|
|
24
28
|
require_relative "cashctrl/resources/location"
|
|
29
|
+
require_relative "cashctrl/resources/organization"
|
|
25
30
|
require_relative "cashctrl/resources/rounding"
|
|
26
31
|
require_relative "cashctrl/resources/sequence_number"
|
|
27
32
|
require_relative "cashctrl/resources/setting"
|
|
@@ -36,6 +41,7 @@ require_relative "cashctrl/resources/fiscal_period/task"
|
|
|
36
41
|
|
|
37
42
|
require_relative "cashctrl/resources/inventory/article"
|
|
38
43
|
require_relative "cashctrl/resources/inventory/article/category"
|
|
44
|
+
require_relative "cashctrl/resources/inventory/article/import"
|
|
39
45
|
require_relative "cashctrl/resources/inventory/asset"
|
|
40
46
|
require_relative "cashctrl/resources/inventory/asset/category"
|
|
41
47
|
require_relative "cashctrl/resources/inventory/unit"
|
|
@@ -53,6 +59,7 @@ require_relative "cashctrl/resources/order/payment"
|
|
|
53
59
|
|
|
54
60
|
require_relative "cashctrl/resources/person"
|
|
55
61
|
require_relative "cashctrl/resources/person/category"
|
|
62
|
+
require_relative "cashctrl/resources/person/import"
|
|
56
63
|
require_relative "cashctrl/resources/person/title"
|
|
57
64
|
|
|
58
65
|
require_relative "cashctrl/resources/report"
|
|
@@ -76,43 +83,46 @@ require_relative "cashctrl/resources/salary/sum"
|
|
|
76
83
|
require_relative "cashctrl/resources/salary/template"
|
|
77
84
|
require_relative "cashctrl/resources/salary/type"
|
|
78
85
|
|
|
79
|
-
module
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
@configuration = nil
|
|
103
|
-
end
|
|
86
|
+
module CashCtrl
|
|
87
|
+
singleton_class.attr_writer :configuration
|
|
88
|
+
|
|
89
|
+
def self.configuration
|
|
90
|
+
@configuration ||= Configuration.new
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
def self.configure
|
|
94
|
+
yield(configuration) if block_given?
|
|
95
|
+
configuration
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
def self.client
|
|
99
|
+
@client ||= Client.new(
|
|
100
|
+
org: configuration.org,
|
|
101
|
+
api_key: configuration.api_key,
|
|
102
|
+
language: configuration.language
|
|
103
|
+
)
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
def self.reset!
|
|
107
|
+
@client = nil
|
|
108
|
+
@configuration = nil
|
|
104
109
|
end
|
|
105
110
|
|
|
106
111
|
Account = Resources::Account
|
|
107
112
|
Currency = Resources::Currency
|
|
108
113
|
CustomField = Resources::CustomField
|
|
114
|
+
File = Resources::File
|
|
109
115
|
FiscalPeriod = Resources::FiscalPeriod
|
|
116
|
+
History = Resources::History
|
|
117
|
+
Inventory = Resources::Inventory
|
|
110
118
|
Journal = Resources::Journal
|
|
111
119
|
Location = Resources::Location
|
|
112
120
|
Order = Resources::Order
|
|
121
|
+
Organization = Resources::Organization
|
|
113
122
|
Person = Resources::Person
|
|
114
123
|
Report = Resources::Report
|
|
115
124
|
Rounding = Resources::Rounding
|
|
125
|
+
Salary = Resources::Salary
|
|
116
126
|
SequenceNumber = Resources::SequenceNumber
|
|
117
127
|
Setting = Resources::Setting
|
|
118
128
|
Tax = Resources::Tax
|
|
@@ -4,7 +4,7 @@ require "yaml"
|
|
|
4
4
|
require "erb"
|
|
5
5
|
require "fileutils"
|
|
6
6
|
|
|
7
|
-
module
|
|
7
|
+
module CashCtrl
|
|
8
8
|
module Generators
|
|
9
9
|
class ModelGenerator
|
|
10
10
|
def initialize(schema_path:, output_dir:)
|
|
@@ -32,7 +32,7 @@ module Cashctrl
|
|
|
32
32
|
lines << ""
|
|
33
33
|
lines << "# This file is auto-generated from schema.yml. Do not edit manually."
|
|
34
34
|
lines << ""
|
|
35
|
-
lines << "module
|
|
35
|
+
lines << "module CashCtrl"
|
|
36
36
|
lines << " module Models"
|
|
37
37
|
lines << " class #{class_name} < Resource"
|
|
38
38
|
|
|
@@ -43,14 +43,26 @@ module Cashctrl
|
|
|
43
43
|
lines << " #{parts.join(", ")}"
|
|
44
44
|
end
|
|
45
45
|
|
|
46
|
+
(config["belongs_to"] || {}).each do |name, association|
|
|
47
|
+
lines << " belongs_to :#{name}, resource: \"#{association["resource"]}\""
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
(config["has_many"] || {}).each do |name, association|
|
|
51
|
+
lines << " has_many :#{name}, resource: \"#{association["resource"]}\", foreign_key: :#{association["foreign_key"]}"
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
(config["nested"] || {}).each do |name, nested|
|
|
55
|
+
lines << " nested :#{name}, model: \"#{camelize(nested["model"])}\""
|
|
56
|
+
end
|
|
57
|
+
|
|
46
58
|
lines << " end"
|
|
47
59
|
lines << " end"
|
|
48
60
|
lines << "end"
|
|
49
61
|
lines << ""
|
|
50
62
|
|
|
51
63
|
content = lines.join("\n")
|
|
52
|
-
file_path = File.join(@output_dir, "#{resource_name}.rb")
|
|
53
|
-
File.write(file_path, content)
|
|
64
|
+
file_path = ::File.join(@output_dir, "#{resource_name}.rb")
|
|
65
|
+
::File.write(file_path, content)
|
|
54
66
|
puts "Generated #{file_path}"
|
|
55
67
|
end
|
|
56
68
|
|
|
@@ -66,8 +78,8 @@ module Cashctrl
|
|
|
66
78
|
end
|
|
67
79
|
lines << ""
|
|
68
80
|
|
|
69
|
-
file_path = File.join(@output_dir, "loader.rb")
|
|
70
|
-
File.write(file_path, lines.join("\n"))
|
|
81
|
+
file_path = ::File.join(@output_dir, "loader.rb")
|
|
82
|
+
::File.write(file_path, lines.join("\n"))
|
|
71
83
|
puts "Generated #{file_path}"
|
|
72
84
|
end
|
|
73
85
|
|
|
@@ -84,7 +96,7 @@ if __FILE__ == $PROGRAM_NAME
|
|
|
84
96
|
schema_path = File.expand_path("../cashctrl/schema.yml", __dir__)
|
|
85
97
|
output_dir = File.expand_path("../cashctrl/models", __dir__)
|
|
86
98
|
|
|
87
|
-
generator =
|
|
99
|
+
generator = CashCtrl::Generators::ModelGenerator.new(
|
|
88
100
|
schema_path: schema_path,
|
|
89
101
|
output_dir: output_dir
|
|
90
102
|
)
|
data/sig/cashctrl.rbs
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: cashctrl
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Marco Roth
|
|
@@ -66,10 +66,12 @@ files:
|
|
|
66
66
|
- lib/cashctrl/collection.rb
|
|
67
67
|
- lib/cashctrl/configuration.rb
|
|
68
68
|
- lib/cashctrl/error.rb
|
|
69
|
+
- lib/cashctrl/errors.rb
|
|
69
70
|
- lib/cashctrl/localized_string.rb
|
|
70
71
|
- lib/cashctrl/models/account.rb
|
|
71
72
|
- lib/cashctrl/models/article.rb
|
|
72
73
|
- lib/cashctrl/models/asset.rb
|
|
74
|
+
- lib/cashctrl/models/attachment.rb
|
|
73
75
|
- lib/cashctrl/models/bank.rb
|
|
74
76
|
- lib/cashctrl/models/category.rb
|
|
75
77
|
- lib/cashctrl/models/certificate_document.rb
|
|
@@ -86,11 +88,13 @@ files:
|
|
|
86
88
|
- lib/cashctrl/models/journal.rb
|
|
87
89
|
- lib/cashctrl/models/journal_import.rb
|
|
88
90
|
- lib/cashctrl/models/journal_import_entry.rb
|
|
91
|
+
- lib/cashctrl/models/journal_item.rb
|
|
89
92
|
- lib/cashctrl/models/loader.rb
|
|
90
93
|
- lib/cashctrl/models/location.rb
|
|
91
94
|
- lib/cashctrl/models/order.rb
|
|
92
95
|
- lib/cashctrl/models/order_book_entry.rb
|
|
93
96
|
- lib/cashctrl/models/order_document.rb
|
|
97
|
+
- lib/cashctrl/models/order_item.rb
|
|
94
98
|
- lib/cashctrl/models/order_layout.rb
|
|
95
99
|
- lib/cashctrl/models/order_payment.rb
|
|
96
100
|
- lib/cashctrl/models/person.rb
|
|
@@ -116,12 +120,14 @@ files:
|
|
|
116
120
|
- lib/cashctrl/models/text.rb
|
|
117
121
|
- lib/cashctrl/models/title.rb
|
|
118
122
|
- lib/cashctrl/models/unit.rb
|
|
123
|
+
- lib/cashctrl/relation.rb
|
|
119
124
|
- lib/cashctrl/resource.rb
|
|
120
125
|
- lib/cashctrl/resources/account.rb
|
|
121
126
|
- lib/cashctrl/resources/account/bank.rb
|
|
122
127
|
- lib/cashctrl/resources/account/category.rb
|
|
123
128
|
- lib/cashctrl/resources/account/cost_center.rb
|
|
124
129
|
- lib/cashctrl/resources/account/cost_center/category.rb
|
|
130
|
+
- lib/cashctrl/resources/attachments.rb
|
|
125
131
|
- lib/cashctrl/resources/base.rb
|
|
126
132
|
- lib/cashctrl/resources/currency.rb
|
|
127
133
|
- lib/cashctrl/resources/custom_field.rb
|
|
@@ -131,8 +137,10 @@ files:
|
|
|
131
137
|
- lib/cashctrl/resources/fiscal_period.rb
|
|
132
138
|
- lib/cashctrl/resources/fiscal_period/task.rb
|
|
133
139
|
- lib/cashctrl/resources/history.rb
|
|
140
|
+
- lib/cashctrl/resources/import_session.rb
|
|
134
141
|
- lib/cashctrl/resources/inventory/article.rb
|
|
135
142
|
- lib/cashctrl/resources/inventory/article/category.rb
|
|
143
|
+
- lib/cashctrl/resources/inventory/article/import.rb
|
|
136
144
|
- lib/cashctrl/resources/inventory/asset.rb
|
|
137
145
|
- lib/cashctrl/resources/inventory/asset/category.rb
|
|
138
146
|
- lib/cashctrl/resources/inventory/unit.rb
|
|
@@ -146,8 +154,10 @@ files:
|
|
|
146
154
|
- lib/cashctrl/resources/order/document.rb
|
|
147
155
|
- lib/cashctrl/resources/order/layout.rb
|
|
148
156
|
- lib/cashctrl/resources/order/payment.rb
|
|
157
|
+
- lib/cashctrl/resources/organization.rb
|
|
149
158
|
- lib/cashctrl/resources/person.rb
|
|
150
159
|
- lib/cashctrl/resources/person/category.rb
|
|
160
|
+
- lib/cashctrl/resources/person/import.rb
|
|
151
161
|
- lib/cashctrl/resources/person/title.rb
|
|
152
162
|
- lib/cashctrl/resources/report.rb
|
|
153
163
|
- lib/cashctrl/resources/report/collection.rb
|
|
@@ -200,7 +210,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
200
210
|
- !ruby/object:Gem::Version
|
|
201
211
|
version: '0'
|
|
202
212
|
requirements: []
|
|
203
|
-
rubygems_version: 4.0.
|
|
213
|
+
rubygems_version: 4.0.20
|
|
204
214
|
specification_version: 4
|
|
205
215
|
summary: Ruby client for the CashCtrl Swiss accounting software API.
|
|
206
216
|
test_files: []
|