Exemple #1
0
 def clean(self):
     form_data = self.cleaned_data
     amount = form_data.get("amount", None)
     if amount:
         from control.account_calculations import total_account_amount
         if total_account_amount(self.account) < amount:
             self._errors['amount'] = "Your balance is not enough!"
Exemple #2
0
 def __init__(self, account, *args, **kwargs):
     from control.account_calculations import total_account_amount
     super(AccountTransferForm, self).__init__(*args, **kwargs)
     self.account = account
     self.fields['to_account'].queryset = Account.objects.filter(
         is_active=True).exclude(id=self.account)
     self.fields['to_account'].empty_label = "Choose Account to transfer"
     self.fields['amount'].max_value = total_account_amount(self.account)
Exemple #3
0
 def clean(self):
     form_data = self.cleaned_data
     amount = form_data.get("expense_amount", None)
     account_id = form_data.get("payment_method", None)
     if amount:
         if not account_id == "Cash Collections":
             if total_account_amount(int(account_id)) < amount:
                 self._errors['payment_method'] = "Your balance is not enough! transfer or recharge"
         else:
             if get_today_total_cash_amount() < amount:
                 self._errors['payment_method'] = "Your balance is not enough! transfer or recharge"
def total_account_amount(account):
    from control.account_calculations import total_account_amount
    total = total_account_amount(account)
    return total