1
0
forked from erp-dev/erp
This commit is contained in:
2026-07-02 18:26:09 +08:00
parent 5170700234
commit 4538e51ad5
14 changed files with 471 additions and 26 deletions

View File

@@ -16,6 +16,7 @@ from stock import models as stock_models
from stock.services import StockFlowService
from basic_info.services import MerchantSettingService
from .amounts import normalize_money_amount
from . import models
from .tasks import (
create_purchase_order_stock_entries,
@@ -2272,7 +2273,7 @@ def _to_decimal(value, field_name: str) -> Decimal:
def _ensure_non_zero_amount(value, field_name: str) -> Decimal:
amount = _to_decimal(value, field_name)
amount = normalize_money_amount(_to_decimal(value, field_name), field_name=field_name)
# 金额类字段要求非零(允许负数用于处理退款场景)
# 付款单负金额 = 供应商退款,收款单负金额 = 退款给客户
if amount == 0:
@@ -2288,7 +2289,7 @@ def _ensure_order_pending(order, pending_status, entity_name: str):
def _ensure_non_negative_amount(value, field_name: str) -> Decimal:
if value in (None, ''):
return Decimal('0')
amount = _to_decimal(value, field_name)
amount = normalize_money_amount(_to_decimal(value, field_name), field_name=field_name)
if amount < 0:
raise ValueError(f'{field_name} 不能小于 0')
return amount