信用卡系统实施?

发布于 2024-08-23 19:22:49 字数 2755 浏览 9 评论 0原文

我的网站将有一个信用系统,其工作原理基本上类似于信用卡。每个用户都有无限的信用额度,但在每周结束时,他们必须还清。例如,用户可能在 3 月 1 日至 7 日之间进行了多次购买,然后在 3 月 7 日结束时,他们将收到一封电子邮件发票,其中列出了他们在一周内的所有购买以及截至 14 日到期的总额。如果他们不还清,他们的帐户就会被停用,直到他们还清为止。我只是想弄清楚如何实现这一点。

我有他们所有购买的清单,这不是问题,但我只是想弄清楚如何处理它。在第 7 天结束时,我可以设置一个 cronjob 来生成发票,该发票基本上有一个 ID 和到期日期,然后我需要另一个多对多表将所有购买链接到发票。然后,当用户向他们的帐户添加资金时,我猜它会应用于他们当前的未结发票?如果他们在新发票开具时没有付清发票,那么现在他们有 2 张未清发票,我如何知道该针对哪张发票应用呢?或者我是否让 cronjob 检查任何以前的未清发票,取消它们,并将新项目添加到新发票作为“余额远期(+利息)”?您将如何根据发票使用这笔钱?每笔付款是否都必须与发票相关联,或者我可以将其存入他们的帐户信用中,然后以某种方式找出已支付的内容和未支付的内容吗?如果他们在发票生成之前提前付款怎么办?我是在生成时从发票的信用额中扣除还是在到期时的周末从发票中扣除?有很多方法可以做到这一点...

任何人都可以描述他们会采取什么方法吗?


如果有人感兴趣,我的发票模型目前如下所示(在 Django 中)。 InvoiceItems 通过反向 ID 链接到实际的“产品”(FK 位于产品上,而不是发票项目上,以允许不同的项目类型(不同的表)),但我想我将对此进行切换。

class Invoice(models.Model):
    user = models.ForeignKey(User, related_name='invoices')
    created = models.DateTimeField(auto_now_add=True)
    updated = models.DateTimeField(auto_now=True)
    closed_date = models.DateTimeField(null=True, blank=True)
    due_date = models.DateTimeField(default=_next_weekday())
    payment_date = models.DateTimeField(null=True, blank=True) # date the invoice was fully paid
    total_payments = CurrencyField(default=0)
    interest_charges = CurrencyField(default=0)

    @property
    def days_overdue(self):
        dt = self.due_date - datetime.date.today()
        return dt.days if dt.days > 0 else 0

    @property
    def item_total(self):
        return self.items.filter(amount__gt=0).aggregate(t=Sum('amount'))['t'] or Decimal('0.00')

    @property
    def daily_interest(self):
        return _round((self.item_total - self.total_payments) * settings.INTEREST_RATE/Decimal('365.242199'))

    @property
    def subtotal(self):
        return self.item_total + self.interest_charges

    @property
    def tax(self):
        return _round(self.subtotal * settings.GST)

    @property
    def total(self):
        return self.subtotal + self.tax

    @property
    def balance_owing(self):
        return self.total - self.total_payments

    @property
    def is_paid(self):
        return self.payment_date != None

    @property
    def is_open(self):
        return self.closed_date == None

    @property
    def is_overdue(self):
        return not self.is_paid and self.due_date < datetime.date.today()

class InvoiceItem(models.Model):
    invoice = models.ForeignKey(Invoice, related_name='items')
    created = models.DateTimeField(auto_now_add=True)
    updated = models.DateTimeField(auto_now=True)
    description = models.CharField(max_length=200)
    trans_date = models.DateTimeField(verbose_name='transaction date')
    amount = CurrencyField()

我设置了一个 crontab,每天晚上午夜运行,为所有逾期项目添加利息费用,并且每周五早上都会邮寄发票。

My site is going to have a credit system that basically works a lot like a credit card. Each user has an unlimited credit limit, but at the end of each week, they have to pay it off. For example, a user might make several purchases between March 1st and 7th, and then at the end of March 7th, they would be emailed an invoice that lists all their purchases during the week and a total that is due by the 14th. If they don't pay it off, their account is simply deactivated until they do. I'm just trying to wrap my head around how to implement this.

I have a list of all their purchases, that's not a problem, but I'm just trying to figure out what to do with it. On the end of the 7th day, I could set up a cronjob to generate an invoice, which would basically have an id, and due date, and then I would need another many-to-many table to link all the purchases to the invoice. Then when a user adds money to their account, I guess it's applied against their current outstanding invoice? And what if they don't pay off their invoice by the time a new invoice rolls around, so now they have 2 outstanding ones, how do I know which to apply it against? Or do I make the cronjob check for any previous outstanding invoices, cancel them, and add a new item to the new invoice as "balance forward (+interest)"? How would you apply the money against an invoice? Would each payment have to be linked to an invoice, or could I just deposit it to their account credit, and then somehow figure out whats been paid and what hasn't? What if they pay in advance, before their invoice has been generated? Do I deduct it from their credit from the invoice upon generation, or at the end of the week when its due? There are so many ways to do this...

Can anyone describe what approach they would take?


If anyone's interested, my Invoice model presently looks as follows (in Django). The InvoiceItems are linked to actual "products" by a reverse ID (the FK is on the product, not the invoice item to allow different item types (different tables)), but I think I'm going to switch that around.

class Invoice(models.Model):
    user = models.ForeignKey(User, related_name='invoices')
    created = models.DateTimeField(auto_now_add=True)
    updated = models.DateTimeField(auto_now=True)
    closed_date = models.DateTimeField(null=True, blank=True)
    due_date = models.DateTimeField(default=_next_weekday())
    payment_date = models.DateTimeField(null=True, blank=True) # date the invoice was fully paid
    total_payments = CurrencyField(default=0)
    interest_charges = CurrencyField(default=0)

    @property
    def days_overdue(self):
        dt = self.due_date - datetime.date.today()
        return dt.days if dt.days > 0 else 0

    @property
    def item_total(self):
        return self.items.filter(amount__gt=0).aggregate(t=Sum('amount'))['t'] or Decimal('0.00')

    @property
    def daily_interest(self):
        return _round((self.item_total - self.total_payments) * settings.INTEREST_RATE/Decimal('365.242199'))

    @property
    def subtotal(self):
        return self.item_total + self.interest_charges

    @property
    def tax(self):
        return _round(self.subtotal * settings.GST)

    @property
    def total(self):
        return self.subtotal + self.tax

    @property
    def balance_owing(self):
        return self.total - self.total_payments

    @property
    def is_paid(self):
        return self.payment_date != None

    @property
    def is_open(self):
        return self.closed_date == None

    @property
    def is_overdue(self):
        return not self.is_paid and self.due_date < datetime.date.today()

class InvoiceItem(models.Model):
    invoice = models.ForeignKey(Invoice, related_name='items')
    created = models.DateTimeField(auto_now_add=True)
    updated = models.DateTimeField(auto_now=True)
    description = models.CharField(max_length=200)
    trans_date = models.DateTimeField(verbose_name='transaction date')
    amount = CurrencyField()

I have a crontab set up to run at midnight every night to add interest charges to all overdue items, and invoices are mailed out every Friday morning.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

只等公子 2024-08-30 19:22:49

您在这里所描述的基本上是未清项目会计和余额远期会计之间的决定。

在未清项目会计中,每张发票在有余额时都保持“未结”状态,并且付款归因于他们正在支付的各个发票。这使得计算利息之类的事情变得更加容易 - 例如,如果您只对超过 30 天的欠款收取利息,那么您需要知道哪些发票的未清余额超过 30 天。

余额远期会计类似于信用卡付款,其中一笔余额可以结转,并且根据该总余额而不是单独的发票进行付款。

更新澄清

未清项目会计适用于复杂的计费流程,例如,当只有部分产品附加到某些发票时。例如,建筑商购买了几十种产品,但要为三个不同的建筑项目单独开具发票。

当您需要跟踪每张发票以用于付款和解决争议时,也可以使用未清项目会计。例如,建筑供应有一个为客户提供的建筑商。有时,提供的货物是错误的或有缺陷的,因此建筑商支付除那一张单独跟踪和处理的发票之外的所有其他发票(包括最近的发票) - 也许在提供替换货物时获得付款,或者可能获得一张贷方票据发票。

在余额远期会计中,您可以通过简单地对整个帐户应用贷方,然后在供应替代货物时重新添加交易来处理这种情况。余额上收取的任何利息也可以从账户中冲销。

简而言之,您可以通过以下方式在数据库中进行设置:

未清项目会计

您需要以下表格:

Client       [ClientId, Name, AccountBalance]
Product      [ProductId, Description, Cost]
Invoice      [InvoiceId, ClientId, Date, TotalAmount, Outstanding]
InvoiceItem  [InvoiceId, ProductId, Quantity, Amount]
Receipt      [ReceiptId, Date, TotalAmount]
ReceiptItem  [ReceiptId, InvoiceId, Amount]

客户在购买产品时获得一张创建的发票。对于购买的每个产品,都会为该产品创建一个发票项目,显示购买的数量和金额。更新发票时,发票的未清余额是发票和客户帐户余额更新的总和(可以动态计算,但如果自动维护,则更容易、更快)。当客户支付一张或多张发票时,将创建收据并将收据项目分配给每张正在支付的发票。发票的未清余额与客户的帐户余额一样更新。请注意,超额付款需要单独处理。利息费用作为发票项目(可以是自定义产品)在下一张发票(或单独的发票)上收取。

余额远期会计

您需要以下表格:

Client       [ClientId, Name, AccountBalance]
Product      [ProductId, Description, Cost]
Invoice      [InvoiceId, ClientId, Date, Amount]
Transaction  [TransactionId, ClientId, InvoiceId, ProductId, Date, Quantity, Amount]

购买产品时,会在客户的帐户上进行交易,显示产品的数量和金额,并且更新客户的帐户余额。当收到收据时,再次在客户的帐户上进行交易并且更新客户的帐户余额。超额支付和利息支付也只是一种交易。在开具发票时,您只需获取未分配给发票的所有交易(购买、收据、利息支付等)并将它们添加到新发票中。发票不会出现在交易列表中,只是为了方便跟踪已开具发票的交易以及在付款时为客户提供参考号。您可能还想跟踪此模型中的收据。

其他注意事项

  • 这没有考虑总账过账,总账过账将是一组完全不同的表。这只是针对管理会计,而不是财务会计。
  • 实际上,客户和发票之间可能有一个项目表,用于跟踪每个客户与您的个人项目。
  • 这真的很简单,只是为了给你一个想法。全面实施无疑需要更多的表和字段。

至于如果他们在开票时不支付发票会发生什么,在任何一个系统中都没有关系 - 您不会回到过去并更改以前的会计分录。现在发生的任何事情都会记在一张新发票上。当然,在新发票上添加一行“先前未清余额”是完全合适的,该行显示他们已经欠下的金额(或因超额付款而记入贷方的金额)。

您还希望能够生成一份账户报表,它不是发票,它就像一封提醒他们有未清余额的信函。当没有要生成的新发票但客户需要有关其帐户余额的提醒时使用此功能。

我更喜欢为我的系统使用未清项目会计,但从您的描述来看,余额远期会计听起来很合适。

What you are describing here is basically a decision between open item accounting and balance forward accounting.

In open item accounting, each invoice is kept "open" while it has a balance owing and payments are attributed to the individual invoices that they are paying. This makes it easier to work out things like interest - for example if you only charge interest on balances owing older than 30 days then you need to know what invoices have outstanding balances more than 30 days old.

Balance forward accounting is similar to credit card payments, when there is one lump sum balance that is carried forwards and payments are made against that total balance rather than individual invoices.

Update for clarification

Open item accounting is good for complex billing processes, for example when only some of the products are attached to certain invoices. For example, a builder buys a few dozen products but they are to be invoiced separately to three different building projects.

Open item accounting is also used when you need to track each individual invoice for payment and dispute resolution purposes. For example, a building supply has a builder for a client. Sometimes the goods supplied are wrong or faulty so the builder pays all the other invoices (including more recent invoices) except that one, which is tracked and dealt with separately - perhaps getting paid when replacement goods are supplied or perhaps getting a credit note against the invoice.

In balance forward accounting, you would deal with this situation by simply applying a credit against the account as a whole, then re-adding the transaction when the replacement goods are supplied. Any interest charged on the balance can also be reversed against the account.

Simplistically, here's a way you could set these up in your database:

Open Item Accounting

You need the following tables:

Client       [ClientId, Name, AccountBalance]
Product      [ProductId, Description, Cost]
Invoice      [InvoiceId, ClientId, Date, TotalAmount, Outstanding]
InvoiceItem  [InvoiceId, ProductId, Quantity, Amount]
Receipt      [ReceiptId, Date, TotalAmount]
ReceiptItem  [ReceiptId, InvoiceId, Amount]

Client gets an invoice created when buying products. For each product bought, an invoice item is created for that product showing the quantity bought and the amount. When the invoice is updated, the invoice's outstanding balance is the total of the invoice and client account balance is updated (can be calculated on the fly but easier and quicker if maintained automatically). When the client pays one or more invoices, a receipt is created and receipt items are allocated to each invoice being paid. The invoice's outstanding balance is updated as with the client's account balance. Note that overpayments need to be dealt with separately. Interest charges are raised on the next invoice (or a separate invoice) as an invoice item (this can be a custom product).

Balance Forward Accounting

You need the following tables:

Client       [ClientId, Name, AccountBalance]
Product      [ProductId, Description, Cost]
Invoice      [InvoiceId, ClientId, Date, Amount]
Transaction  [TransactionId, ClientId, InvoiceId, ProductId, Date, Quantity, Amount]

When a product is purchased, a transaction is made on the client's account showing the quantity of the product and the amount and the client's account balance is updated. When a receipt is made, again a transaction is made on the client's account and the client's account balance is updated. Overpayments and interest payments are just a transaction as well. At invoicing time, you simply grab all the transactions (purchases, receipts, interest payments, etc) that aren't allocated to an invoice and add them to your new invoice. The invoice doesn't appear in the transaction list, it is just for convenience in tracking transactions that have been invoiced and for giving your clients a reference number when paying. You might also want to track receipts in this model.

Other considerations

  • This doesn't take into account the general ledger posting which will be an entirely different set of tables. This is just for the management accounting, not the financial accounting.
  • In practice, there may be a projects table between the client and the invoice to track each of the clients individual projects with you.
  • This is really simplistic just to give you an idea. More tables and fields would no doubt be required for a full implementation.

With regards to what happens if they don't pay of their invoice when it comes time for billing, in either system it doesn't matter - you do not go back in time and change previous accounting entries. Anything that happens now goes on a new invoice. Of course, it is entirely appropriate to have a line on the new invoice saying "Previously outstanding balance" which shows the amount they already owe (or are in credit for overpayments).

You will also want to be able to produce a Statement of Account, which isn't an invoice, its just like a letter reminding them they have outstanding balances. This is used when there is no new invoice to be generated but the client needs a reminder about their account balance.

I prefer open item accounting for my systems but from your description balance forward accounting sounds like a good fit.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文