Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
4.3k views
in Technique[技术] by (71.8m points)

python - Django Create Recurring Payments

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

There're planty of packages you can use: django-crontab, django-background-tasks, django-apscheduler and etc.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...