Вычислите сумму баланса для каждой валюты из модели - Django

Я хочу рассчитать баланс для каждой валюты на основе депозита и снятия. в transaction_type 'd'=депонированная сумма и 'w'=снятая сумма

I want to calculate Balance for each currency based on deposit and withdrawal. in transaction_type 'd'=deposited amount and 'w'=withdrawn amount.

Model Code:
class Transactions(models.Model):
    transaction_currency=models.IntegerField(max_length=50)
    transaction_amount=models.FloatField()
    transaction_date= models.DateField(auto_now_add=False)
    transaction_description=models.TextField()
    transaction_type=models.CharField(max_length=5)

View Function:
def Available_Amount(request):
    
    available_amont = (how to calculate available amount for each currency?)   
 
Вернуться на верх