papierkram_api_client 0.4.0 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop +2 -1
- data/.rubocop.yml +4 -4
- data/CHANGELOG.md +23 -0
- data/Gemfile +4 -4
- data/Gemfile.lock +29 -24
- data/README.md +362 -14
- data/UPGRADING.md +45 -0
- data/lib/papierkram_api/client.rb +4 -0
- data/lib/papierkram_api/v1/business_intelligence/base.rb +9 -0
- data/lib/papierkram_api/v1/endpoints/expense/vouchers.rb +150 -0
- data/lib/papierkram_api/v1/endpoints/income/invoices.rb +154 -8
- data/lib/papierkram_api/v1/endpoints/income/propositions.rb +3 -2
- data/lib/papierkram_api/v1/validators/expense_voucher.rb +2 -2
- data/lib/papierkram_api_client/version.rb +1 -1
- data/lib/papierkram_api_client.rb +1 -0
- metadata +18 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c99716d33a07425d28d28395d3f428e2a3b3340faac0d5cf7a3bdd7a6d28cfd9
|
4
|
+
data.tar.gz: ce4b47ad13476cc988f326a337de4e5e5b2e7e90d94346c5cb2b1ec9cca30a21
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0b8bca55f782b372ac64ef98eaa0a0a1c4d70e5ab558e3d123d53b356081550bd1f2e6a82a1d0d12a023dd457323780e673768c3572e8333227369edef2b497b
|
7
|
+
data.tar.gz: 4bc2662091a4a6df9574227a4101929f38dfb6fce877dfe01d5f263ea3707a3c01c307c198cfae51768858e53053343a8b015285e7484f340afd6feea940b8d8
|
data/.rubocop
CHANGED
@@ -1 +1,2 @@
|
|
1
|
-
--server
|
1
|
+
--server
|
2
|
+
--parallel
|
data/.rubocop.yml
CHANGED
@@ -10,15 +10,15 @@ AllCops:
|
|
10
10
|
- "vendor/**/*"
|
11
11
|
- "papierkram_api_client.gemspec"
|
12
12
|
|
13
|
+
Layout/LineLength:
|
14
|
+
Exclude:
|
15
|
+
- "test/cassettes/**/*"
|
16
|
+
|
13
17
|
Metrics/BlockLength:
|
14
18
|
Enabled: true
|
15
19
|
Exclude:
|
16
20
|
- "test/**/*"
|
17
21
|
|
18
|
-
Layout/LineLength:
|
19
|
-
Exclude:
|
20
|
-
- "test/cassettes/**/*"
|
21
|
-
|
22
22
|
Metrics/MethodLength:
|
23
23
|
Max: 16
|
24
24
|
CountAsOne:
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,28 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
Schema for new entries:
|
4
|
+
|
5
|
+
```markdown
|
6
|
+
- [#<PR_NUMBER>](https://github.com/simonneutert/papierkram_api_client/pull/<PR_NUMBER>) Description. [@<username>](https://github.com/<username>)
|
7
|
+
```
|
8
|
+
|
9
|
+
## [0.4.2] - 2024-02-04
|
10
|
+
|
11
|
+
- [#114](https://github.com/simonneutert/papierkram_api_client/pull/114) Public API of Papierkram changed, adapt your implementation of `vat_rate` attribute, please. [@simonneutert](https://github.com/simonneutert)
|
12
|
+
|
13
|
+
Please see [UPGRADING.md](UPGRADING.md) for more information.
|
14
|
+
|
15
|
+
## [0.4.1] - 2024-01-26
|
16
|
+
|
17
|
+
- [#111](https://github.com/simonneutert/papierkram_api_client/pull/111) Updates dependencies via bundler. [@simonneutert](https://github.com/simonneutert)
|
18
|
+
- [#110](https://github.com/simonneutert/papierkram_api_client/pull/110) Adds debug option to shoot against localhost:3000. [@simonneutert](https://github.com/simonneutert)
|
19
|
+
- [#109](https://github.com/simonneutert/papierkram_api_client/pull/109) Housekeeping. [@simonneutert](https://github.com/simonneutert)
|
20
|
+
- [#108](https://github.com/simonneutert/papierkram_api_client/pull/108) Fixes bug in `Income::Invoice.deliver`. [@simonneutert](https://github.com/simonneutert)
|
21
|
+
- [#101](https://github.com/simonneutert/papierkram_api_client/pull/101) Adds DEPRECATION WARNING 🚨 of experimental Business Intelligence Module. [@simonneutert](https://github.com/simonneutert)
|
22
|
+
- [#100](https://github.com/simonneutert/papierkram_api_client/pull/100) Writing endpoints for (income) invoices. [@simonneutert](https://github.com/simonneutert)
|
23
|
+
- [#99](https://github.com/simonneutert/papierkram_api_client/pull/99) Writing endpoints for (income/expense) vouchers. [@simonneutert](https://github.com/simonneutert)
|
24
|
+
- [#93](https://github.com/simonneutert/papierkram_api_client/pull/93) Fresh set of most endpoints got get_all actions. [@simonneutert](https://github.com/simonneutert)
|
25
|
+
|
3
26
|
## [0.4.0] - 2023-12-02
|
4
27
|
|
5
28
|
### Changes (BREAKING! ⚠️)
|
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', '~> 5.
|
8
|
+
gem 'minitest', '~> 5.21'
|
9
9
|
gem 'minitest-vcr', '~> 1.4'
|
10
10
|
gem 'pry', '~> 0.14.2'
|
11
11
|
gem 'rake', '~> 13.1'
|
12
|
-
gem 'rubocop', '~> 1.
|
13
|
-
gem 'rubocop-minitest', '~> 0.
|
14
|
-
gem 'rubocop-performance', '~> 1.
|
12
|
+
gem 'rubocop', '~> 1.60', require: false
|
13
|
+
gem 'rubocop-minitest', '~> 0.34.5', require: false
|
14
|
+
gem 'rubocop-performance', '~> 1.20', require: false
|
15
15
|
gem 'rubocop-rake', '~> 0.6.0', require: false
|
16
16
|
gem 'vcr', '~> 6.2'
|
17
17
|
gem 'webmock', '~> 3.19'
|
data/Gemfile.lock
CHANGED
@@ -1,57 +1,61 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
papierkram_api_client (0.4.
|
4
|
+
papierkram_api_client (0.4.2)
|
5
5
|
faraday (~> 2.7)
|
6
|
-
|
6
|
+
faraday-multipart (= 1.0.4)
|
7
|
+
httpx (>= 0.22.5, < 1.3.0)
|
7
8
|
|
8
9
|
GEM
|
9
10
|
remote: https://rubygems.org/
|
10
11
|
specs:
|
11
|
-
addressable (2.8.
|
12
|
+
addressable (2.8.6)
|
12
13
|
public_suffix (>= 2.0.2, < 6.0)
|
13
14
|
ast (2.4.2)
|
14
15
|
base64 (0.2.0)
|
15
16
|
coderay (1.1.3)
|
16
17
|
crack (0.4.5)
|
17
18
|
rexml
|
18
|
-
faraday (2.
|
19
|
+
faraday (2.8.1)
|
19
20
|
base64
|
20
21
|
faraday-net_http (>= 2.0, < 3.1)
|
21
22
|
ruby2_keywords (>= 0.0.4)
|
23
|
+
faraday-multipart (1.0.4)
|
24
|
+
multipart-post (~> 2)
|
22
25
|
faraday-net_http (3.0.2)
|
23
|
-
hashdiff (1.0
|
24
|
-
http-2-next (1.0.
|
25
|
-
httpx (1.
|
26
|
-
http-2-next (>= 1.0.
|
27
|
-
json (2.7.
|
26
|
+
hashdiff (1.1.0)
|
27
|
+
http-2-next (1.0.3)
|
28
|
+
httpx (1.2.2)
|
29
|
+
http-2-next (>= 1.0.3)
|
30
|
+
json (2.7.1)
|
28
31
|
language_server-protocol (3.17.0.3)
|
29
32
|
method_source (1.0.0)
|
30
33
|
minispec-metadata (2.0.0)
|
31
34
|
minitest
|
32
|
-
minitest (5.
|
35
|
+
minitest (5.21.2)
|
33
36
|
minitest-vcr (1.4.0)
|
34
37
|
minispec-metadata (~> 2.0)
|
35
38
|
minitest (>= 4.7.5)
|
36
39
|
vcr (>= 2.9)
|
37
|
-
|
38
|
-
|
40
|
+
multipart-post (2.3.0)
|
41
|
+
parallel (1.24.0)
|
42
|
+
parser (3.3.0.5)
|
39
43
|
ast (~> 2.4.1)
|
40
44
|
racc
|
41
45
|
pry (0.14.2)
|
42
46
|
coderay (~> 1.1)
|
43
47
|
method_source (~> 1.0)
|
44
|
-
public_suffix (5.0.
|
48
|
+
public_suffix (5.0.4)
|
45
49
|
racc (1.7.3)
|
46
50
|
rainbow (3.1.1)
|
47
51
|
rake (13.1.0)
|
48
|
-
regexp_parser (2.
|
52
|
+
regexp_parser (2.9.0)
|
49
53
|
rexml (3.2.6)
|
50
|
-
rubocop (1.
|
54
|
+
rubocop (1.60.2)
|
51
55
|
json (~> 2.3)
|
52
56
|
language_server-protocol (>= 3.17.0)
|
53
57
|
parallel (~> 1.10)
|
54
|
-
parser (>= 3.
|
58
|
+
parser (>= 3.3.0.2)
|
55
59
|
rainbow (>= 2.2.2, < 4.0)
|
56
60
|
regexp_parser (>= 1.8, < 3.0)
|
57
61
|
rexml (>= 3.2.5, < 4.0)
|
@@ -60,11 +64,12 @@ GEM
|
|
60
64
|
unicode-display_width (>= 2.4.0, < 3.0)
|
61
65
|
rubocop-ast (1.30.0)
|
62
66
|
parser (>= 3.2.1.0)
|
63
|
-
rubocop-minitest (0.
|
67
|
+
rubocop-minitest (0.34.5)
|
64
68
|
rubocop (>= 1.39, < 2.0)
|
65
|
-
|
66
|
-
|
67
|
-
rubocop
|
69
|
+
rubocop-ast (>= 1.30.0, < 2.0)
|
70
|
+
rubocop-performance (1.20.2)
|
71
|
+
rubocop (>= 1.48.1, < 2.0)
|
72
|
+
rubocop-ast (>= 1.30.0, < 2.0)
|
68
73
|
rubocop-rake (0.6.0)
|
69
74
|
rubocop (~> 1.0)
|
70
75
|
ruby-progressbar (1.13.0)
|
@@ -82,14 +87,14 @@ PLATFORMS
|
|
82
87
|
x86_64-linux
|
83
88
|
|
84
89
|
DEPENDENCIES
|
85
|
-
minitest (~> 5.
|
90
|
+
minitest (~> 5.21)
|
86
91
|
minitest-vcr (~> 1.4)
|
87
92
|
papierkram_api_client!
|
88
93
|
pry (~> 0.14.2)
|
89
94
|
rake (~> 13.1)
|
90
|
-
rubocop (~> 1.
|
91
|
-
rubocop-minitest (~> 0.
|
92
|
-
rubocop-performance (~> 1.
|
95
|
+
rubocop (~> 1.60)
|
96
|
+
rubocop-minitest (~> 0.34.5)
|
97
|
+
rubocop-performance (~> 1.20)
|
93
98
|
rubocop-rake (~> 0.6.0)
|
94
99
|
vcr (~> 6.2)
|
95
100
|
webmock (~> 3.19)
|
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
[![Ruby](https://github.com/simonneutert/papierkram_api_client/actions/workflows/main.yml/badge.svg?branch=main)](https://github.com/simonneutert/papierkram_api_client/actions/workflows/main.yml)
|
4
4
|
|
5
|
-
Der erste ~~illegale~~ inoffizielle API Client in [Ruby](https://www.ruby-lang.org/de/) für [Papierkram.de](https://www.papierkram.de) als [Gem](https://rubygems.org/gems/papierkram_api_client)
|
5
|
+
Der erste ~~illegale~~ inoffizielle API Client in [Ruby](https://www.ruby-lang.org/de/) für [Papierkram.de](https://www.papierkram.de) als [Gem](https://rubygems.org/gems/papierkram_api_client) für dein Projekt!
|
6
6
|
|
7
7
|
<div align="center">
|
8
8
|
<img src="logo.svg" alt="PAC Logo, Zunge leckt an Karl Klammer und zieht Daten aus dem Papierkram-Account wie Frosch die Fliege vom Teich" width="300">
|
@@ -10,9 +10,8 @@ Der erste ~~illegale~~ inoffizielle API Client in [Ruby](https://www.ruby-lang.o
|
|
10
10
|
|
11
11
|
---
|
12
12
|
|
13
|
-
**
|
14
|
-
|
15
|
-
Das Gleiche, nur in grün, also für [NodeJS](https://github.com/simonneutert/papierkram-api-client). Und als Mega-Baustelle 😬
|
13
|
+
**Aufruf zur Mitarbeit für NodeJS/JavaScript 🫠**
|
14
|
+
Das Gleiche, nur in grün, also für [NodeJS ein Papierkram Api Client](https://github.com/simonneutert/papierkram-api-client) 😬
|
16
15
|
|
17
16
|
---
|
18
17
|
|
@@ -26,6 +25,9 @@ Schau in [UPGRADING.md](UPGRADING.md), 💃🕺!
|
|
26
25
|
Hier geht es zu den [offiziellen API Docs](https://demo.papierkram.de/api/v1/api-docs/index.html).
|
27
26
|
Schau bitte dort um alle Rückgabefelder/-werte zu checken, bis ich (oder du mit deiner Zeit und Hingabe) die Dokumentation hier komplett habe.
|
28
27
|
|
28
|
+
**WENN DU PROBLEME HAST,** bitte ich dich erstmal die [offiziellen API Docs](https://demo.papierkram.de/api/v1/api-docs/index.html) zu durchstöbern. Dann lohnt es sich hier die Beispiele (weiter unten) zu lesen und von dort sowohl mal in die Methoden im Code zu springen, oder noch besser in die Tests schauen.
|
29
|
+
Wenn du dann immer noch nicht weiterkommst, kannst du gerne einen Issue erstellen. Poste dabei so viele Informationen wie möglich, damit ich dir bestmöglich weiterhelfen kann. Achte dabei bitte darauf, dass du keine privaten Daten postest. 🙏
|
30
|
+
|
29
31
|
---
|
30
32
|
|
31
33
|
## Aktuell unterstützte Endpunkte der Papierkram API (V1)<!-- omit in toc -->
|
@@ -40,9 +42,11 @@ Schau bitte dort um alle Rückgabefelder/-werte zu checken, bis ich (oder du mit
|
|
40
42
|
- [x] Income::PaymentTerms (Zahlungsbedingungen)
|
41
43
|
- [x] Income::Proposition (Waren / Dienstleistungen)
|
42
44
|
- [x] Info
|
45
|
+
- [ ] Settings::CustomAttribute (Datenfelder)
|
43
46
|
- [x] Project (Projekte)
|
44
47
|
- [x] Tracker::Task (Aufgaben)
|
45
48
|
- [x] Tracker::TimeEntry (Zeiterfassung)
|
49
|
+
- [ ] User
|
46
50
|
|
47
51
|
## Was, wie, warum?<!-- omit in toc -->
|
48
52
|
|
@@ -83,6 +87,16 @@ Ziele:
|
|
83
87
|
- [alle Ausgabe Belege](#alle-ausgabe-belege)
|
84
88
|
- [einen Ausgabe Beleg](#einen-ausgabe-beleg)
|
85
89
|
- [einen Ausgabe Beleg als PDF](#einen-ausgabe-beleg-als-pdf)
|
90
|
+
- [einen Ausgabe Beleg erstellen](#einen-ausgabe-beleg-erstellen)
|
91
|
+
- [einen Ausgabe Beleg aktualisieren](#einen-ausgabe-beleg-aktualisieren)
|
92
|
+
- [einen Ausgabe Beleg löschen](#einen-ausgabe-beleg-löschen)
|
93
|
+
- [einen Ausgabe Beleg archivieren](#einen-ausgabe-beleg-archivieren)
|
94
|
+
- [einen Ausgabe Beleg unarchivieren](#einen-ausgabe-beleg-unarchivieren)
|
95
|
+
- [einen Ausgabe Beleg stornieren](#einen-ausgabe-beleg-stornieren)
|
96
|
+
- [einen Ausgabe Beleg rückwirkend stornieren](#einen-ausgabe-beleg-rückwirkend-stornieren)
|
97
|
+
- [einen Ausgabe Beleg als bezahlt markieren](#einen-ausgabe-beleg-als-bezahlt-markieren)
|
98
|
+
- [einem Ausgabe Beleg ein Dokument hinzufügen](#einem-ausgabe-beleg-ein-dokument-hinzufügen)
|
99
|
+
- [einem Ausgabe Beleg ein Dokument entfernen](#einem-ausgabe-beleg-ein-dokument-entfernen)
|
86
100
|
- [Income::Estimate (Angebot)](#incomeestimate-angebot)
|
87
101
|
- [alle Angebote](#alle-angebote)
|
88
102
|
- [ein Angebot](#ein-angebot)
|
@@ -91,6 +105,13 @@ Ziele:
|
|
91
105
|
- [alle Rechnungen](#alle-rechnungen)
|
92
106
|
- [eine Rechnung](#eine-rechnung)
|
93
107
|
- [eine Rechnung als PDF](#eine-rechnung-als-pdf)
|
108
|
+
- [eine Rechnung erstellen](#eine-rechnung-erstellen)
|
109
|
+
- [eine Rechnung aktualisieren](#eine-rechnung-aktualisieren)
|
110
|
+
- [eine Rechnung löschen](#eine-rechnung-löschen)
|
111
|
+
- [eine Rechnung archivieren](#eine-rechnung-archivieren)
|
112
|
+
- [eine Rechnung unarchivieren](#eine-rechnung-unarchivieren)
|
113
|
+
- [eine Rechnung stornieren](#eine-rechnung-stornieren)
|
114
|
+
- [eine Rechnung verschicken](#eine-rechnung-verschicken)
|
94
115
|
- [Income::PaymentTerms (Zahlungsbedingungen)](#incomepaymentterms-zahlungsbedingungen)
|
95
116
|
- [eine Zahlungsbedingung](#eine-zahlungsbedingung)
|
96
117
|
- [alle Zahlungsbedingungen](#alle-zahlungsbedingungen)
|
@@ -134,8 +155,10 @@ Ziele:
|
|
134
155
|
- [alle Ausgaben eines Monats nach Kategorie gefiltert nach Steuersatz](#alle-ausgaben-eines-monats-nach-kategorie-gefiltert-nach-steuersatz)
|
135
156
|
- [Helpers](#helpers)
|
136
157
|
- [Generiere ein PDF aus Response](#generiere-ein-pdf-aus-response)
|
137
|
-
- [Development](#development)
|
158
|
+
- [Development / Mitentwickeln](#development--mitentwickeln)
|
159
|
+
- [Localhost 3000! 🤫](#localhost-3000-)
|
138
160
|
- [Contributing](#contributing)
|
161
|
+
- [Releasing](#releasing)
|
139
162
|
- [License](#license)
|
140
163
|
|
141
164
|
## Installation
|
@@ -193,6 +216,8 @@ client = PapierkramApi::Client.new('subdomain', "SUPER-LONG-API-KEY")
|
|
193
216
|
|
194
217
|
Oder es werden die Umgebungsvariablen `PAPIERKRAM_API_SUBDOMAIN` und `PAPIERKRAM_API_KEY` gesetzt und der Client ohne Argumente initialisiert.
|
195
218
|
|
219
|
+
Ich kann dir wärmstes https://direnv.net/ empfehlen, um die Umgebungsvariablen zu setzen. 🤓
|
220
|
+
|
196
221
|
```ruby
|
197
222
|
# usage with environment variables
|
198
223
|
client = PapierkramApi::Client.new
|
@@ -340,7 +365,7 @@ Siehe [Companies#create_customer](lib/papierkram_api/v1/endpoints/contact/compan
|
|
340
365
|
|
341
366
|
```ruby
|
342
367
|
company = client.contact_companies.update_by(
|
343
|
-
id: 1,
|
368
|
+
id: 1,
|
344
369
|
name: 'Test GmbH'
|
345
370
|
)
|
346
371
|
puts company.headers
|
@@ -459,6 +484,142 @@ puts PapierkramApi::V1::Helpers::PdfFromResponse.new(voucher).to_pdf
|
|
459
484
|
# => {response: Faraday::Response, path_to_pdf_file: 'path/to/tempfile_pdf.pdf'}
|
460
485
|
```
|
461
486
|
|
487
|
+
#### einen Ausgabe Beleg erstellen
|
488
|
+
|
489
|
+
Siehe [Vouchers#create](lib/papierkram_api/v1/endpoints/expense/vouchers.rb) für mögliche Parameter.
|
490
|
+
|
491
|
+
```ruby
|
492
|
+
voucher = client.expense_vouchers.create(
|
493
|
+
name: "Restaurant visit",
|
494
|
+
due_date: "2020-06-30",
|
495
|
+
document_date: "2020-06-14",
|
496
|
+
description: "Took customer for dinner.",
|
497
|
+
entertainment_reason: "sales meeting",
|
498
|
+
flagged: true,
|
499
|
+
provenance: "domestic",
|
500
|
+
entertainment_persons: [
|
501
|
+
"Carl Customer"
|
502
|
+
],
|
503
|
+
creditor_id: 85,
|
504
|
+
line_items: [
|
505
|
+
{
|
506
|
+
amount: 150.8,
|
507
|
+
name: "restaurant bill",
|
508
|
+
vat_rate: 0.19,
|
509
|
+
category: "Bewirtungskosten"
|
510
|
+
},
|
511
|
+
{
|
512
|
+
amount: 15,
|
513
|
+
name: "tip",
|
514
|
+
vat_rate: 0.19,
|
515
|
+
category: "Bewirtungskosten"
|
516
|
+
}
|
517
|
+
]
|
518
|
+
)
|
519
|
+
```
|
520
|
+
|
521
|
+
#### einen Ausgabe Beleg aktualisieren
|
522
|
+
|
523
|
+
Siehe [Vouchers#update_by](lib/papierkram_api/v1/endpoints/expense/vouchers.rb) für mögliche Parameter.
|
524
|
+
|
525
|
+
```ruby
|
526
|
+
voucher = client.expense_vouchers.update_by(
|
527
|
+
id: 1,
|
528
|
+
document_date: "2020-06-13",
|
529
|
+
creditor_id: 102,
|
530
|
+
line_items: [
|
531
|
+
{
|
532
|
+
amount: 170.8,
|
533
|
+
name: "restaurant bill",
|
534
|
+
vat_rate: 0.19,
|
535
|
+
category: "Bewirtungskosten",
|
536
|
+
billing: null,
|
537
|
+
depreciation: null
|
538
|
+
},
|
539
|
+
{
|
540
|
+
amount: 15,
|
541
|
+
name: "tip",
|
542
|
+
vat_rate: 0.19,
|
543
|
+
category: "Bewirtungskosten"
|
544
|
+
}
|
545
|
+
]
|
546
|
+
)
|
547
|
+
```
|
548
|
+
|
549
|
+
#### einen Ausgabe Beleg löschen
|
550
|
+
|
551
|
+
```ruby
|
552
|
+
voucher = client.expense_vouchers.delete_by(id: 1)
|
553
|
+
```
|
554
|
+
|
555
|
+
#### einen Ausgabe Beleg archivieren
|
556
|
+
|
557
|
+
```ruby
|
558
|
+
voucher = client.expense_vouchers.archive_by(id: 1)
|
559
|
+
```
|
560
|
+
|
561
|
+
#### einen Ausgabe Beleg unarchivieren
|
562
|
+
|
563
|
+
```ruby
|
564
|
+
voucher = client.expense_vouchers.unarchive_by(id: 1)
|
565
|
+
```
|
566
|
+
|
567
|
+
#### einen Ausgabe Beleg stornieren
|
568
|
+
|
569
|
+
```ruby
|
570
|
+
voucher = client.expense_vouchers.cancel_by(id: 1)
|
571
|
+
```
|
572
|
+
|
573
|
+
#### einen Ausgabe Beleg rückwirkend stornieren
|
574
|
+
|
575
|
+
```ruby
|
576
|
+
voucher = client.expense_vouchers.cancel_with_reverse_entry_by(id: 1)
|
577
|
+
```
|
578
|
+
|
579
|
+
#### einen Ausgabe Beleg als bezahlt markieren
|
580
|
+
|
581
|
+
Siehe [Vouchers#mark_as_paid_by](lib/papierkram_api/v1/endpoints/expense/vouchers.rb) für mögliche Parameter.
|
582
|
+
|
583
|
+
```ruby
|
584
|
+
voucher = client.expense_vouchers.mark_as_paid_by(
|
585
|
+
id: 1,
|
586
|
+
value: 119.0
|
587
|
+
)
|
588
|
+
```
|
589
|
+
|
590
|
+
#### einem Ausgabe Beleg ein Dokument hinzufügen
|
591
|
+
|
592
|
+
Siehe [Vouchers#add_document_by](lib/papierkram_api/v1/endpoints/expense/vouchers.rb) für mögliche Parameter.
|
593
|
+
|
594
|
+
Um ein PDF hinzuzufügen:
|
595
|
+
|
596
|
+
```ruby
|
597
|
+
voucher = client.expense_vouchers.add_document_by(
|
598
|
+
id: 1,
|
599
|
+
path_to_file: 'path/to/file.pdf',
|
600
|
+
file_type: 'application/pdf'
|
601
|
+
)
|
602
|
+
```
|
603
|
+
|
604
|
+
oder mit einem Bild im jpeg Format
|
605
|
+
|
606
|
+
```ruby
|
607
|
+
voucher = client.expense_vouchers.add_document_by(
|
608
|
+
id: 1,
|
609
|
+
path_to_file: 'path/to/file.jpeg',
|
610
|
+
file_type: 'image/jpeg'
|
611
|
+
)
|
612
|
+
```
|
613
|
+
|
614
|
+
#### einem Ausgabe Beleg ein Dokument entfernen
|
615
|
+
|
616
|
+
```ruby
|
617
|
+
voucher = client.expense_vouchers.delete_document_by(
|
618
|
+
id: 1,
|
619
|
+
document_id: 1
|
620
|
+
)
|
621
|
+
```
|
622
|
+
|
462
623
|
### Income::Estimate (Angebot)
|
463
624
|
|
464
625
|
Der Endpunkt `/papierkram_api/v1/endpoints/income/estimates` liefert Informationen über die Angebote. Die Informationen werden als `Faraday::Response` zurückgegeben.
|
@@ -519,6 +680,141 @@ puts PapierkramApi::V1::Helpers::PdfFromResponse.new(invoice).to_pdf
|
|
519
680
|
# => {response: Faraday::Response, path_to_pdf_file: 'path/to/tempfile_pdf.pdf'}
|
520
681
|
```
|
521
682
|
|
683
|
+
#### eine Rechnung erstellen
|
684
|
+
|
685
|
+
Siehe [Invoices#create](lib/papierkram_api/v1/endpoints/income/invoices.rb) für mögliche Parameter.
|
686
|
+
|
687
|
+
```ruby
|
688
|
+
invoice = client.income_invoices.create(
|
689
|
+
name: 'Neuausstattung des Büros',
|
690
|
+
supply_date: '01.01.2024 - 14.01.2024',
|
691
|
+
document_date: '2024-01-15',
|
692
|
+
payment_term_id: 46,
|
693
|
+
customer_id: 3,
|
694
|
+
project_id: 15,
|
695
|
+
line_items: [
|
696
|
+
{
|
697
|
+
name: 'Anlieferung',
|
698
|
+
description: 'Anlieferung der neuen Möbel',
|
699
|
+
quantity: 1.25,
|
700
|
+
unit: 'Stunden',
|
701
|
+
vat_rate: 0.19,
|
702
|
+
price: 100
|
703
|
+
},
|
704
|
+
{
|
705
|
+
name: 'Bestuhlung',
|
706
|
+
description: 'Bestuhlung des Bürogebäudes',
|
707
|
+
quantity: 1.25,
|
708
|
+
unit: 'Arbeitstage',
|
709
|
+
vat_rate: 0.19,
|
710
|
+
price: 800
|
711
|
+
},
|
712
|
+
{
|
713
|
+
name: 'Büroartikel',
|
714
|
+
description: 'Neue Bürostühle',
|
715
|
+
quantity: 200,
|
716
|
+
unit: 'Stühle',
|
717
|
+
vat_rate: 0.19,
|
718
|
+
price: 125
|
719
|
+
}
|
720
|
+
]
|
721
|
+
)
|
722
|
+
```
|
723
|
+
|
724
|
+
#### eine Rechnung aktualisieren
|
725
|
+
|
726
|
+
Siehe [Invoices#update_by](lib/papierkram_api/v1/endpoints/income/invoices.rb) für mögliche Parameter.
|
727
|
+
|
728
|
+
```ruby
|
729
|
+
response = client.income_invoices.update_by(
|
730
|
+
id: 9,
|
731
|
+
name: 'Neuausstattung eines Büros',
|
732
|
+
line_items: [
|
733
|
+
{
|
734
|
+
name: 'Anlieferung',
|
735
|
+
description: 'Anlieferung der neuen Möbel',
|
736
|
+
quantity: 1.5,
|
737
|
+
unit: 'Stunden',
|
738
|
+
vat_rate: 0.19,
|
739
|
+
price: 100
|
740
|
+
},
|
741
|
+
{
|
742
|
+
name: 'Bestuhlung',
|
743
|
+
description: 'Bestuhlung des Bürogebäudes',
|
744
|
+
quantity: 1.5,
|
745
|
+
unit: 'Arbeitstage',
|
746
|
+
vat_rate: 0.19,
|
747
|
+
price: 800
|
748
|
+
},
|
749
|
+
{
|
750
|
+
name: 'Büroartikel',
|
751
|
+
description: 'Neue Bürostühle',
|
752
|
+
quantity: 200,
|
753
|
+
unit: 'Stühle',
|
754
|
+
vat_rate: 0.19,
|
755
|
+
price: 125
|
756
|
+
}
|
757
|
+
]
|
758
|
+
)
|
759
|
+
```
|
760
|
+
|
761
|
+
#### eine Rechnung löschen
|
762
|
+
|
763
|
+
Siehe [Invoices#delete_by](lib/papierkram_api/v1/endpoints/income/invoices.rb) für mögliche Parameter.
|
764
|
+
|
765
|
+
```ruby
|
766
|
+
invoice = client.income_invoices.delete_by(id: 1)
|
767
|
+
```
|
768
|
+
|
769
|
+
#### eine Rechnung archivieren
|
770
|
+
|
771
|
+
Siehe [Invoices#archive_by](lib/papierkram_api/v1/endpoints/income/invoices.rb) für mögliche Parameter.
|
772
|
+
|
773
|
+
```ruby
|
774
|
+
invoice = client.income_invoices.archive_by(id: 1)
|
775
|
+
```
|
776
|
+
|
777
|
+
#### eine Rechnung unarchivieren
|
778
|
+
|
779
|
+
Siehe [Invoices#unarchive_by](lib/papierkram_api/v1/endpoints/income/invoices.rb) für mögliche Parameter.
|
780
|
+
|
781
|
+
```ruby
|
782
|
+
invoice = client.income_invoices.unarchive_by(id: 1)
|
783
|
+
```
|
784
|
+
|
785
|
+
#### eine Rechnung stornieren
|
786
|
+
|
787
|
+
Siehe [Invoices#cancel_by](lib/papierkram_api/v1/endpoints/income/invoices.rb) für mögliche Parameter.
|
788
|
+
|
789
|
+
```ruby
|
790
|
+
invoice = client.income_invoices.cancel_by(id: 1)
|
791
|
+
```
|
792
|
+
|
793
|
+
#### eine Rechnung verschicken
|
794
|
+
|
795
|
+
Siehe [Invoices#send_by](lib/papierkram_api/v1/endpoints/income/invoices.rb) für mögliche Parameter.
|
796
|
+
|
797
|
+
Per E-Mail:
|
798
|
+
|
799
|
+
```ruby
|
800
|
+
invoice = client.income_invoices.deliver_by(
|
801
|
+
id: 1,
|
802
|
+
send_via: 'email',
|
803
|
+
email_recipient: "test@test.test",
|
804
|
+
email_subject: "Ich verkaufe was du brauchst",
|
805
|
+
email_body: "Sag einfach was du brauchst und ich verkaufe es dir.",
|
806
|
+
)
|
807
|
+
```
|
808
|
+
|
809
|
+
Per PDF:
|
810
|
+
|
811
|
+
```ruby
|
812
|
+
invoice = client.income_invoices.deliver_by(
|
813
|
+
id: 1,
|
814
|
+
send_via: 'pdf'
|
815
|
+
)
|
816
|
+
```
|
817
|
+
|
522
818
|
### Income::PaymentTerms (Zahlungsbedingungen)
|
523
819
|
|
524
820
|
Der Endpunkt `/papierkram_api/v1/endpoints/income/payment_terms` liefert Informationen über die Zahlungsbedingungen. Die Informationen werden als `Faraday::Response` zurückgegeben.
|
@@ -573,7 +869,7 @@ proposition = client.income_propositions.create(
|
|
573
869
|
time_unit: 'hour',
|
574
870
|
proposition_type: 'service',
|
575
871
|
price: '150.0',
|
576
|
-
vat_rate:
|
872
|
+
vat_rate: 0.19
|
577
873
|
)
|
578
874
|
puts proposition.headers
|
579
875
|
puts proposition.body
|
@@ -587,7 +883,7 @@ Siehe [Propositions#create](lib/papierkram_api/v1/endpoints/income/propositions.
|
|
587
883
|
client.income_propositions.update_by(
|
588
884
|
id: 1,
|
589
885
|
name: 'Software design',
|
590
|
-
vat_rate:
|
886
|
+
vat_rate: 0.19 # verpflichtend bei Änderung
|
591
887
|
)
|
592
888
|
```
|
593
889
|
|
@@ -716,7 +1012,7 @@ puts task.body
|
|
716
1012
|
|
717
1013
|
#### erstelle eine Aufgabe
|
718
1014
|
|
719
|
-
|
1015
|
+
Siehe [Tasks#create](lib/papierkram_api/v1/endpoints/tracker/tasks.rb) für mögliche Parameter.
|
720
1016
|
|
721
1017
|
```ruby
|
722
1018
|
task = client.tracker_tasks.create(name: 'Aufgabe 1')
|
@@ -726,7 +1022,7 @@ puts task.body
|
|
726
1022
|
|
727
1023
|
#### aktualisiere eine Aufgabe
|
728
1024
|
|
729
|
-
|
1025
|
+
Siehe [Tasks#update_by](lib/papierkram_api/v1/endpoints/tracker/tasks.rb) für mögliche Parameter.
|
730
1026
|
|
731
1027
|
```ruby
|
732
1028
|
task = client.tracker_tasks.update_by(id: 1, name: 'Aufgabe 2' )
|
@@ -766,7 +1062,7 @@ Der Endpunkt `/papierkram_api/v1/tracker/time_entries` liefert Informationen üb
|
|
766
1062
|
|
767
1063
|
#### alle Zeiteinträge
|
768
1064
|
|
769
|
-
|
1065
|
+
Siehe [TimeEntries](lib/papierkram_api/v1/endpoints/tracker/time_entries.rb) für mögliche Parameter.
|
770
1066
|
|
771
1067
|
```ruby
|
772
1068
|
time_entries = client.tracker_time_entries.all
|
@@ -784,7 +1080,7 @@ puts time_entry.body
|
|
784
1080
|
|
785
1081
|
#### erstelle einen Zeiteintrag
|
786
1082
|
|
787
|
-
|
1083
|
+
Siehe [TimeEntries](lib/papierkram_api/v1/endpoints/tracker/time_entries.rb) für mögliche Parameter.
|
788
1084
|
|
789
1085
|
```ruby
|
790
1086
|
time_entry = client.tracker_time_entries.create(
|
@@ -799,7 +1095,7 @@ puts time_entry.body
|
|
799
1095
|
|
800
1096
|
#### aktualisiere einen Zeiteintrag
|
801
1097
|
|
802
|
-
|
1098
|
+
Siehe [TimeEntries](lib/papierkram_api/v1/endpoints/tracker/time_entries.rb) für mögliche Parameter.
|
803
1099
|
|
804
1100
|
```ruby
|
805
1101
|
time_entry = client.tracker_time_entries.update_by(
|
@@ -852,6 +1148,8 @@ quota = client.info.remaining_quota(response)
|
|
852
1148
|
|
853
1149
|
## Business Intelligence
|
854
1150
|
|
1151
|
+
> **DEPRECATED** Bitte verwende dieses Modul nicht mehr, es wird in Zukunft entfernt werden.
|
1152
|
+
|
855
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.
|
856
1154
|
|
857
1155
|
TODO ergänzen wie man `SmartQueries` erstellt und verwendet.
|
@@ -860,6 +1158,8 @@ TODO ergänzen wie die Rückgabewerte von `SmartQueries` gestaltet werden sollte
|
|
860
1158
|
|
861
1159
|
### Business::Intelligence (BI) ExpenseByCategory (Ausgaben nach Kategorie)
|
862
1160
|
|
1161
|
+
> **DEPRECATED** Bitte verwende dieses Modul nicht mehr, es wird in Zukunft entfernt werden.
|
1162
|
+
|
863
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.
|
864
1164
|
|
865
1165
|
#### alle Ausgaben eines Monats nach Kategorie
|
@@ -957,12 +1257,43 @@ puts pdf
|
|
957
1257
|
}
|
958
1258
|
```
|
959
1259
|
|
960
|
-
## Development
|
1260
|
+
## Development / Mitentwickeln
|
1261
|
+
|
1262
|
+
🇬🇧/🇺🇸
|
961
1263
|
|
962
1264
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
963
1265
|
|
964
1266
|
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
965
1267
|
|
1268
|
+
You need to have at least the following environment variables set to run the tests:
|
1269
|
+
|
1270
|
+
- `MT_COMPAT=true` or `export MT_COMPAT=true` (when in .envrc)
|
1271
|
+
|
1272
|
+
Please, see the [`.envrc.sample`](.envrc.sample) file for more (https://direnv.net/).
|
1273
|
+
|
1274
|
+
🇩🇪
|
1275
|
+
|
1276
|
+
Nachdem du das Repository überprüft hast, führe `bin/setup` aus, um Abhängigkeiten zu installieren. Anschließend führe `rake test` aus, um die Tests durchzuführen. Du kannst auch `bin/console` ausführen, um eine interaktive Konsole zu starten und Experimente durchzuführen.
|
1277
|
+
|
1278
|
+
Um dieses Gem auf deinem lokalen Rechner zu installieren, führe `bundle exec rake install` aus. Um eine neue Version zu veröffentlichen, aktualisiere die Versionsnummer in `version.rb` und führe dann `bundle exec rake release` aus. Dadurch wird ein Git-Tag für die Version erstellt, Git-Commits und das erstellte Tag werden gepusht, und die `.gem`-Datei wird nach [rubygems.org](https://rubygems.org) gepusht.
|
1279
|
+
|
1280
|
+
Um die Tests auszuführen, muss die Umgebungsvariable `MT_COMPAT=true` gesetzt sein.
|
1281
|
+
|
1282
|
+
Bitte, schaue in die Datei [`.envrc.sample`](.envrc.sample) für mehr Details (https://direnv.net/).
|
1283
|
+
|
1284
|
+
### Localhost 3000! 🤫
|
1285
|
+
|
1286
|
+
Es gibt Menschen da draußen, die können gegen direkt gegen die Papierkram API entwickeln. 🤯
|
1287
|
+
Und wie das geht, verrate ich hier allen Lesern! 🤫
|
1288
|
+
|
1289
|
+
`DEBUG_LOCALHOST=true bin/console`
|
1290
|
+
|
1291
|
+
siehe: [test/test_api_v1_client.rb](test/test_api_v1_client.rb)
|
1292
|
+
|
1293
|
+
OR to make it stick:
|
1294
|
+
- Set `export DEBUG_LOCALHOST=true` in your `.env` or `.envrc` file.
|
1295
|
+
- Enjoy the magic: `bin/setup && bin/console` 🎉
|
1296
|
+
|
966
1297
|
## Contributing
|
967
1298
|
|
968
1299
|
Bug reports and pull requests are welcome on GitHub at https://github.com/simonneutert/papierkram_api_client.
|
@@ -975,6 +1306,23 @@ Bitte achte darauf, dass du die Tests ausführst und die Tests dann auch grün s
|
|
975
1306
|
|
976
1307
|
Wenn du unsicher bist, sprich mich an oder erstelle ein Issue. Ich helfe dir gerne weiter. 🤗
|
977
1308
|
|
1309
|
+
## Releasing
|
1310
|
+
|
1311
|
+
1. checkout `main`
|
1312
|
+
2. close the changelog
|
1313
|
+
3. Set the correct/desired version number in `version.rb` and run `bundle install` just for sure
|
1314
|
+
4. commit if needed
|
1315
|
+
5. `bundle exec rake release`
|
1316
|
+
|
1317
|
+
After a successful release, the gem is pushed to [rubygems.org](https://rubygems.org/gems/papierkram_api_client).
|
1318
|
+
|
1319
|
+
Here are the steps you need to take after a successful release:
|
1320
|
+
|
1321
|
+
1. edit `lib/papierkram_api_client/version.rb` and bump the version number to the next patch version
|
1322
|
+
2. run `bundle install`
|
1323
|
+
3. open the changelog again
|
1324
|
+
4. commit and push the changes
|
1325
|
+
|
978
1326
|
## License
|
979
1327
|
|
980
1328
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/UPGRADING.md
CHANGED
@@ -1,3 +1,48 @@
|
|
1
|
+
## From 0.4.2 onwards
|
2
|
+
|
3
|
+
`vat_rate` attribute of line_items, were Strings, like "19%", but the public API of Papierkram changed and expects Floats/Decimals like `0.19`. Please update your code accordingly.
|
4
|
+
|
5
|
+
**Create an invoice:**
|
6
|
+
|
7
|
+
see [Invoices#create](lib/papierkram_api/v1/endpoints/income/invoices.rb) for possible params.
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
invoice = client.income_invoices.create(
|
11
|
+
name: 'Neuausstattung des Büros',
|
12
|
+
supply_date: '01.01.2024 - 14.01.2024',
|
13
|
+
document_date: '2024-01-15',
|
14
|
+
payment_term_id: 46,
|
15
|
+
customer_id: 3,
|
16
|
+
project_id: 15,
|
17
|
+
line_items: [
|
18
|
+
{
|
19
|
+
name: 'Anlieferung',
|
20
|
+
description: 'Anlieferung der neuen Möbel',
|
21
|
+
quantity: 1.25,
|
22
|
+
unit: 'Stunden',
|
23
|
+
vat_rate: 0.19, # << here >>
|
24
|
+
price: 100
|
25
|
+
},
|
26
|
+
{
|
27
|
+
name: 'Bestuhlung',
|
28
|
+
description: 'Bestuhlung des Bürogebäudes',
|
29
|
+
quantity: 1.25,
|
30
|
+
unit: 'Arbeitstage',
|
31
|
+
vat_rate: 0.19, # << here >>
|
32
|
+
price: 800
|
33
|
+
},
|
34
|
+
{
|
35
|
+
name: 'Büroartikel',
|
36
|
+
description: 'Neue Bürostühle',
|
37
|
+
quantity: 200,
|
38
|
+
unit: 'Stühle',
|
39
|
+
vat_rate: 0.19, # << here >>
|
40
|
+
price: 125
|
41
|
+
}
|
42
|
+
]
|
43
|
+
)
|
44
|
+
```
|
45
|
+
|
1
46
|
## From 0.3 to 0.4
|
2
47
|
|
3
48
|
Some endpoints are calling `update` have changed. Instead of `update_by(id: 123, attributes: { ... })` you now use keywords e.g. `update_by(id: 123, name: 'New name')`.
|
@@ -23,8 +23,10 @@ module PapierkramApi
|
|
23
23
|
def build_client!
|
24
24
|
@client = Faraday.new(url: @base_url) do |config|
|
25
25
|
config.request :authorization, 'Bearer', @api_key
|
26
|
+
config.request :multipart
|
26
27
|
config.request :json
|
27
28
|
config.response :json
|
29
|
+
|
28
30
|
config.adapter :httpx
|
29
31
|
yield(config) if block_given?
|
30
32
|
end
|
@@ -103,6 +105,8 @@ module PapierkramApi
|
|
103
105
|
private
|
104
106
|
|
105
107
|
def base_url_env
|
108
|
+
return 'http://localhost:3000' if ENV.fetch('DEBUG_LOCALHOST', false).to_s == 'true'
|
109
|
+
|
106
110
|
"https://#{@subdomain}.papierkram.de"
|
107
111
|
end
|
108
112
|
end
|
@@ -15,6 +15,15 @@ module PapierkramApi
|
|
15
15
|
#
|
16
16
|
class Base
|
17
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
|
+
|
18
27
|
@expenses_by_category ||= PapierkramApi::V1::BusinessIntelligence::ExpensesByCategory.new
|
19
28
|
end
|
20
29
|
end
|
@@ -6,6 +6,8 @@ module PapierkramApi
|
|
6
6
|
module Expense
|
7
7
|
# This class is responsible for all the API calls related to expense vouchers.
|
8
8
|
class Vouchers < PapierkramApi::V1::Endpoints::Base
|
9
|
+
ALLOWED_DIFFERENCE_REASONS = %w[sonstige mahnung teilzahlung skonto sonstige schmaelerung].freeze
|
10
|
+
|
9
11
|
def find_by(id:, pdf: false)
|
10
12
|
if pdf == true
|
11
13
|
return get("#{@url_api_path}/expense/vouchers/#{id}/pdf", nil,
|
@@ -38,6 +40,154 @@ module PapierkramApi
|
|
38
40
|
|
39
41
|
http_get("#{@url_api_path}/expense/vouchers", query)
|
40
42
|
end
|
43
|
+
|
44
|
+
def create( # rubocop:disable Metrics/ParameterLists,Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity,Metrics/MethodLength
|
45
|
+
name:,
|
46
|
+
provenance:,
|
47
|
+
line_items:,
|
48
|
+
due_date: nil,
|
49
|
+
document_date: nil,
|
50
|
+
description: nil,
|
51
|
+
entertainment_reason: nil,
|
52
|
+
entertainment_persons: nil,
|
53
|
+
flagged: nil,
|
54
|
+
creditor_id: nil
|
55
|
+
)
|
56
|
+
body = {}
|
57
|
+
body[:name] = name
|
58
|
+
body[:line_items] = line_items
|
59
|
+
body[:provenance] = provenance
|
60
|
+
|
61
|
+
body[:due_date] = due_date if due_date
|
62
|
+
body[:document_date] = document_date if document_date
|
63
|
+
body[:description] = description if description
|
64
|
+
body[:entertainment_reason] = entertainment_reason if entertainment_reason
|
65
|
+
body[:entertainment_persons] = entertainment_persons if entertainment_persons
|
66
|
+
body[:flagged] = flagged if flagged
|
67
|
+
body[:creditor] = { id: creditor_id } if creditor_id
|
68
|
+
|
69
|
+
if entertainment_persons
|
70
|
+
raise ArgumentError, 'entertainment_persons must be an array' unless entertainment_persons.is_a?(Array)
|
71
|
+
|
72
|
+
unless entertainment_persons.all?(String)
|
73
|
+
raise ArgumentError,
|
74
|
+
'entertainment_persons must be an array of strings'
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
if line_items
|
79
|
+
raise ArgumentError, 'line_items must be an array' unless line_items.is_a?(Array)
|
80
|
+
raise ArgumentError, 'line_items must be an array of hashes' unless line_items.all?(Hash)
|
81
|
+
end
|
82
|
+
|
83
|
+
http_post("#{@url_api_path}/expense/vouchers", body)
|
84
|
+
end
|
85
|
+
|
86
|
+
def update_by( # rubocop:disable Metrics/ParameterLists,Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
|
87
|
+
id:,
|
88
|
+
name: nil,
|
89
|
+
due_date: nil,
|
90
|
+
document_date: nil,
|
91
|
+
description: nil,
|
92
|
+
entertainment_reason: nil,
|
93
|
+
entertainment_persons: nil,
|
94
|
+
flagged: nil,
|
95
|
+
provenance: nil,
|
96
|
+
creditor_id: nil,
|
97
|
+
line_items: nil
|
98
|
+
)
|
99
|
+
body = {}
|
100
|
+
body[:name] = name if name
|
101
|
+
body[:due_date] = due_date if due_date
|
102
|
+
body[:document_date] = document_date if document_date
|
103
|
+
body[:description] = description if description
|
104
|
+
body[:entertainment_reason] = entertainment_reason if entertainment_reason
|
105
|
+
body[:entertainment_persons] = entertainment_persons if entertainment_persons
|
106
|
+
body[:flagged] = flagged if flagged
|
107
|
+
body[:provenance] = provenance if provenance
|
108
|
+
body[:creditor] = { id: creditor_id } if creditor_id
|
109
|
+
body[:line_items] = line_items if line_items
|
110
|
+
|
111
|
+
if line_items
|
112
|
+
raise ArgumentError, 'line_items must be an array' unless line_items.is_a?(Array)
|
113
|
+
raise ArgumentError, 'line_items must be an array of hashes' unless line_items.all?(Hash)
|
114
|
+
end
|
115
|
+
|
116
|
+
http_put("#{@url_api_path}/expense/vouchers/#{id}", body)
|
117
|
+
end
|
118
|
+
|
119
|
+
def add_document_by(id:, path_to_file:, file_type:)
|
120
|
+
doc = Faraday::Multipart::FilePart.new(path_to_file, file_type)
|
121
|
+
|
122
|
+
http_post("#{@url_api_path}/expense/vouchers/#{id}/documents", { file: doc })
|
123
|
+
end
|
124
|
+
|
125
|
+
def delete_document_by(id:, document_id:)
|
126
|
+
http_delete("#{@url_api_path}/expense/vouchers/#{id}/documents/#{document_id}")
|
127
|
+
end
|
128
|
+
|
129
|
+
def delete_by(id:)
|
130
|
+
http_delete("#{@url_api_path}/expense/vouchers/#{id}")
|
131
|
+
end
|
132
|
+
|
133
|
+
def archive_by(id:)
|
134
|
+
http_post("#{@url_api_path}/expense/vouchers/#{id}/archive")
|
135
|
+
end
|
136
|
+
|
137
|
+
def unarchive_by(id:)
|
138
|
+
http_post("#{@url_api_path}/expense/vouchers/#{id}/unarchive")
|
139
|
+
end
|
140
|
+
|
141
|
+
def cancel_by(id:)
|
142
|
+
http_post("#{@url_api_path}/expense/vouchers/#{id}/cancel")
|
143
|
+
end
|
144
|
+
|
145
|
+
def cancel_with_reverse_entry_by(id:)
|
146
|
+
http_post("#{@url_api_path}/expense/vouchers/#{id}/cancel_with_reverse_entry")
|
147
|
+
end
|
148
|
+
|
149
|
+
def mark_as_paid_by(
|
150
|
+
id:,
|
151
|
+
value: nil,
|
152
|
+
payment_date: nil,
|
153
|
+
banking_transaction_id: nil,
|
154
|
+
difference_reason: nil
|
155
|
+
)
|
156
|
+
unless value || banking_transaction_id
|
157
|
+
raise ArgumentError, 'either value or banking_transaction_id must be given'
|
158
|
+
end
|
159
|
+
|
160
|
+
body = {}
|
161
|
+
|
162
|
+
if value
|
163
|
+
validate_value!(value)
|
164
|
+
body[:value] = value
|
165
|
+
end
|
166
|
+
|
167
|
+
if difference_reason
|
168
|
+
validate_difference_reason!(difference_reason)
|
169
|
+
body[:difference_reason] = difference_reason
|
170
|
+
end
|
171
|
+
|
172
|
+
body[:payment_date] = payment_date if payment_date
|
173
|
+
body[:banking_transaction] = { id: banking_transaction_id } if banking_transaction_id
|
174
|
+
|
175
|
+
http_post("#{@url_api_path}/expense/vouchers/#{id}/pay", body)
|
176
|
+
end
|
177
|
+
|
178
|
+
private
|
179
|
+
|
180
|
+
def validate_value!(value)
|
181
|
+
raise ArgumentError, 'value must be a float' unless value.is_a?(Numeric)
|
182
|
+
end
|
183
|
+
|
184
|
+
def validate_difference_reason!(difference_reason)
|
185
|
+
raise ArgumentError, 'difference_reason must be a string' unless difference_reason.is_a?(String)
|
186
|
+
|
187
|
+
return if ALLOWED_DIFFERENCE_REASONS.include?(difference_reason)
|
188
|
+
|
189
|
+
raise ArgumentError, "difference_reason must be one of: #{ALLOWED_DIFFERENCE_REASONS.join(', ')}"
|
190
|
+
end
|
41
191
|
end
|
42
192
|
end
|
43
193
|
end
|
@@ -6,6 +6,8 @@ module PapierkramApi
|
|
6
6
|
module Income
|
7
7
|
# This class is responsible for all the API calls related to income invoices.
|
8
8
|
class Invoices < PapierkramApi::V1::Endpoints::Base
|
9
|
+
ALLOWED_SEND_VIA = %i[email pdf].freeze
|
10
|
+
|
9
11
|
def find_by(id:, pdf: false)
|
10
12
|
if pdf == true
|
11
13
|
return http_get(
|
@@ -18,14 +20,16 @@ module PapierkramApi
|
|
18
20
|
http_get("#{@url_api_path}/income/invoices/#{id}")
|
19
21
|
end
|
20
22
|
|
21
|
-
def all(
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
23
|
+
def all( # rubocop:disable Metrics/CyclomaticComplexity
|
24
|
+
page: 1,
|
25
|
+
page_size: 100,
|
26
|
+
order_by: nil,
|
27
|
+
order_direction: nil,
|
28
|
+
creditor_id: nil,
|
29
|
+
project_id: nil,
|
30
|
+
document_date_range_start: nil,
|
31
|
+
document_date_range_end: nil
|
32
|
+
)
|
29
33
|
query = {
|
30
34
|
page: page,
|
31
35
|
page_size: page_size
|
@@ -42,6 +46,148 @@ module PapierkramApi
|
|
42
46
|
|
43
47
|
http_get("#{@url_api_path}/income/invoices", query)
|
44
48
|
end
|
49
|
+
|
50
|
+
def create( # rubocop:disable Metrics/ParameterLists,Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity
|
51
|
+
name:,
|
52
|
+
line_items:,
|
53
|
+
payment_term_id:,
|
54
|
+
description: nil,
|
55
|
+
flagged: nil,
|
56
|
+
document_date: nil,
|
57
|
+
supply_date: nil,
|
58
|
+
customer_id: nil,
|
59
|
+
contact_person_id: nil,
|
60
|
+
project_id: nil,
|
61
|
+
custom_template_id: nil,
|
62
|
+
billing_company: nil,
|
63
|
+
billing_department: nil,
|
64
|
+
billing_contact_person: nil,
|
65
|
+
billing_street: nil,
|
66
|
+
billing_zip: nil,
|
67
|
+
billing_city: nil,
|
68
|
+
billing_country: nil,
|
69
|
+
billing_ust_idnr: nil,
|
70
|
+
billing_email: nil
|
71
|
+
)
|
72
|
+
body = {}
|
73
|
+
body[:name] = name
|
74
|
+
body[:line_items] = line_items
|
75
|
+
body[:payment_term] = { id: payment_term_id }
|
76
|
+
body[:description] = description if description
|
77
|
+
body[:flagged] = flagged if flagged
|
78
|
+
body[:document_date] = document_date if document_date
|
79
|
+
body[:supply_date] = supply_date if supply_date
|
80
|
+
body[:customer] = { id: customer_id } if customer_id
|
81
|
+
body[:customer][:contact_person] = { id: contact_person_id } if contact_person_id
|
82
|
+
body[:customer][:project] = { id: project_id } if project_id
|
83
|
+
body[:custom_template] = { id: custom_template_id } if custom_template_id
|
84
|
+
|
85
|
+
body[:billing] = {}
|
86
|
+
body[:billing][:company] = billing_company if billing_company
|
87
|
+
body[:billing][:department] = billing_department if billing_department
|
88
|
+
body[:billing][:contact_person] = billing_contact_person if billing_contact_person
|
89
|
+
body[:billing][:street] = billing_street if billing_street
|
90
|
+
body[:billing][:zip] = billing_zip if billing_zip
|
91
|
+
body[:billing][:city] = billing_city if billing_city
|
92
|
+
body[:billing][:country] = billing_country if billing_country
|
93
|
+
body[:billing][:ust_idnr] = billing_ust_idnr if billing_ust_idnr
|
94
|
+
body[:billing][:email] = billing_email if billing_email
|
95
|
+
|
96
|
+
http_post("#{@url_api_path}/income/invoices", body)
|
97
|
+
end
|
98
|
+
|
99
|
+
def update_by( # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity,Metrics/ParameterLists
|
100
|
+
id:,
|
101
|
+
name: nil,
|
102
|
+
line_items: nil,
|
103
|
+
payment_term_id: nil,
|
104
|
+
description: nil,
|
105
|
+
flagged: nil,
|
106
|
+
document_date: nil,
|
107
|
+
supply_date: nil,
|
108
|
+
customer_id: nil,
|
109
|
+
contact_person_id: nil,
|
110
|
+
project_id: nil,
|
111
|
+
custom_template_id: nil,
|
112
|
+
billing_company: nil,
|
113
|
+
billing_department: nil,
|
114
|
+
billing_contact_person: nil,
|
115
|
+
billing_street: nil,
|
116
|
+
billing_zip: nil,
|
117
|
+
billing_city: nil,
|
118
|
+
billing_country: nil,
|
119
|
+
billing_ust_idnr: nil,
|
120
|
+
billing_email: nil
|
121
|
+
)
|
122
|
+
body = {}
|
123
|
+
body[:name] = name if name
|
124
|
+
body[:line_items] = line_items if line_items
|
125
|
+
body[:payment_term] = { id: payment_term_id } if payment_term_id
|
126
|
+
body[:description] = description if description
|
127
|
+
body[:flagged] = flagged if flagged
|
128
|
+
body[:document_date] = document_date if document_date
|
129
|
+
body[:supply_date] = supply_date if supply_date
|
130
|
+
body[:customer] = { id: customer_id } if customer_id
|
131
|
+
body[:customer][:contact_person] = { id: contact_person_id } if contact_person_id
|
132
|
+
body[:customer][:project] = { id: project_id } if project_id
|
133
|
+
body[:custom_template] = { id: custom_template_id } if custom_template_id
|
134
|
+
|
135
|
+
body[:billing] = {}
|
136
|
+
body[:billing][:company] = billing_company if billing_company
|
137
|
+
body[:billing][:department] = billing_department if billing_department
|
138
|
+
body[:billing][:contact_person] = billing_contact_person if billing_contact_person
|
139
|
+
body[:billing][:street] = billing_street if billing_street
|
140
|
+
body[:billing][:zip] = billing_zip if billing_zip
|
141
|
+
body[:billing][:city] = billing_city if billing_city
|
142
|
+
body[:billing][:country] = billing_country if billing_country
|
143
|
+
body[:billing][:ust_idnr] = billing_ust_idnr if billing_ust_idnr
|
144
|
+
body[:billing][:email] = billing_email if billing_email
|
145
|
+
|
146
|
+
http_put("#{@url_api_path}/income/invoices/#{id}", body)
|
147
|
+
end
|
148
|
+
|
149
|
+
def deliver_by( # rubocop:disable Metrics/AbcSize
|
150
|
+
id:,
|
151
|
+
email_recipient: nil,
|
152
|
+
email_subject: nil,
|
153
|
+
email_body: nil,
|
154
|
+
send_via: :pdf
|
155
|
+
)
|
156
|
+
|
157
|
+
raise ArgumentError, 'send_via must be :email or :pdf' unless ALLOWED_SEND_VIA.include?(send_via)
|
158
|
+
|
159
|
+
body = {}
|
160
|
+
body[:send_via] = send_via
|
161
|
+
|
162
|
+
if send_via == :email
|
163
|
+
if email_recipient.nil? || email_subject.nil? || email_body.nil?
|
164
|
+
raise ArgumentError, 'email_recipient, email_subject and email_body must be set'
|
165
|
+
end
|
166
|
+
|
167
|
+
body[:email] = {}
|
168
|
+
body[:email][:recipient] = email_recipient
|
169
|
+
body[:email][:subject] = email_subject
|
170
|
+
body[:email][:body] = email_body
|
171
|
+
end
|
172
|
+
|
173
|
+
http_post("#{@url_api_path}/income/invoices/#{id}/deliver", body)
|
174
|
+
end
|
175
|
+
|
176
|
+
def delete_by(id:)
|
177
|
+
http_delete("#{@url_api_path}/income/invoices/#{id}")
|
178
|
+
end
|
179
|
+
|
180
|
+
def archive_by(id:)
|
181
|
+
http_post("#{@url_api_path}/income/invoices/#{id}/archive")
|
182
|
+
end
|
183
|
+
|
184
|
+
def unarchive_by(id:)
|
185
|
+
http_post("#{@url_api_path}/income/invoices/#{id}/unarchive")
|
186
|
+
end
|
187
|
+
|
188
|
+
def cancel_by(id:)
|
189
|
+
http_post("#{@url_api_path}/income/invoices/#{id}/cancel")
|
190
|
+
end
|
45
191
|
end
|
46
192
|
end
|
47
193
|
end
|
@@ -27,11 +27,12 @@ module PapierkramApi
|
|
27
27
|
body = {}
|
28
28
|
body[:name] = name
|
29
29
|
body[:article_no] = article_no
|
30
|
+
|
31
|
+
body[:proposition_type] = proposition_type if proposition_type
|
30
32
|
body[:description] = description if description
|
31
33
|
body[:time_unit] = time_unit if time_unit
|
32
|
-
body[:proposition_type] = proposition_type if proposition_type
|
33
|
-
body[:price] = price if price
|
34
34
|
body[:vat_rate] = vat_rate if vat_rate
|
35
|
+
body[:price] = price if price
|
35
36
|
|
36
37
|
http_post("#{@url_api_path}/income/propositions", body)
|
37
38
|
end
|
@@ -68,7 +68,7 @@ module PapierkramApi
|
|
68
68
|
name: 'restaurant bill',
|
69
69
|
amount: 150.8,
|
70
70
|
category: 'Bewirtungskosten',
|
71
|
-
vat_rate:
|
71
|
+
vat_rate: 0.19,
|
72
72
|
billing: nil,
|
73
73
|
depreciation: nil
|
74
74
|
},
|
@@ -76,7 +76,7 @@ module PapierkramApi
|
|
76
76
|
name: 'tip',
|
77
77
|
amount: 15,
|
78
78
|
category: 'Bewirtungskosten',
|
79
|
-
vat_rate:
|
79
|
+
vat_rate: 0.19,
|
80
80
|
billing: nil,
|
81
81
|
depreciation: nil
|
82
82
|
}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: papierkram_api_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Simon Neutert
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-02-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '2.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: faraday-multipart
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.0.4
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.0.4
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: httpx
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -33,7 +47,7 @@ dependencies:
|
|
33
47
|
version: 0.22.5
|
34
48
|
- - "<"
|
35
49
|
- !ruby/object:Gem::Version
|
36
|
-
version: 1.
|
50
|
+
version: 1.3.0
|
37
51
|
type: :runtime
|
38
52
|
prerelease: false
|
39
53
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -43,7 +57,7 @@ dependencies:
|
|
43
57
|
version: 0.22.5
|
44
58
|
- - "<"
|
45
59
|
- !ruby/object:Gem::Version
|
46
|
-
version: 1.
|
60
|
+
version: 1.3.0
|
47
61
|
description: Papierkram API Client, um deine Buchhaltung auf das nächste Level zu
|
48
62
|
bringen.
|
49
63
|
email:
|