From: <ex...@us...> - 2016-02-01 19:17:59
|
Revision: 7456 http://sourceforge.net/p/web-erp/reponame/7456 Author: exsonqu Date: 2016-02-01 19:17:56 +0000 (Mon, 01 Feb 2016) Log Message: ----------- 02/02/16 Exson?\239?\188?\154Fixed the bug of chartdetails bfwd amount wrong in GLPostings.inc. Modified Paths: -------------- trunk/includes/GLPostings.inc Modified: trunk/includes/GLPostings.inc =================================================================== --- trunk/includes/GLPostings.inc 2016-02-01 13:28:43 UTC (rev 7455) +++ trunk/includes/GLPostings.inc 2016-02-01 19:17:56 UTC (rev 7456) @@ -67,9 +67,23 @@ $ErrMsg = _('Inserting new chart details records required failed because'); $InsChartDetailsRecords = DB_query($sql,$ErrMsg); } +//now lets update those new created period with the bfwd amount +$sql = "SELECT max(period),accountcode + FROM chartdetails + WHERE bfwd!=0 + GROUP BY accountcode"; +$ErrMsg = _('Failed to retrieve new period data'); +$NewAccountsResult = DB_query($sql,$ErrMsg); +if (DB_num_rows($NewAccountsResult)>0) { + while ($NewAccountsRow = DB_fetch_row($NewAccountsResult)) { + $sql = "UPDATE chartdetails AS c INNER JOIN chartdetails AS s ON c.accountcode=s.accountcode AND c.period=s.period + SET c.bfwd= (SELECT bfwd FROM (SELECT bfwd FROM chartdetails WHERE period='" . $NewAccountsRow[0]. "' AND accountcode='" . $NewAccountsRow[1] . "') AS temple) + WHERE c.accountcode='" . $NewAccountsRow[1] . "' AND c.period>'" . $NewAccountsRow[0] . "'"; + $ErrMsg = _('Failed to update chartdetails bfwd data'); + $result = DB_query($sql,$ErrMsg); + } +} - - /*All the ChartDetail records should have been created now and be available to accept postings */ for ( $CurrPeriod = $CreateFrom; $CurrPeriod <= $CreateTo; $CurrPeriod++ ) { @@ -107,7 +121,7 @@ $TotalAmount += $UnpostedTrans['amount']; } // There will be one account still to post after the loop - if($CurrentAccount != 0) { + if($CurrentAccount != '0') { $sql = "UPDATE chartdetails SET actual = actual + " . $TotalAmount . " WHERE accountcode = '" . $CurrentAccount . "' AND period= '" . $CurrPeriod . "'"; |