/[lohnrechner]/trunk/RCS/lohnrechner.py
ViewVC logotype

Annotation of /trunk/RCS/lohnrechner.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 30 - (hide annotations)
Mon Jan 31 10:31:05 2005 UTC (20 years, 2 months ago) by wilde
File MIME type: text/x-python
File size: 11074 byte(s)
Komplete Berechnung f�r Sozialabgaben hinzugef�gt
Das rechtfertigt einen Versionssprung  :-)

1 wilde 6 #! /usr/bin/python
2 wilde 19 # -*- coding: iso-8859-1 -*-
3 wilde 6 # --------------------------------------------------------------------
4     # Lohnsteuer und Sozialabgaben Rechner
5     # $Id$
6     # --------------------------------------------------------------------
7     #
8     # Copyright (c) 2005 by Intevation GmbH
9     # Authors:
10     # Sascha Wilde <[email protected]>
11     #
12     # This program is free software under the GPL (>=v2)
13     # Read the file COPYING coming with this package for details.
14    
15     """Lohn/Gehaltsrechner für das Jahr 2005"""
16    
17 wilde 7 __version__ = "$Revision$"
18     # $Source$
19    
20 wilde 21 _release_version = "0.%s beta" % __version__[11:-2]
21 wilde 7
22 wilde 6 import LST2005
23     from Tkinter import *
24    
25     class Lohnrechner(LST2005.LStRechner2005):
26    
27     def __init__(self, root):
28     LST2005.LStRechner2005.__init__(self)
29    
30 wilde 22 # Land, Kirchensteuersatz
31     self.laender = [("Baden-Württemberg", 8),
32     ("Bayern", 8),
33     ("Berlin", 9),
34     ("Brandenburg", 9),
35     ("Bremen", 9),
36     ("Bremerhaven", 9),
37     ("Hamburg", 9),
38     ("Hessen", 9),
39     ("Mecklenburg-Vorpommern", 9),
40     ("Niedersachsen" ,9),
41     ("Nordrhein-Westfalen", 9),
42     ("Rheinland-Pfalz", 9),
43     ("Saarland", 9),
44     ("Sachsen", 9),
45     ("Sachsen-Anhalt", 9),
46     ("Schleswig-Holstein", 9),
47     ("Thüringen", 9)]
48    
49 wilde 30 self.InitSozv()
50    
51 wilde 17 self.root = root
52 wilde 7
53 wilde 29 self.root.title("Lohnrechner 2005 - v%s" % _release_version)
54    
55     self.SetupUI()
56     self.ResetInput()
57    
58     def SetupUI(self):
59     self.root.resizable(NO, NO)
60    
61 wilde 22 frame = Frame(root)
62     frame.grid(padx=10, pady=10)
63    
64 wilde 29 # Steuern Ein/Ausgabe
65 wilde 22 Label(frame, text="Lohn:").grid(row=0, sticky=E)
66     self.lohn = Entry(frame)
67 wilde 9 self.lohn.bind("<Return>", self.NewInput)
68 wilde 6 self.lohn.grid(row=0, column=1, sticky=W)
69    
70 wilde 22 Label(frame, text="Steuerklasse:").grid(row=1, sticky=E)
71 wilde 21 self.stkl = IntVar()
72 wilde 22 stklframe = Frame(frame)
73 wilde 6 stklframe.grid(row=1, column=1, sticky=W)
74 wilde 21 for text, val in [("I", 1),
75     ("II", 2),
76     ("III", 3),
77     ("IV", 4),
78     ("V", 5),
79     ("VI", 6)]:
80 wilde 6 stklradio = Radiobutton(stklframe, text=text, value=val,
81 wilde 25 indicatoron=0, command=self.NewInput,
82 wilde 6 variable=self.stkl)
83     if text == "I":
84     stklradio.select()
85     stklradio.pack(side=LEFT)
86    
87 wilde 22 Label(frame, text="Kirchensteuer:").grid(row=2, sticky=E)
88     self.kirche = IntVar()
89 wilde 30 Checkbutton(frame, onvalue=1, offvalue=0, command=self.NewInput,
90     variable=self.kirche).grid(row=2, column=1,sticky=W)
91 wilde 10
92 wilde 22 Label(frame, text="Kinderfreibetrag:").grid(row=3, sticky=E)
93     self.kfb = Entry(frame)
94 wilde 19 self.kfb.bind("<Return>", self.NewInput)
95     self.kfb.grid(row=3, column=1, sticky=W)
96    
97 wilde 30 Label(frame, text="Bundesland:").grid(row=4, sticky=NE)
98 wilde 22 landframe = Frame(frame)
99     scrollbar = Scrollbar(landframe, orient=VERTICAL)
100 wilde 24 self.landbox = Listbox(landframe, height=4, selectmode=SINGLE,
101     yscrollcommand=scrollbar.set)
102 wilde 22 for land in self.laender:
103 wilde 24 self.landbox.insert(END, land[0])
104 wilde 25 self.landbox.select_set(0)
105 wilde 24 self.landbox.bind("<<ListboxSelect>>", self.NewLandSel)
106     self.landbox.pack(side=RIGHT, fill=Y)
107     scrollbar.config(command=self.landbox.yview)
108 wilde 22 scrollbar.pack(side=LEFT, fill=BOTH, expand=1)
109 wilde 30 landframe.grid(row=4, rowspan=4, column=1, sticky=W)
110 wilde 22
111     Label(frame, text="Lohnsteuer:").grid(row=0, column=2, sticky=E)
112     self.lst = Entry(frame)
113 wilde 6 self.lst.grid(row=0, column=3, sticky=W)
114    
115 wilde 22 Label(frame, text="Solidaritätszuschlag:").grid(row=1, column=2, sticky=E)
116     self.soli = Entry(frame)
117 wilde 6 self.soli.grid(row=1, column=3, sticky=W)
118    
119 wilde 22 Label(frame, text="Kirchensteuer:").grid(row=2, column=2, sticky=E)
120     self.kist = Entry(frame)
121 wilde 16 self.kist.grid(row=2, column=3, sticky=W)
122 wilde 10
123 wilde 25 Label(frame, text="Lohn nach Steuern:").grid(row=3, column=2, sticky=E)
124 wilde 30 self.netto1 = Entry(frame)
125     self.netto1.grid(row=3, column=3, sticky=W)
126 wilde 25
127 wilde 30 # Sozialversicherung Ein/Ausgabe
128     Label(frame, text="Sozialversicherung:").grid(row=8, sticky=E)
129     self.sozv = IntVar()
130     sozvradio = Checkbutton(frame, onvalue=1, offvalue=0,
131     command=self.NewInput, variable=self.sozv)
132     sozvradio.select()
133     sozvradio.grid(row=8, column=1, sticky=W)
134    
135     Label(frame, text="Krankenkassenbeitrag:").grid(row=9, sticky=E)
136     self.kvsatz = Entry(frame)
137     self.kvsatz.bind("<Return>", self.NewInput)
138     self.kvsatz.grid(row=9, column=1, sticky=W)
139    
140     Label(frame, text="Rentenversicherung:").grid(row=4, column=2, sticky=E)
141     self.rv = Entry(frame)
142     self.rv.grid(row=4, column=3, sticky=W)
143    
144     Label(frame, text="Krankenversicherung:").grid(row=5, column=2, sticky=E)
145     self.kv = Entry(frame)
146     self.kv.grid(row=5, column=3, sticky=W)
147    
148     Label(frame, text="Arbeitslosenversicherung:").grid(row=6, column=2,
149     sticky=E)
150     self.av = Entry(frame)
151     self.av.grid(row=6, column=3, sticky=W)
152    
153     Label(frame, text="Pflegeversicherung:").grid(row=7, column=2, sticky=E)
154     self.pv = Entry(frame)
155     self.pv.grid(row=7, column=3, sticky=W)
156    
157     Label(frame, text="Netto Lohn:").grid(row=8, column=2, sticky=E)
158     self.netto2 = Entry(frame)
159     self.netto2.grid(row=8, column=3, sticky=W)
160    
161 wilde 29 # Allgemeine UI Elemente
162 wilde 22 buttons = Frame(frame)
163 wilde 30 buttons.grid(row=9, column=2, columnspan=2)
164 wilde 17 Button(buttons, text="Quit", command=root.quit).pack(side=LEFT)
165     Button(buttons, text="Info", command=self.Info).pack(side=LEFT)
166     Button(buttons, text="Berechnen", command=self.CalcOutput).pack(side=LEFT)
167 wilde 9
168 wilde 25 def NewInput(self, event=0):
169 wilde 24 # Es ist möglich alle Einträge in der Listbox zu deselektieren,
170     # es ist aber immer genau ein Eintrag aktuell, darum wird er ggf.
171     # zwangsselektiert:
172     # FIX ME: eigendlich wäre das ein Fall für ein custom widget!
173     if len(self.landbox.curselection()) == 0:
174     self.landbox.select_set(self.land)
175 wilde 9 self.CalcOutput()
176    
177 wilde 25 def UpdateLand(self):
178 wilde 24 self.land = int(self.landbox.curselection()[0])
179    
180 wilde 25 def NewLandSel(self, event=0):
181     self.UpdateLand()
182     self.CalcOutput()
183    
184 wilde 6 def ResetInput(self):
185 wilde 9 self.ResetInputLohn()
186 wilde 23 self.ResetInputKfb()
187 wilde 30 self.ResetInputKVsatz()
188 wilde 29 self.NewLandSel()
189 wilde 9
190     def ResetInputLohn(self):
191     self.lohn.delete(0, END)
192 wilde 6 self.lohn.insert(0, "0")
193 wilde 10
194 wilde 19 def ResetInputKfb(self):
195     self.kfb.delete(0, END)
196     self.kfb.insert(0, "0")
197    
198 wilde 30 def ResetInputKVsatz(self):
199     self.kvsatz.delete(0, END)
200     self.kvsatz.insert(0, "14.7")
201    
202 wilde 6 def InitCalc(self):
203 wilde 9 try:
204     self.SetLohn(float(self.lohn.get()))
205     except:
206     self.ResetInputLohn()
207 wilde 10
208 wilde 19 try:
209     self.SetKinderfreibetrag(float(self.kfb.get()))
210     except:
211     self.ResetInputKfb()
212    
213 wilde 30 try:
214     self.SetKV(float(self.kvsatz.get()))
215     except:
216     self.ResetInputKVsatz()
217    
218 wilde 21 self.SetSteuerklasse(self.stkl.get())
219 wilde 25 self.SetKirchensteuerProzent(self.kirche.get() *
220     self.laender[self.land][1])
221 wilde 6
222     def CalcOutput(self):
223     self.InitCalc()
224     self.Calc()
225     self.lst.delete(0, END)
226 wilde 25 self.lst.insert(0, "%.2f" % self.GetLohnsteuer())
227 wilde 6 self.soli.delete(0, END)
228 wilde 25 self.soli.insert(0, "%.2f" % self.GetSoli())
229 wilde 16 self.kist.delete(0, END)
230 wilde 25 self.kist.insert(0, "%.2f" % self.GetKirchensteuer())
231 wilde 30 netto1 = self.GetLohn() - self.GetLohnsteuer() \
232     - self.GetSoli() - self.GetKirchensteuer()
233     self.netto1.delete(0, END)
234     self.netto1.insert(0, "%.2f" % netto1)
235     self.rv.delete(0, END)
236     self.rv.insert(0, "%.2f" % self.GetRV())
237     self.pv.delete(0, END)
238     self.pv.insert(0, "%.2f" % self.GetPV())
239     self.av.delete(0, END)
240     self.av.insert(0, "%.2f" % self.GetAV())
241     self.kv.delete(0, END)
242     self.kv.insert(0, "%.2f" % self.GetKV())
243     netto2 = netto1 - self.GetRV() - self.GetAV() \
244     - self.GetPV() - self.GetKV()
245     self.netto2.delete(0, END)
246     self.netto2.insert(0, "%.2f" % netto2)
247 wilde 6
248 wilde 17 def Info(self):
249     infowin = Toplevel(self.root)
250     infowin.title("Info")
251 wilde 18 Label(infowin, text="Lohnrechner 2005 v%s" % _release_version,
252 wilde 17 font=("Times", 14, "bold italic")).grid(row=0, pady=20)
253     Label(infowin, text=
254     "Copyright (C) 2005 Intevation GmbH \n\n\
255     Lohnrechner 2005 comes with ABSOLUTELY NO WARRANTY.\n\
256     This is free software, and you are welcome to redistribute it\n\
257     under the terms of the GNU General Public License.\n\
258     For more information about these matters, see the file named COPYING.\n\n\
259     Dieses Programm verwendet LST2005 %s" % LST2005._ModulVersion()).grid(row=1, padx=10)
260     Button(infowin, text="Ok", command=infowin.destroy).grid(row=2, pady=10)
261 wilde 6
262 wilde 30 #
263     # Funktionen zur Berechnung der Sozialversicherungsbeiträge.
264     #
265     # FIX ME: Dieser Teil könnte evl. in ein eigenes Modul ausgelagert werden.
266     #
267 wilde 17
268 wilde 30 def InitSozv(self):
269     self.AVsatz = 0.065
270     self.RVsatz = 0.195
271     self.PVsatz = 0.017
272     self.PVkinderlose = 0.0025
273     self.BMG1 = 3525
274     self.BMG2 = 5200
275    
276     def SetKV(self, value):
277     assert value >= 0.0 and value <= 100.0, \
278     "must be in range 0.0-100.0 (Percent)"
279     self.KVsatz = (value / 100.0)
280    
281     def GetAV(self):
282     lohn = self.GetLohn()
283     if lohn > self.BMG2 : lohn = self.BMG2
284     return round(self.sozv.get() * self.AVsatz * lohn / 2, 2)
285    
286     def GetRV(self):
287     lohn = self.GetLohn()
288     if lohn > self.BMG2 : lohn = self.BMG2
289     return round(self.sozv.get() * self.RVsatz * lohn / 2, 2)
290    
291     def GetPV(self):
292     lohn = self.GetLohn()
293     if lohn > self.BMG1 : lohn = self.BMG1
294     PV = self.PVsatz * lohn / 2
295     if float(self.kfb.get()) == 0.0 :
296     PV += lohn * self.PVkinderlose
297     return round(self.sozv.get() * PV, 2)
298    
299     def GetKV(self):
300     lohn = self.GetLohn()
301     if lohn > self.BMG1 : lohn = self.BMG1
302     return round(self.sozv.get() * self.KVsatz * lohn / 2, 2)
303    
304    
305 wilde 6 if __name__ == "__main__":
306     root = Tk()
307     lr = Lohnrechner(root)
308     root.mainloop()

Properties

Name Value
svn:eol-style native
svn:executable *
svn:keywords Author Date Id Revision

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26