{"type":"doc","content":[{"type":"paragraph","attrs":{"id":"25780310-5e2a-4c3c-b4ce-7765d1b494e8","textAlign":"inherit","indent":0,"color":null,"background":null,"isHoverDragHandle":false},"content":[{"type":"text","text":"固定资产多、卡片几十张,每月折旧手工算易错。本文用 pandas 按直线法(年限平均)自动算每张卡片的月折旧额、累计折旧、账面净值,并输出一张折旧测算表。"}]},{"type":"paragraph","attrs":{"id":"c0064f17-061a-42be-9e33-3285be5d11d5","textAlign":"inherit","indent":0,"color":null,"background":null,"isHoverDragHandle":false},"content":[{"type":"text","text":"一、数据假设"}]},{"type":"paragraph","attrs":{"id":"5df97dec-3943-4a25-a799-60dbb05f363e","textAlign":"inherit","indent":0,"color":null,"background":null,"isHoverDragHandle":false},"content":[{"type":"text","text":"fa.xlsx 至少包含这些列(代码中用英文列名,便于直接运行):"}]},{"type":"bulletList","attrs":{"id":"d1f43903-9b3c-40d8-aeb7-b69baa1653fe","isHoverDragHandle":false},"content":[{"type":"listItem","attrs":{"id":"378f1c8a-b208-40a0-b855-6e68eee9fbbe"},"content":[{"type":"paragraph","attrs":{"id":"58811b6c-f749-4137-8716-476ee0ac8cf6","textAlign":"inherit","indent":0,"color":null,"background":null,"isHoverDragHandle":false},"content":[{"type":"text","text":"name 资产名称"}]}]},{"type":"listItem","attrs":{"id":"26b83e28-e0b4-4331-9b6b-82ac9af48ef3"},"content":[{"type":"paragraph","attrs":{"id":"c0a1cfd7-8dd4-4113-b63b-672e6f94a7a7","textAlign":"inherit","indent":0,"color":null,"background":null,"isHoverDragHandle":false},"content":[{"type":"text","text":"cost 原值"}]}]},{"type":"listItem","attrs":{"id":"6efa64ba-a0a8-464e-a8a9-e13252e48595"},"content":[{"type":"paragraph","attrs":{"id":"f1e7cec1-db7c-4d4f-9536-91ec320bbc8a","textAlign":"inherit","indent":0,"color":null,"background":null,"isHoverDragHandle":false},"content":[{"type":"text","text":"salvage 残值"}]}]},{"type":"listItem","attrs":{"id":"37a7a07b-e71e-46f1-b5fb-08c51a3380c8"},"content":[{"type":"paragraph","attrs":{"id":"efa6a727-1366-4d3d-84d2-e3b24bbaf112","textAlign":"inherit","indent":0,"color":null,"background":null,"isHoverDragHandle":false},"content":[{"type":"text","text":"life 使用年限(年)"}]}]},{"type":"listItem","attrs":{"id":"d619ac35-c214-43fd-b8c8-1b0c9e8bd50f"},"content":[{"type":"paragraph","attrs":{"id":"eded21fd-8fe7-4b3f-8aa5-43348202285c","textAlign":"inherit","indent":0,"color":null,"background":null,"isHoverDragHandle":false},"content":[{"type":"text","text":"start 开始计提日期"}]}]},{"type":"listItem","attrs":{"id":"2773a3df-463a-40a4-bb52-b67a2f5761bc"},"content":[{"type":"paragraph","attrs":{"id":"c27ff939-f3bd-453f-b55a-3d2180d08c70","textAlign":"inherit","indent":0,"color":null,"background":null,"isHoverDragHandle":false},"content":[{"type":"text","text":"base 计提基准日(如 2026-06-30)"}]}]}]},{"type":"paragraph","attrs":{"id":"6216c9c5-88c2-418d-952d-ded1b8a0d62f","textAlign":"inherit","indent":0,"color":null,"background":null,"isHoverDragHandle":false},"content":[{"type":"text","text":"(实战把路径和列名换成你自己的即可)"}]},{"type":"paragraph","attrs":{"id":"f4977de4-d688-49bc-b3cb-5ce36a84cc4f","textAlign":"inherit","indent":0,"color":null,"background":null,"isHoverDragHandle":false},"content":[{"type":"text","text":"二、核心思路"}]},{"type":"orderedList","attrs":{"id":"81efc4be-9a86-4cec-a425-70b4e2ca9300","start":1,"isHoverDragHandle":false},"content":[{"type":"listItem","attrs":{"id":"7f1a2482-63b7-4743-b25c-3ca02f360a18"},"content":[{"type":"paragraph","attrs":{"id":"246947b8-052c-4132-95b7-4a5b07c3e4a8","textAlign":"inherit","indent":0,"color":null,"background":null,"isHoverDragHandle":false},"content":[{"type":"text","text":"月折旧额 = (原值 - 残值) / (年限 * 12);"}]}]},{"type":"listItem","attrs":{"id":"6e060c1b-f6ce-4897-8432-e54b077fae5c"},"content":[{"type":"paragraph","attrs":{"id":"d64786ab-abb8-48e5-a619-de3c8b1ac778","textAlign":"inherit","indent":0,"color":null,"background":null,"isHoverDragHandle":false},"content":[{"type":"text","text":"已计提月数 = 基准日 - 开始计提日(按月);"}]}]},{"type":"listItem","attrs":{"id":"0a63074e-0004-40a7-90b6-815b2d5135a1"},"content":[{"type":"paragraph","attrs":{"id":"2c819fce-060a-4f7d-97d7-763c1f9aa18e","textAlign":"inherit","indent":0,"color":null,"background":null,"isHoverDragHandle":false},"content":[{"type":"text","text":"累计折旧 = 月折旧额 * 已计提月数(不超过原值 - 残值);"}]}]},{"type":"listItem","attrs":{"id":"6092d174-ef54-49e7-b974-2acba1a68211"},"content":[{"type":"paragraph","attrs":{"id":"c346c142-f6e9-440c-a688-869b7f3a2dae","textAlign":"inherit","indent":0,"color":null,"background":null,"isHoverDragHandle":false},"content":[{"type":"text","text":"账面净值 = 原值 - 累计折旧。"}]}]}]},{"type":"paragraph","attrs":{"id":"3af82d7c-e7c3-47fd-b85a-8439a0c1bbd6","textAlign":"inherit","indent":0,"color":null,"background":null,"isHoverDragHandle":false},"content":[{"type":"text","text":"三、完整代码(自包含,可直接跑)"}]},{"type":"codeBlock","attrs":{"id":"a115ad5f-fcd1-44c0-a250-1f64df6e2897","language":"javascript","theme":"atom-one-dark","runtimes":0,"isHoverDragHandle":false,"key":"","languageByAi":"javascript"},"content":[{"type":"text","text":"import pandas as pd\n\nbase_date = pd.Timestamp(\"2026-06-30\")\nfa = pd.DataFrame({\n \"name\": [\"Machine A\", \"Vehicle B\", \"Building C\"],\n \"cost\": [120000, 300000, 2000000],\n \"salvage\": [12000, 30000, 200000],\n \"life\": [10, 5, 20],\n \"start\": [\"2024-01-15\", \"2025-06-01\", \"2023-03-10\"],\n})\nfa[\"start\"] = pd.to_datetime(fa[\"start\"])\n\nfa[\"monthly\"] = ((fa[\"cost\"] - fa[\"salvage\"]) / (fa[\"life\"] * 12)).round(2)\nfa[\"months_used\"] = ((base_date.year - fa[\"start\"].dt.year) * 12 +\n (base_date.month - fa[\"start\"].dt.month))\nfa[\"months_used\"] = fa[\"months_used\"].clip(lower=0)\n\nmax_dep = fa[\"cost\"] - fa[\"salvage\"]\nfa[\"accum\"] = (fa[\"monthly\"] * fa[\"months_used\"]).clip(upper=max_dep).round(2)\nfa[\"net\"] = (fa[\"cost\"] - fa[\"accum\"]).round(2)\n\nprint(fa[[\"name\", \"monthly\", \"months_used\", \"accum\", \"net\"]])\n"}]},{"type":"paragraph","attrs":{"id":"9d911fbe-6c23-4693-8211-1ee796f13dfc","textAlign":"inherit","indent":0,"color":null,"background":null,"isHoverDragHandle":false},"content":[{"type":"text","text":"四、几个实战坑"}]},{"type":"bulletList","attrs":{"id":"aa27ea54-3c12-497d-9adf-39cff89df490","isHoverDragHandle":false},"content":[{"type":"listItem","attrs":{"id":"90e79d34-6e7e-4f77-8b11-fd9a6ece6611"},"content":[{"type":"paragraph","attrs":{"id":"6a780eb5-cfe8-4027-a619-232bddef8dc5","textAlign":"inherit","indent":0,"color":null,"background":null,"isHoverDragHandle":false},"content":[{"type":"text","text":"当月增加的固定资产当月不提折旧(次月起提),months_used 要减 1,代码里基数按\"满月\"算,实际需按企业政策微调;"}]}]},{"type":"listItem","attrs":{"id":"e980f4d7-06b5-472d-9793-d38354e5252c"},"content":[{"type":"paragraph","attrs":{"id":"86c46e52-2e78-4356-bc98-1dfa0d48ac10","textAlign":"inherit","indent":0,"color":null,"background":null,"isHoverDragHandle":false},"content":[{"type":"text","text":"残值率、折旧年限要对照税法与会计政策,不一致做纳税调整;"}]}]},{"type":"listItem","attrs":{"id":"7fd6dede-593e-44b1-b40f-13ce8d62c221"},"content":[{"type":"paragraph","attrs":{"id":"be03dfe7-18e1-4fee-941c-65490e4e0e5b","textAlign":"inherit","indent":0,"color":null,"background":null,"isHoverDragHandle":false},"content":[{"type":"text","text":"已提足折旧仍在使用(months_used 超上限)的,clip 到上限防超额;"}]}]},{"type":"listItem","attrs":{"id":"38dd2b27-b941-404c-9d12-9cb573c6d46c"},"content":[{"type":"paragraph","attrs":{"id":"935274f6-f82d-4831-9450-13ee221c2f01","textAlign":"inherit","indent":0,"color":null,"background":null,"isHoverDragHandle":false},"content":[{"type":"text","text":"减值准备的资产要先扣减值再算;"}]}]},{"type":"listItem","attrs":{"id":"7bfa9ce8-1a38-4301-92c8-58e95f0a134c"},"content":[{"type":"paragraph","attrs":{"id":"fbb9e09d-b8da-437b-aab5-9bbd144edcb1","textAlign":"inherit","indent":0,"color":null,"background":null,"isHoverDragHandle":false},"content":[{"type":"text","text":"读 csv 注意指定编码为 gbk(Windows 中文环境),xlsx 一般无此问题。"}]}]}]},{"type":"paragraph","attrs":{"id":"2ca0e55f-a476-47c3-9a0c-bb1dc1371131","textAlign":"inherit","indent":0,"color":null,"background":null,"isHoverDragHandle":false},"content":[{"type":"text","text":"五、边界"}]},{"type":"paragraph","attrs":{"id":"8ba2f89d-62d3-4ac8-ae7a-a97dea25f0d0","textAlign":"inherit","indent":0,"color":null,"background":null,"isHoverDragHandle":false},"content":[{"type":"text","text":"脚本只负责按规则算数,折旧政策、年限、残值率由注册会计师和企业确认。客户数据本地跑,别贴通用云端大模型。"}]},{"type":"paragraph","attrs":{"id":"84b2003d-9835-403d-9065-1b8c3fdda6ff","textAlign":"inherit","indent":0,"color":null,"background":null,"isHoverDragHandle":false},"content":[{"type":"text","text":"我是会计师事务所的一名注册会计师,做过财报审计、经济责任审计、专项审计、尽职调查、内控评价各类项目,从手写底稿到 AI 辅助都经历过。如果你也在财务 / 审计岗位想提效,欢迎关注、交流实战。"}]},{"type":"paragraph","attrs":{"id":"fa766931-6fe9-4bd4-ac9f-df5ce8d5b9fb","textAlign":"inherit","indent":0,"color":null,"background":null,"isHoverDragHandle":false},"content":[{"type":"text","text":"感谢你看到这里。如果这段代码对你有用,欢迎点赞 + 收藏 + 关注——我是会计师事务所的一名注册会计师,会继续分享审计提效与 Python 实战,咱们下篇见。"}]}]}