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

Diff of /trunk/lohnrechner2007.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

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

Legend:
Removed from v.22  
changed lines
  Added in v.54

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26