fix: 出库单金额使用刷卡金额,单价由刷卡金额反算
This commit is contained in:
@@ -9,6 +9,7 @@ from __future__ import annotations
|
||||
import argparse
|
||||
import re
|
||||
import shutil
|
||||
from datetime import date
|
||||
from pathlib import Path
|
||||
|
||||
from . import get_logger
|
||||
@@ -79,14 +80,10 @@ def _format_money(value: str | float) -> str:
|
||||
return f"{num:.2f}"
|
||||
|
||||
|
||||
def _format_cn_date(date_str: str) -> str:
|
||||
if not date_str:
|
||||
return ""
|
||||
parts = date_str.replace("-", "/").split("/")
|
||||
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 _today_cn_date() -> str:
|
||||
"""当前日期,格式:2026年5月26日"""
|
||||
today = date.today()
|
||||
return f"{today.year}年{today.month}月{today.day}日"
|
||||
|
||||
|
||||
def _apply_font(rng) -> None:
|
||||
@@ -159,9 +156,7 @@ def fill_consumable_doc(
|
||||
doc = word.Documents.Open(str(doc_path.resolve()))
|
||||
|
||||
try:
|
||||
if invoices:
|
||||
cn_date = _format_cn_date(invoices[0].get("invoice_date", ""))
|
||||
_replace_date_in_doc(doc, cn_date)
|
||||
_replace_date_in_doc(doc, _today_cn_date())
|
||||
|
||||
tbl = doc.Tables(1)
|
||||
storage = config.get("consumable_storage", "躬行楼 C205")
|
||||
@@ -172,11 +167,16 @@ def fill_consumable_doc(
|
||||
break
|
||||
|
||||
parsed = parse_spec_model(inv.get("spec_model", ""))
|
||||
amount = _format_money(inv.get("total_amount", ""))
|
||||
unit_price = _format_money(parsed["unit_price"])
|
||||
qty = parsed["qty"]
|
||||
if qty and qty.isdigit():
|
||||
qty = str(int(qty))
|
||||
card_amount = inv.get("card_amount") or 0
|
||||
qty_str = parsed["qty"]
|
||||
qty_val = int(qty_str) if qty_str and qty_str.isdigit() else 0
|
||||
|
||||
# 金额填写刷卡金额,单价由刷卡金额反算
|
||||
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 = [
|
||||
str(inv.get("seq", i + 1)),
|
||||
|
||||
Reference in New Issue
Block a user