fix: 出库单金额使用刷卡金额,单价由刷卡金额反算
This commit is contained in:
@@ -128,6 +128,7 @@ python -m app.fill_consumable_doc --no-backup # 不生成 .doc.bak 备份
|
|||||||
|
|
||||||
填写规则概要:
|
填写规则概要:
|
||||||
|
|
||||||
|
- 表头「日期」使用**填写当天**的日期(非发票开票日期)
|
||||||
- 从 `规格型号` 解析品名、规格、单位、数量、单价;`价税合计` 写入金额列
|
- 从 `规格型号` 解析品名、规格、单位、数量、单价;`价税合计` 写入金额列
|
||||||
- 单价/金额保留两位小数;表格内统一为 **宋体五号(10.5 磅)**
|
- 单价/金额保留两位小数;表格内统一为 **宋体五号(10.5 磅)**
|
||||||
- 存放地点取自 `consumable_storage`;购货人/领用人签字、备注保持空白
|
- 存放地点取自 `consumable_storage`;购货人/领用人签字、备注保持空白
|
||||||
@@ -201,7 +202,6 @@ python web/app.py
|
|||||||
## 注意事项
|
## 注意事项
|
||||||
|
|
||||||
- 浏览器填报时会打开或使用 Chromium,请勿手动干扰自动化流程
|
- 浏览器填报时会打开或使用 Chromium,请勿手动干扰自动化流程
|
||||||
- 首次运行可能需要处理 SSO 登录(已保存会话时可跳过)
|
|
||||||
- 调试截图保存在 `images/` 目录
|
- 调试截图保存在 `images/` 目录
|
||||||
- OCR 不会覆盖 CSV 中已有非空字段
|
- OCR 不会覆盖 CSV 中已有非空字段
|
||||||
- 项目根目录需保留 `易耗品、出库单.doc` 模板;Web 每次从模板复制到会话目录再填写,不修改原模板
|
- 项目根目录需保留 `易耗品、出库单.doc` 模板;Web 每次从模板复制到会话目录再填写,不修改原模板
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ from __future__ import annotations
|
|||||||
import argparse
|
import argparse
|
||||||
import re
|
import re
|
||||||
import shutil
|
import shutil
|
||||||
|
from datetime import date
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from . import get_logger
|
from . import get_logger
|
||||||
@@ -79,14 +80,10 @@ def _format_money(value: str | float) -> str:
|
|||||||
return f"{num:.2f}"
|
return f"{num:.2f}"
|
||||||
|
|
||||||
|
|
||||||
def _format_cn_date(date_str: str) -> str:
|
def _today_cn_date() -> str:
|
||||||
if not date_str:
|
"""当前日期,格式:2026年5月26日"""
|
||||||
return ""
|
today = date.today()
|
||||||
parts = date_str.replace("-", "/").split("/")
|
return f"{today.year}年{today.month}月{today.day}日"
|
||||||
if len(parts) != 3:
|
|
||||||
return date_str
|
|
||||||
y, m, d = parts[0], str(int(parts[1])), str(int(parts[2]))
|
|
||||||
return f"{y}年{m}月{d}日"
|
|
||||||
|
|
||||||
|
|
||||||
def _apply_font(rng) -> None:
|
def _apply_font(rng) -> None:
|
||||||
@@ -159,9 +156,7 @@ def fill_consumable_doc(
|
|||||||
doc = word.Documents.Open(str(doc_path.resolve()))
|
doc = word.Documents.Open(str(doc_path.resolve()))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if invoices:
|
_replace_date_in_doc(doc, _today_cn_date())
|
||||||
cn_date = _format_cn_date(invoices[0].get("invoice_date", ""))
|
|
||||||
_replace_date_in_doc(doc, cn_date)
|
|
||||||
|
|
||||||
tbl = doc.Tables(1)
|
tbl = doc.Tables(1)
|
||||||
storage = config.get("consumable_storage", "躬行楼 C205")
|
storage = config.get("consumable_storage", "躬行楼 C205")
|
||||||
@@ -172,11 +167,16 @@ def fill_consumable_doc(
|
|||||||
break
|
break
|
||||||
|
|
||||||
parsed = parse_spec_model(inv.get("spec_model", ""))
|
parsed = parse_spec_model(inv.get("spec_model", ""))
|
||||||
amount = _format_money(inv.get("total_amount", ""))
|
card_amount = inv.get("card_amount") or 0
|
||||||
unit_price = _format_money(parsed["unit_price"])
|
qty_str = parsed["qty"]
|
||||||
qty = parsed["qty"]
|
qty_val = int(qty_str) if qty_str and qty_str.isdigit() else 0
|
||||||
if qty and qty.isdigit():
|
|
||||||
qty = str(int(qty))
|
# 金额填写刷卡金额,单价由刷卡金额反算
|
||||||
|
amount = _format_money(card_amount)
|
||||||
|
unit_price = _format_money(card_amount / qty_val) if qty_val > 0 else _format_money(card_amount)
|
||||||
|
|
||||||
|
# 数量:去掉前导零
|
||||||
|
qty = str(qty_val) if qty_val > 0 else ""
|
||||||
|
|
||||||
values = [
|
values = [
|
||||||
str(inv.get("seq", i + 1)),
|
str(inv.get("seq", i + 1)),
|
||||||
|
|||||||
BIN
易耗品、出库单.doc
BIN
易耗品、出库单.doc
Binary file not shown.
Reference in New Issue
Block a user