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

Contents of /trunk/lohnrechner2007.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 29 - (show annotations)
Mon Jan 31 08:55:33 2005 UTC (20 years, 3 months ago) by wilde
Original Path: trunk/RCS/lohnrechner.py
File MIME type: text/x-python
File size: 7660 byte(s)
Etwas code cleanup

1 #! /usr/bin/python
2 # -*- coding: iso-8859-1 -*-
3 # --------------------------------------------------------------------
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 __version__ = "$Revision$"
18 # $Source$
19
20 _release_version = "0.%s beta" % __version__[11:-2]
21
22 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 # 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 self.root = root
50
51 self.root.title("Lohnrechner 2005 - v%s" % _release_version)
52
53 self.SetupUI()
54 self.ResetInput()
55
56 def SetupUI(self):
57 self.root.resizable(NO, NO)
58
59 frame = Frame(root)
60 frame.grid(padx=10, pady=10)
61
62 # Steuern Ein/Ausgabe
63 Label(frame, text="Lohn:").grid(row=0, sticky=E)
64 self.lohn = Entry(frame)
65 self.lohn.bind("<Return>", self.NewInput)
66 self.lohn.grid(row=0, column=1, sticky=W)
67
68 Label(frame, text="Steuerklasse:").grid(row=1, sticky=E)
69 self.stkl = IntVar()
70 stklframe = Frame(frame)
71 stklframe.grid(row=1, column=1, sticky=W)
72 for text, val in [("I", 1),
73 ("II", 2),
74 ("III", 3),
75 ("IV", 4),
76 ("V", 5),
77 ("VI", 6)]:
78 stklradio = Radiobutton(stklframe, text=text, value=val,
79 indicatoron=0, command=self.NewInput,
80 variable=self.stkl)
81 if text == "I":
82 stklradio.select()
83 stklradio.pack(side=LEFT)
84
85 Label(frame, text="Kirchensteuer:").grid(row=2, sticky=E)
86 self.kirche = IntVar()
87 kircheradio = Checkbutton(frame, onvalue=1, offvalue=0,
88 command=self.NewInput,
89 variable=self.kirche).grid(row=2, column=1,
90 sticky=W)
91
92 Label(frame, text="Kinderfreibetrag:").grid(row=3, sticky=E)
93 self.kfb = Entry(frame)
94 self.kfb.bind("<Return>", self.NewInput)
95 self.kfb.grid(row=3, column=1, sticky=W)
96
97 Label(frame, text="Bundesland:").grid(row=4, sticky=E)
98 landframe = Frame(frame)
99 scrollbar = Scrollbar(landframe, orient=VERTICAL)
100 self.landbox = Listbox(landframe, height=4, selectmode=SINGLE,
101 yscrollcommand=scrollbar.set)
102 for land in self.laender:
103 self.landbox.insert(END, land[0])
104 self.landbox.select_set(0)
105 self.landbox.bind("<<ListboxSelect>>", self.NewLandSel)
106 self.landbox.pack(side=RIGHT, fill=Y)
107 scrollbar.config(command=self.landbox.yview)
108 scrollbar.pack(side=LEFT, fill=BOTH, expand=1)
109 landframe.grid(row=4, column=1, sticky=W)
110
111 Label(frame, text="Lohnsteuer:").grid(row=0, column=2, sticky=E)
112 self.lst = Entry(frame)
113 self.lst.grid(row=0, column=3, sticky=W)
114
115 Label(frame, text="Solidaritätszuschlag:").grid(row=1, column=2, sticky=E)
116 self.soli = Entry(frame)
117 self.soli.grid(row=1, column=3, sticky=W)
118
119 Label(frame, text="Kirchensteuer:").grid(row=2, column=2, sticky=E)
120 self.kist = Entry(frame)
121 self.kist.grid(row=2, column=3, sticky=W)
122
123 Label(frame, text="Lohn nach Steuern:").grid(row=3, column=2, sticky=E)
124 self.netto = Entry(frame)
125 self.netto.grid(row=3, column=3, sticky=W)
126
127 # Allgemeine UI Elemente
128 buttons = Frame(frame)
129 buttons.grid(row=4, column=2, columnspan=2)
130 Button(buttons, text="Quit", command=root.quit).pack(side=LEFT)
131 Button(buttons, text="Info", command=self.Info).pack(side=LEFT)
132 Button(buttons, text="Berechnen", command=self.CalcOutput).pack(side=LEFT)
133
134 def NewInput(self, event=0):
135 # Es ist möglich alle Einträge in der Listbox zu deselektieren,
136 # es ist aber immer genau ein Eintrag aktuell, darum wird er ggf.
137 # zwangsselektiert:
138 # FIX ME: eigendlich wäre das ein Fall für ein custom widget!
139 if len(self.landbox.curselection()) == 0:
140 self.landbox.select_set(self.land)
141 self.CalcOutput()
142
143 def UpdateLand(self):
144 self.land = int(self.landbox.curselection()[0])
145
146 def NewLandSel(self, event=0):
147 self.UpdateLand()
148 self.CalcOutput()
149
150 def ResetInput(self):
151 self.ResetInputLohn()
152 self.ResetInputKfb()
153 self.NewLandSel()
154
155 def ResetInputLohn(self):
156 self.lohn.delete(0, END)
157 self.lohn.insert(0, "0")
158
159 def ResetInputKfb(self):
160 self.kfb.delete(0, END)
161 self.kfb.insert(0, "0")
162
163 def InitCalc(self):
164 try:
165 self.SetLohn(float(self.lohn.get()))
166 except:
167 self.ResetInputLohn()
168
169 try:
170 self.SetKinderfreibetrag(float(self.kfb.get()))
171 except:
172 self.ResetInputKfb()
173
174 self.SetSteuerklasse(self.stkl.get())
175 self.SetKirchensteuerProzent(self.kirche.get() *
176 self.laender[self.land][1])
177
178 def CalcOutput(self):
179 self.InitCalc()
180 self.Calc()
181 self.lst.delete(0, END)
182 self.lst.insert(0, "%.2f" % self.GetLohnsteuer())
183 self.soli.delete(0, END)
184 self.soli.insert(0, "%.2f" % self.GetSoli())
185 self.kist.delete(0, END)
186 self.kist.insert(0, "%.2f" % self.GetKirchensteuer())
187 self.netto.delete(0, END)
188 self.netto.insert(0, "%.2f" %
189 (self.GetLohn() - self.GetLohnsteuer()
190 - self.GetSoli() - self.GetKirchensteuer()))
191
192 def Info(self):
193 infowin = Toplevel(self.root)
194 infowin.title("Info")
195 Label(infowin, text="Lohnrechner 2005 v%s" % _release_version,
196 font=("Times", 14, "bold italic")).grid(row=0, pady=20)
197 Label(infowin, text=
198 "Copyright (C) 2005 Intevation GmbH \n\n\
199 Lohnrechner 2005 comes with ABSOLUTELY NO WARRANTY.\n\
200 This is free software, and you are welcome to redistribute it\n\
201 under the terms of the GNU General Public License.\n\
202 For more information about these matters, see the file named COPYING.\n\n\
203 Dieses Programm verwendet LST2005 %s" % LST2005._ModulVersion()).grid(row=1, padx=10)
204 Button(infowin, text="Ok", command=infowin.destroy).grid(row=2, pady=10)
205
206
207 if __name__ == "__main__":
208 root = Tk()
209 lr = Lohnrechner(root)
210 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