১৪.৩ : ডিপোজিট , উইথড্র , লোন রিকোয়েস্ট ফর্ম তৈরী
class DepositForm(TransactionForm):
def clean_amount(self): # amount field ke filter korbo
min_deposit_amount = 100
amount = self.cleaned_data.get('amount') # user er fill up kora form theke amra amount field er value ke niye aslam, 50
if amount < min_deposit_amount:
raise forms.ValidationError(
f'You need to deposit at least {min_deposit_amount} $'
)
return amountclass WithdrawForm(TransactionForm):
def clean_amount(self):
account = self.account
min_withdraw_amount = 500
max_withdraw_amount = 20000
balance = account.balance # 1000
amount = self.cleaned_data.get('amount')
if amount < min_withdraw_amount:
raise forms.ValidationError(
f'You can withdraw at least {min_withdraw_amount} $'
)
if amount > max_withdraw_amount:
raise forms.ValidationError(
f'You can withdraw at most {max_withdraw_amount} $'
)
if amount > balance: # amount = 5000, tar balance ache 200
raise forms.ValidationError(
f'You have {balance} $ in your account. '
'You can not withdraw more than your account balance'
)
return amountLast updated