lohnausweis 0.1.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 +7 -0
- data/Gemfile +7 -0
- data/Gemfile.lock +47 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +1 -0
- data/lib/lohnausweis/daten.rb +142 -0
- data/lib/lohnausweis/daten_eintrag.rb +136 -0
- data/lib/lohnausweis/pdf_generator.rb +129 -0
- data/lib/lohnausweis/rohdaten.rb +92 -0
- data/lib/lohnausweis/version.rb +5 -0
- data/lib/lohnausweis.rb +25 -0
- data/locale/de.yml +133 -0
- data/lohnausweis.gemspec +26 -0
- data/mit_korrektur_januar.pdf +1089 -0
- data/sandbox/mit_korrektur_januar.pdf +168 -0
- data/sandbox/test_bounding_box.rb +69 -0
- data/spec/lohnausweis/daten_eintrag_spec.rb +74 -0
- data/spec/lohnausweis/daten_spec.rb +11 -0
- data/spec/lohnausweis/pdf_generator_spec.rb +35 -0
- data/spec/spec_helper.rb +8 -0
- metadata +111 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 2e972c3cb76bffb2728116a69cdf8b99d2cf2aee
|
4
|
+
data.tar.gz: f36f640f550c262ac2526cdd2d971e84e70ebdf8
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c401421476a17a8ec854e8748ba8be94b8cd225be83dfd744c1e36b3349f3883ba1a59154d6bc760999ebe9b3c99fdc431011cc936b6142a4c5fbe898dc41e96
|
7
|
+
data.tar.gz: afede2c96a459e6c148bd727a6a8dc645916e2ec7a3998ae39c4fbb03ffd7fe91bceb0ce1232ab3c212a3f322adc3b4fb45b735728616f0346535c23a880bdb8
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
lohnausweis (0.0.1)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
activesupport (4.0.4)
|
10
|
+
i18n (~> 0.6, >= 0.6.9)
|
11
|
+
minitest (~> 4.2)
|
12
|
+
multi_json (~> 1.3)
|
13
|
+
thread_safe (~> 0.1)
|
14
|
+
tzinfo (~> 0.3.37)
|
15
|
+
atomic (1.1.16)
|
16
|
+
diff-lcs (1.2.5)
|
17
|
+
i18n (0.6.9)
|
18
|
+
minitest (4.7.5)
|
19
|
+
multi_json (1.9.2)
|
20
|
+
pdf-core (0.2.5)
|
21
|
+
prawn (1.0.0)
|
22
|
+
pdf-core (~> 0.2.2)
|
23
|
+
ttfunk (~> 1.1.1)
|
24
|
+
rake (10.1.1)
|
25
|
+
rspec (2.14.1)
|
26
|
+
rspec-core (~> 2.14.0)
|
27
|
+
rspec-expectations (~> 2.14.0)
|
28
|
+
rspec-mocks (~> 2.14.0)
|
29
|
+
rspec-core (2.14.8)
|
30
|
+
rspec-expectations (2.14.5)
|
31
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
32
|
+
rspec-mocks (2.14.6)
|
33
|
+
thread_safe (0.3.1)
|
34
|
+
atomic (>= 1.1.7, < 2)
|
35
|
+
ttfunk (1.1.1)
|
36
|
+
tzinfo (0.3.39)
|
37
|
+
|
38
|
+
PLATFORMS
|
39
|
+
ruby
|
40
|
+
|
41
|
+
DEPENDENCIES
|
42
|
+
activesupport
|
43
|
+
bundler (~> 1.5)
|
44
|
+
lohnausweis!
|
45
|
+
prawn (~> 1.0)
|
46
|
+
rake
|
47
|
+
rspec
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 hrigu
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Lohnausweis
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'lohnausweis'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install lohnausweis
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it ( http://github.com/<my-github-username>/lohnausweis/fork )
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,142 @@
|
|
1
|
+
module Planik
|
2
|
+
module Lohnausweis
|
3
|
+
|
4
|
+
class Daten
|
5
|
+
|
6
|
+
class Block
|
7
|
+
attr_reader :titel_leiste
|
8
|
+
attr_reader :eintraege
|
9
|
+
|
10
|
+
def initialize eintraege, titel_leiste = nil
|
11
|
+
@eintraege, @titel_leiste = eintraege, titel_leiste
|
12
|
+
end
|
13
|
+
|
14
|
+
def daten
|
15
|
+
d = []
|
16
|
+
d << titel_leiste unless titel_leiste.nil?
|
17
|
+
|
18
|
+
eintraege.each do |e|
|
19
|
+
x = []
|
20
|
+
x << e.name
|
21
|
+
x << e.menge_to_s
|
22
|
+
x << e.ansatz_to_s
|
23
|
+
x << e.betrag_gerundet_to_s
|
24
|
+
d << x
|
25
|
+
end
|
26
|
+
d
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
|
32
|
+
def initialize(rohdaten)
|
33
|
+
@rohdaten = rohdaten
|
34
|
+
bruttolohn_eintrag = create_lohn_block
|
35
|
+
create_abzuege_block(bruttolohn_eintrag)
|
36
|
+
create_ferien_block
|
37
|
+
create_arbeitszeit_block
|
38
|
+
end
|
39
|
+
|
40
|
+
def create_lohn_block
|
41
|
+
lohn_positiv = []
|
42
|
+
lohn_positiv << Fakt.new("Monatslohn", nil, nil, @rohdaten.monatslohn)
|
43
|
+
lohn_positiv << Zulage.new("Zulage Nacht", @rohdaten.zulage_nacht.menge, @rohdaten.zulage_nacht.ansatz)
|
44
|
+
lohn_positiv << Zulage.new("Zulage Wochenende", @rohdaten.zulage_wochenende.menge, @rohdaten.zulage_wochenende.ansatz)
|
45
|
+
lohn_positiv << Zulage.new("Kinderzulagen bis 12 Jahre", @rohdaten.kinderzulage.menge, @rohdaten.kinderzulage.ansatz) unless @rohdaten.kinderzulage.nil?
|
46
|
+
lohn_positiv << Fakt.new("Funktionszulage", nil, nil, @rohdaten.funktionszulage) unless @rohdaten.funktionszulage.nil?
|
47
|
+
|
48
|
+
@rohdaten.lohn_freifelder.each do |ff|
|
49
|
+
lohn_positiv << Fakt.new(ff.name, ff.menge, ff.ansatz, ff.betrag)
|
50
|
+
end
|
51
|
+
|
52
|
+
bruttolohn_eintrag = Rechnung.new("Bruttolohn", lohn_positiv, [])
|
53
|
+
|
54
|
+
lohnblock_eintraege = lohn_positiv + [bruttolohn_eintrag]
|
55
|
+
|
56
|
+
@lohnblock = Block.new(lohnblock_eintraege, ["Monatslohn", "Menge", "Ansatz / %", "Betrag"])
|
57
|
+
bruttolohn_eintrag
|
58
|
+
end
|
59
|
+
|
60
|
+
def create_abzuege_block(bruttolohn_eintrag)
|
61
|
+
lohn_abzuege = []
|
62
|
+
lohn_abzuege << Abzug.new("AHV, IV, EO", @rohdaten.monatslohn, @rohdaten.ahv)
|
63
|
+
lohn_abzuege << Abzug.new("ALV", @rohdaten.monatslohn, @rohdaten.alv)
|
64
|
+
lohn_abzuege << Abzug.new("NBU", @rohdaten.monatslohn, @rohdaten.nbu)
|
65
|
+
lohn_abzuege << Abzug.new("Krankentaggeld", @rohdaten.monatslohn, @rohdaten.krankentaggeld)
|
66
|
+
# lohn_abzuege << Fakt.new("Pensionskasse BVG", nil, nil, @rohdaten.pensionskasse)
|
67
|
+
@rohdaten.abzug_freifelder.each do |ff|
|
68
|
+
lohn_abzuege << Fakt.new(ff.name, ff.menge, ff.ansatz, ff.betrag)
|
69
|
+
end
|
70
|
+
|
71
|
+
nettolohn_eintrag = Rechnung.new("Nettolohn", [bruttolohn_eintrag], lohn_abzuege)
|
72
|
+
abzuege_eingtraege = lohn_abzuege + [nettolohn_eintrag]
|
73
|
+
|
74
|
+
@abzuege_block = Block.new(abzuege_eingtraege)
|
75
|
+
end
|
76
|
+
|
77
|
+
|
78
|
+
def create_ferien_block
|
79
|
+
eintraege = []
|
80
|
+
titel = ["Ferien", nil, nil, "Tage"]
|
81
|
+
|
82
|
+
eintraege << Fakt.new("Ferienguthaben #{jahr}", nil, nil, @rohdaten.ferien.guthaben, nil)
|
83
|
+
eintraege << Fakt.new("Bezogene Ferien bis #{end_datum}", nil, nil, @rohdaten.ferien.bezogen, nil)
|
84
|
+
eintraege << Rechnung.new("Ferienguthaben per #{end_datum}", [eintraege[0]], [eintraege[1]], nil)
|
85
|
+
|
86
|
+
@ferien_block = Block.new(eintraege, titel)
|
87
|
+
end
|
88
|
+
|
89
|
+
def create_arbeitszeit_block
|
90
|
+
eintraege = []
|
91
|
+
titel = ["Arbeitszeit", nil, nil, "Stunden"]
|
92
|
+
|
93
|
+
eintraege << Fakt.new("Stundensaldo Vormonat", nil, nil, @rohdaten.arbeitszeit.gleitzeit_vor, nil)
|
94
|
+
eintraege << Fakt.new("Sollstunden von #{start_datum} bis #{end_datum}", nil, nil, @rohdaten.arbeitszeit.soll_stunden, nil)
|
95
|
+
eintraege << Fakt.new("Geleistete Stunden von #{start_datum} bis #{end_datum}", nil, nil, @rohdaten.arbeitszeit.ist_stunden, nil)
|
96
|
+
eintraege << Rechnung.new("Saldo per #{end_datum}", [eintraege[0], eintraege[2]], [eintraege[1]], nil)
|
97
|
+
|
98
|
+
@arbeitszeit_block = Block.new(eintraege, titel)
|
99
|
+
end
|
100
|
+
|
101
|
+
def adresse
|
102
|
+
@rohdaten.adresse
|
103
|
+
end
|
104
|
+
|
105
|
+
def lohn_daten
|
106
|
+
@lohnblock.daten
|
107
|
+
end
|
108
|
+
|
109
|
+
def abzug_daten
|
110
|
+
@abzuege_block.daten
|
111
|
+
|
112
|
+
end
|
113
|
+
|
114
|
+
def ferien_daten
|
115
|
+
@ferien_block.daten
|
116
|
+
end
|
117
|
+
|
118
|
+
def arbeitszeit_daten
|
119
|
+
@arbeitszeit_block.daten
|
120
|
+
end
|
121
|
+
|
122
|
+
def start_datum
|
123
|
+
@rohdaten.start_datum.strftime("%d.%m.%Y")
|
124
|
+
end
|
125
|
+
|
126
|
+
def end_datum
|
127
|
+
@rohdaten.end_datum.strftime("%d.%m.%Y")
|
128
|
+
end
|
129
|
+
|
130
|
+
def jahr
|
131
|
+
@rohdaten.start_datum.strftime("%Y")
|
132
|
+
end
|
133
|
+
|
134
|
+
def monat
|
135
|
+
puts I18n.load_path
|
136
|
+
I18n.localize @rohdaten.start_datum, :format => "%B", :locale => :de
|
137
|
+
end
|
138
|
+
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
@@ -0,0 +1,136 @@
|
|
1
|
+
require 'mathn'
|
2
|
+
require 'active_support/number_helper'
|
3
|
+
|
4
|
+
module Planik
|
5
|
+
module Lohnausweis
|
6
|
+
|
7
|
+
# Abstrakte Klasse für alle Einträge in den Tabellen des Lohnausweises
|
8
|
+
# Ein Eintrag hat vier mögliche Spalten: Name, Menge, Ansatz und Betrag, von denen aber der einte oder andere nil sein kann.
|
9
|
+
class Eintrag
|
10
|
+
attr_reader :name, :menge, :ansatz, :einheit
|
11
|
+
|
12
|
+
def initialize(name, menge, ansatz, einheit = "Fr")
|
13
|
+
@name, @menge, @ansatz, @einheit= name, menge, ansatz, einheit
|
14
|
+
end
|
15
|
+
|
16
|
+
def betrag
|
17
|
+
raise "implement in subclass"
|
18
|
+
end
|
19
|
+
|
20
|
+
# Die Menge, gerundet auf zwei Kommastellen genau
|
21
|
+
def menge_to_s
|
22
|
+
menge.nil? ? nil : ActiveSupport::NumberHelper.number_to_rounded(menge, precision: 2)
|
23
|
+
end
|
24
|
+
|
25
|
+
# Default Wert ist nil
|
26
|
+
def ansatz_to_s
|
27
|
+
nil
|
28
|
+
end
|
29
|
+
|
30
|
+
def betrag_gerundet_to_s
|
31
|
+
value_gerundet_to_s betrag
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
def value_gerundet_to_s value
|
37
|
+
value = betrag_gerundet(value) if einheit == "Fr"
|
38
|
+
x = ActiveSupport::NumberHelper.number_to_rounded(value, precision: 2)
|
39
|
+
x = ActiveSupport::NumberHelper.number_to_delimited(x, delimiter: "'")
|
40
|
+
x = "#{einheit} #{x}" if einheit
|
41
|
+
x
|
42
|
+
end
|
43
|
+
|
44
|
+
|
45
|
+
def betrag_gerundet(_betrag)
|
46
|
+
(_betrag * 2).round(1) / 2.0
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
|
51
|
+
|
52
|
+
class Fakt < Eintrag
|
53
|
+
attr_reader :betrag
|
54
|
+
|
55
|
+
def initialize(name, menge, ansatz, betrag, einheit = "Fr")
|
56
|
+
super(name, menge, ansatz, einheit)
|
57
|
+
@betrag = betrag
|
58
|
+
end
|
59
|
+
|
60
|
+
def ansatz_to_s
|
61
|
+
ansatz
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
|
66
|
+
class IstStunden < Eintrag
|
67
|
+
def initialize(name, menge)
|
68
|
+
super(name, menge, nil)
|
69
|
+
end
|
70
|
+
|
71
|
+
def betrag;
|
72
|
+
0;
|
73
|
+
end
|
74
|
+
|
75
|
+
# überschreibt
|
76
|
+
def betrag_gerundet_to_s
|
77
|
+
nil
|
78
|
+
end
|
79
|
+
|
80
|
+
end
|
81
|
+
|
82
|
+
class Zulage < Eintrag
|
83
|
+
|
84
|
+
def initialize(name, menge, ansatz)
|
85
|
+
super(name, menge, ansatz)
|
86
|
+
end
|
87
|
+
|
88
|
+
def betrag
|
89
|
+
menge * ansatz
|
90
|
+
end
|
91
|
+
|
92
|
+
def ansatz_to_s
|
93
|
+
value_gerundet_to_s(ansatz)
|
94
|
+
end
|
95
|
+
|
96
|
+
end
|
97
|
+
|
98
|
+
class Abzug < Eintrag
|
99
|
+
#ansatz = prozent
|
100
|
+
def initialize name, menge, ansatz
|
101
|
+
super(name, menge, ansatz)
|
102
|
+
end
|
103
|
+
|
104
|
+
def betrag
|
105
|
+
menge * (ansatz / 100)
|
106
|
+
end
|
107
|
+
|
108
|
+
def menge_to_s
|
109
|
+
menge.nil? ? nil : value_gerundet_to_s(menge)
|
110
|
+
end
|
111
|
+
|
112
|
+
def ansatz_to_s
|
113
|
+
x = ActiveSupport::NumberHelper.number_to_rounded(ansatz, precision: 2)
|
114
|
+
"#{x}%"
|
115
|
+
end
|
116
|
+
|
117
|
+
end
|
118
|
+
|
119
|
+
class Rechnung < Eintrag
|
120
|
+
|
121
|
+
def initialize name, positive, negative, einheit = "Fr"
|
122
|
+
super(name, nil, nil, einheit)
|
123
|
+
@positive, @negative = positive, negative
|
124
|
+
end
|
125
|
+
|
126
|
+
def betrag
|
127
|
+
v = 0
|
128
|
+
v = @positive.inject(v) { |v, x| v + x.betrag }
|
129
|
+
v = @negative.inject(v) { |v, x| v - x.betrag }
|
130
|
+
v
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
|
135
|
+
end
|
136
|
+
end
|
@@ -0,0 +1,129 @@
|
|
1
|
+
require "prawn"
|
2
|
+
|
3
|
+
module Planik
|
4
|
+
module Lohnausweis
|
5
|
+
|
6
|
+
# Generiert aus den Rohdaten das PDF
|
7
|
+
class PdfGenerator
|
8
|
+
WIDTH = 500
|
9
|
+
XPOS = 0
|
10
|
+
|
11
|
+
# Erstellt aus den Rohdaten das Daten Objekt mit den aufbereiteten Daten
|
12
|
+
def initialize(rohdaten)
|
13
|
+
daten = Daten.new(rohdaten)
|
14
|
+
@daten = daten
|
15
|
+
end
|
16
|
+
|
17
|
+
# Erstellt das PDF und liefert es zurück
|
18
|
+
def create_pdf
|
19
|
+
@pdf = Prawn::Document.new(page_size: "A4")
|
20
|
+
@pdf.stroke_axis # Die Masse auf den Achsen
|
21
|
+
@pdf.font("Helvetica", size: 8) #Default Font and size
|
22
|
+
@pdf.default_leading = 0
|
23
|
+
next_y = 750
|
24
|
+
next_y = header(next_y)
|
25
|
+
next_y = lohn_block(next_y)
|
26
|
+
next_y = ferien_block(next_y)
|
27
|
+
arbeitszeit_block(next_y)
|
28
|
+
footer()
|
29
|
+
@pdf
|
30
|
+
end
|
31
|
+
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def header(ypos)
|
36
|
+
|
37
|
+
bb = @pdf.bounding_box([XPOS, ypos], width: WIDTH) do
|
38
|
+
@pdf.font("Helvetica", size: 12) do
|
39
|
+
parent = @pdf.bounds
|
40
|
+
xpos = parent.top_left[0] + 350
|
41
|
+
ypos = parent.height - 70
|
42
|
+
width = parent.top_right[0] - xpos
|
43
|
+
|
44
|
+
@pdf.bounding_box([350, ypos], width: width, height: 70) do
|
45
|
+
@pdf.text "#{@daten.adresse.voller_name}"
|
46
|
+
@pdf.text @daten.adresse.strasse_nr
|
47
|
+
@pdf.text "#{@daten.adresse.plz} <u> #{@daten.adresse.ort}</u>", inline_format: true
|
48
|
+
#@pdf.stroke_bounds
|
49
|
+
end
|
50
|
+
@pdf.text("Lohnabrechnung #{@daten.monat} #{@daten.jahr}", style: :bold)
|
51
|
+
end
|
52
|
+
#@pdf.stroke_bounds
|
53
|
+
end
|
54
|
+
bb.absolute_bottom
|
55
|
+
end
|
56
|
+
|
57
|
+
def lohn_block(ypos)
|
58
|
+
ypos = ypos - 50
|
59
|
+
bb = @pdf.bounding_box([XPOS, ypos], width: WIDTH) do
|
60
|
+
ypos = 0
|
61
|
+
make_table(XPOS, ypos, @daten.lohn_daten, true)
|
62
|
+
@pdf.move_down 10 # Abstand
|
63
|
+
make_table(XPOS, ypos, @daten.abzug_daten, false)
|
64
|
+
@pdf.stroke_bounds
|
65
|
+
end
|
66
|
+
bb.absolute_bottom
|
67
|
+
end
|
68
|
+
|
69
|
+
def ferien_block(ypos)
|
70
|
+
ypos = ypos - 50
|
71
|
+
#ypos = @pdf.bounds.absolute_bottom
|
72
|
+
bb = @pdf.bounding_box([XPOS, ypos], width: WIDTH) do
|
73
|
+
ypos = 0
|
74
|
+
make_table(XPOS, ypos, @daten.ferien_daten, true)
|
75
|
+
@pdf.stroke_bounds
|
76
|
+
end
|
77
|
+
bb.absolute_bottom
|
78
|
+
end
|
79
|
+
|
80
|
+
def arbeitszeit_block(ypos)
|
81
|
+
ypos = ypos - 50
|
82
|
+
@pdf.bounding_box([XPOS, ypos], width: WIDTH) do
|
83
|
+
ypos = 0
|
84
|
+
make_table(XPOS, ypos, @daten.arbeitszeit_daten, true)
|
85
|
+
@pdf.stroke_bounds
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
def footer
|
90
|
+
ypos = 18
|
91
|
+
@pdf.bounding_box([XPOS, ypos], width: WIDTH) do
|
92
|
+
@pdf.font("Helvetica", size: 8) do
|
93
|
+
@pdf.text("Wir bitten Sie, die Lohnabrechnung sofort zu prüfen und Unstimmigkeiten unverzüglich mitzuteilen.")
|
94
|
+
@pdf.text("Anhang: Arbeitszeit vom #{@daten.start_datum} bis #{@daten.end_datum}.")
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
|
100
|
+
def make_table(xpos, ypos, daten, title = false)
|
101
|
+
@pdf.bounding_box([xpos, ypos], width: WIDTH) do #height dynmaisch
|
102
|
+
p_width = @pdf.bounds.width
|
103
|
+
r1 = Rational(1, 2)
|
104
|
+
r2 = r1 * Rational(1, 3)
|
105
|
+
column_width = [p_width * r1, p_width * r2, p_width * r2, p_width * r2]
|
106
|
+
@pdf.table(daten, column_widths: column_width,
|
107
|
+
cell_style: {
|
108
|
+
borders: [], #keine Ränder
|
109
|
+
padding_top: 3, padding_bottom: 3
|
110
|
+
|
111
|
+
}
|
112
|
+
) do |t|
|
113
|
+
if title
|
114
|
+
t.row(0).style(font_style: :bold) #Titel bold
|
115
|
+
t.row(0).background_color = "D8D8D8"
|
116
|
+
end
|
117
|
+
t.columns(1..3).style(align: :right)
|
118
|
+
t.cells[t.row_length-1, 0].font_style = :bold
|
119
|
+
t.cells[t.row_length-1, 3].borders = [:top]
|
120
|
+
t.cells[t.row_length-1, 3].font_style = :bold
|
121
|
+
end
|
122
|
+
# @pdf.stroke_bounds
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
module Planik
|
2
|
+
module Lohnausweis
|
3
|
+
|
4
|
+
|
5
|
+
# Die Rohdaten um einen Lohnausweis zu generieren
|
6
|
+
class Rohdaten
|
7
|
+
|
8
|
+
class MengeAnsatz
|
9
|
+
attr_accessor :menge, :ansatz
|
10
|
+
|
11
|
+
def initialize(menge, ansatz)
|
12
|
+
@menge, @ansatz = menge, ansatz;
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
class Arbeitszeit
|
17
|
+
attr_accessor :gleitzeit_vor, :soll_stunden, :ist_stunden
|
18
|
+
|
19
|
+
def initialize(gleitzeit_vor, soll_stunden, ist_stunden)
|
20
|
+
@gleitzeit_vor, @soll_stunden, @ist_stunden = gleitzeit_vor, soll_stunden, ist_stunden
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
class Adresse
|
25
|
+
attr_accessor :vorname, :name
|
26
|
+
attr_accessor :strasse, :nummer
|
27
|
+
attr_accessor :plz, :ort
|
28
|
+
|
29
|
+
def initialize (voname, name, strasse, nummer, plz, ort)
|
30
|
+
@vorname, @name, @strasse, @nummer, @plz, @ort = voname, name, strasse, nummer, plz, ort
|
31
|
+
end
|
32
|
+
|
33
|
+
def voller_name
|
34
|
+
"#{vorname} #{name}"
|
35
|
+
end
|
36
|
+
|
37
|
+
def plz_ort
|
38
|
+
"#{plz} #{ort}"
|
39
|
+
end
|
40
|
+
|
41
|
+
def strasse_nr
|
42
|
+
"#{strasse} #{nummer}"
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
class Ferien
|
48
|
+
attr_accessor :guthaben, :bezogen
|
49
|
+
|
50
|
+
def initialize(guthaben, bezogen)
|
51
|
+
@guthaben, @bezogen = guthaben, bezogen
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
class Freifeld
|
56
|
+
attr_accessor :name, :menge, :ansatz, :betrag
|
57
|
+
|
58
|
+
def initialize(name, menge, ansatz, betrag)
|
59
|
+
@name, @menge, @ansatz, @betrag = name, menge, ansatz, betrag
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
attr_accessor :start_datum, :end_datum
|
64
|
+
attr_accessor :monatslohn
|
65
|
+
attr_accessor :adresse
|
66
|
+
attr_accessor :arbeitszeit
|
67
|
+
attr_accessor :zulage_nacht, :zulage_wochenende, :kinderzulage
|
68
|
+
attr_accessor :funktionszulage
|
69
|
+
attr_accessor :ahv, :alv, :nbu, :krankentaggeld
|
70
|
+
#attr_accessor :pensionskasse
|
71
|
+
attr_accessor :ferien
|
72
|
+
attr_accessor :lohn_freifelder
|
73
|
+
attr_accessor :abzug_freifelder
|
74
|
+
|
75
|
+
def initialize
|
76
|
+
@lohn_freifelder = []
|
77
|
+
@abzug_freifelder = []
|
78
|
+
yield self
|
79
|
+
|
80
|
+
end
|
81
|
+
|
82
|
+
def add_lohn_freifeld freifeld
|
83
|
+
lohn_freifelder << freifeld
|
84
|
+
end
|
85
|
+
def add_abzug_freifeld freifeld
|
86
|
+
abzug_freifelder << freifeld
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
|
data/lib/lohnausweis.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
require "lohnausweis/version"
|
2
|
+
require "lohnausweis/pdf_generator"
|
3
|
+
require "lohnausweis/rohdaten"
|
4
|
+
require "lohnausweis/daten_eintrag"
|
5
|
+
require "lohnausweis/daten"
|
6
|
+
|
7
|
+
module Planik
|
8
|
+
module Lohnausweis
|
9
|
+
|
10
|
+
file = __FILE__
|
11
|
+
dir = File.dirname(file)
|
12
|
+
|
13
|
+
|
14
|
+
# The base source directory for Prawn as installed on the system
|
15
|
+
#
|
16
|
+
#
|
17
|
+
BASEDIR = File.expand_path(File.join(dir, '..'))
|
18
|
+
|
19
|
+
locale_dir = BASEDIR+'/locale/*.yml'
|
20
|
+
I18n.load_path = Dir[locale_dir]
|
21
|
+
I18n.backend.load_translations
|
22
|
+
|
23
|
+
# Your code goes here...
|
24
|
+
end
|
25
|
+
end
|