如何处理发票申请中的价格波动? [英] How to handle price fluctuations in an invoice application?

查看:131
本文介绍了如何处理发票申请中的价格波动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在发票应用程序中,请考虑以下内容:

In an invoicing application, consider following:

我有一个产品表,其中还包含产品的价格。然后我有一张发票和invoice_lines表,在每个发票行中,我指的是产品ID和数量。在这种情况下,我没有将产品的价格与发票行存入。

I have a products table that also contains the price of the product. And then I have an invoice and invoice_lines table and in each invoice line, I refer to the product id along with quantity. In this case, I am not storing the price of the product with the invoice line.

现在几个月后,如果产品的价格发生变化,任何报告都会显示根据当前价格而不是实际销售产品的价格,销售量。

Now few months later, if the price of the product changes, any report would show the volume of the sales based on current price instead of the price on which the product was actually sold.

我想到的一个解决方案是我们保留一个单独的表命名的价格链接到每个产品,每当产品的价格改变时,记录被插入到这个价格表中。该表中的最新记录始终被视为新发票的当前价格。每个发票行通过指示价格的ID来表示其价格,以便在报告中稍后显示。

One solution that comes to my mind is that we keep a separate table named prices that links to each product and whenever the price of the product is changed a record is inserted into this prices table. The latest record in this table always is considered as the current price for new invoices. Each invoice line indicates its price by indicating the id of the price so that it shows correctly later in reports.

处理这种情况的最佳做法是什么? >

What are the best practices for handling such situations?

推荐答案

我会在购买时根据每个订单项存储实际的名称,数量和价格,有效地使数据退化。一个订单是及时的快照,不应该与可以改变的东西相关联。价格波动不仅可以,如果您删除或重命名原始产品,发票与之相关吗?

I would always store the actual name, quantity and price at the time of purchase against each order item, effectively de-normalising the data. An order is a snap-shot in time and shouldn't be related back to something that can change. Not only can prices fluctuate, but what happens if you delete or rename the original product and your invoice relates back to it?

这篇关于如何处理发票申请中的价格波动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆