Features: 1) Add validation to return_balance_back to skip execution if status is already "RETURNED"; 2) Raise NotImplementedError when attempting to process a return without an associated user.
Fixes: None; Extra: None;
This commit is contained in:
parent
afaab0354e
commit
135fc6e26d
1 changed files with 4 additions and 0 deletions
|
|
@ -1937,8 +1937,12 @@ class OrderProduct(ExportModelOperationsMixin("order_product"), NiceModel):
|
||||||
]
|
]
|
||||||
|
|
||||||
def return_balance_back(self):
|
def return_balance_back(self):
|
||||||
|
if self.status == "RETURNED":
|
||||||
|
return
|
||||||
self.status = "RETURNED"
|
self.status = "RETURNED"
|
||||||
self.save()
|
self.save()
|
||||||
|
if not self.order.user:
|
||||||
|
raise NotImplementedError
|
||||||
self.order.user.payments_balance.amount += self.buy_price
|
self.order.user.payments_balance.amount += self.buy_price
|
||||||
self.order.user.payments_balance.save()
|
self.order.user.payments_balance.save()
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue