add & fix - transaction dashboard / edit distribution with stat validation bug

This commit is contained in:
2025-11-26 09:52:14 +03:30
parent 552813edd5
commit d63aa36a19
7 changed files with 209 additions and 8 deletions

View File

@@ -50,14 +50,14 @@ class QuotaStatsValidator:
if amount < 0:
raise DistributionException("مقدار وزن نباید منفی باشد", status.HTTP_403_FORBIDDEN) # noqa
if remaining < amount and not allow_zero:
if remaining + amount < amount and not allow_zero:
if update_operation:
raise DistributionException(
"مقدار وزن ویرایش شده از وزن باقیمانده بیشتر است", # noqa
status.HTTP_403_FORBIDDEN
)
raise DistributionException(
f"تخصیص مقدار {amount} بیشتر از مقدار باقیمانده {remaining} برای سازمان {assigner_org.name} میباشد.",
f"تخصیص مقدار {amount} بیشتر از مقدار باقیمانده {remaining + amount} برای سازمان {assigner_org.name} میباشد.",
# noqa
status.HTTP_403_FORBIDDEN
)