Good day,
I have two models, one for the destitute and the other for credit payments to be submitted to a bank for deposit into the destitute's acc.
I need some guidance creating a function that loops through the Destitute table, creates recurring payments every month, and records them in the Credit table. Logic is if the destitute is above the age of 50 they get paid 2500k if below the age of 50 they get paid 2000k. If there is a Django package that can help achieve that would be great.
class Destitute(models.Model):
GENDER = (("male", "male"), ("female", "female"))
name = models.CharField(max_length=100)
acc_no = models.CharField(_("Bank Account"),max_length=50)
age = models.PositiveIntegerField(default=1)
sex = models.CharField(
_("Gender "), max_length=64, choices=GENDER)
created_on = models.DateTimeField(_("Date Joined"), auto_now_add=True)
def __str__(self):
return self.name
class Credit(models.Model):
credit_title = models.CharField(_("Payment Title"), max_length=50)
payee = models.ForeignKey(
Destitute, related_name="destitute_paid", on_delete=models.SET_NULL, null=True, blank=True)
total_amount = models.DecimalField(
blank=True, null=True, max_digits=12)
payment_date = models.DateField(blank=True, null=True)
def __str__(self):
return self.credit_title