bug_4831: Use unitprice (actual cost) when totalling spent amounts for "All available funds", as in "Already received"

Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>

To test:
- add new fund for an active budget
- order item, price 8.00
- check funds page and acq home: committed amount should be 8.00
- receive item, enter actual price 10.00
- check funds page and acq home: spent amount should be 10.00

Signed-off-by: Ian Walls <ian.walls@bywatersolutions.com>
Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
This commit is contained in:
Srdjan Jankovic 2011-09-07 16:02:21 +12:00 committed by Chris Cormack
parent 65e65d7c37
commit 4fb88deaa7

View file

@ -304,7 +304,7 @@ sub GetBudgetSpent {
my ($budget_id) = @_;
my $dbh = C4::Context->dbh;
my $sth = $dbh->prepare(qq|
SELECT SUM(ecost * quantity) AS sum FROM aqorders
SELECT SUM( COALESCE(unitprice, ecost) * quantity ) AS sum FROM aqorders
WHERE budget_id = ? AND
quantityreceived > 0 AND
datecancellationprinted IS NULL