1가구 2주택 양도소득세 계산기 by 파이썬

1가구 2주택 양도소득세 계산기 by 파이썬

다음은 앞에서 설명드린 내용을 바탕으로 작성한 파이썬 GUI 기반 1가구 2주택 양도소득세 계산기의 전체 소스 코드입니다. 이 코드를 복사하여 바로 사용하실 수 있습니다.

1가구 2주택 양도소득세 계산기 by 파이썬

📌 1가구 2주택 양도소득세 계산기 전체 파이썬 소스 코드 (tax_calculator.py)

import tkinter as tkfrom tkinter import ttk, messagebox# 메인 GUI 생성root = tk.Tk()root.title("1가구 2주택 양도소득세 계산기")root.geometry("500x600")# 제목 설정title = ttk.Label(root, text="1가구 2주택 양도소득세 계산기", font=("맑은 고딕", 18))title.pack(pady=15)# 입력 프레임 구성frame = ttk.Frame(root, padding=20)frame.pack(pady=10)# 양도가액 입력ttk.Label(frame, text="양도가액 (만원):", font=("맑은 고딕", 12)).grid(row=0, column=0, sticky="W", pady=5)sell_price_entry = ttk.Entry(frame, font=("맑은 고딕", 12))sell_price_entry.grid(row=0, column=1, pady=5)# 취득가액 입력ttk.Label(frame, text="취득가액 (만원):", font=("맑은 고딕", 12)).grid(row=1, column=0, sticky="W", pady=5)buy_price_entry = ttk.Entry(frame, font=("맑은 고딕", 12))buy_price_entry.grid(row=1, column=1, pady=5)# 필요경비 입력ttk.Label(frame, text="필요경비 (만원):", font=("맑은 고딕", 12)).grid(row=2, column=0, sticky="W", pady=5)expense_entry = ttk.Entry(frame, font=("맑은 고딕", 12))expense_entry.grid(row=2, column=1, pady=5)# 보유기간 입력ttk.Label(frame, text="보유기간 (년):", font=("맑은 고딕", 12)).grid(row=3, column=0, sticky="W", pady=5)holding_period_entry = ttk.Entry(frame, font=("맑은 고딕", 12))holding_period_entry.grid(row=3, column=1, pady=5)# 계산 로직 구현def calculate_tax():    try:        sell_price = float(sell_price_entry.get())        buy_price = float(buy_price_entry.get())        expense = float(expense_entry.get())        holding_period = int(holding_period_entry.get())        # 양도차익 계산        profit = sell_price - buy_price - expense        if profit <= 0:            messagebox.showinfo("계산 결과", "양도차익이 없습니다. 납부할 세금이 없습니다.")            return        # 양도소득세율 적용        if profit <= 1200:            tax_rate = 0.06        elif profit <= 4600:            tax_rate = 0.15        elif profit <= 8800:            tax_rate = 0.24        elif profit <= 15000:            tax_rate = 0.35        elif profit <= 30000:            tax_rate = 0.38        elif profit <= 50000:            tax_rate = 0.40        else:            tax_rate = 0.42        # 1가구 2주택 중과세 추가 세율        additional_tax_rate = 0.20        total_tax_rate = tax_rate + additional_tax_rate        # 장기보유특별공제율 계산        if holding_period >= 10:            deduction_rate = 0.80        elif holding_period >= 9:            deduction_rate = 0.72        elif holding_period >= 8:            deduction_rate = 0.64        elif holding_period >= 7:            deduction_rate = 0.56        elif holding_period >= 6:            deduction_rate = 0.48        elif holding_period >= 5:            deduction_rate = 0.40        elif holding_period >= 4:            deduction_rate = 0.32        elif holding_period >= 3:            deduction_rate = 0.24        else:            deduction_rate = 0.0        # 과세표준 계산        taxable_profit = profit * (1 - deduction_rate)        tax_amount = taxable_profit * total_tax_rate        # 결과 메시지 출력        result = (            f"양도차익: {profit:.2f} 만원\n\n"            f"장기보유특별공제율: {deduction_rate * 100:.0f}%\n"            f"공제 후 과세표준: {taxable_profit:.2f} 만원\n\n"            f"적용 세율 (기본+중과): {total_tax_rate * 100:.2f}%\n\n"            f"최종 양도소득세: {tax_amount:.2f} 만원"        )        messagebox.showinfo("계산 결과", result)    except ValueError:        messagebox.showerror("입력 오류", "모든 값을 올바른 숫자로 입력해주세요.")# 계산 버튼 추가calculate_button = ttk.Button(root, text="양도소득세 계산하기", command=calculate_tax)calculate_button.pack(pady=20)# 제작자 정보ttk.Label(root, text="Developed by ChatGPT", font=("Arial", 10)).pack(side="bottom", pady=10)# GUI 실행root.mainloop()

🚩 프로그램 실행 방법

위의 코드를 tax_calculator.py라는 이름으로 저장합니다.

터미널을 열고 다음 명령어를 입력하여 프로그램을 실행합니다:

python tax_calculator.py

🚩 EXE 파일로 변환하는 방법 (배포용)

다음 명령어로 pyinstaller를 설치합니다.

pip install pyinstaller

터미널에서 다음 명령어를 실행하면 EXE 파일이 생성됩니다:

pyinstaller --onefile --windowed tax_calculator.py
  • 생성된 파일은 dist 폴더에서 확인할 수 있습니다.
  • exe 파일을 클릭하면 파이썬 없이 독립적으로 프로그램 실행이 가능합니다.

🚩 실행 환경 및 요구사항

항목 권장 사항
운영체제 Windows 10 이상
Python 버전 Python 3.7 이상
사용 라이브러리 Tkinter (기본 내장 라이브러리)

이제 누구나 쉽게 양도소득세 계산기를 사용할 수 있게 되었습니다.
부동산 거래 시 정확하고 신속한 세금 계산을 통해 효율적인 재무 관리를 하시길 바랍니다!

댓글 남기기