class Loan(models.Model):
        id = models.AutoField(primary_key=True,default=1)
        loan_type       =models.CharField(max_length=20, 
choices=LTYPE,default=1)
        def number():
                no =Account.objects.count()
                if no == None:
                        return 100000
                else:
                        return no + 100001


        
loan_statement_no=models.IntegerField(('loan_statement_no'),max_length=10, 
unique =True, default=number)
        branch_cod      =models.IntegerField(blank=True, null=True)
        comp_per_ya     =models.IntegerField(default=1, help_text="Number 
of compoundings in a year")
        time_years      =models.DecimalField(default=1.0, max_digits=10, 
decimal_places=1)
        loan_number     =models.SlugField(unique=True)
        #branch         =models.ManyToManyField(Branche)
        start_date      =models.DateField(blank=True, 
null=True,default=datetime.datetime.now())
        end_date        =models.DateField(blank=True, null=True)
        no_days         =models.IntegerField(default=1)
        account_name    =models.ForeignKey(Account)
        loan_amount     =models.DecimalField(default=1.0, max_digits=10, 
decimal_places=2)
        interest_rate   =models.DecimalField(default=1.0, max_digits=10, 
decimal_places=2, null=True, blank=True)
        compound_period =models.IntegerField(max_length=64, 
choices=compound_period, default=Yearly)
        loan_fee        =models.DecimalField(default=1.0, max_digits=10, 
decimal_places=2, null=True, blank=True)
        ammount_repaid= models.DecimalField(default=1.0, max_digits=10, 
decimal_places=2, null=True, blank=True)
        sd_amount       =models.DecimalField(default=1.0, max_digits=10, 
decimal_places=2, null=True, blank=True)
        dd_amount       =models.DecimalField(default=1.0, max_digits=10, 
decimal_places=2, null=True, blank=True)
        #interest (base) rate
        ib_rate         =models.DecimalField(default=1.0, max_digits=10, 
decimal_places=2, null=True, blank=True)
        #interest (penal) rate
        ip_rate         =models.DecimalField(default=1.0, max_digits=10, 
decimal_places=2, null=True, blank=True)
        #interest repayment frequency
        ir_frequency    
=models.IntegerField(max_length=64,choices=IRFREQUENCY,default=WEEKLY)
        pr_frequency    
=models.IntegerField(max_length=64,choices=PRFREQUENCY,default=DAILY,help_text="Suggested
 
value automatically generated from title. Must be unique.")


        last_edit_time  = models.TimeField(auto_now=True)
        last_edit_date  = models.DateField(auto_now=True)
           no_of_instalments = models.DecimalField(default=1.0, 
max_digits=10, decimal_places=2, null=True, blank=True)
        no_of_instalments_interest =models.DecimalField(default=1.0, 
max_digits=10, decimal_places=2, null=True, blank=True)
        interest_charged = models.DecimalField(default=1.0, max_digits=10, 
decimal_places=2, editable=False)
       

        def save(self, *args, **kwargs):
                i
                self.no_days =(self.end_date - self.start_date).days
                self.required_payment =self.loan_amount 
((1+(((self.interest_rate)/(self.compound_period))/100))**((self.compound_period)
 
* (self.time_years)))
        self.no_of_instalments = (self.no_days) / (self.pr_frequency)
                self.no_of_instalments_interest = (self.no_days) / 
(self.ir_frequency)
 def name(self):
                return self.account_name.name
 


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to