Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class InterestLoanSet(models.QuerySet):
- def add_end_date(self):
- return self.annotate(loan_end_date=ExpressionWrapper(F('start_date') + relativedelta(months=+F('term'), output_field=DateField())))
- def active_loans(self, start_date, end_date):
- return self.exclude(start_date__gt=end_date).add_end_date().exclude(loan_end_date__lt=start_date)
- class InterestLoan(AbstractTransaction):
- objects = InterestLoanSet.as_manager()
- interest_nominal_code = models.ForeignKey(NominalCode, null=False, on_delete=models.PROTECT)
- balance_nominal_code = models.ForeignKey(NominalCode, null=False, on_delete=models.PROTECT, related_name='loans')
- principal = models.DecimalField(max_digits=10, decimal_places=2)
- term = models.PositiveIntegerField()
- interest_rate = models.DecimalField(max_digits=4, decimal_places=4)
Add Comment
Please, Sign In to add comment