feat(invoice-check): 通过invoice号反查tghx的采购单,生成PO订单

This commit is contained in:
sophie committed 2026-09-15 16:15:08 +08:00
1 parent 1c34ab962f
commit 40cead7430
27 files changed
+792 -74

No files matched your search

+3 -1
View File
@@ -103,12 +103,14 @@ def create_app(config_name='default'):
try:
from app.services.voucher_check.schedule_seed import (
ensure_default_voucher_check_schedule,
ensure_default_voucher_po_print_schedule,
register_voucher_check_schedule_hooks,
)
register_voucher_check_schedule_hooks()
ensure_default_voucher_check_schedule()
ensure_default_voucher_po_print_schedule()
except Exception as exc: # pragma: no cover - 表未就绪时容忍
logger.warning('Failed to ensure accounting-voucher-check schedule: %s', exc)
logger.warning('Failed to ensure accounting-voucher-check / po-print schedules: %s', exc)
try:
from app.services.contract_payment.schedule_seed import ensure_default_contract_payment_schedules
ensure_default_contract_payment_schedules()
+40 -2
View File
@@ -2,7 +2,7 @@
backend/app/services/schedule/job_registry.py
用途:平台内置排程 Job Registry(任务契约中心:key → handler + 展示信息 + params_schema + defaults)。
依赖:shipping_inventory_rpa_job、faq_hot_aggregate_job、fixed_assets_snapshot_job、voucher_check_job、job_params。
依赖:shipping_inventory_rpa_job、faq_hot_aggregate_job、fixed_assets_snapshot_job、voucher_check_job、voucher_po_print_job、job_params。
逻辑:internal_jobs API 与 platform_job 排程通过 platform_api_path 引用已注册 key;
api/schedule/platform_tasks.py 下发 params_schema 供前端 DynamicTaskParamsForm 通用渲染。
"""
@@ -140,11 +140,12 @@ def _register_builtin_platform_jobs() -> None:
run_shipping_post_ot_auto_fulfill_compensation_schedule,
)
from app.services.schedule.voucher_check_job import run_voucher_check_schedule
from app.services.schedule.voucher_po_print_job import run_voucher_po_print_schedule
from app.services.schedule.contract_payment_job import (
run_contract_payment_alert_schedule,
run_contract_payment_sync_schedule,
)
from app.services.voucher_check.config import DEFAULT_JOB_PARAMS
from app.services.voucher_check.config import DEFAULT_JOB_PARAMS, DEFAULT_PO_PRINT_JOB_PARAMS
from app.services.schedule.contract_payment_job import (
run_contract_payment_alert_schedule,
run_contract_payment_sync_schedule,
@@ -379,6 +380,43 @@ def _register_builtin_platform_jobs() -> None:
),
defaults=dict(DEFAULT_JOB_PARAMS),
))
register_platform_job(PlatformJobDefinition(
key="accounting-voucher-po-print",
label="立账凭证 PO 订单生成",
label_key="admin.schedule.form.platformJobAccountingVoucherPoPrint",
handler=run_voucher_po_print_schedule,
description="每周二 05:00 按上月发票从 TGHX 取数,生成制式采购单 PDF 并上传到「PO订单」;早于 06:00 检核周批。",
description_key="admin.schedule.form.accountingVoucherPoPrintHint",
category="finance",
params_schema=(
{
"key": "scope_code",
"type": "select",
"label": "账套",
"label_key": "admin.schedule.form.voucherCheckScope",
"required": True,
"default": "HXJM",
"options": [{"value": "HXJM", "label": "HXJM"}],
},
{
"key": "profile_code",
"type": "text",
"label": "业务方 Profile",
"label_key": "admin.schedule.form.voucherCheckProfile",
"required": True,
"default": "sales",
},
{
"key": "notify_failure_enabled",
"type": "boolean",
"label": "失败告警",
"label_key": "admin.schedule.form.voucherCheckNotifyFailure",
"required": False,
"default": True,
},
),
defaults=dict(DEFAULT_PO_PRINT_JOB_PARAMS),
))
register_platform_job(PlatformJobDefinition(
key="in-transit-receipt-file",
label="在途收料文件抓取",
@@ -0,0 +1,20 @@
"""
backend/app/services/schedule/voucher_po_print_job.py
用途:立账凭证 PO 订单生成 platform_job 薄封装。
依赖:voucher_check.po_print_runner。
逻辑:job_registry 注册 accounting-voucher-po-print 后由 schedule worker 调用;早于检核周批。
"""
from __future__ import annotations
from app.models import ScheduleRun, ScheduleTask
from app.services.voucher_check.po_print_runner import ScheduleExecuteResult, run_po_print_batch
def run_voucher_po_print_schedule(task: ScheduleTask, run: ScheduleRun) -> ScheduleExecuteResult:
"""
执行立账凭证 PO 订单生成排程。
核心逻辑:委托 po_print_runner;默认周二 05:00,检核周批 06:00 只扫目录。
"""
return run_po_print_batch(task, run)
@@ -3,8 +3,8 @@ backend/app/services/voucher_check/adapters/erp_po_print.py
用途:ERP 反查 PO 后写入「PO订单」类型目录的 Adapter。
依赖:adapters.base、erp_po_repository、voucher_check.po_order。
逻辑:fetch_documents / publish_for_invoices 已接线(HXJM.oma99 → TGHX.pmm99)。
fetch() 仍占位,周任务不调用。render_given 只出本地 PDF。
逻辑:fetch_documents / publish_for_invoices 由独立排程 accounting-voucher-po-print(周二 05:00)调用。
fetch() 仍占位,检核 runner(周二 06:00)不调用。render_given 只出本地 PDF。
"""
from __future__ import annotations
@@ -30,7 +30,7 @@ class ErpPoPrintAdapter:
def fetch(self, *, period_month: date, subjects: list[SubjectRow]) -> list[ScannedFile]:
"""
周检核入口仍关闭。
【AI 触发时机】不要在周二 runner 中调用。独立抓取请用 fetch_documents / publish_for_invoices。
【AI 触发时机】不要在周二检核 runner 中调用。独立抓取排程请用 fetch_documents / publish_for_invoices。
"""
raise ServiceUnavailableError(
"ERP PO 打印尚未接入周检核",
@@ -50,7 +50,7 @@ class ErpPoPrintAdapter:
) -> list[PoOrderDocument]:
"""
按发票号从 ERP 组装制式采购单数据。
【AI 触发时机】独立抓取 PO、已有 invoice 清单时调用;不要在周二 runner 里调用。
【AI 触发时机】独立抓取 PO、已有 invoice 清单时调用;检核 runner 不要调用。周二 05:00 排程走本方法。
"""
from app.services.voucher_check.config import load_engine_config
from app.services.voucher_check.erp_po_repository import fetch_po_documents_for_invoices
@@ -97,7 +97,7 @@ class ErpPoPrintAdapter:
) -> list[PoOrderPublishResult]:
"""
按发票号查 ERP、生成 PDF 并上传到当月「PO订单」目录。
【AI 触发时机】独立抓取任务要写入文档库时调用;不要在周二 runner 里调用。
【AI 触发时机】独立抓取任务要写入文档库时调用;检核 runner 不要调用。周二 05:00 排程走本方法。
"""
results: list[PoOrderPublishResult] = []
for document in self.fetch_documents(invoice_nos, config=config):
+8 -2
View File
@@ -1,9 +1,9 @@
"""
backend/app/services/voucher_check/config.py
用途:解析立账凭证检核环境变量与 ScheduleTask.job_params。
用途:解析立账凭证检核 / PO 生成环境变量与 ScheduleTask.job_params。
依赖:Flask current_app.config、core.errors.ValidationError。
逻辑:runner / erp_repository / 引擎启动前调用;非法配置抛 VOUCHER_CHECK.CONFIG_INVALID;
逻辑:runner / po_print_runner / erp_repository 启动前调用;非法配置抛 VOUCHER_CHECK.CONFIG_INVALID;
ERP 账号优先 VOUCHER_CHECK_ERP_*,否则 ERP_*,再回退 CONTRACT_PAYMENT_ERP_*。
"""
@@ -24,6 +24,12 @@ DEFAULT_JOB_PARAMS: dict[str, Any] = {
"notify_failure_enabled": True,
}
DEFAULT_PO_PRINT_JOB_PARAMS: dict[str, Any] = {
"profile_code": "sales",
"scope_code": "HXJM",
"notify_failure_enabled": True,
}
@dataclass(frozen=True)
class VoucherCheckEngineConfig:
@@ -407,7 +407,7 @@ def fetch_po_documents_for_invoices(
) -> list[PoOrderDocument]:
"""
按销售发票号从 ERP 组装制式采购单数据。
【AI 触发时机】独立「抓取 PO」任务已有 invoice 清单、要生成 PDF 之前调用;不要在周二 runner 里调用。
【AI 触发时机】独立「抓取 PO」任务或周二 05:00 accounting-voucher-po-print 排程已有 invoice 清单、要生成 PDF 之前调用;不要在检核 runner 里调用。
核心逻辑:HXJM.oma99(空则 oga99/oea99)TRIM 后对 TGHX.pmm99;一票可多张 PO,每张一个文档。
@@ -1,9 +1,9 @@
"""
backend/app/services/voucher_check/notification.py
用途:立账凭证检核批次级企微汇总与技术失败告警。
用途:立账凭证检核缺件汇总、以及检核 / PO 生成排程的技术失败告警。
依赖:wecom_notify、ScheduleTask.notify_user_ids_json、engine_persistence。
逻辑:一个批次一条缺件汇总;未配置接收人不发送;设置 domain_notification_managed 避免通用排程重复通知。
逻辑:检核批次一条缺件汇总;PO 生成只在技术失败时告警;未配置接收人不发送;domain_notification_managed 避免通用排程重复通知。
"""
from __future__ import annotations
@@ -186,8 +186,14 @@ def send_failure_alert(
error_code: str,
error_message: str,
enabled: bool,
title: str | None = None,
) -> None:
"""批次级技术失败告警(ERP/DMS/配置异常),不计入缺件通知。"""
"""
批次级技术失败告警(ERP/DMS/配置/上传异常),不计入缺件通知。
Args:
title: 企微标题;默认「立账凭证检核失败」。PO 生成排程传入自己的标题。
"""
if not enabled:
return
if not current_app.config.get("WECOM_NOTIFY_ENABLED", True):
@@ -203,7 +209,7 @@ def send_failure_alert(
if not users:
return
title = f"立账凭证检核失败: {task.name}"
title = title or f"立账凭证检核失败: {task.name}"
description = (
f"批次 {run.run_no}\n"
f"失败阶段:{stage}\n"
@@ -0,0 +1,206 @@
"""
backend/app/services/voucher_check/po_print_runner.py
用途:立账凭证「PO 订单生成」周批:上月发票 → TGHX 取数 → 制式 PDF 上传到「PO订单」。
依赖:config、erp_repository、ErpPoPrintAdapter、dms_client、notification。
逻辑:独立排程 accounting-voucher-po-print 调用;不要从检核 runner 调用。
同名跳过;找不到 PO 的发票记 skipped,不阻断其它票。
"""
from __future__ import annotations
from typing import Any
from flask import current_app
from app import db
from app.core.errors import AppError
from app.models import ScheduleRun, ScheduleTask
from app.services.voucher_check.adapters.erp_po_print import ErpPoPrintAdapter
from app.services.voucher_check.config import load_engine_config
from app.services.voucher_check.dms_client import SalesDmsClient
from app.services.voucher_check.erp_repository import fetch_month_invoices
from app.services.voucher_check.notification import send_failure_alert
ScheduleExecuteResult = tuple[int, int, int, int, list[dict[str, Any]], list[str], list[dict[str, Any]]]
def _mark_domain_notification_managed(run: ScheduleRun) -> None:
"""避免通用排程再发一条企微;本任务只在技术失败时告警。"""
summary = dict(run.response_summary_json or {})
summary["domain_notification_managed"] = True
run.response_summary_json = summary
db.session.commit()
def _write_summary(run: ScheduleRun, payload: dict[str, Any]) -> None:
summary = dict(run.response_summary_json or {})
summary["domain_notification_managed"] = True
summary["voucher_po_print"] = payload
run.response_summary_json = summary
db.session.commit()
def run_po_print_batch(task: ScheduleTask, run: ScheduleRun) -> ScheduleExecuteResult:
"""
按上月销售发票生成制式采购单 PDF 并上传到文档库「PO订单」。
【AI 触发时机】仅 accounting-voucher-po-print 排程(默认周二 05:00)调用;检核周批不要调用。
核心逻辑:fetch_month_invoices → fetch_documents → 逐张 upload_given(同名跳过)。
不调用 ErpPoPrintAdapter.fetch,不写 voucher_check_runs。
Returns:
ScheduleExecuteResult:(发票数, 新上传数, 失败数, 跳过数, details, errors, step_logs)
跳过 = 同名已存在 + 发票没有对应 TGHX 采购单。
"""
step_logs: list[dict[str, Any]] = []
errors: list[str] = []
details: list[dict[str, Any]] = []
adapter = ErpPoPrintAdapter()
current_app.logger.info(
"[voucher-po-print] start name=%s path=accounting-voucher-po-print run_no=%s",
getattr(task, "name", None) or "立账凭证 PO 订单生成",
run.run_no,
)
_mark_domain_notification_managed(run)
try:
config = load_engine_config(task.job_params if isinstance(task.job_params, dict) else {})
SalesDmsClient.ensure_configured()
period_month, invoices = fetch_month_invoices(config)
except AppError as exc:
send_failure_alert(
task=task,
run=run,
stage="config_or_erp",
error_code=exc.code,
error_message=exc.message,
enabled=True,
title=f"立账凭证 PO 生成失败: {task.name}",
)
raise
invoice_nos = [row.invoice_no for row in invoices]
step_logs.append(
{
"step": "list_invoices",
"status": "success",
"detail": {"period": period_month.isoformat(), "invoice_count": len(invoice_nos)},
}
)
if not invoice_nos:
_write_summary(
run,
{
"period": period_month.isoformat(),
"invoice_count": 0,
"uploaded": 0,
"skipped_same_name": 0,
"skipped_no_po": 0,
"failed": 0,
},
)
return (0, 0, 0, 0, [], [], step_logs)
try:
documents = adapter.fetch_documents(invoice_nos, config=config)
except AppError as exc:
send_failure_alert(
task=task,
run=run,
stage="erp_po",
error_code=exc.code,
error_message=exc.message,
enabled=config.notify_failure_enabled,
title=f"立账凭证 PO 生成失败: {task.name}",
)
raise
covered = {item.invoice_no for item in documents}
skipped_no_po = 0
for invoice_no in invoice_nos:
if invoice_no not in covered:
skipped_no_po += 1
details.append({"invoice_no": invoice_no, "status": "skipped_no_po"})
uploaded = 0
skipped_same_name = 0
failed = 0
for document in documents:
try:
result = adapter.upload_given(document, period_month=period_month)
if result.skipped_same_name:
skipped_same_name += 1
status = "skipped_same_name"
else:
uploaded += 1
status = "uploaded"
details.append(
{
"invoice_no": document.invoice_no,
"po_no": document.po_no,
"status": status,
"filename": result.file.filename,
}
)
except Exception as exc:
failed += 1
errors.append(f"{document.invoice_no}/{document.po_no}: {type(exc).__name__}")
details.append(
{
"invoice_no": document.invoice_no,
"po_no": document.po_no,
"status": "failed",
"error_type": type(exc).__name__,
}
)
current_app.logger.exception(
"[voucher-po-print] upload failed invoice=%s po=%s",
document.invoice_no,
document.po_no,
)
skipped = skipped_same_name + skipped_no_po
if failed:
send_failure_alert(
task=task,
run=run,
stage="upload",
error_code="VOUCHER_CHECK.PO_PRINT_PARTIAL",
error_message=f"上传失败 {failed} 张,成功 {uploaded},跳过 {skipped}",
enabled=config.notify_failure_enabled,
title=f"立账凭证 PO 生成部分失败: {task.name}",
)
step_logs.append(
{
"step": "upload",
"status": "failed" if failed else "success",
"detail": {
"uploaded": uploaded,
"skipped_same_name": skipped_same_name,
"skipped_no_po": skipped_no_po,
"failed": failed,
},
}
)
_write_summary(
run,
{
"period": period_month.isoformat(),
"invoice_count": len(invoice_nos),
"po_count": len(documents),
"uploaded": uploaded,
"skipped_same_name": skipped_same_name,
"skipped_no_po": skipped_no_po,
"failed": failed,
},
)
current_app.logger.info(
"[voucher-po-print] done period=%s invoices=%s uploaded=%s skipped=%s failed=%s",
period_month.isoformat(),
len(invoice_nos),
uploaded,
skipped,
failed,
)
return (len(invoice_nos), uploaded, failed, skipped, details, errors, step_logs)
@@ -3,7 +3,7 @@ backend/app/services/voucher_check/profiles/sales.py
用途:销售一期 Profile 定义(六类必检文件、类型目录、命名模板)。
依赖:无外部 IO;由 profile_loader 发布快照。
逻辑:周任务扫描 source_type=directory_scan;subject_adapter=hxjm_apa 实际查 oma_file;erp_po_print.fetch / oa_sales_release 仅登记,不在周二 runner 调用。PO 独立抓取走 fetch_documents。
逻辑:周任务扫描 source_type=directory_scan;subject_adapter=hxjm_apa 实际查 oma_file;erp_po_print.fetch / oa_sales_release 仅登记,不在检核 runner 调用。PO PDF 由独立排程 accounting-voucher-po-print(周二 05:00)写入类型目录。
"""
from __future__ import annotations
+2 -1
View File
@@ -3,7 +3,8 @@ backend/app/services/voucher_check/runner.py
用途:销售一期周批次编排(上月清单、目录扫描、按票归档、缺件聚合、Excel、企微汇总)。
依赖:profile_loader、adapters、dms_client、aggregator、engine_persistence、excel_rows、notification。
逻辑:不调用 erp_po_print.fetch / oa_sales_release.fetch;命中文件复制到所有归档,同名跳过仍记 archived。
逻辑:不调用 erp_po_print.fetch / oa_sales_release.fetch;PO PDF 由独立排程 accounting-voucher-po-print 提前写入类型目录。
命中文件复制到所有归档,同名跳过仍记 archived。
"""
from __future__ import annotations
@@ -1,9 +1,9 @@
"""
backend/app/services/voucher_check/schedule_seed.py
用途:确保 accounting-voucher-check 默认周批 ScheduleTask 存在(周二 06:00 Asia/Shanghai)。
依赖:ScheduleTask/User、timezone_util、voucher_check.config.DEFAULT_JOB_PARAMS。
逻辑:迁移种子 + create_app / User after_commit 幂等补建;已存在的日批改成周二,并剥离 schema 外的旧 job_params。
用途:确保立账凭证检核(周二 06:00)与 PO 订单生成(周二 05:00)默认 ScheduleTask 存在。
依赖:ScheduleTask/User、timezone_util、voucher_check.config。
逻辑:迁移种子 + create_app / User after_commit 幂等补建;检核排程剥离 schema 外的旧 job_params。
"""
from __future__ import annotations
@@ -19,7 +19,7 @@ from sqlalchemy.orm.attributes import flag_modified
from app import db
from app.models import ScheduleTask, User
from app.services.schedule.timezone_util import compute_next_run_at
from app.services.voucher_check.config import DEFAULT_JOB_PARAMS
from app.services.voucher_check.config import DEFAULT_JOB_PARAMS, DEFAULT_PO_PRINT_JOB_PARAMS
_LOGGER = logging.getLogger(__name__)
@@ -28,6 +28,11 @@ DEFAULT_VOUCHER_CHECK_PLATFORM_PATH = "accounting-voucher-check"
DEFAULT_VOUCHER_CHECK_CRON = "0 6 * * 2"
DEFAULT_VOUCHER_CHECK_NAME = "立账凭证检核(周批)"
DEFAULT_VOUCHER_PO_PRINT_SCHEDULE_NO = "SCH-ACCOUNTING-VOUCHER-PO-PRINT"
DEFAULT_VOUCHER_PO_PRINT_PLATFORM_PATH = "accounting-voucher-po-print"
DEFAULT_VOUCHER_PO_PRINT_CRON = "0 5 * * 2"
DEFAULT_VOUCHER_PO_PRINT_NAME = "立账凭证 PO 订单生成(周批)"
_HOOKS_REGISTERED = False
_SESSION_INFO_KEY = "_seed_voucher_check_schedule"
@@ -163,6 +168,113 @@ def ensure_default_voucher_check_schedule(
return task
def _pick_schedule_owner(sess: Any) -> Any | None:
"""优先管理员,否则任意用户;尚无用户时返回 None。"""
owner = (
sess.query(User)
.filter(User.role == "admin")
.order_by(User.id.asc())
.first()
)
if owner is None:
owner = sess.query(User).order_by(User.id.asc()).first()
return owner
def ensure_default_voucher_po_print_schedule(
*,
commit: bool = True,
session: Any | None = None,
) -> ScheduleTask | None:
"""
幂等确保默认 PO 订单生成周批排程存在(周二 05:00,早于检核 06:00)。
核心逻辑:已存在同 schedule_no / platform_api_path 则跳过;新建时尽量复用检核任务的企微接收人。
Args:
commit: 是否立即提交。
session: 可选独立 Session。
Returns:
新建或已存在的 ScheduleTask;尚无用户时返回 None。
"""
sess = session if session is not None else db.session
existing = (
sess.query(ScheduleTask)
.filter(
(ScheduleTask.schedule_no == DEFAULT_VOUCHER_PO_PRINT_SCHEDULE_NO)
| (ScheduleTask.platform_api_path == DEFAULT_VOUCHER_PO_PRINT_PLATFORM_PATH)
)
.first()
)
if existing is not None:
return existing
owner = _pick_schedule_owner(sess)
if owner is None:
_LOGGER.info("skip seed accounting-voucher-po-print schedule: no users yet")
return None
check_task = (
sess.query(ScheduleTask)
.filter(
(ScheduleTask.schedule_no == DEFAULT_VOUCHER_CHECK_SCHEDULE_NO)
| (ScheduleTask.platform_api_path == DEFAULT_VOUCHER_CHECK_PLATFORM_PATH)
)
.first()
)
notify_ids = []
if check_task is not None and isinstance(check_task.notify_user_ids_json, list):
notify_ids = list(check_task.notify_user_ids_json)
now = datetime.utcnow()
next_run = compute_next_run_at(
DEFAULT_VOUCHER_PO_PRINT_CRON,
timezone_name="Asia/Shanghai",
) or now
task = ScheduleTask(
schedule_no=DEFAULT_VOUCHER_PO_PRINT_SCHEDULE_NO,
name=DEFAULT_VOUCHER_PO_PRINT_NAME,
schedule_type="platform_job",
owner_user_id=int(owner.id),
cron_expr=DEFAULT_VOUCHER_PO_PRINT_CRON,
schedule_timezone="Asia/Shanghai",
wait_seconds=0,
platform_api_path=DEFAULT_VOUCHER_PO_PRINT_PLATFORM_PATH,
job_params=dict(DEFAULT_PO_PRINT_JOB_PARAMS),
kb_sync_enabled=False,
notify_user_ids_json=notify_ids,
notify_enabled=True,
enabled=True,
next_run_at=next_run,
created_by=int(owner.id),
updated_by=int(owner.id),
created_at=now,
updated_at=now,
)
sess.add(task)
if commit:
try:
sess.commit()
except Exception:
sess.rollback()
existing = (
sess.query(ScheduleTask)
.filter(
(ScheduleTask.schedule_no == DEFAULT_VOUCHER_PO_PRINT_SCHEDULE_NO)
| (ScheduleTask.platform_api_path == DEFAULT_VOUCHER_PO_PRINT_PLATFORM_PATH)
)
.first()
)
if existing is not None:
return existing
raise
else:
sess.flush()
_LOGGER.info("seeded accounting-voucher-po-print schedule id=%s", task.id)
return task
def register_voucher_check_schedule_hooks() -> None:
"""注册 User after_commit 补建钩子(幂等)。"""
global _HOOKS_REGISTERED
@@ -181,6 +293,7 @@ def register_voucher_check_schedule_hooks() -> None:
factory = sessionmaker(bind=bind)
with factory() as new_sess:
ensure_default_voucher_check_schedule(commit=True, session=new_sess)
ensure_default_voucher_po_print_schedule(commit=True, session=new_sess)
except Exception:
_LOGGER.exception("voucher-check schedule seed after_commit failed")
@@ -0,0 +1,136 @@
"""
backend/migrations/versions/vc4e5f6a7b8c_seed_voucher_po_print_schedule.py
用途:写入立账凭证 PO 订单生成周批(周二 05:00),早于检核周批(06:00)。
依赖:Alembic revision vc3d4e5f6a7b;schedule_tasks / users 已存在。
逻辑:有用户则插入 SCH-ACCOUNTING-VOUCHER-PO-PRINT;无用户时跳过,由应用钩子补建。
企微接收人尽量从检核排程复制。downgrade 只删本 schedule_no。
Revision ID: vc4e5f6a7b8c
Revises: vc3d4e5f6a7b
Create Date: 2026-09-14 19:40:00.000000
"""
from __future__ import annotations
import json
from datetime import datetime, timedelta, timezone
import sqlalchemy as sa
from alembic import op
revision = "vc4e5f6a7b8c"
down_revision = "vc3d4e5f6a7b"
branch_labels = None
depends_on = None
_SCHEDULE_NO = "SCH-ACCOUNTING-VOUCHER-PO-PRINT"
_CRON_EXPR = "0 5 * * 2"
_TZ_NAME = "Asia/Shanghai"
_JOB_PARAMS = {
"profile_code": "sales",
"scope_code": "HXJM",
"notify_failure_enabled": True,
}
def _compute_next_run_at_utc_naive() -> datetime:
"""按周二 05:00 Asia/Shanghai 计算下次执行,返回 UTC naive。"""
try:
from croniter import croniter
from zoneinfo import ZoneInfo
tz = ZoneInfo(_TZ_NAME)
base = datetime.now(tz)
next_local = croniter(_CRON_EXPR, base).get_next(datetime)
if next_local.tzinfo is None:
next_local = next_local.replace(tzinfo=tz)
return next_local.astimezone(timezone.utc).replace(tzinfo=None)
except Exception:
tz = timezone(timedelta(hours=8))
now_local = datetime.now(tz)
next_local = now_local.replace(hour=5, minute=0, second=0, microsecond=0)
while next_local <= now_local or next_local.weekday() != 1:
next_local = next_local + timedelta(days=1)
next_local = next_local.replace(hour=5, minute=0, second=0, microsecond=0)
return next_local.astimezone(timezone.utc).replace(tzinfo=None)
def upgrade() -> None:
conn = op.get_bind()
exists = conn.execute(
sa.text(
"SELECT 1 FROM schedule_tasks "
"WHERE schedule_no = :sno OR platform_api_path = 'accounting-voucher-po-print' "
"LIMIT 1"
),
{"sno": _SCHEDULE_NO},
).first()
if exists:
return
owner = conn.execute(
sa.text("SELECT id FROM users WHERE role = 'admin' ORDER BY id ASC LIMIT 1")
).first()
if owner is None:
owner = conn.execute(sa.text("SELECT id FROM users ORDER BY id ASC LIMIT 1")).first()
if owner is None:
return
notify_row = conn.execute(
sa.text(
"SELECT notify_user_ids_json FROM schedule_tasks "
"WHERE schedule_no = 'SCH-ACCOUNTING-VOUCHER-CHECK' "
" OR platform_api_path = 'accounting-voucher-check' "
"LIMIT 1"
)
).first()
notify_ids = notify_row[0] if notify_row and notify_row[0] is not None else []
if not isinstance(notify_ids, list):
notify_ids = []
now = datetime.utcnow()
next_run = _compute_next_run_at_utc_naive()
conn.execute(
sa.text(
"""
INSERT INTO schedule_tasks (
schedule_no, name, schedule_type, owner_user_id,
cron_expr, schedule_timezone, wait_seconds,
platform_api_path, job_params, notify_user_ids_json,
kb_sync_enabled, notify_enabled,
enabled, next_run_at, last_run_at,
created_by, updated_by, created_at, updated_at
) VALUES (
:schedule_no, :name, 'platform_job', :owner_user_id,
:cron_expr, 'Asia/Shanghai', 0,
'accounting-voucher-po-print', CAST(:job_params AS JSONB), CAST(:notify_ids AS JSONB),
false, true,
true, :next_run_at, NULL,
:owner_user_id, :owner_user_id, :now, :now
)
"""
).bindparams(
sa.bindparam("job_params", type_=sa.String()),
sa.bindparam("notify_ids", type_=sa.String()),
),
{
"schedule_no": _SCHEDULE_NO,
"name": "立账凭证 PO 订单生成(周批)",
"owner_user_id": int(owner[0]),
"cron_expr": _CRON_EXPR,
"job_params": json.dumps(_JOB_PARAMS, ensure_ascii=False),
"notify_ids": json.dumps(notify_ids, ensure_ascii=False),
"next_run_at": next_run,
"now": now,
},
)
def downgrade() -> None:
"""仅删除本迁移约定的 schedule_no,避免误删管理员手工创建的同路径排程。"""
conn = op.get_bind()
conn.execute(
sa.text("DELETE FROM schedule_tasks WHERE schedule_no = :sno"),
{"sno": _SCHEDULE_NO},
)
@@ -38,6 +38,7 @@ def test_platform_jobs_registered():
assert "shipping-inventory-rpa" in keys
assert "faq-aggregate-hot" in keys
assert "fixed-assets-snapshot" in keys
assert "accounting-voucher-po-print" in keys
assert get_platform_job("shipping-inventory-rpa") is not None
@@ -217,6 +218,7 @@ def test_get_platform_jobs_api(client, admin_jwt_headers):
assert by_key["shipping-inventory-rpa"]["label_key"] == "admin.schedule.form.platformJobShippingInventory"
assert by_key["faq-aggregate-hot"]["label_key"] == "admin.schedule.form.platformJobFaqHotAggregate"
assert by_key["fixed-assets-snapshot"]["label_key"] == "admin.schedule.form.platformJobFixedAssetsSnapshot"
assert by_key["accounting-voucher-po-print"]["label_key"] == "admin.schedule.form.platformJobAccountingVoucherPoPrint"
defs = client.get("/api/admin/platform-tasks/definitions", headers=admin_jwt_headers)
assert defs.status_code == 200
@@ -0,0 +1,184 @@
"""
backend/tests/voucher_check/test_po_print_schedule.py
用途:PO 订单生成周批早于检核,且不走 erp_po_print.fetch。
依赖:pytest、app fixture;不连 Oracle / 文档库。
逻辑:断言 cron 05:00、种子幂等、取数后上传、无 PO 跳过、检核 fetch 仍关闭。
"""
from __future__ import annotations
from datetime import date
from types import SimpleNamespace
import pytest
from app.core.errors import ServiceUnavailableError
from app.models import ScheduleRun, ScheduleTask
from app.services.voucher_check.adapters.erp_po_print import ErpPoPrintAdapter
from app.services.voucher_check.erp_po_repository import map_po_document
from app.services.voucher_check.po_print_runner import run_po_print_batch
from app.services.voucher_check.schedule_seed import (
DEFAULT_VOUCHER_CHECK_CRON,
DEFAULT_VOUCHER_PO_PRINT_CRON,
DEFAULT_VOUCHER_PO_PRINT_PLATFORM_PATH,
DEFAULT_VOUCHER_PO_PRINT_SCHEDULE_NO,
ensure_default_voucher_check_schedule,
ensure_default_voucher_po_print_schedule,
)
def test_po_print_cron_is_earlier_than_check():
"""周二 05:00 早于检核 06:00。"""
assert DEFAULT_VOUCHER_PO_PRINT_CRON == "0 5 * * 2"
assert DEFAULT_VOUCHER_CHECK_CRON == "0 6 * * 2"
def test_ensure_po_print_schedule_is_idempotent(app):
with app.app_context():
from app import db
from app.models import User
if db.session.query(User).first() is None:
user = User(
username="po-print-seed-admin",
email="po-print-seed-admin@example.com",
role="admin",
status="active",
)
user.set_password("test")
db.session.add(user)
db.session.commit()
check = ensure_default_voucher_check_schedule(commit=True)
first = ensure_default_voucher_po_print_schedule(commit=True)
second = ensure_default_voucher_po_print_schedule(commit=True)
assert check is not None
assert first is not None
assert first.id == second.id
assert first.schedule_no == DEFAULT_VOUCHER_PO_PRINT_SCHEDULE_NO
assert first.platform_api_path == DEFAULT_VOUCHER_PO_PRINT_PLATFORM_PATH
assert first.cron_expr == DEFAULT_VOUCHER_PO_PRINT_CRON
assert check.cron_expr == DEFAULT_VOUCHER_CHECK_CRON
assert first.platform_api_path != check.platform_api_path
def test_po_print_batch_uploads_and_skips_no_po(app, monkeypatch):
"""有 PO 的发票上传;没有 TGHX 采购单的发票记 skipped_no_po;不调用 fetch()。"""
uploaded: list[str] = []
def fake_fetch_month(config):
return (
date(2026, 8, 1),
[
SimpleNamespace(invoice_no="EWZZ26090002"),
SimpleNamespace(invoice_no="EWZZ26090099"),
],
)
monkeypatch.setattr(
"app.services.voucher_check.po_print_runner.fetch_month_invoices",
fake_fetch_month,
)
monkeypatch.setattr(
"app.services.voucher_check.po_print_runner.SalesDmsClient.ensure_configured",
lambda: None,
)
monkeypatch.setattr(
"app.services.voucher_check.po_print_runner.load_engine_config",
lambda params=None: SimpleNamespace(notify_failure_enabled=False),
)
monkeypatch.setattr(
ErpPoPrintAdapter,
"fetch_documents",
lambda self, invoices, config=None: [map_po_document("EWZZ26090002", [{"po_no": "5220-1", "pmn02": 1}])],
)
def fake_upload(self, document, period_month):
uploaded.append(document.po_no)
return SimpleNamespace(
skipped_same_name=False,
file=SimpleNamespace(filename=f"{document.invoice_no}-{document.po_no}.pdf"),
)
monkeypatch.setattr(ErpPoPrintAdapter, "upload_given", fake_upload)
monkeypatch.setattr("app.services.voucher_check.po_print_runner.send_failure_alert", lambda **kwargs: None)
with app.app_context():
task = ScheduleTask(
schedule_no="SCH-TEST-PO",
name="po print",
schedule_type="platform_job",
platform_api_path="accounting-voucher-po-print",
owner_user_id=1,
cron_expr="0 5 * * 2",
job_params={"profile_code": "sales", "scope_code": "HXJM", "notify_failure_enabled": False},
)
run = ScheduleRun(run_no="RUN-PO-1", schedule_task_id=1, status="running")
total, success, failed, skipped, details, errors, logs = run_po_print_batch(task, run)
assert total == 2
assert success == 1
assert failed == 0
assert skipped == 1
assert uploaded == ["5220-1"]
assert any(item.get("status") == "skipped_no_po" for item in details)
assert ErpPoPrintAdapter.wired is False
with pytest.raises(ServiceUnavailableError) as exc:
ErpPoPrintAdapter().fetch(period_month=date(2026, 8, 1), subjects=[])
assert exc.value.code == "VOUCHER_CHECK.ADAPTER_NOT_WIRED"
def test_po_print_batch_counts_upload_failure(app, monkeypatch):
monkeypatch.setattr(
"app.services.voucher_check.po_print_runner.fetch_month_invoices",
lambda config: (date(2026, 8, 1), [SimpleNamespace(invoice_no="EWZZ26090002")]),
)
monkeypatch.setattr(
"app.services.voucher_check.po_print_runner.SalesDmsClient.ensure_configured",
lambda: None,
)
monkeypatch.setattr(
"app.services.voucher_check.po_print_runner.load_engine_config",
lambda params=None: SimpleNamespace(notify_failure_enabled=False),
)
monkeypatch.setattr(
ErpPoPrintAdapter,
"fetch_documents",
lambda self, invoices, config=None: [map_po_document("EWZZ26090002", [{"po_no": "PO-FAIL", "pmn02": 1}])],
)
monkeypatch.setattr(
ErpPoPrintAdapter,
"upload_given",
lambda self, document, period_month: (_ for _ in ()).throw(RuntimeError("dms down")),
)
alerts: list[str] = []
monkeypatch.setattr(
"app.services.voucher_check.po_print_runner.send_failure_alert",
lambda **kwargs: alerts.append(kwargs.get("stage") or ""),
)
with app.app_context():
task = ScheduleTask(
schedule_no="SCH-TEST-PO2",
name="po print",
schedule_type="platform_job",
platform_api_path="accounting-voucher-po-print",
owner_user_id=1,
cron_expr="0 5 * * 2",
job_params={},
)
run = ScheduleRun(run_no="RUN-PO-2", schedule_task_id=1, status="running")
total, success, failed, skipped, details, errors, logs = run_po_print_batch(task, run)
assert total == 1
assert success == 0
assert failed == 1
assert "upload" in alerts
assert errors
def test_platform_job_registered():
from app.services.schedule.job_registry import get_platform_job
job = get_platform_job("accounting-voucher-po-print")
assert job is not None
assert job.label_key == "admin.schedule.form.platformJobAccountingVoucherPoPrint"
assert job.handler is not None
+1 -1
View File
@@ -81,7 +81,7 @@ def _log_queue_startup_diagnostics(logger: logging.Logger, app, queue_names: lis
if 'schedule' in queue_names:
logger.info(
'schedule 队列身份:domain/job_type 固定为 schedule/schedule_run;'
'立账凭证检核看 business_ref 后缀 accounting-voucher-check 或 payload.platform_api_path'
'立账凭证检核看 accounting-voucher-check;PO 生成看 accounting-voucher-po-print'
)
+1 -1
View File
@@ -216,7 +216,7 @@
- **文档库**:复用现有文档管理系统(全公司一个库,LibraryID 与合同相同);销售开票附件是该库下独立文件夹,只单独配根 FolderID,不得复用合同根目录。
- **通知**:每个检核批次一条企业微信汇总;接收人在界面从系统用户多选,未配置则不发。
- **判定边界**:只做文件获取、命名/关联校验和归档结果;不读取文件内容、不使用 LLM、不核对金额/供应商等字段、不回写 ERP。
- **实现状态**:周任务已按上月 + 文档库扫描 + 按票归档(同名跳过)+ 缺件汇总落地;PO 制式 PDF 可生成上传,ERP 取数见 [technical-design.md §3.4](features/accounting-voucher-check/technical-design.md)(发票 HXJM、采购单 TGHX,`TRIM(oma99)=TRIM(pmm99)` 已接线,仅独立抓取,周二 runner 不调用);OA 打印仍待接线。不做 Chatflow;查询走工作台 API。
- **实现状态**:周二 05:00 独立排程生成 PO PDF 并上传到「PO订单」;周二 06:00 检核周任务按上月 + 文档库扫描 + 按票归档(同名跳过)+ 缺件汇总。ERP 取数见 [technical-design.md §3.4](features/accounting-voucher-check/technical-design.md)(HXJM → TGHX,`TRIM(oma99)=TRIM(pmm99)`);OA 打印仍待接线。不做 Chatflow;查询走工作台 API。
- 权威需求见 [docs/features/accounting-voucher-check/demand.md](features/accounting-voucher-check/demand.md)。
### 3.x 货代发货通知库存源补充需求
@@ -15,4 +15,4 @@
**检核内容**:只做必检文件的获取、存在性和归档结果;不做文件内容解析或金额、供应商等字段一致性核对。
**结果输出**:每批生成 Excel,区分缺件文件总数和缺件 `invoice` 数;企业微信每批一条汇总通知,完整明细以 Excel 与执行记录为准。
**状态**:销售一期需求以 [demand.md](demand.md) 为准;采购二期及其它业务方通过新增 Profile 扩展。周任务已切到文档库引擎;旧共享盘扫描、Chatflow Tool 与一票一状态表已移除。PO 制式 PDF 生成并上传到「PO订单」已实现;ERP 取数(HXJM → TGHX,`TRIM(oma99)=TRIM(pmm99)`)已接线,仅独立抓取,周二 runner 不调用;OA 销货放行打印仍待接线。
**状态**:销售一期需求以 [demand.md](demand.md) 为准;采购二期及其它业务方通过新增 Profile 扩展。周任务已切到文档库引擎;旧共享盘扫描、Chatflow Tool 与一票一状态表已移除。PO 制式 PDF 由周二 05:00 独立排程生成并上传;06:00 检核只扫描目录。OA 销货放行打印仍待接线。
@@ -1,8 +1,8 @@
# 立账凭证资料检核需求说明
> 文档版本:v1.13
> 文档版本:v1.14
> 更新时间:2026-09-14
> 状态:一期销售需求确认中;采购及其它业务方待后续 Profile 配置。PO 制式 PDF 已可生成上传;ERP 取数(HXJM → TGHX,`TRIM(oma99)=TRIM(pmm99)`)已接线,仅独立抓取,周二周任务不调用。
> 状态:一期销售需求确认中;采购及其它业务方待后续 Profile 配置。PO 制式 PDF 由独立周批(周二 05:00)生成并上传;检核周批(周二 06:00)只扫描目录。ERP 取数 HXJM → TGHX,`TRIM(oma99)=TRIM(pmm99)`。
>
> 本文是本期需求权威。部署与冒烟见 [ops-checklist.md](ops-checklist.md)。旧共享盘存在性扫描、Chatflow Tool 与一票一状态表已移除,不得再按该口径扩展。
@@ -27,7 +27,7 @@
| 项目 | 规则 |
| -------- | ----------------------------------------------------------------------------------------------------------------------- |
| 执行频率 | 每周二执行一次(默认 06:00,Asia/Shanghai) |
| 执行频率 | **两段周批(Asia/Shanghai)**:周二 **05:00** 生成并上传 PO 订单 PDF;周二 **06:00** 检核上月附件。 |
| 检核期间 | 执行日的上一个自然月;例如 2026-08-18 执行,检核 2026-07 |
| 执行方式 | 增量执行:已成功归档且来源文件/规则未变化的 `invoice + 文件规则` 可跳过;新增、缺件、规则变更或来源变更的记录重新检核。归档目录已有同名文件时按「同名跳过」不覆盖 |
| 强制重检 | 支持对上一个自然月全量重检;不跳过任何主体。工作台「强制重检上月」入队 `force_all` |
@@ -100,7 +100,7 @@
| 文件类型 | 命名方式 | 获取方式 | 存放路径 | `invoice` 关联 | 扫描/查询条件 |
| -------------- | ------------------------------ | -------------------------- | --------------------------------------------- | --------------------------- | ---------------------- |
| PO 订单 | `{invoice号}-{订单号}.pdf` | 按发票从 TGHX 取数生成制式采购单 PDF,并上传到当月「PO订单」目录(独立抓取;周任务只扫描目录) | `文档库/销售开票附件/{yyyy}/{MM}/PO订单/` | `TRIM(HXJM.oma99)=TRIM(TGHX.pmm99)` → `pmm01` | **已确认**:发票 HXJM、采购单 TGHX;多角序号关联(样本 `EWZZ26090002` → `5220-2609010001`)。拿到 `pmm01` 后按 [technical-design.md §3.4](technical-design.md) 对照 apmr900 取数;命名 `{invoice}-{订单号}.pdf`;上传走 Attachment/Upload + CreateFiles,同名跳过 |
| PO 订单 | `{invoice号}-{订单号}.pdf` | 周二 05:00 独立排程按发票从 TGHX 取数生成制式 PDF 并上传到当月「PO订单」;06:00 检核只扫描该目录 | `文档库/销售开票附件/{yyyy}/{MM}/PO订单/` | `TRIM(HXJM.oma99)=TRIM(TGHX.pmm99)` → `pmm01` | **已确认**:发票 HXJM、采购单 TGHX。Job `accounting-voucher-po-print`(`SCH-ACCOUNTING-VOUCHER-PO-PRINT`)。同名跳过 |
| 报关资料 | `{invoice号}.pdf` | 固定目录扫描 | `文档库/销售开票附件/{yyyy}/{MM}/报关资料/` | 文件名含 `invoice` | 扫描上月对应类型目录 |
| 销货放行申请单 | `{invoice号}-{销货单号}.pdf` | OA 自定义报表逐条打印 PDF | `文档库/销售开票附件/{yyyy}/{MM}/销货单/` | OA 列表读取发票号、销货单号 | 见 5.1 |
| 发票 | `{invoice号}-{发票号}.pdf` | 固定目录扫描 | `文档库/销售开票附件/{yyyy}/{MM}/发票/` | 文件名含 `invoice` | 扫描上月对应类型目录 |
@@ -153,7 +153,7 @@ flowchart TD
| 6 | 再复制到「所有归档/{invoice号}/」 |
| 7 | 周检核只扫描类型目录,不在周二 runner 里生成 PDF |
制式 PDF:`save_po_order_pdf` 只写本地;写入文档库用 `publish_po_order_pdf`(`ErpPoPrintAdapter.upload_given`)。调用方传入已组装好的采购单字段(含 `invoice_no`、`po_no`、明细行)以及类型目录所属月 `period_month`;`invoice_no` 只出现在文件名,不印在采购单版面。年/月/「PO订单」目录没有就建。目标已有同名文件则跳过、不覆盖。独立抓取任务上线前不要把生成或上传塞进周检核。
制式 PDF:`save_po_order_pdf` 只写本地;写入文档库用 `publish_po_order_pdf`(`ErpPoPrintAdapter.upload_given`)。周二 05:00 排程 `accounting-voucher-po-print` 按上月发票取数并上传;06:00 检核只扫描「PO订单」目录。`invoice_no` 只出现在文件名,不印在采购单版面。年/月/「PO订单」目录没有就建。目标已有同名文件则跳过、不覆盖。
拿到 `pmm01` 之后的主表(业务可读摘要;完整对照见技术设计 §3.4):
@@ -265,10 +265,10 @@ flowchart TD
| 待确认项 | 当前结论 | 仍缺什么 |
| --- | --- | --- |
| 销售 invoice 清单 | **已确认**:HXJM `oma_file.oma10/oma02`,`oma10` 至少 6 位字母或数字,`omaconf='Y'`、`omavoid='N'`、`oma64='1'`、`oma00 IN (11,12,13)`,期间为上一个月 | 无 |
| ERP 反查 PO 并打印 | **打印、上传与取数已接线(独立抓取,周二 runner 不调用)**。采购单在 **TGHX**。关联 **已确认**:`TRIM(HXJM.oma99)=TRIM(TGHX.pmm99)`(样本 `EWZZ26090002` → `5220-2609010001`,`pmm02=TRI`)。`oma99` 为空时才走 `oma16` 备用。到货日 `pmn34`。详见 [technical-design.md §3.4](technical-design.md) | 制表者;卤素/环保是否拆列。原始编号优先 `ta_ima11` 否则 `pmn24`(业务仍略含糊)。`oma99` 为空的备用路径尚未用空值票验证 |
| ERP 反查 PO 并打印 | **打印、上传与取数已接线(周二 05:00 独立排程 `accounting-voucher-po-print`,06:00 检核不调用)**。采购单在 **TGHX**。关联 **已确认**:`TRIM(HXJM.oma99)=TRIM(TGHX.pmm99)`。`oma99` 为空时才走 `oma16` 备用。到货日 `pmn34`。详见 [technical-design.md §3.4](technical-design.md) | 制表者;卤素/环保是否拆列。原始编号优先 `ta_ima11` 否则 `pmn24`(业务仍略含糊)。`oma99` 为空的备用路径尚未用空值票验证 |
| OA 销货放行单 | **已确认方向**:一期只做模拟页面;后期对接新 OA 接口 | 模拟登录、分页、打印落盘细节 |
| 文档管理系统 | **已确认**:同一文档库 LibraryID;销售根 FolderID=`727c3683-dcdb-4d62-a5b1-b164224162bc`;建文件夹 `SaveFolder`、上传 `Attachment/Upload` + `Item/CreateFiles`、复制 `Item/Copy`;同名跳过 | 无 |
| 企微接收人 | **已确认产品**:界面从系统用户多选;人可以后配 | 业务最终勾选哪些人 |
| 周任务 | **已确认**:每周二(默认 06:00 上海时区) | 无 |
| 周任务 | **已确认**:周二 05:00 生成 PO PDF;周二 06:00 检核(上海时区) | 无 |
| 销售类型目录名 | **已确认固定**:`PO订单`、`报关资料`、`销货单`、`发票`、`报关单`、`提单` | 无 |
| 重复文件策略 | **已确认**:同名跳过 | 目标 `所有归档/{invoice}/` 或类型目录「PO订单」已有相同文件名则不覆盖 |
@@ -1,6 +1,6 @@
# 立账凭证检核 — 部署验收清单
> 覆盖当前引擎:每周二检核**上一个自然月**、HXJM `oma_file` 发票清单、文档库类型目录扫描与按票归档(Copy,同名跳过)、单文件结果与企微批次汇总。PO 取数仅独立抓取(TGHX 只读授权见 §2),不进周任务。
> 覆盖当前引擎:每周二 **05:00** 生成 PO PDF 并上传到「PO订单」,**06:00** 检核**上一个自然月**、HXJM `oma_file` 发票清单、文档库类型目录扫描与按票归档(Copy,同名跳过)、单文件结果与企微批次汇总。TGHX 只读授权见 §2。
>
> 产品需求见 [demand.md](demand.md),设计见 [technical-design.md](technical-design.md)。
>
@@ -10,9 +10,9 @@
| 项 | 值 |
| --- | --- |
| Job key | `accounting-voucher-check` |
| 默认排程号 | `SCH-ACCOUNTING-VOUCHER-CHECK` |
| Cron | `0 6 * * 2`(Asia/Shanghai,每周二 06:00) |
| Job key | `accounting-voucher-check`(检核)· `accounting-voucher-po-print`(PO 生成) |
| 默认排程号 | `SCH-ACCOUNTING-VOUCHER-CHECK` · `SCH-ACCOUNTING-VOUCHER-PO-PRINT` |
| Cron | 检核 `0 6 * * 2`;PO 生成 `0 5 * * 2`(Asia/Shanghai,周二,生成早于检核) |
| 检核期间 | 上一个自然月 |
| 销售类型目录 | PO订单、报关资料、销货单、发票、报关单、提单 |
| 引擎表 | `voucher_check_profiles` / `runs` / `subjects` / `file_results` / `notifications` |
@@ -40,8 +40,8 @@ flask db upgrade
```sql
SELECT id, schedule_no, name, cron_expr, platform_api_path, enabled, next_run_at
FROM schedule_tasks
WHERE schedule_no = 'SCH-ACCOUNTING-VOUCHER-CHECK'
OR platform_api_path = 'accounting-voucher-check';
WHERE schedule_no IN ('SCH-ACCOUNTING-VOUCHER-CHECK', 'SCH-ACCOUNTING-VOUCHER-PO-PRINT')
OR platform_api_path IN ('accounting-voucher-check', 'accounting-voucher-po-print');
```
- [ ] 若无用户时尚无种子:先建管理员账号,再重启 `hxops-backend`(启动钩子会补建)
@@ -77,7 +77,7 @@ VOUCHER_CHECK_DMS_ROOT_FOLDER_ID=<sales-root-folder-id>
- [ ] `hxops-backend` 与 `hxops-schedule-worker` 均注入相同 `VOUCHER_CHECK_ERP_*` / `VOUCHER_CHECK_DMS_*`
- [ ] 密码未出现在 `job_params`、日志样例、Excel 字段中
- [ ] 不再配置 `VOUCHER_CHECK_LOCAL_ROOT` / `VOUCHER_CHECK_SHARE_*`(旧共享盘方案已移除)
- [ ] 只读账号除 HXJM `oma_file` 外,还须能读 **TGHX** 采购单及码表、以及 HXJM 备用出货/订单表(周任务仍不查这些表;独立抓取 PO 需要)。DBA 对只读用户执行(把 `<readonly-user>` 换成实际账号,勿把密码写进工单附件以外的仓库):
- [ ] 只读账号除 HXJM `oma_file` 外,还须能读 **TGHX** 采购单及码表、以及 HXJM 备用出货/订单表(周二 05:00 PO 生成排程需要;06:00 检核仍不查 TGHX)。DBA 对只读用户执行(把 `<readonly-user>` 换成实际账号,勿把密码写进工单附件以外的仓库):
```sql
-- HXJM:发票头;oma99 为空时备用
@@ -102,11 +102,12 @@ GRANT SELECT ON TGHX.zo_file TO <readonly-user>;
## 3. 排程与通知配置
- [ ] 管理后台打开任务「立账凭证检核(周批)」
- [ ] `enabled=true`,时区 `Asia/Shanghai`,Cron `0 6 * * 2`
- [ ] 管理后台打开任务「立账凭证检核(周批)」与「立账凭证 PO 订单生成(周批)」
- [ ] 二者 `enabled=true`,时区 `Asia/Shanghai`
- [ ] PO 生成 Cron `0 5 * * 2`;检核 Cron `0 6 * * 2`(生成必须早于检核)
- [ ] `kb_sync_enabled=false`(本域不需要进知识库)
- [ ] `notify_enabled=true`,`notify_user_ids_json` 填已绑定企微的用户;未配置则不发
- [ ] `job_params.profile_code=sales`,`scope_code=HXJM`
- [ ] 两任务 `job_params.profile_code=sales`,`scope_code=HXJM`
---
@@ -139,32 +140,24 @@ GRANT SELECT ON TGHX.zo_file TO <readonly-user>;
- [ ] DMS 或 ERP 不可用时批次 `failed`,不得把空结果批量判为缺件
- [ ] 企微失败告警到达(若开启)
### 4.5 独立抓取 PO(不走周二任务)
### 4.5 PO 订单生成排程(周二 05:00)
- [ ] 只读账号已 GRANT TGHX(见 §2);周任务日志中**没有** `fetch_po_documents_for_invoices` / `publish_for_invoices`
- [ ] 在 `backend/` 用样本发票出本地 PDF(需应用配置与 Oracle):
```bash
python -m app.services.voucher_check.po_order --out-dir ./tmp-po --invoice EWZZ26090002
```
- [ ] 文件名为 `{发票号}-{pmm01}.pdf`(样本应为 `EWZZ26090002-5220-2609010001.pdf`)
- [ ] 上传走 `ErpPoPrintAdapter.publish_for_invoices`,同名跳过;不要把该方法接到周二 runner
- [ ] 只读账号已 GRANT TGHX(见 §2)
- [ ] 管理台可见 `SCH-ACCOUNTING-VOUCHER-PO-PRINT`,Cron 早于检核
- [ ] 「立即执行」后文档库 `销售开票附件/{年}/{月}/PO订单/` 出现 `{发票}-{pmm01}.pdf`(同名跳过)
- [ ] 检核周批日志中**没有** `fetch_po_documents_for_invoices`;PO 排程日志关键字 `[voucher-po-print]`
- [ ] 工作台「最近一次检核」卡片仍只显示 `accounting-voucher-check`,不被 PO 生成排程抢入口
---
## 5. 在 jobs 表识别立账凭证检核
## 5. 在 jobs 表识别立账凭证排程
平台排程(含立账凭证)仍走统一 `schedule` 队列,**`domain`/`job_type` 会一直是 `schedule` / `schedule_run`**,这是 worker 认领约定,不要按这两列区分业务。
平台排程仍走统一 `schedule` 队列,**`domain`/`job_type` 会一直是 `schedule` / `schedule_run`**。
升级后新入队的 Job:
| 列 | 立账凭证检核示例 |
| --- | --- |
| `business_ref` | `schedule_run:{id}:accounting-voucher-check` |
| `payload_json.platform_api_path` | `accounting-voucher-check` |
| `payload_json.task_name` | `立账凭证检核` |
| `message` | `立账凭证检核等待后台执行` |
| 列 | 检核 | PO 生成 |
| --- | --- | --- |
| `business_ref` | `schedule_run:{id}:accounting-voucher-check` | `schedule_run:{id}:accounting-voucher-po-print` |
| `payload_json.platform_api_path` | `accounting-voucher-check` | `accounting-voucher-po-print` |
```sql
SELECT id, status, business_ref, message, payload_json
@@ -173,13 +166,16 @@ SELECT id, status, business_ref, message, payload_json
AND job_type = 'schedule_run'
AND (
business_ref LIKE '%:accounting-voucher-check'
OR payload_json->>'platform_api_path' = 'accounting-voucher-check'
OR business_ref LIKE '%:accounting-voucher-po-print'
OR payload_json->>'platform_api_path' IN (
'accounting-voucher-check', 'accounting-voucher-po-print'
)
)
ORDER BY id DESC
LIMIT 20;
```
Worker 日志关键字:`[voucher-check]` 或 `[schedule-run] name=立账凭证检核 path=accounting-voucher-check`。
Worker 日志关键字:`[voucher-check]`(检核)或 `[voucher-po-print]`(PO 生成)。
---
@@ -1,8 +1,8 @@
# 立账凭证资料检核技术设计
> 文档版本:v2.10
> 文档版本:v2.11
> 更新时间:2026-09-14
> 状态:销售一期引擎已落地;发票清单改查 oma_file;PO 制式 PDF 生成并上传到「PO订单」目录已实现;ERP 取数(HXJM.oma99 → TGHX.pmm99)已接线,仅独立抓取任务调用,周二 runner 不调用;OA 打印仍待接线
> 状态:销售一期引擎已落地。周二 05:00 `accounting-voucher-po-print` 从 TGHX 取数生成 PO PDF 并上传;周二 06:00 检核只扫描目录。OA 打印仍待接线
> 需求基线:[demand.md](demand.md)
>
> 本文替代旧实现「当月 + 单一共享盘 + 固定文件名存在性」。旧表、共享盘扫描与 Chatflow Tool 已删除,不得按旧口径扩展。
@@ -88,7 +88,7 @@ Adapter 不负责归档、Excel 或通知;引擎不理解 ERP/OA 的具体页
| 命令行 | 在 `backend/` 执行 `python -m app.services.voucher_check.po_order --out-dir DIR [--json FILE.json|--sample|--invoice 发票号]`(只出本地 PDF,不上传) |
| 文件名 | `{invoice_no}-{po_no}.pdf`;`invoice_no` 只用于命名,不印在采购单版面 |
| 数据 | 给定 `PoOrderDocument` / JSON,或 `fetch_po_documents_for_invoices` / `--invoice` 从 Oracle 组装;`po_order` 模块不要写 SQL |
| 周任务 | 仍只扫描「PO订单」目录;`erp_po_print.fetch` 保持 `wired=False`,不要调用 `fetch_documents` / `upload_given` |
| 周任务 | 检核仍只扫描「PO订单」目录;`erp_po_print.fetch` 保持 `wired=False`。生成/上传走独立排程 `accounting-voucher-po-print`(周二 05:00) |
| 字体 | 默认 Windows 宋体或镜像内 `fonts-noto-cjk`;可选 `VOUCHER_CHECK_PO_FONT_PATH` |
对照样张数据在 `po_order/sample.py`,仅供版式核对。
@@ -97,7 +97,7 @@ Adapter 不负责归档、Excel 或通知;引擎不理解 ERP/OA 的具体页
对照现场 TIPTOP 打印作业 `apmr900.4gl`(採購單)。销售发票在 **HXJM**;对应采购单在 **TGHX**(多角贸易抛转后的采购厂,不是 HXJM 自己的 `pmm_file`,也不是 HOX)。拿到 `TGHX.pmm01` 之后按本节填 `PoOrderDocument`;**不要**调 TIPTOP 客户端打印。码表(`pmc`/`pme`/`smy`/`zo` 等)随采购单走 **TGHX**。
实现:`erp_po_repository.fetch_po_documents_for_invoices`;Adapter `fetch_documents` / `publish_for_invoices`。只给独立抓取任务用,**不要**从周二 runner 调用,也**不要**把 `wired` 改成 `True`。只读账号需 GRANT 见 [ops-checklist.md](ops-checklist.md)。
实现:`erp_po_repository.fetch_po_documents_for_invoices`;Adapter `fetch_documents` / `upload_given`。由独立排程 **`accounting-voucher-po-print`(默认周二 05:00)** 调用,**不要**从检核 runner(06:00)调用,也**不要**把 `wired` 改成 `True`。只读账号需 GRANT 见 [ops-checklist.md](ops-checklist.md)。
#### 3.4.1 入口与关联
@@ -365,8 +365,8 @@ ERP/OA 打印或目录扫描的成功文件先写入类型存放目录;完成
1. **已做**:Profile、文件规则、批次/单文件结果表、上月期间、周二 cron、销售 DMS 只读、directory_scan、缺件聚合、批次企微、工作台任务列表、最近一次检核卡片与企微发送记录。
2. **已做**:`dms_archive` 建文件夹(`SaveFolder`)+ 复制(`Item/Copy`),重复策略同名跳过;命中文件记 `archived`。
3. **已做**:制式采购单 PDF(`save_po_order_pdf`)及上传到当月「PO订单」目录(`publish_po_order_pdf` / `upload_given`),命名 `{invoice}-{order_no}.pdf`,同名跳过;`erp_po_print.fetch` 与 OA 仍占位,周任务不调用生成或上传。
4. **已做**:ERP PO 取数(独立抓取:`fetch_po_documents_for_invoices` / `publish_for_invoices`,表字段见 §3.4)。**不要**把生成或上传 PDF 塞进周二 runner。关联:`TRIM(HXJM.oma99)=TRIM(TGHX.pmm99)`。
3. **已做**:制式采购单 PDF(`save_po_order_pdf`)及上传到当月「PO订单」目录(`publish_po_order_pdf` / `upload_given`),命名 `{invoice}-{order_no}.pdf`,同名跳过;`erp_po_print.fetch` 与 OA 仍占位,检核 runner 不调用生成或上传。
4. **已做**:ERP PO 取数 + 独立周批 `accounting-voucher-po-print`(周二 05:00,早于检核 06:00)。检核 runner 不要生成或上传 PDF。关联:`TRIM(HXJM.oma99)=TRIM(TGHX.pmm99)`。
5. 接入 OA 模拟页;采购通过新增 Profile 和 Adapter 参数接入。
## 10. 验收重点
@@ -391,7 +391,7 @@ ERP/OA 打印或目录扫描的成功文件先写入类型存放目录;完成
| ------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------- |
| 每日 `0 6 * * *`,检核**当前自然月** | **每周二** `0 6 * * 2`,检核**上一个自然月** |
| HXJM `apa_file.apa08/apa09` 拉发票清单 | 改为 `oma_file`:`oma10` 发票号码、`oma02` 帐款日期;仅 `omaconf='Y'`、`omavoid='N'`、`oma64='1'`、`oma00` 为 11/12/13;期间为上一个月 |
| 共享盘 `vouche/{YYYY}/{MM}/{invoice_no}/` 只做文件名存在性 | 从文档库类型目录扫描(PO 取数仅独立抓取;OA 打印一期未接线),先落入 `销售开票附件/{年}/{月}/{类型}/`,再归档到同月 `所有归档/{invoice}/` |
| 共享盘 `vouche/{YYYY}/{MM}/{invoice_no}/` 只做文件名存在性 | 从文档库类型目录扫描(PO 由 05:00 独立排程写入类型目录;OA 打印一期未接线),先落入 `销售开票附件/{年}/{月}/{类型}/`,再归档到同月 `所有归档/{invoice}/` |
| 必检「核价单.pdf」「采购单.pdf」 | 销售一期:PO、报关资料、销货放行申请单、发票、报关单、提单 |
| 一票一状态;缺资料按票发企微 textcard、同票同日节流 | 单文件结果;每批一条汇总通知 + invoice 行 Excel |
| Chatflow Tool `/api/accounting-voucher-check/tools/*` | 已删除;查询走工作台 `/api/workspace/accounting-voucher-check/*` |
@@ -202,7 +202,7 @@ error_message 失败原因
| Adapter | 用途 | 销售/采购示例 |
| ------------------------- | ---------------------------------- | -------------------------------- |
| `directory_scan` | 固定目录按规则扫描文件 | 销售发票、提单;采购对账单、发票 |
| `erp_query_print` / `erp_po_print` | 销售 PO:独立抓取按发票从 TGHX 取数(`fetch_documents` / `publish_for_invoices`),生成制式 PDF 并上传到「PO订单」;`fetch()` 仍占位,周任务不调用。表字段见 [technical-design.md §3.4](technical-design.md) | 销售 PO、采购 PO |
| `erp_query_print` / `erp_po_print` | 销售 PO:独立排程 `accounting-voucher-po-print`(周二 05:00)按发票从 TGHX 取数并上传到「PO订单」;`fetch()` 仍占位,检核 runner(06:00)不调用。表字段见 [technical-design.md §3.4](technical-design.md) | 销售 PO、采购 PO |
| `oa_report_print` | OA 报表过滤后逐条打印 | 销售销货放行单 |
| `oa_relation_print` | 根据出货单号等关联字段查 OA 并打印 | 采购核价单 |
| `upload_directory_scan` | 网盘或上传目录扫描 | 采购送货单 |
@@ -531,7 +531,7 @@ backend/app/domains/document_check/
| 采购各固定目录路径 | 待确认 |
| 销售 invoice 主体来源与 ERP 字段 | 已确认:HXJM `oma_file` `oma10`/`oma02`,`oma10` 至少 6 位字母或数字,`omaconf='Y'`、`omavoid='N'`、`oma64='1'`、`oma00 IN (11,12,13)`,期间上一个月 |
| 采购 invoice 主体来源 | 待确认 |
| ERP PO 查询字段与打印方式 | **打印与取数已接线(独立抓取)**。发票 HXJM、采购单 **TGHX**。关联 `TRIM(oma99)=TRIM(pmm99)`。对照 apmr900,见 [technical-design.md §3.4](technical-design.md)。到货日 `pmn34`。周二 runner 不调用 |
| ERP PO 查询字段与打印方式 | **打印与取数已接线(周二 05:00 独立排程)**。发票 HXJM、采购单 **TGHX**。关联 `TRIM(oma99)=TRIM(pmm99)`。对照 apmr900。到货日 `pmn34`。检核 runner 不调用 |
| OA 登录、报表分页和打印接口 | 一期模拟页面;后期对接新 OA 接口 |
| 文档管理系统 | 已确认:同一文档库 LibraryID;销售根 FolderID=`727c3683-dcdb-4d62-a5b1-b164224162bc`;建文件夹 `SaveFolder`、上传 `Attachment/Upload` + `Item/CreateFiles`、复制 `Item/Copy`;同名跳过 |
| 企业微信通知接收人、模板和频率 | 界面从系统用户多选;每周二;具体人选可后配 |
+1 -1
View File
@@ -218,7 +218,7 @@
| --- | --- | --- |
| 销售一期需求、规格与技术设计 | 已文档化 | [需求](features/accounting-voucher-check/demand.md) · [规格](features/accounting-voucher-check/technical.md) · [设计](features/accounting-voucher-check/technical-design.md);每周增量检核上一个月;销售 invoice 来自 HXJM `oma_file`(已确认、未作废、状况码 1、帐款类别 11/12/13) |
| 通用 Profile + Adapter 架构 | 实施中 | 销售 Profile 与 Adapter 协议已落地;周任务扫描文档库类型目录;OA 销货放行单打印仅占位 |
| PO 订单制式 PDF | 已实现(取数仅独立抓取) | `save_po_order_pdf` 按给定数据生成 Crystal/apmr900 对照版式;`fetch_po_documents_for_invoices` / `publish_for_invoices` 按发票从 TGHX 取数并上传到 `销售开票附件/{年}/{月}/PO订单/`;`erp_po_print.fetch` 不进周二 runner;关联 `TRIM(oma99)=TRIM(pmm99)`,见 [technical-design.md §3.4](features/accounting-voucher-check/technical-design.md) |
| PO 订单制式 PDF | 已实现(周二 05:00 独立排程) | 排程 `accounting-voucher-po-print`(`SCH-ACCOUNTING-VOUCHER-PO-PRINT`,`0 5 * * 2`)按上月发票从 TGHX 取数并上传到 `销售开票附件/{年}/{月}/PO订单/`;检核 `accounting-voucher-check` 仍为周二 06:00 只扫目录;`erp_po_print.fetch` 不进检核 runner |
| 单一共享盘旧检核 | 已移除 | 已删除共享盘扫描、Chatflow Tool、`voucher_check_invoice_states` / `voucher_check_run_items` |
| 增量、归档与缺件通知 | 实施中 | 每周二上月;单文件结果;归档复制同名跳过;企微每批一条汇总 |
| 工作台查询 | 已实现 | 工作台含检核任务与企微发送记录两 Tab;期间为年+月(默认上月,月份可「全部」看该年);Tab 下「最近一次检核」卡片不跟筛选;「强制重检上月」在卡片上(admin);`GET /runs/latest`、`/runs`、`/notifications` |
+1 -1
View File
@@ -220,7 +220,7 @@ PDF 证据锚定优先使用现有 `pypdfium2` 逐字文本坐标定位,并由
- **文档库**:复用现有 DMS(`CONTRACT_DMS_BASE_URL`、`/Login/_api/Login`、`/Api/_api/APS/Public/Item/Page`、`SaveFolder`、`Attachment/Upload`、`Item/CreateFiles`、`Item/Copy`、现有账号);LibraryID 与合同相同,销售开票附件只单独配置根 FolderID。类型目录上传与归档复制均为同名跳过。
- **通知**:排程/任务界面从系统用户多选企微接收人;未配置不发送。
- **判定边界**:不读取文件内容、不调用 LLM 判断合格、不回写 ERP。批次级依赖不可用时整批失败,不得把空结果批量判为缺件。
- **当前代码**:周任务已切到上月 `oma_file` 清单 + 文档库类型目录扫描 + 按票归档(Copy,同名跳过)+ 单文件结果 + 批次企微;PO 制式 PDF 生成与上传到「PO订单」已实现。ERP PO 取数(`HXJM.oma99` → `TGHX.pmm99`)已接线,仅独立抓取;`erp_po_print.fetch` / OA 仍为占位,周任务不调用。旧共享盘扫描、Chatflow Tool 与 `voucher_check_invoice_states` / `voucher_check_run_items` 已删除。
- **当前代码**:周二 05:00 `accounting-voucher-po-print` 按上月 `oma_file` 从 TGHX 取数生成 PO PDF 并上传到「PO订单」;周二 06:00 检核扫描类型目录 + 按票归档(Copy,同名跳过)+ 单文件结果 + 批次企微。`erp_po_print.fetch` / OA 仍为占位,检核 runner 不调用生成。旧共享盘扫描、Chatflow Tool 与 `voucher_check_invoice_states` / `voucher_check_run_items` 已删除。
- 详细业务需求见 [docs/features/accounting-voucher-check/demand.md](features/accounting-voucher-check/demand.md),研发落地设计见 [docs/features/accounting-voucher-check/technical-design.md](features/accounting-voucher-check/technical-design.md)。
### 2.x 货代发货通知批次库存能力
+2
View File
@@ -2360,6 +2360,8 @@
"difySystemPromptPlaceholder": "e.g. You are a material compliance assistant. Based on record test data, return JSON with dify_result (pass/fail/manual review) and dify_message.",
"platformJobAccountingVoucherCheck": "Accounting voucher check",
"accountingVoucherCheckHint": "Every Tuesday, check the previous calendar month of sales invoice attachments: load the ERP invoice list, scan document-library type folders, and archive by invoice (skip same names).",
"platformJobAccountingVoucherPoPrint": "Accounting voucher PO print",
"accountingVoucherPoPrintHint": "Every Tuesday at 05:00, fetch last month's invoices from ERP, generate purchase-order PDFs, and upload them to the PO-order folder—before the 06:00 check. Skip same names.",
"voucherCheckScope": "Ledger scope",
"voucherCheckProfile": "Business profile",
"voucherCheckNotifyMissing": "Notify on missing materials",
+2
View File
@@ -2238,6 +2238,8 @@
"difySystemPromptPlaceholder": "เช่น คุณเป็นผู้ช่วยตรวจสอบความสอดคล้องของวัสดุ จากข้อมูล record ให้คืน JSON: dify_result (ผ่าน/ไม่ผ่าน/ตรวจด้วยมือ) และ dify_message",
"platformJobAccountingVoucherCheck": "ตรวจสอบเอกสารบัญชี",
"accountingVoucherCheckHint": "ทุกวันอังคาร ตรวจเอกสารใบแจ้งหนี้ขายของเดือนก่อน: ดึงรายการใบแจ้งหนี้จาก ERP สแกนโฟลเดอร์ประเภทในคลังเอกสาร แล้วจัดเก็บตาม invoice (ข้ามชื่อซ้ำ)",
"platformJobAccountingVoucherPoPrint": "สร้างใบสั่งซื้อ PO สำหรับเอกสารบัญชี",
"accountingVoucherPoPrintHint": "ทุกวันอังคาร 05:00 ดึงใบแจ้งหนี้เดือนก่อนจาก ERP สร้าง PDF ใบสั่งซื้อมาตรฐาน แล้วอัปโหลดไปยังโฟลเดอร์ PO — ก่อนงานตรวจ 06:00 ข้ามชื่อซ้ำ",
"voucherCheckScope": "ชุดบัญชี",
"voucherCheckProfile": "โปรไฟล์ฝ่ายธุรกิจ",
"voucherCheckNotifyMissing": "แจ้งเตือนเมื่อขาดเอกสาร",
+2
View File
@@ -2472,6 +2472,8 @@
"difySystemPromptPlaceholder": "例如:你是物料合规判定助手。根据 record 中的检测数据判定是否合格,仅返回 JSON:dify_result(合格/不合格/人工判定)与 dify_message。",
"platformJobAccountingVoucherCheck": "立账凭证检核",
"accountingVoucherCheckHint": "每周二检核上一个自然月的销售开票附件:拉取 ERP 发票清单,扫描文档库类型目录并按 invoice 归档(同名跳过)。",
"platformJobAccountingVoucherPoPrint": "立账凭证 PO 订单生成",
"accountingVoucherPoPrintHint": "每周二 05:00 按上月发票从 ERP 取数,生成制式采购单 PDF 并上传到「PO订单」目录;早于 06:00 检核周批。同名跳过。",
"voucherCheckScope": "账套",
"voucherCheckProfile": "业务方 Profile",
"voucherCheckNotifyMissing": "缺资料通知",
+2
View File
@@ -2243,6 +2243,8 @@
"difySystemPromptPlaceholder": "例如:你是物料合規判定助手。根據 record 中的檢測資料判定是否合格,僅返回 JSON:dify_result(合格/不合格/人工判定)與 dify_message。",
"platformJobAccountingVoucherCheck": "立帳憑證檢核",
"accountingVoucherCheckHint": "每週二檢核上一個自然月的銷售開票附件:拉取 ERP 發票清單,掃描文件庫類型目錄並依 invoice 歸檔(同名略過)。",
"platformJobAccountingVoucherPoPrint": "立帳憑證 PO 訂單產生",
"accountingVoucherPoPrintHint": "每週二 05:00 依上月發票從 ERP 取數,產生制式採購單 PDF 並上傳到「PO訂單」目錄;早於 06:00 檢核週批。同名略過。",
"voucherCheckScope": "帳套",
"voucherCheckProfile": "業務方 Profile",
"voucherCheckNotifyMissing": "缺資料通知",