简体   繁体   English

Django 创建定期付款

[英]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 .我需要一些指导来创建一个循环遍历 Destitute的 function,每月创建定期付款,并将它们记录在Credit 表中 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.逻辑是,如果穷人超过 50 岁,他们将获得 2500k 的报酬,如果低于 50 岁,他们将获得 2000k 的报酬。 If there is a Django package that can help achieve that would be great.如果有一个 Django package 可以帮助实现,那就太好了。

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

There're planty of packages you can use: django-crontab , django-background-tasks , django-apscheduler and etc.您可以使用许多软件包: django-crontabdjango-background-tasksdjango-apscheduler等。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM