Topic: Inventory planning report 2.4.3

There's a small error in reporting/rep302.php in the first sql statement that causes the QOH column to show weird results.

I copied the similar statement from rep303.php with a change from QtyOnHand to qty_on_hand and that seems to correct the issue.

Here is the new code:

function getTransactions($category, $location)
{
    $sql = "SELECT item.category_id,
            category.description AS cat_description,
            item.stock_id, item.units,
            item.description, item.inactive,
            IF(move.stock_id IS NULL, '', move.loc_code) AS loc_code,
            SUM(IF(move.stock_id IS NULL,0,move.qty)) AS qty_on_hand
        FROM ("
            .TB_PREF."stock_master item,"
            .TB_PREF."stock_category category)
            LEFT JOIN ".TB_PREF."stock_moves move ON item.stock_id=move.stock_id
        WHERE item.category_id=category.category_id
        AND (item.mb_flag='B' OR item.mb_flag='M')";
    if ($category != 0)
        $sql .= " AND item.category_id = ".db_escape($category);
    if ($location != 'all')
        $sql .= " AND IF(move.stock_id IS NULL, '1=1',move.loc_code = ".db_escape($location).")";

    $sql .= " GROUP BY item.category_id,
        category.description,
        item.stock_id,
        item.description
        ORDER BY item.category_id,
        item.stock_id";

    return db_query($sql,"No transactions were returned");

}

Re: Inventory planning report 2.4.3

Hello,

Strange, shouldn't IFNULL(move.stock_id, 0) give the same result as you suggest. I will investigate this.

/Joe

Re: Inventory planning report 2.4.3

Ah, now I see the problem. Of course it gives weird results using the move.stock_id value instead of move.qty smile

Will be fixed asap and committed to 2.4. repo. Thanks for observing this.

/Joe

Committed