papierkram_api_client 0.5.0 → 0.6.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/.rubocop.yml +1 -1
- data/CHANGELOG.md +12 -0
- data/Gemfile +9 -9
- data/Gemfile.lock +80 -62
- data/README.md +10 -89
- data/lib/papierkram_api/client.rb +1 -5
- data/lib/papierkram_api/v1/endpoints/contact/companies.rb +0 -2
- data/lib/papierkram_api/v1/endpoints/income/invoices.rb +0 -1
- data/lib/papierkram_api/v1/endpoints/income/propositions.rb +0 -2
- data/lib/papierkram_api/v1/endpoints/projects.rb +0 -2
- data/lib/papierkram_api/v1/validators/expense_voucher.rb +1 -1
- data/lib/papierkram_api_client/version.rb +1 -1
- data/lib/papierkram_api_client.rb +0 -3
- data/mise.toml +0 -0
- metadata +12 -17
- data/lib/papierkram_api/v1/business_intelligence/base.rb +0 -32
- data/lib/papierkram_api/v1/business_intelligence/expenses_by_category.rb +0 -96
- data/lib/papierkram_api/v1/business_intelligence/smart_queries/expense_vouchers_for_month_in_year.rb +0 -57
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2c9a175ef578cfbf1c6b5f584bd3ceb46a6fc49e895c3eadacf23eb6e7e55af1
|
|
4
|
+
data.tar.gz: 5562d7d36a1f757b040be4552f10f594c6923ba176528dfd822a3e7ed89076d1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 15e29b762bba407492648b92adbee09fa201ba6163e273ddc222aa3593a43625892c9740a03cfea49be49e1de41588a8af4d1c6eaab092a53fd0b4da7de9f51b
|
|
7
|
+
data.tar.gz: 3870632bd739dea34bf89d33e9fcb65e6c875a483923d0e77973e9d5b3adec74596ade614a595eb170fecc84012e472491243c9c9ae82c34333c6e75f3a733bb
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
|
@@ -8,6 +8,18 @@ Schema for new entries:
|
|
|
8
8
|
- [#<PR_NUMBER>](https://github.com/simonneutert/papierkram_api_client/pull/<PR_NUMBER>) Description. [@<username>](https://github.com/<username>)
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## [0.6.0] - 2026-05-26
|
|
14
|
+
|
|
15
|
+
- Bumps minimal ruby version to 3.3.0. [@simonneutert](https://github.com/simonneutert)
|
|
16
|
+
- DEPRECATION WARNING 🚨 This gem is no longer maintained.
|
|
17
|
+
- [#102](https://github.com/simonneutert/papierkram_api_client/pull/102) Removes deprecated Business Intelligence Module. [@simonneutert](https://github.com/simonneutert)
|
|
18
|
+
|
|
19
|
+
## [0.5.1] - 2025-03-04
|
|
20
|
+
|
|
21
|
+
- Updates URI Gem [@simonneutert](https://github.com/simonneutert)
|
|
22
|
+
|
|
11
23
|
## [0.5.0] - 2024-09-24
|
|
12
24
|
|
|
13
25
|
- [#112](https://github.com/simonneutert/papierkram_api_client/pull/112) Drops support for ruby v2.x. [@simonneutert](https://github.com/simonneutert)
|
data/Gemfile
CHANGED
|
@@ -5,13 +5,13 @@ source 'https://rubygems.org'
|
|
|
5
5
|
# Specify your gem's dependencies in papierkram_api_client.gemspec
|
|
6
6
|
gemspec
|
|
7
7
|
|
|
8
|
-
gem 'minitest', '~>
|
|
8
|
+
gem 'minitest', '~> 6.0'
|
|
9
9
|
gem 'minitest-vcr', '~> 1.4'
|
|
10
|
-
gem 'pry', '~> 0.
|
|
11
|
-
gem 'rake', '~> 13.
|
|
12
|
-
gem 'rubocop', '~> 1.
|
|
13
|
-
gem 'rubocop-minitest', '~> 0.
|
|
14
|
-
gem 'rubocop-performance', '~> 1.
|
|
15
|
-
gem 'rubocop-rake', '~> 0.
|
|
16
|
-
gem 'vcr', '~> 6.
|
|
17
|
-
gem 'webmock', '~> 3.
|
|
10
|
+
gem 'pry', '~> 0.16.0'
|
|
11
|
+
gem 'rake', '~> 13.4'
|
|
12
|
+
gem 'rubocop', '~> 1.75', require: false
|
|
13
|
+
gem 'rubocop-minitest', '~> 0.39.1', require: false
|
|
14
|
+
gem 'rubocop-performance', '~> 1.26', require: false
|
|
15
|
+
gem 'rubocop-rake', '~> 0.7.1', require: false
|
|
16
|
+
gem 'vcr', '~> 6.4'
|
|
17
|
+
gem 'webmock', '~> 3.26'
|
data/Gemfile.lock
CHANGED
|
@@ -1,84 +1,102 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
papierkram_api_client (0.
|
|
4
|
+
papierkram_api_client (0.6.0)
|
|
5
5
|
faraday (~> 2.7)
|
|
6
|
-
faraday-multipart (= 1.0
|
|
7
|
-
httpx (>= 0.22.5, < 1.
|
|
6
|
+
faraday-multipart (= 1.2.0)
|
|
7
|
+
httpx (>= 0.22.5, < 1.8.0)
|
|
8
8
|
|
|
9
9
|
GEM
|
|
10
10
|
remote: https://rubygems.org/
|
|
11
11
|
specs:
|
|
12
|
-
addressable (2.
|
|
13
|
-
public_suffix (>= 2.0.2, <
|
|
14
|
-
ast (2.4.
|
|
15
|
-
|
|
16
|
-
bigdecimal (3.1.8)
|
|
12
|
+
addressable (2.9.0)
|
|
13
|
+
public_suffix (>= 2.0.2, < 8.0)
|
|
14
|
+
ast (2.4.3)
|
|
15
|
+
bigdecimal (4.1.2)
|
|
17
16
|
coderay (1.1.3)
|
|
18
|
-
crack (1.0.
|
|
17
|
+
crack (1.0.1)
|
|
19
18
|
bigdecimal
|
|
20
19
|
rexml
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
faraday-net_http (>= 2.0, < 3.
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
20
|
+
drb (2.2.3)
|
|
21
|
+
faraday (2.14.2)
|
|
22
|
+
faraday-net_http (>= 2.0, < 3.5)
|
|
23
|
+
json
|
|
24
|
+
logger
|
|
25
|
+
faraday-multipart (1.2.0)
|
|
26
|
+
multipart-post (~> 2.0)
|
|
27
|
+
faraday-net_http (3.4.3)
|
|
28
|
+
net-http (~> 0.5)
|
|
29
|
+
hashdiff (1.2.1)
|
|
30
|
+
http-2 (1.1.3)
|
|
31
|
+
httpx (1.7.8)
|
|
32
|
+
http-2 (>= 1.1.3)
|
|
33
|
+
io-console (0.8.2)
|
|
34
|
+
json (2.19.5)
|
|
35
|
+
language_server-protocol (3.17.0.5)
|
|
36
|
+
lint_roller (1.1.0)
|
|
37
|
+
logger (1.7.0)
|
|
38
|
+
method_source (1.1.0)
|
|
35
39
|
minispec-metadata (2.0.0)
|
|
36
40
|
minitest
|
|
37
|
-
minitest (
|
|
41
|
+
minitest (6.0.6)
|
|
42
|
+
drb (~> 2.0)
|
|
43
|
+
prism (~> 1.5)
|
|
38
44
|
minitest-vcr (1.4.0)
|
|
39
45
|
minispec-metadata (~> 2.0)
|
|
40
46
|
minitest (>= 4.7.5)
|
|
41
47
|
vcr (>= 2.9)
|
|
42
|
-
multipart-post (2.
|
|
43
|
-
|
|
44
|
-
|
|
48
|
+
multipart-post (2.4.1)
|
|
49
|
+
net-http (0.9.1)
|
|
50
|
+
uri (>= 0.11.1)
|
|
51
|
+
parallel (2.1.0)
|
|
52
|
+
parser (3.3.11.1)
|
|
45
53
|
ast (~> 2.4.1)
|
|
46
54
|
racc
|
|
47
|
-
|
|
55
|
+
prism (1.9.0)
|
|
56
|
+
pry (0.16.0)
|
|
48
57
|
coderay (~> 1.1)
|
|
49
58
|
method_source (~> 1.0)
|
|
50
|
-
|
|
59
|
+
reline (>= 0.6.0)
|
|
60
|
+
public_suffix (7.0.5)
|
|
51
61
|
racc (1.8.1)
|
|
52
62
|
rainbow (3.1.1)
|
|
53
|
-
rake (13.2
|
|
54
|
-
regexp_parser (2.
|
|
55
|
-
|
|
56
|
-
|
|
63
|
+
rake (13.4.2)
|
|
64
|
+
regexp_parser (2.12.0)
|
|
65
|
+
reline (0.6.3)
|
|
66
|
+
io-console (~> 0.5)
|
|
67
|
+
rexml (3.4.4)
|
|
68
|
+
rubocop (1.86.2)
|
|
57
69
|
json (~> 2.3)
|
|
58
|
-
language_server-protocol (
|
|
59
|
-
|
|
70
|
+
language_server-protocol (~> 3.17.0.2)
|
|
71
|
+
lint_roller (~> 1.1.0)
|
|
72
|
+
parallel (>= 1.10)
|
|
60
73
|
parser (>= 3.3.0.2)
|
|
61
74
|
rainbow (>= 2.2.2, < 4.0)
|
|
62
|
-
regexp_parser (>= 2.
|
|
63
|
-
rubocop-ast (>= 1.
|
|
75
|
+
regexp_parser (>= 2.9.3, < 3.0)
|
|
76
|
+
rubocop-ast (>= 1.49.0, < 2.0)
|
|
64
77
|
ruby-progressbar (~> 1.7)
|
|
65
|
-
unicode-display_width (>= 2.4.0, <
|
|
66
|
-
rubocop-ast (1.
|
|
67
|
-
parser (>= 3.3.
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
rubocop (>= 1.
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
rubocop (
|
|
78
|
+
unicode-display_width (>= 2.4.0, < 4.0)
|
|
79
|
+
rubocop-ast (1.49.1)
|
|
80
|
+
parser (>= 3.3.7.2)
|
|
81
|
+
prism (~> 1.7)
|
|
82
|
+
rubocop-minitest (0.39.1)
|
|
83
|
+
lint_roller (~> 1.1)
|
|
84
|
+
rubocop (>= 1.75.0, < 2.0)
|
|
85
|
+
rubocop-ast (>= 1.38.0, < 2.0)
|
|
86
|
+
rubocop-performance (1.26.1)
|
|
87
|
+
lint_roller (~> 1.1)
|
|
88
|
+
rubocop (>= 1.75.0, < 2.0)
|
|
89
|
+
rubocop-ast (>= 1.47.1, < 2.0)
|
|
90
|
+
rubocop-rake (0.7.1)
|
|
91
|
+
lint_roller (~> 1.1)
|
|
92
|
+
rubocop (>= 1.72.1)
|
|
76
93
|
ruby-progressbar (1.13.0)
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
94
|
+
unicode-display_width (3.2.0)
|
|
95
|
+
unicode-emoji (~> 4.1)
|
|
96
|
+
unicode-emoji (4.2.0)
|
|
97
|
+
uri (1.1.1)
|
|
98
|
+
vcr (6.4.0)
|
|
99
|
+
webmock (3.26.2)
|
|
82
100
|
addressable (>= 2.8.0)
|
|
83
101
|
crack (>= 0.3.2)
|
|
84
102
|
hashdiff (>= 0.4.0, < 2.0.0)
|
|
@@ -89,17 +107,17 @@ PLATFORMS
|
|
|
89
107
|
x86_64-linux
|
|
90
108
|
|
|
91
109
|
DEPENDENCIES
|
|
92
|
-
minitest (~>
|
|
110
|
+
minitest (~> 6.0)
|
|
93
111
|
minitest-vcr (~> 1.4)
|
|
94
112
|
papierkram_api_client!
|
|
95
|
-
pry (~> 0.
|
|
96
|
-
rake (~> 13.
|
|
97
|
-
rubocop (~> 1.
|
|
98
|
-
rubocop-minitest (~> 0.
|
|
99
|
-
rubocop-performance (~> 1.
|
|
100
|
-
rubocop-rake (~> 0.
|
|
101
|
-
vcr (~> 6.
|
|
102
|
-
webmock (~> 3.
|
|
113
|
+
pry (~> 0.16.0)
|
|
114
|
+
rake (~> 13.4)
|
|
115
|
+
rubocop (~> 1.75)
|
|
116
|
+
rubocop-minitest (~> 0.39.1)
|
|
117
|
+
rubocop-performance (~> 1.26)
|
|
118
|
+
rubocop-rake (~> 0.7.1)
|
|
119
|
+
vcr (~> 6.4)
|
|
120
|
+
webmock (~> 3.26)
|
|
103
121
|
|
|
104
122
|
BUNDLED WITH
|
|
105
123
|
2.5.19
|
data/README.md
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
# Deprecated / Unmaintained
|
|
2
|
+
|
|
3
|
+
This package is no longer maintained as of 2026-05-26.
|
|
4
|
+
|
|
5
|
+
Existing versions remain available on rubygems.org for compatibility, but no new features, bug fixes, or security fixes are planned.
|
|
6
|
+
|
|
7
|
+
Please migrate away, replace it, or fork it under a new package name.
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
1
11
|
# Papierkram API Client<!-- omit in toc -->
|
|
2
12
|
|
|
3
13
|
[](https://github.com/simonneutert/papierkram_api_client/actions/workflows/main.yml)
|
|
@@ -149,10 +159,6 @@ Ziele:
|
|
|
149
159
|
- [archiviere einen Zeiteintrag](#archiviere-einen-zeiteintrag)
|
|
150
160
|
- [unarchiviere einen Zeiteintrag](#unarchiviere-einen-zeiteintrag)
|
|
151
161
|
- [Verbleibendes Quota](#verbleibendes-quota)
|
|
152
|
-
- [Business Intelligence](#business-intelligence)
|
|
153
|
-
- [Business::Intelligence (BI) ExpenseByCategory (Ausgaben nach Kategorie)](#businessintelligence-bi-expensebycategory-ausgaben-nach-kategorie)
|
|
154
|
-
- [alle Ausgaben eines Monats nach Kategorie](#alle-ausgaben-eines-monats-nach-kategorie)
|
|
155
|
-
- [alle Ausgaben eines Monats nach Kategorie gefiltert nach Steuersatz](#alle-ausgaben-eines-monats-nach-kategorie-gefiltert-nach-steuersatz)
|
|
156
162
|
- [Helpers](#helpers)
|
|
157
163
|
- [Generiere ein PDF aus Response](#generiere-ein-pdf-aus-response)
|
|
158
164
|
- [Development / Mitentwickeln](#development--mitentwickeln)
|
|
@@ -1146,91 +1152,6 @@ response = client.info.details
|
|
|
1146
1152
|
quota = client.info.remaining_quota(response)
|
|
1147
1153
|
```
|
|
1148
1154
|
|
|
1149
|
-
## Business Intelligence
|
|
1150
|
-
|
|
1151
|
-
> **DEPRECATED** Bitte verwende dieses Modul nicht mehr, es wird in Zukunft entfernt werden.
|
|
1152
|
-
|
|
1153
|
-
Ich lasse diesen ersten Ausflug in Auswertungen erstmal hier im Gem. Aber sollte ich die Zeit finden und weitere KPIs wichtig finden, dann gehören die Auswertungen eigentlich in ein eigenes Package.
|
|
1154
|
-
|
|
1155
|
-
TODO ergänzen wie man `SmartQueries` erstellt und verwendet.
|
|
1156
|
-
TODO ergänzen wie man `SmartQueries` funktioneren.
|
|
1157
|
-
TODO ergänzen wie die Rückgabewerte von `SmartQueries` gestaltet werden sollten.
|
|
1158
|
-
|
|
1159
|
-
### Business::Intelligence (BI) ExpenseByCategory (Ausgaben nach Kategorie)
|
|
1160
|
-
|
|
1161
|
-
> **DEPRECATED** Bitte verwende dieses Modul nicht mehr, es wird in Zukunft entfernt werden.
|
|
1162
|
-
|
|
1163
|
-
Der Endpunkt `/papierkram_api/v1/business_intelligence/expense_by_categories` liefert Informationen über die Ausgaben nach Kategorie. Die Informationen werden als `Hash` zurückgegeben.
|
|
1164
|
-
|
|
1165
|
-
#### alle Ausgaben eines Monats nach Kategorie
|
|
1166
|
-
|
|
1167
|
-
```ruby
|
|
1168
|
-
client = PapierkramApi::Client.new
|
|
1169
|
-
expense_voucher_data_service = client.expense_vouchers.data_service(:for_month_in_year_service)
|
|
1170
|
-
expense_vouchers_in_date_range = expense_voucher_data_service.for_month_in_year(year: 2020, month: 8)
|
|
1171
|
-
|
|
1172
|
-
service = client.business_intelligence.expenses_by_category
|
|
1173
|
-
result = service.call(expense_vouchers: expense_vouchers_in_date_range)
|
|
1174
|
-
puts result
|
|
1175
|
-
```
|
|
1176
|
-
|
|
1177
|
-
```ruby
|
|
1178
|
-
{"Betriebsbedarf"=>
|
|
1179
|
-
{"amount"=>476.0,
|
|
1180
|
-
"amount_by_creditor"=>{nil=>476.0},
|
|
1181
|
-
"line_items"=>
|
|
1182
|
-
[{"name"=>"2020-01-03",
|
|
1183
|
-
"amount"=>119.0,
|
|
1184
|
-
"category"=>"Betriebsbedarf",
|
|
1185
|
-
"vat_rate"=>"19%",
|
|
1186
|
-
"billing"=>nil,
|
|
1187
|
-
"depreciation"=>nil,
|
|
1188
|
-
"voucher_name"=>"B-00214 - 2020-08-01",
|
|
1189
|
-
"voucher_id"=>641,
|
|
1190
|
-
"creditor"=>nil},
|
|
1191
|
-
{"name"=>"2020-01-03",
|
|
1192
|
-
"amount"=>119.0,
|
|
1193
|
-
"category"=>"Betriebsbedarf",
|
|
1194
|
-
"vat_rate"=>"19%",
|
|
1195
|
-
"billing"=>nil,
|
|
1196
|
-
"depreciation"=>nil,
|
|
1197
|
-
"voucher_name"=>"B-00215 - 2020-08-02",
|
|
1198
|
-
"voucher_id"=>644,
|
|
1199
|
-
"creditor"=>nil},
|
|
1200
|
-
{"name"=>"2020-01-03",
|
|
1201
|
-
"amount"=>119.0,
|
|
1202
|
-
"category"=>"Betriebsbedarf",
|
|
1203
|
-
"vat_rate"=>"19%",
|
|
1204
|
-
"billing"=>nil,
|
|
1205
|
-
"depreciation"=>nil,
|
|
1206
|
-
"voucher_name"=>"B-00216 - 2020-08-03",
|
|
1207
|
-
"voucher_id"=>647,
|
|
1208
|
-
"creditor"=>nil},
|
|
1209
|
-
{"name"=>"2020-01-03",
|
|
1210
|
-
"amount"=>119.0,
|
|
1211
|
-
"category"=>"Betriebsbedarf",
|
|
1212
|
-
"vat_rate"=>"19%",
|
|
1213
|
-
"billing"=>nil,
|
|
1214
|
-
"depreciation"=>nil,
|
|
1215
|
-
"voucher_name"=>"B-00217 - 2020-08-04",
|
|
1216
|
-
"voucher_id"=>650,
|
|
1217
|
-
"creditor"=>nil}]}}
|
|
1218
|
-
```
|
|
1219
|
-
|
|
1220
|
-
#### alle Ausgaben eines Monats nach Kategorie gefiltert nach Steuersatz
|
|
1221
|
-
|
|
1222
|
-
```ruby
|
|
1223
|
-
client = PapierkramApi::Client.new
|
|
1224
|
-
expense_voucher_data_service = client.expense_vouchers.data_service(:for_month_in_year_service)
|
|
1225
|
-
expense_vouchers_in_date_range = expense_voucher_data_service.for_month_in_year(year: 2020, month: 8)
|
|
1226
|
-
|
|
1227
|
-
service = client.business_intelligence.expenses_by_category
|
|
1228
|
-
result = service.call(expense_vouchers: expense_vouchers_in_date_range) do |line_items|
|
|
1229
|
-
line_items.select { |v| v['vat_rate'] == '19%' }
|
|
1230
|
-
end
|
|
1231
|
-
puts result
|
|
1232
|
-
```
|
|
1233
|
-
|
|
1234
1155
|
## Helpers
|
|
1235
1156
|
|
|
1236
1157
|
Es gibt einige Helper, die dir das Leben leichter machen.
|
|
@@ -10,6 +10,7 @@ module PapierkramApi
|
|
|
10
10
|
:remaining_quota
|
|
11
11
|
|
|
12
12
|
extend Forwardable
|
|
13
|
+
|
|
13
14
|
def_delegators :@client, :get, :post, :put, :patch, :delete
|
|
14
15
|
|
|
15
16
|
def initialize(subdomain = nil, api_key = nil)
|
|
@@ -32,11 +33,6 @@ module PapierkramApi
|
|
|
32
33
|
end
|
|
33
34
|
end
|
|
34
35
|
|
|
35
|
-
def business_intelligence
|
|
36
|
-
@business_intelligence ||=
|
|
37
|
-
PapierkramApi::V1::BusinessIntelligence::Base.new
|
|
38
|
-
end
|
|
39
|
-
|
|
40
36
|
def banking_bank_connections
|
|
41
37
|
@banking_bank_connections ||=
|
|
42
38
|
PapierkramApi::V1::Endpoints::Banking::BankConnections.new(@client)
|
|
@@ -49,7 +49,6 @@ module PapierkramApi
|
|
|
49
49
|
notes: nil,
|
|
50
50
|
color: nil
|
|
51
51
|
)
|
|
52
|
-
|
|
53
52
|
body = {}
|
|
54
53
|
body[:contact_type] = 'supplier'
|
|
55
54
|
body[:name] = name
|
|
@@ -104,7 +103,6 @@ module PapierkramApi
|
|
|
104
103
|
notes: nil,
|
|
105
104
|
color: nil
|
|
106
105
|
)
|
|
107
|
-
|
|
108
106
|
body = {}
|
|
109
107
|
body[:contact_type] = 'customer'
|
|
110
108
|
body[:name] = name
|
|
@@ -23,7 +23,6 @@ module PapierkramApi
|
|
|
23
23
|
price: nil,
|
|
24
24
|
vat_rate: nil
|
|
25
25
|
)
|
|
26
|
-
|
|
27
26
|
body = {}
|
|
28
27
|
body[:name] = name
|
|
29
28
|
body[:article_no] = article_no
|
|
@@ -47,7 +46,6 @@ module PapierkramApi
|
|
|
47
46
|
time_unit: nil,
|
|
48
47
|
vat_rate: nil
|
|
49
48
|
)
|
|
50
|
-
|
|
51
49
|
body = {}
|
|
52
50
|
body[:name] = name if name
|
|
53
51
|
body[:description] = description if description
|
|
@@ -36,7 +36,6 @@ module PapierkramApi
|
|
|
36
36
|
default_proposition: nil,
|
|
37
37
|
team_members: nil
|
|
38
38
|
)
|
|
39
|
-
|
|
40
39
|
body = {}
|
|
41
40
|
body[:name] = name
|
|
42
41
|
body[:customer] = { id: customer_id }
|
|
@@ -71,7 +70,6 @@ module PapierkramApi
|
|
|
71
70
|
default_proposition: nil,
|
|
72
71
|
team_members: nil
|
|
73
72
|
)
|
|
74
|
-
|
|
75
73
|
body = {}
|
|
76
74
|
body[:name] = name if name
|
|
77
75
|
body[:customer] = { id: customer_id } if customer_id
|
|
@@ -91,7 +91,7 @@ module PapierkramApi
|
|
|
91
91
|
}.freeze
|
|
92
92
|
SWAGGER_SAMPLE_KEYS_STRINGIFIED = SWAGGER_SAMPLE.keys.map(&:to_s).sort.freeze
|
|
93
93
|
|
|
94
|
-
def validate!(expense_voucher)
|
|
94
|
+
def validate!(expense_voucher) # rubocop:disable Naming/PredicateMethod
|
|
95
95
|
unless expense_voucher['type'] == 'expense_voucher' &&
|
|
96
96
|
expense_voucher.keys.sort == SWAGGER_SAMPLE_KEYS_STRINGIFIED
|
|
97
97
|
raise ArgumentError, 'expense_voucher does not match the expected format'
|
|
@@ -24,8 +24,5 @@ require_relative 'papierkram_api/v1/endpoints/info'
|
|
|
24
24
|
require_relative 'papierkram_api/v1/endpoints/projects'
|
|
25
25
|
require_relative 'papierkram_api/v1/endpoints/tracker/tasks'
|
|
26
26
|
require_relative 'papierkram_api/v1/endpoints/tracker/time_entries'
|
|
27
|
-
require_relative 'papierkram_api/v1/business_intelligence/base'
|
|
28
|
-
require_relative 'papierkram_api/v1/business_intelligence/expenses_by_category'
|
|
29
|
-
require_relative 'papierkram_api/v1/business_intelligence/smart_queries/expense_vouchers_for_month_in_year'
|
|
30
27
|
|
|
31
28
|
require_relative 'papierkram_api/client'
|
data/mise.toml
ADDED
|
File without changes
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: papierkram_api_client
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.6.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Simon Neutert
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: exe
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: faraday
|
|
@@ -30,14 +29,14 @@ dependencies:
|
|
|
30
29
|
requirements:
|
|
31
30
|
- - '='
|
|
32
31
|
- !ruby/object:Gem::Version
|
|
33
|
-
version: 1.0
|
|
32
|
+
version: 1.2.0
|
|
34
33
|
type: :runtime
|
|
35
34
|
prerelease: false
|
|
36
35
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
36
|
requirements:
|
|
38
37
|
- - '='
|
|
39
38
|
- !ruby/object:Gem::Version
|
|
40
|
-
version: 1.0
|
|
39
|
+
version: 1.2.0
|
|
41
40
|
- !ruby/object:Gem::Dependency
|
|
42
41
|
name: httpx
|
|
43
42
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -47,7 +46,7 @@ dependencies:
|
|
|
47
46
|
version: 0.22.5
|
|
48
47
|
- - "<"
|
|
49
48
|
- !ruby/object:Gem::Version
|
|
50
|
-
version: 1.
|
|
49
|
+
version: 1.8.0
|
|
51
50
|
type: :runtime
|
|
52
51
|
prerelease: false
|
|
53
52
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -57,9 +56,9 @@ dependencies:
|
|
|
57
56
|
version: 0.22.5
|
|
58
57
|
- - "<"
|
|
59
58
|
- !ruby/object:Gem::Version
|
|
60
|
-
version: 1.
|
|
61
|
-
description: Papierkram API Client, um deine Buchhaltung
|
|
62
|
-
bringen.
|
|
59
|
+
version: 1.8.0
|
|
60
|
+
description: 'DEPRECATED AND UNMAINTAINED: Papierkram API Client, um deine Buchhaltung
|
|
61
|
+
auf das nächste Level zu bringen.'
|
|
63
62
|
email:
|
|
64
63
|
- simonneutert@users.noreply.github.com
|
|
65
64
|
executables: []
|
|
@@ -78,9 +77,6 @@ files:
|
|
|
78
77
|
- Rakefile
|
|
79
78
|
- UPGRADING.md
|
|
80
79
|
- lib/papierkram_api/client.rb
|
|
81
|
-
- lib/papierkram_api/v1/business_intelligence/base.rb
|
|
82
|
-
- lib/papierkram_api/v1/business_intelligence/expenses_by_category.rb
|
|
83
|
-
- lib/papierkram_api/v1/business_intelligence/smart_queries/expense_vouchers_for_month_in_year.rb
|
|
84
80
|
- lib/papierkram_api/v1/endpoints/banking/bank_connections.rb
|
|
85
81
|
- lib/papierkram_api/v1/endpoints/banking/transactions.rb
|
|
86
82
|
- lib/papierkram_api/v1/endpoints/base.rb
|
|
@@ -101,6 +97,7 @@ files:
|
|
|
101
97
|
- lib/papierkram_api_client.rb
|
|
102
98
|
- lib/papierkram_api_client/version.rb
|
|
103
99
|
- logo.svg
|
|
100
|
+
- mise.toml
|
|
104
101
|
- pac.svg
|
|
105
102
|
- sig/papierkram_api_client.rbs
|
|
106
103
|
homepage: https://github.com/simonneutert/papierkram_api_client
|
|
@@ -111,7 +108,6 @@ metadata:
|
|
|
111
108
|
source_code_uri: https://github.com/simonneutert/papierkram_api_client
|
|
112
109
|
changelog_uri: https://github.com/simonneutert/papierkram_api_client/blob/main/CHANGELOG.md
|
|
113
110
|
rubygems_mfa_required: 'true'
|
|
114
|
-
post_install_message:
|
|
115
111
|
rdoc_options: []
|
|
116
112
|
require_paths:
|
|
117
113
|
- lib
|
|
@@ -119,15 +115,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
119
115
|
requirements:
|
|
120
116
|
- - ">="
|
|
121
117
|
- !ruby/object:Gem::Version
|
|
122
|
-
version: 3.
|
|
118
|
+
version: 3.3.0
|
|
123
119
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
124
120
|
requirements:
|
|
125
121
|
- - ">="
|
|
126
122
|
- !ruby/object:Gem::Version
|
|
127
123
|
version: '0'
|
|
128
124
|
requirements: []
|
|
129
|
-
rubygems_version: 3.
|
|
130
|
-
signing_key:
|
|
125
|
+
rubygems_version: 3.6.9
|
|
131
126
|
specification_version: 4
|
|
132
|
-
summary: Papierkram API Client
|
|
127
|
+
summary: 'DEPRECATED AND UNMAINTAINED: Papierkram API Client'
|
|
133
128
|
test_files: []
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module PapierkramApi
|
|
4
|
-
module V1
|
|
5
|
-
module BusinessIntelligence
|
|
6
|
-
# Business Intelligence Base Class
|
|
7
|
-
#
|
|
8
|
-
# Business Intelligence is a set of services that can be used to gain
|
|
9
|
-
# insights into the data stored in the system.
|
|
10
|
-
#
|
|
11
|
-
# Therefor you should pass data to the service and get back a result.
|
|
12
|
-
#
|
|
13
|
-
# IMPORTANT no calls to the API should be made in this class.
|
|
14
|
-
# This is an intentional design decision! To seperate logic from the data source.
|
|
15
|
-
#
|
|
16
|
-
class Base
|
|
17
|
-
def expenses_by_category
|
|
18
|
-
warning = <<~MSG
|
|
19
|
-
[DEPRECATION] `expenses_by_category` is deprecated. #{' '}
|
|
20
|
-
It will be removed in a version after 0.4.0, most probably in 0.5.0.
|
|
21
|
-
|
|
22
|
-
[DEPRECATION] Support for RUBY 2.7 will be dropped#{' '}
|
|
23
|
-
in a version after 0.4.0, most probably in 0.5.0.
|
|
24
|
-
MSG
|
|
25
|
-
warn(warning)
|
|
26
|
-
|
|
27
|
-
@expenses_by_category ||= PapierkramApi::V1::BusinessIntelligence::ExpensesByCategory.new
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
end
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module PapierkramApi
|
|
4
|
-
module V1
|
|
5
|
-
module BusinessIntelligence
|
|
6
|
-
# Business Intelligence for Expenses
|
|
7
|
-
class ExpensesByCategory
|
|
8
|
-
#
|
|
9
|
-
# Calculate the expenses by category
|
|
10
|
-
#
|
|
11
|
-
# @param [Array<Hash>] expense_vouchers represents a list of expense vouchers in the format:
|
|
12
|
-
#
|
|
13
|
-
# @param [<Type>] &block <description>
|
|
14
|
-
#
|
|
15
|
-
# @return [<Type>] <description>
|
|
16
|
-
#
|
|
17
|
-
def call(expense_vouchers:, &block)
|
|
18
|
-
return {} if expense_vouchers.is_a?(Array) && expense_vouchers.empty?
|
|
19
|
-
|
|
20
|
-
validate_expense_vouchers!(expense_vouchers)
|
|
21
|
-
return results(expense_vouchers, &block) if block
|
|
22
|
-
|
|
23
|
-
results(expense_vouchers)
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
private
|
|
27
|
-
|
|
28
|
-
def results(expense_vouchers)
|
|
29
|
-
coll = prepare_voucher_data(expense_vouchers)
|
|
30
|
-
coll = yield(coll) if block_given?
|
|
31
|
-
line_items_grouped_by_category = coll.group_by { |v| v['category'] }
|
|
32
|
-
sum_categories!(line_items_grouped_by_category)
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
def sum_categories!(line_items_grouped_by_category)
|
|
36
|
-
lookup_table = {}
|
|
37
|
-
line_items_grouped_by_category.each do |category_name, line_items|
|
|
38
|
-
line_items_by_creditor_lot = {}
|
|
39
|
-
line_items_by_creditor = line_items.group_by { |v| v['creditor'] }
|
|
40
|
-
sum_up_creditor!(line_items_by_creditor, line_items_by_creditor_lot)
|
|
41
|
-
build_result_lookup_table!(lookup_table, category_name, line_items, line_items_by_creditor_lot)
|
|
42
|
-
end
|
|
43
|
-
lookup_table
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
def sum_up_creditor!(line_items_by_creditor, line_items_by_creditor_lot)
|
|
47
|
-
line_items_by_creditor.each do |category_name, line_items|
|
|
48
|
-
line_items_by_creditor_lot[category_name] = line_items.reduce(0) do |sum, creditor|
|
|
49
|
-
sum + creditor['amount']
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
line_items_by_creditor_lot
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
def build_result_lookup_table!(lookup_table, category_name, line_items, line_items_by_creditor_lot)
|
|
56
|
-
lookup_table[category_name] = {
|
|
57
|
-
'amount' => line_items.reduce(0) { |sum, line_item| sum + line_item['amount'] },
|
|
58
|
-
'amount_by_creditor' => line_items_by_creditor_lot,
|
|
59
|
-
'line_items' => line_items
|
|
60
|
-
}
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
def prepare_voucher_data(vouchers)
|
|
64
|
-
coll = []
|
|
65
|
-
vouchers.flat_map do |voucher|
|
|
66
|
-
voucher['line_items'].each do |line_item|
|
|
67
|
-
res = line_item.merge(
|
|
68
|
-
{ 'voucher_name' => voucher['name'] },
|
|
69
|
-
{ 'voucher_id' => voucher['id'] },
|
|
70
|
-
'creditor' => voucher['creditor']
|
|
71
|
-
)
|
|
72
|
-
coll.push(res)
|
|
73
|
-
end
|
|
74
|
-
end
|
|
75
|
-
coll
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
# TODO: move to a validator class forPapierkramApi::V1::Validators::ExpenseVouchers
|
|
79
|
-
def validate_expense_vouchers!(expense_vouchers)
|
|
80
|
-
raise ArgumentError, 'expense_vouchers must be an Array' unless expense_vouchers.is_a?(Array)
|
|
81
|
-
raise ArgumentError, 'expense_vouchers must not be empty' if expense_vouchers.empty?
|
|
82
|
-
raise ArgumentError, 'expense_vouchers must contain Hashes' unless expense_vouchers.all?(Hash)
|
|
83
|
-
|
|
84
|
-
validator = PapierkramApi::V1::Validators::ExpenseVoucher.new
|
|
85
|
-
expense_vouchers.all? do |voucher|
|
|
86
|
-
validate_expense_voucher!(validator, voucher)
|
|
87
|
-
end
|
|
88
|
-
end
|
|
89
|
-
|
|
90
|
-
def validate_expense_voucher!(validator, expense_voucher)
|
|
91
|
-
validator.validate!(expense_voucher)
|
|
92
|
-
end
|
|
93
|
-
end
|
|
94
|
-
end
|
|
95
|
-
end
|
|
96
|
-
end
|
data/lib/papierkram_api/v1/business_intelligence/smart_queries/expense_vouchers_for_month_in_year.rb
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module PapierkramApi
|
|
4
|
-
module V1
|
|
5
|
-
module BusinessIntelligence
|
|
6
|
-
module SmartQueries
|
|
7
|
-
# This class is responsible for all the API calls related to expense vouchers.
|
|
8
|
-
class ExpenseVouchersForMonthInYear
|
|
9
|
-
include PapierkramApi::V1::Helper::DateHelper
|
|
10
|
-
|
|
11
|
-
def initialize(expense_voucher_api)
|
|
12
|
-
@expense_voucher_api = expense_voucher_api
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def for_month_in_year(year:, month:)
|
|
16
|
-
@year = year
|
|
17
|
-
@month = month
|
|
18
|
-
@start_date = Date.new(@year, @month, 1)
|
|
19
|
-
@end_date = Date.new(@year, @month + 1, 1) - 1
|
|
20
|
-
collect_expense_vouchers
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
private
|
|
24
|
-
|
|
25
|
-
def collect_expense_vouchers
|
|
26
|
-
all_expense_vouchers_in_date_range.map do |voucher|
|
|
27
|
-
@expense_voucher_api.find_by(id: voucher['id']).body
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
def all_expense_vouchers_in_date_range
|
|
32
|
-
page = 1
|
|
33
|
-
res = expense_vouchers(page: page)
|
|
34
|
-
vouchers = res.body['entries'].map { |v| v }
|
|
35
|
-
while res.body['page'] != res.body['total_pages']
|
|
36
|
-
res = expense_vouchers(page: page)
|
|
37
|
-
res.body['entries'].each { |v| vouchers << v }
|
|
38
|
-
end
|
|
39
|
-
vouchers
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
def expense_vouchers(page: 1)
|
|
43
|
-
@expense_voucher_api.all(
|
|
44
|
-
page: page,
|
|
45
|
-
document_date_range_start: build_date_string_for_api(@start_date),
|
|
46
|
-
document_date_range_end: build_date_string_for_api(@end_date)
|
|
47
|
-
)
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
def expense_voucher(id)
|
|
51
|
-
@expense_voucher_api.find_by(id: id)
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
end
|
|
55
|
-
end
|
|
56
|
-
end
|
|
57
|
-
end
|