feat(crm): add settlement clause default text helper
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
38a9f6f724
commit
a73ee89f44
2 files changed
+64
No files matched your search
@@ -0,0 +1,34 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Optional
|
||||
|
||||
ADVANCE_PAYMENT = "advance_payment"
|
||||
ARRIVE_PAYMENT = "arrive_payment"
|
||||
|
||||
CLAUSE_LABELS = {
|
||||
"volume_settlement": "按量结算",
|
||||
"monthly_settlement": "月结",
|
||||
"quarterly_settlement": "季结",
|
||||
"other_settlement": "其他",
|
||||
}
|
||||
|
||||
ADVANCE_CLAUSE = (
|
||||
"款到发货。需方付款后安排发货,需方收到货物后,供方开具13%增值税专用发票。"
|
||||
)
|
||||
ARRIVE_CLAUSE = (
|
||||
"货到付款,需方收到供方货物后,供方开具13%增值税专用发票,无异议后,以现汇方式月结。"
|
||||
)
|
||||
|
||||
|
||||
def default_settlement_clause(settlement_method: Optional[str]) -> str:
|
||||
method = (settlement_method or "").strip() or ARRIVE_PAYMENT
|
||||
if method == ADVANCE_PAYMENT:
|
||||
return ADVANCE_CLAUSE
|
||||
if method in CLAUSE_LABELS:
|
||||
label = CLAUSE_LABELS[method]
|
||||
return (
|
||||
f"请根据双方约定填写结算方式:{label}。"
|
||||
"供方开具13%增值税专用发票,无异议后,以现汇方式月结。"
|
||||
)
|
||||
# arrive_payment 与未知值
|
||||
return ARRIVE_CLAUSE
|
||||
@@ -0,0 +1,30 @@
|
||||
from app.services.crm_settlement_clause import default_settlement_clause
|
||||
|
||||
|
||||
def test_advance_payment_clause():
|
||||
assert "款到发货" in default_settlement_clause("advance_payment")
|
||||
|
||||
|
||||
def test_arrive_payment_clause():
|
||||
assert "货到付款" in default_settlement_clause("arrive_payment")
|
||||
|
||||
|
||||
def test_monthly_settlement_clause_uses_label():
|
||||
text = default_settlement_clause("monthly_settlement")
|
||||
assert text.startswith("请根据双方约定填写结算方式:月结。")
|
||||
assert "13%增值税专用发票" in text
|
||||
|
||||
|
||||
def test_volume_quarterly_other_labels():
|
||||
assert "按量结算" in default_settlement_clause("volume_settlement")
|
||||
assert "季结" in default_settlement_clause("quarterly_settlement")
|
||||
assert "其他" in default_settlement_clause("other_settlement")
|
||||
|
||||
|
||||
def test_unknown_falls_back_to_arrive():
|
||||
assert default_settlement_clause("weird") == default_settlement_clause("arrive_payment")
|
||||
|
||||
|
||||
def test_empty_falls_back_to_arrive():
|
||||
assert default_settlement_clause("") == default_settlement_clause("arrive_payment")
|
||||
assert default_settlement_clause(None) == default_settlement_clause("arrive_payment")
|
||||
Reference in new issue
Block a user