CORE-POS / IS4C

Cooperative Operational Retail Environment
http://www.core-pos.com
GNU General Public License v2.0
63 stars 44 forks source link

Some products being left out of SpinsSubmitTask #1230

Open roberski opened 2 months ago

roberski commented 2 months ago

So we noticed a couple of products being left out of the SPINS data and when I looked into it it seems that the query in the submit task is:

SELECT d.upc, p.description, SUM(CASE WHEN d.quantity <> d.ItemQtty AND d.ItemQtty <> 0 THEN d.quantity*d.ItemQtty ELSE d.quantity END) as quantity, SUM(d.total) AS dollars, '$lastDay' AS lastDay FROM $dlog AS d " . DTrans::joinProducts('d', 'p', 'INNER') . " WHERE p.Scale = 0 AND d.upc > '0000000999999' AND tdate BETWEEN ? AND ? " . ($this->config->get('STORE_MODE') == 'HQ' ? ' AND d.store_id=? ' : '') . " GROUP BY d.upc, p.description"

The issue is that some of our product data has a null scale value because there is no default set in the model so when the query is checking p.Scale = 0 it isn't finding those products.

I fixed the issue for us by checking d.Scale = 0 instead of p.scale = 0. This works because the dtransactions model does have a default set for the scale value. This seemed like an easier fix than setting all the null scale values in products to zero and changing the products model so that no other products can be imported with null values.

This may or may not be an issue for others depending on how their products are entered but I figured I should bring it up incase it does.