SQL bug in Item Maintenance re. stock category
Have found that changing stock category causes an SQL error due to the syntax of the inserts into
gltrans - the generated SQL is missing the closing parenthesis, has quotes around numeric columns, and has a mis-spelt variable ($NewStockAccount - should be $NewStockAct). My corrected version is as follows (the other 3 gltrans inserts are modified similarly) :
$SQL = "INSERT INTO gltrans (type,
typeno,
trandate,
periodno,
account,
narrative,
amount)
VALUES ( 0,
" . $JournalNo . ",
'" . Date('Y-m-d') . "',
" . GetPeriod(Date($_SESSION['DefaultDateFormat']),$db,true) . ",
" . $NewStockAct . ",
'" . $StockID . ' ' . _('Change stock category') . "',
" . ($UnitCost* $StockQtyRow[0]) . ")";
As an aside, I always use "heredoc" syntax for statements like this, as it makes it so much easier
to embed quotes. Hope this helps.
|