Explorar el Código

分账逻辑修改 增加分润0.01分的归属检测

zjl hace 1 año
padre
commit
cecb1c0a2d
Se han modificado 1 ficheros con 9 adiciones y 1 borrados
  1. 9 1
      apps/web/report/ledger.py

+ 9 - 1
apps/web/report/ledger.py

@@ -340,7 +340,7 @@ class LedgerConsumeOrder(object):
     """
     _source = "ledger_consume"
 
-    def __init__(self, statsRecord, ledgerTime=None):   # type: (DealerGroupStats, str) -> None
+    def __init__(self, statsRecord, ledgerTime=None):   # type: (DealerGroupStat, str) -> None
         self._record = statsRecord
         self._time = ledgerTime
         self._owner = self._record.dealer               # type: Dealer
@@ -445,6 +445,14 @@ class LedgerConsumeOrder(object):
             totalP += _s
             partition.append(_p)
 
+        # 最后有可能会出现 多一分的 情况
+        if abs(leftShareMoney) > RMB(0.01):
+            raise ValueError("leftShareMoney gt 0.01, record = {}".format(self._record.id))
+
+        if leftShareMoney != RMB(0):
+            partition[-1]["money"] = RMB(leftShareMoney).mongo_amount + RMB(partition[-1]["money"]).mongo_amount
+            totalMoney += leftShareMoney
+
         if elecPayerCount > 1:
             raise ValueError("elecPayerCount gt 1, record = {}".format(self._record.id))
         if abs(totalMoney) > abs(totalAmount):