Hello everyone was requesting for help on this micro-finance software am 
developing, needed to make the account balance reflect updated  
amount/value on the database when deposits/withdraws are made on either the 
account or loan repayment 

*class Branch(models.Model):*
    time_stamp     =models.DateTimeField(default=datetime.datetime.now(), 
editable=False)
    name         =models.CharField(max_length=200) 
    physical_location=models.CharField(max_length=200)
    email        =models.EmailField()

*class Account(models.Model):*
    account_type        =models.CharField(max_length=200, choices=ACCTYPE)
    branch            =models.ForeignKey('Branch')
    first_name            =models.CharField(max_length=200)
    last_name               =models.CharField(max_length=200)
    account_number =models.SlugField(unique=True)   
    account_current_balance =models.FloatField(max_length=255,default=0)
*
class Account_holder(models.Model):*
    id                 =models.IntegerField(primary_key=True,default=1)
    account_id         =models.ManyToManyField(Account)
    

*

class Loan(models.Model):*
    id = models.AutoField(primary_key=True,default=1)
    branch_cod    =models.IntegerField(blank=True, null=True)
    time_years    =models.DecimalField(default=1.0, max_digits=10, 
decimal_places=4)
    loan_number     =models.SlugField(unique=True)
    account_name    =models.ForeignKey(Account)
    loan_amount    =models.DecimalField(default=0.0, max_digits=10, 
decimal_places=2)
    interest_rate    =models.DecimalField(default=0.0, max_digits=10, 
decimal_places=2)
    interest_charged = models.DecimalField(default=0.0, max_digits=10, 
decimal_places=2, editable=False)
    required_payement = models.DecimalField(default=1.0, max_digits=10, 
decimal_places=2)
*
class statement(models.Model):*
    account_id =models.ForeignKey(Account)
     date = models.DateTimeField(default=datetime.datetime.now(), 
editable=False)
     deposit = models.PositiveIntegerField(null=True, default=0)
     withdraw = models.PositiveIntegerField(null=True, default=0)
     description =models.TextField(max_length=200)
     current_balance = models.FloatField(max_length=200, editable=False)
    
    def save(self, *args, **kwargs):
         self.current_balance =  self.account_id.average_balance + 
self.credit - self.debit
                 self.average_balance = self.account_id.average_balance + 
self.credit - self.debit -self.minimum_balance
         super(statement,self).save(*args, **kwargs)
*
 class Savant_user(models.Model):*
      user =models.OneToOneField(User) 
      branch =models.ManyToManyField('Branch')
     
              

      def create_Dashboard_user_callback(sender, instance, **kwargs):
          Dashboard, new = Savant_user.objects.get_or_create(user=instance)
          post_save.connect(create_Dashboard_user_callback, User)

-- 
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 django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/bc56f702-6038-4855-8e90-809ecc67c7d5%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to