4 replies [Last post]
BayerMeister's picture
Offline
Joined: 07/21/2009
Juice: 197
Was this information Helpful?

Hi,

I am up to implement "my version" of uc_stock, but I am wondering if there isn't anything like this already written.

Motivation:
For accounting and managing my warehouse I need to remember what I bought stuff for and what I sold it for - the suppliers change their prices from time to time so...

Here is the idea:
Instead of remembering the qty of a given SKU i need more:

  • I need to know when (date/time) each item was stored in stock and what the price I bought it for was.
  • Later I need to remember what I sold it for and when that happened.
  • Also I'd like to remember the order_id of the order that sold the item.

Is there anything like this done already?

If not, I already browsed the code and it seems to be not so difficult. Here's the plan:

  • I'll keep the "uc_product_stock" table, just will remove the "stock" column.
  • I will add another table which will be something like "stock_units", which will have just the information mentioned above: mandatory buying price, date and the SKU of course, voluntary selling price, date and the order_id.
  • The amount in stock is the count of units that don't have the last three set. Sold units are also kept in the table.
  • When a unit is sold, instead of decreasing the qty, the given amount of free-for-sale items is picked from the table and the selling price, date and order_id is set.

So this implies some changes. As far as I know the "Stock form" for each product has to be altered so that the qty can not be changed (does not make sense anymore)

  • The amount in stock is read-only and the number itself could lead the sore administrator to a view of the table described above for the SKU (for the product).
  • A new form for store administrators is needed: one that does what the previous form can't do anymore: get stuff into stock. One has to enter what the buying price was.

So, if you sell something, the catalog tells you the selling price. When something is sold and later the catalog price changes, the selling price for the item sold before is kept - all this is needed for accounting stuff, like I bought 4 guitars this month for $x, sold 3 guitars for $y and thus I should have $(y-x) in my pocket... And my suppliers can change the price twice a month if they want.

I hope this is understandable enough. I will be very grateful for any suggestions, tips and questions AND I will reply to them (if on-topic). And if I will have to do this by myself, I will make all changes public and well documented of course.

Richard G. Bayer

EDIT: Changes to this proposal are lower. That is:

  • Some data would overlap with information in the respective order (table uc_order_products) so that can be removed.
  • This approach enables us to remember each items location (like which warehouse it is in).
paulgrimshaw's picture
Offline
Joined: 05/19/2008
Juice: 91
Hey Richard, Just marking

Hey Richard,

Just marking this post - this is something I would be interested in for myself. This is something that many purchased packages do from the get go (e.g. Sage Accounts), would be useful addition.

Sorry, but I have no skills to offer Sad.

Thanks,
Paul.

zeezhao's picture
Offline
Joined: 04/23/2008
Juice: 969
Re: more stock management (uc_stock "2")

Hi. What you are trying to do sounds similar to what is done for financial stocks...

In any case, my initial thoughts are:
- the uc_order_products table already has order_id, price at which goods were sold, and quantity sold. It also has a cost column too. The date/time can be got from the uc_orders table

- the uc_order_line_items table has other stuff line tax, shipping, etc.

- the uc_product_stock keeps the stock [similar to a financial position]. but needs to be supported by transactions for stock brought in, and hence only updated then

- so the only new table may be the one to keep track of cost/time for each new stock brought in... Then your accounting will have to be on FIFO or LIFO or Average Cost or something like that.

Unless I am missing something else...

BayerMeister's picture
Offline
Joined: 07/21/2009
Juice: 197
Re: Re: more stock management (uc_stock "2")

Thanks for the thoughts. All true. All useful.

Only that the lookup of what is in stock and what isn't would be complicated -- I wouldn't want to go through orders to find out if something was already sold or not. But yes, a lot of information is overlapping (I guess the order_id is enough to remember when the rest is there).

So the new table would contain cost and time of items brought in and an order_id (EDIT: Technical detail: id of a row in uc_order_products), which would be NULL until sold (as said -- to keep getting the amount of a product (SKU) in stock simple).

Another thing which I could have mentioned earlier is to support multiple warehouses by just adding a warehouse_id to each item in stock (and a respective simple table of existing warehouses (id, name, address...)). This would jeopardise your FIFO/LIFO thought, because there would be as many queues as warehouses. But as I want to keep the order_id, nothing of this is needed.

So I hope this still makes sense -- I am new to both Drupal and Übercart. Any comments, suggestions and thoughts are appreciated.
Thanks, zeezhao, again.

BayerMeister's picture
Offline
Joined: 07/21/2009
Juice: 197
News...

Hi. A week passed since I had this idea and here are the news:

I realized there is a need to block something in stock, when it is ordered, but the same order also orders something not in stock... so that is an additional state of orders similar to "pending". I'm getting aware of the pitfalls here.

The uc_stock module is very simple. If you want to keep track of what exactly is in stock, you need to undo changes done by an order (the blocking of things for example) if this order is cancelled.
Being new to UC and Drupal I'm not sure if I'll manage to cover all situations an order changes. So the news here (for me) is that it is not just rewriting uc_stock, but also creating all handling of order changes.

I guess I'd like to discuss this with someone experienced. That implies I should make a fork of uc_stock and start a project on UC/Drupal for collaboration. How to start? Any tips?

Thanks for reading, thanks for replys.
RGB