吾爱破解 - 52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 2035|回复: 34
收起左侧

[原创工具] 【原创】实用房贷计算器。附带py源码和au3源码

  [复制链接]
1125xiaoyu 发表于 2024-7-26 15:58
大家好!我是吾爱破解的1125xiaoyu。今天给大家带来一款实用的房贷计算器工具,au3编写的只有400多kb
[Python] 纯文本查看 复制代码
import tkinter as tkfrom tkinter import ttk
from math import pow

# 央行最新利率(假设的值)
LATEST_MORTGAGE_RATE = 4.9  # 房贷利率
LATEST_CAR_LOAN_RATE = 4.5  # 车贷利率

class SalaryCalculator(tk.Tk):
    def __init__(self):
        super().__init__()

        self.title("房贷车贷计算器_1.0.0.0_吾爱破解:1125xiaoyu")
        self.geometry("300x620")
        self.resizable(False, False)  # 禁用窗口拉伸

        # 输入字段
        self.create_input("基本工资:", 0, "basic_salary")
        self.create_input("住房公积金比例 (%):", 1, "housing_fund_rate", 12)
        self.create_input("养老保险比例 (%):", 2, "pension_rate", 8)
        self.create_input("房贷总额:", 3, "mortgage_total")
        self.create_input("房贷利率 (%):", 4, "mortgage_rate", LATEST_MORTGAGE_RATE)
        self.create_input("房贷年限 (年):", 5, "mortgage_years")
        self.create_radio("房贷计算方式:", 6, "mortgage_method", ["等额本息", "等额本金"])
        self.create_input("车贷总额:", 7, "car_loan_total")
        self.create_input("车贷利率 (%):", 8, "car_loan_rate", LATEST_CAR_LOAN_RATE)
        self.create_input("车贷年限 (年):", 9, "car_loan_years")
        self.create_radio("车贷计算方式:", 10, "car_loan_method", ["等额本息", "等额本金"])

        # 计算按钮
        ttk.Button(self, text="计算", command=self.calculate).grid(column=0, row=11, columnspan=2, pady=20)

        # 显示框
        self.result_frame = ttk.Frame(self)
        self.result_frame.grid(column=0, row=12, columnspan=2, padx=10, pady=5)
        self.result_text = tk.Text(self.result_frame, wrap=tk.WORD, width=38, height=10)
        self.result_text.pack(side=tk.LEFT, fill=tk.BOTH, expand=True)
        self.scrollbar = ttk.Scrollbar(self.result_frame, orient=tk.VERTICAL, command=self.result_text.yview)
        self.scrollbar.pack(side=tk.RIGHT, fill=tk.Y)
        self.result_text.config(yscrollcommand=self.scrollbar.set)

        # 复制按钮
        ttk.Button(self, text="复制", command=self.copy_to_clipboard).grid(column=0, row=13, columnspan=2, pady=5)

    def create_input(self, text, row, var_name, default_value=0):
        ttk.Label(self, text=text).grid(column=0, row=row, padx=10, pady=5)
        setattr(self, var_name, tk.DoubleVar(value=default_value))
        ttk.Entry(self, textvariable=getattr(self, var_name)).grid(column=1, row=row, padx=10, pady=5)

    def create_radio(self, text, row, var_name, options):
        ttk.Label(self, text=text).grid(column=0, row=row, padx=10, pady=5)
        var = tk.StringVar(value=options[0])
        setattr(self, var_name, var)
        frame = ttk.Frame(self)
        frame.grid(column=1, row=row)
        for option in options:
            ttk.Radiobutton(frame, text=option, variable=var, value=option).pack(side=tk.LEFT)

    def calculate(self):
        basic_salary = self.basic_salary.get()
        housing_fund = basic_salary * self.housing_fund_rate.get() / 100
        pension = basic_salary * self.pension_rate.get() / 100

        mortgage_payment, mortgage_details = self.calculate_loan_payment(
            self.mortgage_total.get(),
            self.mortgage_rate.get() / 100 / 12,
            int(self.mortgage_years.get() * 12),
            self.mortgage_method.get()
        )

        car_loan_payment, car_loan_details = self.calculate_loan_payment(
            self.car_loan_total.get(),
            self.car_loan_rate.get() / 100 / 12,
            int(self.car_loan_years.get() * 12),
            self.car_loan_method.get()
        )

        net_salary = basic_salary - housing_fund - pension - mortgage_payment - car_loan_payment

        result = (f"住房公积金: {housing_fund:.2f} 元\n"
                  f"养老保险: {pension:.2f} 元\n"
                  f"房贷偿还: {mortgage_payment:.2f} 元 ({self.mortgage_method.get()})\n"
                  f"车贷偿还: {car_loan_payment:.2f} 元 ({self.car_loan_method.get()})\n"
                  f"扣除后的工资: {net_salary:.2f} 元\n\n"
                  f"房贷详细信息:\n{mortgage_details}\n\n"
                  f"车贷详细信息:\n{car_loan_details}")

        self.result_text.config(state=tk.NORMAL)
        self.result_text.delete(1.0, tk.END)
        self.result_text.insert(tk.END, result)
        self.result_text.config(state=tk.DISABLED)

    def calculate_loan_payment(self, principal, monthly_rate, months, method):
        details = ""
        if months == 0:
            return 0, details
        if method == "等额本息":
            if monthly_rate == 0:
                payment = principal / months
                for i in range(1, months + 1):
                    details += f"第 {i} 个月: {payment:.2f} 元\n"
                return payment, details
            payment = principal * monthly_rate * pow(1 + monthly_rate, months) / (pow(1 + monthly_rate, months) - 1)
            for i in range(1, months + 1):
                details += f"第 {i} 个月: {payment:.2f} 元\n"
            return payment, details
        elif method == "等额本金":
            principal_payment = principal / months
            for i in range(1, months + 1):
                interest_payment = (principal - (i - 1) * principal_payment) * monthly_rate
                payment = principal_payment + interest_payment
                details += f"第 {i} 个月: {payment:.2f} 元\n"
            return principal_payment + interest_payment, details

    def copy_to_clipboard(self):
        self.clipboard_clear()
        self.clipboard_append(self.result_text.get(1.0, tk.END))
        self.update()


if __name__ == "__main__":
    app = SalaryCalculator()
    app.mainloop()
[AAuto] 纯文本查看 复制代码
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <StaticConstants.au3>
#include <ButtonConstants.au3>

Global $LATEST_MORTGAGE_RATE = 4.9  ; 房贷利率
Global $LATEST_CAR_LOAN_RATE = 4.5  ; 车贷利率
Global $basic_salary, $housing_fund_rate, $pension_rate, $mortgage_total
Global $mortgage_rate, $mortgage_years, $mortgage_method
Global $car_loan_total, $car_loan_rate, $car_loan_years, $car_loan_method
Global $radio_buttons_mortgage[2], $radio_buttons_car_loan[2]

; 创建主窗口
GUICreate("房贷车贷计算器_1.0.0吾爱破解1125xiaoyu", 300, 620)
GUISetBkColor(0xFFFFFF) ; 设置背景颜色为白色

; 创建输入字段
CreateInput("基本工资:", 10, 10, $basic_salary)
CreateInput("住房公积金比例 (%):", 10, 40, $housing_fund_rate, 12)
CreateInput("养老保险比例 (%):", 10, 70, $pension_rate, 8)
CreateInput("房贷总额:", 10, 100, $mortgage_total)
CreateInput("房贷利率 (%):", 10, 130, $mortgage_rate, $LATEST_MORTGAGE_RATE)
CreateInput("房贷年限 (年):", 10, 160, $mortgage_years)
CreateRadio("房贷计算方式:", 10, 190, $radio_buttons_mortgage)
CreateInput("车贷总额:", 10, 230, $car_loan_total)
CreateInput("车贷利率 (%):", 10, 260, $car_loan_rate, $LATEST_CAR_LOAN_RATE)
CreateInput("车贷年限 (年):", 10, 290, $car_loan_years)
CreateRadio("车贷计算方式:", 10, 320, $radio_buttons_car_loan)

; 创建计算按钮
$calculate_btn = GUICtrlCreateButton("计算", 100, 350, 100, 30)
; 创建显示框
$result_text = GUICtrlCreateEdit("", 10, 390, 270, 200, $ES_READONLY + $WS_VSCROLL)
; 创建复制按钮
$copy_btn = GUICtrlCreateButton("复制", 100, 600, 100, 30)

GUISetState(@SW_SHOW)

While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then
        Exit
    ElseIf $msg = $calculate_btn Then
        Calculate()
    ElseIf $msg = $copy_btn Then
        ClipPut(GUICtrlRead($result_text))
    EndIf
WEnd

Func CreateInput($label, $x, $y, ByRef $name, $default_value = 0)
    GUICtrlCreateLabel($label, $x, $y, 100, 20)
    $name = GUICtrlCreateInput($default_value, $x + 110, $y - 3, 150, 20)
    GUICtrlSetState(-1, $GUI_DROPACCEPTED)
EndFunc

Func CreateRadio($label, $x, $y, ByRef $radio_buttons)
    GUICtrlCreateLabel($label, $x, $y, 100, 20)
    GUICtrlCreateGroup("", $x + 110, $y - 10, 150, 30)
    $radio_buttons[0] = GUICtrlCreateRadio("等额本息", $x + 120, $y)
    $radio_buttons[1] = GUICtrlCreateRadio("等额本金", $x + 180, $y)
    GUICtrlCreateGroup("", -99, -99) ; 结束分组
EndFunc

Func Calculate()
    Global $basic_salary, $housing_fund_rate, $pension_rate, $mortgage_total
    Global $mortgage_rate, $mortgage_years, $mortgage_method
    Global $car_loan_total, $car_loan_rate, $car_loan_years, $car_loan_method
    Global $radio_buttons_mortgage, $radio_buttons_car_loan

    Local $basic_salary_value = GUICtrlRead($basic_salary)
    Local $housing_fund_rate_value = GUICtrlRead($housing_fund_rate) / 100
    Local $pension_rate_value = GUICtrlRead($pension_rate) / 100
    Local $mortgage_total_value = GUICtrlRead($mortgage_total)
    Local $mortgage_rate_value = GUICtrlRead($mortgage_rate) / 100 / 12
    Local $mortgage_years_value = GUICtrlRead($mortgage_years) * 12
    Local $mortgage_method_value = GetSelectedRadio($radio_buttons_mortgage)
    Local $car_loan_total_value = GUICtrlRead($car_loan_total)
    Local $car_loan_rate_value = GUICtrlRead($car_loan_rate) / 100 / 12
    Local $car_loan_years_value = GUICtrlRead($car_loan_years) * 12
    Local $car_loan_method_value = GetSelectedRadio($radio_buttons_car_loan)

    ; 输出调试信息
    ConsoleWrite("基本工资: " & $basic_salary_value & @CRLF)
    ConsoleWrite("住房公积金比例: " & $housing_fund_rate_value & @CRLF)
    ConsoleWrite("养老保险比例: " & $pension_rate_value & @CRLF)
    ConsoleWrite("房贷总额: " & $mortgage_total_value & @CRLF)
    ConsoleWrite("房贷利率: " & $mortgage_rate_value & @CRLF)
    ConsoleWrite("房贷年限 (月): " & $mortgage_years_value & @CRLF)
    ConsoleWrite("房贷计算方式: " & $mortgage_method_value & @CRLF)
    ConsoleWrite("车贷总额: " & $car_loan_total_value & @CRLF)
    ConsoleWrite("车贷利率: " & $car_loan_rate_value & @CRLF)
    ConsoleWrite("车贷年限 (月): " & $car_loan_years_value & @CRLF)
    ConsoleWrite("车贷计算方式: " & $car_loan_method_value & @CRLF)

    Local $housing_fund = $basic_salary_value * $housing_fund_rate_value
    Local $pension = $basic_salary_value * $pension_rate_value

    Local $mortgage_payment, $mortgage_details
    $mortgage_payment = CalculateLoanPayment($mortgage_total_value, $mortgage_rate_value, $mortgage_years_value, $mortgage_method_value, $mortgage_details)

    Local $car_loan_payment, $car_loan_details
    $car_loan_payment = CalculateLoanPayment($car_loan_total_value, $car_loan_rate_value, $car_loan_years_value, $car_loan_method_value, $car_loan_details)

    ; 输出调试信息
    ConsoleWrite("房贷每月还款: " & $mortgage_payment & @CRLF)
    ConsoleWrite("房贷详细信息: " & @CRLF & $mortgage_details & @CRLF)
    ConsoleWrite("车贷每月还款: " & $car_loan_payment & @CRLF)
    ConsoleWrite("车贷详细信息: " & @CRLF & $car_loan_details & @CRLF)

    Local $net_salary = $basic_salary_value - $housing_fund - $pension - $mortgage_payment - $car_loan_payment

    Local $result = "住房公积金: " & Round($housing_fund, 2) & " 元" & @CRLF & _
                    "养老保险: " & Round($pension, 2) & " 元" & @CRLF & _
                    "房贷偿还: " & Round($mortgage_payment, 2) & " 元 (" & ($mortgage_method_value = 1 ? "等额本息" : "等额本金") & ")" & @CRLF & _
                    "车贷偿还: " & Round($car_loan_payment, 2) & " 元 (" & ($car_loan_method_value = 1 ? "等额本息" : "等额本金") & ")" & @CRLF & _
                    "扣除后的工资: " & Round($net_salary, 2) & " 元" & @CRLF & @CRLF & _
                    "房贷详细信息:" & @CRLF & $mortgage_details & @CRLF & _
                    "车贷详细信息:" & @CRLF & $car_loan_details

    GUICtrlSetData($result_text, $result)
EndFunc

Func CalculateLoanPayment($principal, $monthly_rate, $months, $method, ByRef $details)
    $details = ""
    Local $payment
    If $months = 0 Then Return 0
    If $method = 1 Then ; 等额本息
        If $monthly_rate = 0 Then
            $payment = $principal / $months
            For $i = 1 To $months
                $details &= "第 " & $i & " 个月: " & Round($payment, 2) & " 元" & @CRLF
            Next
            Return $payment
        EndIf
        $payment = $principal * $monthly_rate * Exp(Log(1 + $monthly_rate) * $months) / (Exp(Log(1 + $monthly_rate) * $months) - 1)
        For $i = 1 To $months
            $details &= "第 " & $i & " 个月: " & Round($payment, 2) & " 元" & @CRLF
        Next
        Return $payment
    ElseIf $method = 2 Then ; 等额本金
        Local $principal_payment = $principal / $months
        For $i = 1 To $months
            Local $interest_payment = ($principal - ($i - 1) * $principal_payment) * $monthly_rate
            $payment = $principal_payment + $interest_payment
            $details &= "第 " & $i & " 个月: " & Round($payment, 2) & " 元" & @CRLF
        Next
        Return $payment
    EndIf
EndFunc

Func GetSelectedRadio($radio_buttons)
    For $i = 0 To UBound($radio_buttons) - 1
        If BitAND(GUICtrlRead($radio_buttons[$i]), $GUI_CHECKED) Then
            Return $i + 1
        EndIf
    Next
    Return 0
EndFunc

能够帮助大家轻松计算住房公积金、养老保险、房贷和车贷的每月偿还金额,并提供详细的还款计划。
这个工具有两个版本,一个是用Python编写的,另一个是用AutoIt编写的,大家可以根据自己的需求选择使用。
功能特点
  • 住房公积金和养老保险计算
    • 根据输入的基本工资,计算出住房公积金和养老保险的金额。
  • 房贷和车贷每月偿还金额计算
    • 支持输入房贷和车贷的总额、利率和年限,计算每月的偿还金额。
  • 两种贷款计算方式
    • 提供等额本息和等额本金两种计算方式。
  • 详细还款计划
    • 显示每月还款计划,直到还款期结束。
  • 结果复制功能
    • 计算结果可以复制,方便保存或进一步处理。
  • 图形用户界面
    • 简洁友好的图形用户界面,方便输入数据并获取计算结果。

程序截图:(请在此插入程序的截图,包括输入界面和结果显示界面)
下载链接
  • 链接:https://pan.baidu.com/s/1FHHRwpA-l3wV9GVXPkzePw
  • 提取码:1jav

使用说明
  • 启动程序后,输入基本工资、住房公积金比例、养老保险比例。
  • 输入房贷和车贷的总额、利率和年限,并选择计算方式(等额本息或等额本金)。
  • 点击“计算”按钮,程序将显示计算结果,包括住房公积金、养老保险金额、房贷和车贷每月偿还金额以及扣除后的工资。
  • 详细的每月还款计划将显示在结果框中,用户可以复制结果进行进一步处理或保存。

系统需求
  • Python版:需要安装Python 3.x及相关库(如tkinter)。
  • AutoIt版:需要Windows操作系统,且已安装AutoIt。

感谢:感谢吾爱破解论坛和社区对本程序的支持与帮助。特别感谢所有提供反馈和建议的用户,你们的支持是我不断改进和完善的动力。
如有任何问题或建议,请在帖子下方留言或联系我。希望这款工具能对大家有所帮助!
编写人:吾爱破解1125xiaoyu
希望大家喜欢并多多支持!谢谢!
1.jpg

py源码.txt

5.73 KB, 下载次数: 17, 下载积分: 吾爱币 -2 CB

免费评分

参与人数 5吾爱币 +9 热心值 +4 收起 理由
ulife + 1 不知大佬,是否可以为房贷增加利率调整及提前还贷的功能
xiaohang621 + 1 谢谢@Thanks!
667337 + 1 1
简减 + 1 + 1 感谢发布原创作品,吾爱破解论坛因你更精彩!
风之暇想 + 7 + 1 感谢发布原创作品,吾爱破解论坛因你更精彩!

查看全部评分

本帖被以下淘专辑推荐:

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

ulife 发表于 2024-8-16 14:02
希望大佬可以为房贷增加利率调整及提前还贷的功能,当利率发生变化或提前还部分贷款后,计算新的每月还款金额
fanliansuo1 发表于 2024-7-26 23:17
kashliu 发表于 2024-7-27 08:45
haobuhao 发表于 2024-7-27 09:58
简洁实用,学习下
bujimo3 发表于 2024-7-27 10:36
简洁实用,感谢分享
ytfihc 发表于 2024-7-27 10:45
学习,学习
简减 发表于 2024-7-27 11:02
感谢分享原创工具,收藏了
langjuxv 发表于 2024-7-27 11:08
ε=(&#180;ο`*)))唉,打工人一个。没公积金。。。
qjz159 发表于 2024-7-27 13:18
简洁实用,感谢分享
Fandeying225 发表于 2024-7-27 15:15
学习,小东西还怪有意思呢
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则

返回列表

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-11-22 16:00

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表