forked from erp-dev/erp
beta
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user