You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I need to add the capability to import an items CSV file (similar to the ones I used to originally populate the items table but this time it's to update prices (or any other attributes).
Primarily it is to add items missing in the original import and to update prices that weren't originally provided or that have changed.
So I'm modifying it to both add and update. Since the vendors in question do not necessarily provide UPC number for all of the items I'm also modifying it to locate the item by item name (which will most likely be unique if the vendor doesn't provide a UPC code for it).
If it's a change to an existing item it will not update any tax information or stock location quantities.
Also, it will only update fields for which data is being provided. It cannot be used to clear a field. If data is not provided for the field the field is left untouched.
When done I will submit it as a pull request and you can choose to merge it or not.
As I was testing my changes it occurred to me that there is a requirement (which will be addressed in a future change) to identify what prices were changed so that price labels can be reprinted. For now I'm just going to copy the items table to an items_save table so that I can run a query to compare price differences.
I thought I had it nailed, then during testing realized that I needed to make sure that the inventory records are being properly created when an item is being added. So since a single upload can both add new records and update existing records I need to at least specify the location for the stock items to handle the situation if the row is for a new item. If a quantity is specified then it should create the stock record with that quantity. If a quantity is not provided (including zero) then the stock item should be created with a zero quantity.
Currently there's no constraint of having unique items per name, so how can you know which one to pick there?
Also you're right on inventory tracking, once an item is updated we should indeed add records to that table to indicate the quantities changed.
Regarding item change history: I think it would be better to take that back to the drawing table, as right now there is already some sort of 'price and tax history' by copying fields into sales_items and receiving_items.
Adding a item history table should then replace those two as it kind of generalizes the idea. It'll be better to have one single source of truth on past values for the items instead of multiple. So in that case I'd replace these with a fk to this history table, but that would mean that we need to refactor quite a bit
Regarding your first question, I do not apply the update if there is more than one item with the same name. I would have liked to have the vendor id (the company that packages the product) on the item file which would increase the chances of a unique item description per name/vendor combination. But I gots what I gots, so it's a "make do" situation.
I consider the existence of price and taxes on sales_items as a "statement of record" related to the sale. I don't believe it would be a good idea to remove those from those tables.
Over generalization can be a real performance drag - in addition to making SQL statements significantly more complex to maintain.
And I agree with jekkos, maintaining a central table with price history would be a better choice so we even avoid the problem of how many with an old price and how many with a new price in stock such any stock check will produce the right value.
With regards to database tables we need to rationalise a bit things going forward. There are two parts in this story, one is the domain oriented data model mainly around basic notions in OSPOS like item, attribute, person. The other is more a dimensional model used for reporting and historical purposes. At the moment the dimensional model is mainly achieved with temp tables that aggregate data from different sources. We could have that data stored in a table so the performance is better when we move from the now to the historical mode.
As it is now we have the supplier id on the item table which is necessary. However for pricing updates it seems that I need the vendor id and the vendor part number. That's necessary because not only is the bar code not always provided by the vendor, but the item name isn't always unique (which was a surprise to me but @jekkos had pointed out earlier).
Now I have already populated the vendor and the vendor part number into the custom fields so I can use that for my own purposes, but since the intent was to make this useful to the wider community it seems to me that it can only be useful if vendor id and vendor part number were made a permanent part of the database.
If the decision is to NOT add the vendor id and vendor part number then what I would publish would only be useful if the barcode/upc field is always populated. It will only update using the barcode if the barcode is provided. If there isn't a barcode then it will update using a unique item description. It there are two or more items with the same description then the change will be flagged as an error and ignored. If there isn't an item with that description then the item will be added.
Activity
SteveIreland commentedon Jul 23, 2017
As I was testing my changes it occurred to me that there is a requirement (which will be addressed in a future change) to identify what prices were changed so that price labels can be reprinted. For now I'm just going to copy the
itemstable to anitems_savetable so that I can run a query to compare price differences.SteveIreland commentedon Jul 24, 2017
I thought I had it nailed, then during testing realized that I needed to make sure that the inventory records are being properly created when an item is being added. So since a single upload can both add new records and update existing records I need to at least specify the location for the stock items to handle the situation if the row is for a new item. If a quantity is specified then it should create the stock record with that quantity. If a quantity is not provided (including zero) then the stock item should be created with a zero quantity.
So this should be available tomorrow night.
jekkos commentedon Jul 24, 2017
Currently there's no constraint of having unique items per name, so how can you know which one to pick there?
Also you're right on inventory tracking, once an item is updated we should indeed add records to that table to indicate the quantities changed.
Regarding item change history: I think it would be better to take that back to the drawing table, as right now there is already some sort of 'price and tax history' by copying fields into sales_items and receiving_items.
Adding a item history table should then replace those two as it kind of generalizes the idea. It'll be better to have one single source of truth on past values for the items instead of multiple. So in that case I'd replace these with a fk to this history table, but that would mean that we need to refactor quite a bit
SteveIreland commentedon Jul 24, 2017
Regarding your first question, I do not apply the update if there is more than one item with the same name. I would have liked to have the vendor id (the company that packages the product) on the item file which would increase the chances of a unique item description per name/vendor combination. But I gots what I gots, so it's a "make do" situation.
I consider the existence of price and taxes on sales_items as a "statement of record" related to the sale. I don't believe it would be a good idea to remove those from those tables.
Over generalization can be a real performance drag - in addition to making SQL statements significantly more complex to maintain.
SteveIreland commentedon Jul 25, 2017
A pull request has been submitted for this enhancement. No warranties are expressed or implied. Buyer beware. 😄
daN4cat commentedon Jul 25, 2017
Do you check the Barcode before checking the name? Barcode is unique so more reliable than a name. Name should be a second choice.
daN4cat commentedon Jul 25, 2017
And I agree with jekkos, maintaining a central table with price history would be a better choice so we even avoid the problem of how many with an old price and how many with a new price in stock such any stock check will produce the right value.
SteveIreland commentedon Jul 25, 2017
Yes, the barcode is checked first and I use the item name only if I can't find an item with a unique barcode.
daN4cat commentedon Jul 25, 2017
Sounds good.
daN4cat commentedon Jul 25, 2017
With regards to database tables we need to rationalise a bit things going forward. There are two parts in this story, one is the domain oriented data model mainly around basic notions in OSPOS like item, attribute, person. The other is more a dimensional model used for reporting and historical purposes. At the moment the dimensional model is mainly achieved with temp tables that aggregate data from different sources. We could have that data stored in a table so the performance is better when we move from the now to the historical mode.
daN4cat commentedon Jul 25, 2017
However there is some historical data that is used in the "now" like this cost of items. That should stay in the domain model side of things.
SteveIreland commentedon Jul 25, 2017
I'm on board with the concept.
SteveIreland commentedon Jul 28, 2017
As it is now we have the supplier id on the
itemtable which is necessary. However for pricing updates it seems that I need the vendor id and the vendor part number. That's necessary because not only is the bar code not always provided by the vendor, but the item name isn't always unique (which was a surprise to me but @jekkos had pointed out earlier).Now I have already populated the vendor and the vendor part number into the custom fields so I can use that for my own purposes, but since the intent was to make this useful to the wider community it seems to me that it can only be useful if vendor id and vendor part number were made a permanent part of the database.
If the decision is to NOT add the vendor id and vendor part number then what I would publish would only be useful if the barcode/upc field is always populated. It will only update using the barcode if the barcode is provided. If there isn't a barcode then it will update using a unique item description. It there are two or more items with the same description then the change will be flagged as an error and ignored. If there isn't an item with that description then the item will be added.
Thoughts?
35 remaining items
Import update rework (#1412)
Import update rework (#1412)
Import update rework (#1412)
Fix merge issues (#1412)
Import update rework (#1412)
Fix merge issues (#1412)
Fix merge issues (#1412)
Import update rework (#1412)
Fix merge issues (#1412)
Import update rework (#1412) (#3029)
objecttothis commentedon Aug 5, 2021
CSV Item Import/Update via CSV is now in the master.