Hi all.
Im banging my head against a wall trying to figure this out, and the basic form of the problem seems to be a fairly common question from what I can find searching around, but I cant seem to make heads or tails of the solutions.
I am working on a simple inventory management app, and theres a particular workflow that I would like to follow:
I have 3 tables:
- Sites - a list of locations that can have an inventory of stock
- Inventory - a list of items that are held at a site and their quantities
- Log - a list of changes to each inventory item
I want to be able to select one of 3 actions per inventory item:
- Add - I should increase the quantity of the inventory item by x
- Take - I should decrease the quantity of the inventory item by x
- Stocktake - I should set the quantity of the inventory item to x
The action is chosen from a list and stored along with a quantity for that action in the Log table.
All of the basic functionality such as creating sites, creating inventory items at a site, and adding log entries against an inventory item is functional.
So in particular, given the action specified in the form, I would ideally like to see the quantity of the widget change as follows:
- After the Add action, the quantity increases from 10 to 15
- Then, after the Take action, the quantity should decrease from 15 to 13
- Then, after the Stocktake action, the quantity should be set to 9
The bit I am struggling with is how to make the 3 actions work. I have been searching for hours and there is a lot of talk of using Actions to accomplish this, but I just cant wrap my head around how to make it work. I suppose in some ways I am looking for the elegant solution where the quantity column of an inventory row is adjusted based on the action (Add increments, Take decrements, Stocktake sets), as opposed to doing a SUM() over a collection of rows in the Log table for example (I dont know if that would work too well with my Stocktake option).
Asking for some help from someone here who can help me with this. I have plenty of experience programming in C, Python, and even assembly for various CPUs, but Im struggling with this - maybe because I am approaching it too much from a regular programmers perspective..? ![]()
I have attached a couple of screenshots of the screens I have implemented so far so you can hopefully see the basic set of data I am working with and how it links together.
Thanks!
List of sites:
Looking at a site and its inventory:
Looking at a particular inventory item:
The form you use to perform an action on an item (i.e. when you click Manage):





