Plutus Lite — Expense Tracker (Free) — Plutus Lite — 费用跟踪器(免费)
v1.0.0Plutus Lite — 费用跟踪器(免费)。可分类最多 15 项交易,并查看基本的支出明细。这是 Plutus Pro 为您提供的全面功能的免费预览。
运行时依赖
安装命令
点击复制技能文档
Plutus Lite — 免费支出预览 粘贴最多 15 项支出,快速查看分类明细。 免费版与专业版功能对比 Plutus Lite(免费) Plutus Pro 交易 15 项最大值 无限制 CSV 文件输入 预算比较 月度趋势 税款扣除跟踪 储蓄率分析 支出预测 1-12 个月导出(CSV + JSON) Upgrade:openclaw skills 安装 plutus-pro — 关键在 ko-fi.com/occupythemilkyway
步骤 1 — 安装 pip3 install rich --break-system-packages --quiet
步骤 2 — 快速支出扫描(Lite) 导入 os、re 从 datetime 导入 date 从 collections 导入 defaultdict 从 rich.console 导入 Console 从 rich.table 导入 Table 从 rich.panel 导入 Panel 从 rich 导入 box console = Console() EXPENSES_TEXT = os.environ.get("EXPENSES_TEXT","").strip() CURRENCY = os.environ.get("CURRENCY","USD").upper() SYM = {"USD":"$","EUR":"€","GBP":"£"}.get(CURRENCY,"$") TODAY = date.today() TX_LIMIT = 15
定义 fmt(a): 返回 f"{SYM}{a:,.2f}"
定义 parse_amount(raw): c = re.sub(r"[^0-9.]","",str(raw)) 或 "0" 尝试: 返回 float(c) 如果 c.count(".")<=1 否则返回 None 异常: 返回 None
CATEGORIES = { "Food & Dining": ["coffee","starbucks","restaurant","pizza","burger","cafe","food","doordash","grubhub","grocery","walmart","whole foods"], "Transport": ["uber","lyft","taxi","gas","fuel","parking","transit","bus","train","flight"], "Shopping": ["amazon","ebay","etsy","target","bestbuy","clothing","shoes"], "Subscriptions": ["netflix","spotify","hulu","disney","prime","subscription","membership","software"], "Utilities": ["electric","water","internet","phone","mobile","utility","bill"], "Health": ["pharmacy","doctor","dentist","medical","gym","fitness","cvs","walgreens"], "Entertainment": ["movie","cinema","concert","ticket","game","gaming","book"], "Other": [], }
定义 categorise(desc): dl = desc.lower() 对于 cat, kws 在 CATEGORIES.items(): 如果 cat == "Other": 继续 如果任何 k 在 dl: 返回 cat 返回 "Other"
transactions = [] 如果 EXPENSES_TEXT: 对于 line 在 EXPENSES_TEXT.strip().splitlines(): 如果 len(transactions) >= TX_LIMIT: console.print(f"[yellow]_lite 限制:显示前 {TX_LIMIT} 笔交易。升级到 Pro 以获取无限制。[/yellow]") 中断 line = line.strip() 如果不 line: 继续 tokens = line.split() amt = None 对于 tok 在 reversed(tokens): a = parse_amount(tok) 如果 a 不是 None: amt = a; 中断 如果 amt 是 None: 继续 desc_tokens = tokens[:-1] 如果 tokens[-1] == str(amt) 否则 [t 为 t 在 tokens 如果 parse_amount(t) != amt] 如果 len(desc_tokens) >= 2: 尝试: int(desc_tokens[0]) desc_tokens = desc_tokens[1:] 除 ValueError: 传递 description = " ".join(desc_tokens) 或 "Expense" transactions.append({"description": description, "amount": amt, "category": categorise(description)}) 否则: console.print("[yellow]_no EXPENSES_TEXT 设置 — 使用演示数据。[/yellow]") console.print("[dim]设置 EXPENSES_TEXT='Coffee 4.50\nAmazon 34.99\nUber 18.30' 以使用您自己的。\n[/dim]") demo = [ ("Starbucks coffee",5.50), ("Uber ride",18.30), ("Netflix",15.99), ("Groceries Walmart",87.45), ("Amazon order",34.99), ("Restaurant dinner",62.00), ("Gas station",55.00), ("Spotify premium",9.99), ("CVS pharmacy",22.10), ("Gym membership",45.00), ] 对于 desc,amt 在 demo: transactions.append({"description":desc,"amount":amt,"category":categorise(desc)}) 如果不 transactions: console.print("[yellow]没有找到交易。[/yellow]") 引发 SystemExit(0) total_spend = sum(t["amount"] 为 t 在 transactions) console.print() console.print(Panel.fit( f"[bold green]_plutus Lite — 支出快照[/bold green]\n" f"交易:[yellow]{len(transactions)}/{TX_LIMIT}[/yellow] 总计:[red]{fmt(total_spend)}[/red]\n" f"[dim]Lite:{TX_LIMIT} 交易最大值 — 升级到 Pro 以获取无限制 + 全面分析[/dim]", border_style="green" ))
类别总计 cat_totals = defaultdict(float) 对于 t 在 transactions: cat_totals[t["category"]] += t["amount"] console.print() tbl = Table(title="按类别支出", box=box.ROUNDED, border_style="green") tbl.add_column("类别", width=20, style="cyan") tbl.add_column(f"总计 ({CURRENCY})", width=14, justify="right", style="red") tbl.add_column("% of 支出", width=12, justify="right", style="yellow") 对于 cat,total 在 sorted(cat_totals.items(),key=lambda x:-x[1]): pct = total/total_spend*100 如果 total_spend 否则 0 tbl.add_row(cat, fmt(total), f"{pct:.1f}%") console.print(tbl)
交易列表 console.print() tx_tbl = Table(title="交易列表"