简体   繁体   English

如何处理库存系统中的数量/库存监控?

[英]How to handle quantity/stock monitoring in an inventory system?

I'm creating a simple inventory/pos system for a hardware store as a school project. 我正在为学校项目的五金店创建一个简单的库存/销售点系统。

I'm wondering how to properly implement monitoring of stocks/quantity on hand and sales of items. 我想知道如何正确实施对现有库存/数量和物品销售的监控。 As of now i have a field 'QuantityOnHand' in my products table. 到目前为止,我的产品表中有一个“ QuantityOnHand”字段。 This is where the total number of stocks is stored. 这是存储库存总数的位置。 Whenever a sale is made, i subtract the quantity of item(s) sold on the 'QuantityOnHand' field and save the items in two related tables, 'Sales' for the recording of the transaction and 'SalesItems' for the items sold. 每当进行销售时,我都会在“ QuantityOnHand”字段上减去所售商品的数量,并将这些商品保存在两个相关的表中,“ Sales”(用于记录交易)和“ SalesItems”(用于出售的商品)。

This design was ok for the most part but i cannot create a report that compares the remaining quantity of items of the past day/week against the remaining balance of the current minus the sales/defective items because the quantity of items was not properly tracked and is only saved in a single field. 这种设计在大多数情况下是可以的,但是我无法创建将过去一天/一周的剩余项目数量与当前的剩余余额减去销售/有缺陷项目进行比较的报告,因为未正确跟踪和仅保存在单个字段中。

How do i design the database in such a way that i can properly monitor the quantity of items? 如何设计数据库以正确监控项目数量?

You must carefully analyze all of your reporting requirements and design your tables in such a way as to make it straightforward to achieve your goals. 您必须仔细分析所有报告要求,并设计表以使其易于实现目标。

However, it's generally a good idea to create a table to store stock events that might look something like this: 但是,通常最好创建一个表来存储可能如下所示的库存事件:

  • eventid - a unique identifier for this event. eventid-此事件的唯一标识符。
  • productid - the product / item id productid-产品/商品ID
  • eventtype - identifies the type of event (eg receive, sale, loss, restock, count, transferin, transferout, etc...) eventtype-标识事件的类型(例如,接收,出售,亏损,补货,盘点,转入,转出等)
  • timestamp - when event occurred. 时间戳-事件发生的时间。
  • stockinglocationid - identifies the warehouse/store/... stockinglocationid-标识仓库/商店/ ...
  • . . .

stock events are only created, they are never updated. 仅创建库存事件,而不会更新它们。 That's the key to being able to get the kind of analysis you want. 这是获得所需分析类型的关键。

From this, you should be able to reconstitute the qoh for any product at a prior time. 由此,您应该能够在任何时候重新构造任何产品的质量。

For sales, you would certainly want all sorts of other data points in addition to quantity, price, product - customer type, customer country/region/state/city, sales location, salesperson, . 对于销售,您当然需要除数量,价格,产品-客户类型,客户国家(地区)/州/城市,销售地点,销售员,之外的各种其他数据点。 . . Treat this table as immutable, just like stock event. 就像股票事件一样,将此表视为不可变的。

I'd encourge you to google 'inventory star schema' and 'sales star schema'. 我鼓励您使用Google的“库存星图”和“销售星图”。 This should give you some food for thought on how best to organize your data for reporting. 这应该使您思考如何最好地组织数据以进行报告。

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

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