|
Lines 210-220
sub GetBudgetsPlanCell {
Link Here
|
| 210 |
my ( $cell, $period, $budget ) = @_; |
210 |
my ( $cell, $period, $budget ) = @_; |
| 211 |
my ($actual, $sth); |
211 |
my ($actual, $sth); |
| 212 |
my $dbh = C4::Context->dbh; |
212 |
my $dbh = C4::Context->dbh; |
|
|
213 |
my $roundsql = _get_rounding_sql(qq|ecost_tax_included|); |
| 213 |
if ( $cell->{'authcat'} eq 'MONTHS' ) { |
214 |
if ( $cell->{'authcat'} eq 'MONTHS' ) { |
| 214 |
# get the actual amount |
215 |
# get the actual amount |
| 215 |
$sth = $dbh->prepare( qq| |
216 |
$sth = $dbh->prepare( qq| |
| 216 |
|
217 |
|
| 217 |
SELECT SUM(ecost_tax_included) AS actual FROM aqorders |
218 |
SELECT SUM(| . $roundsql . qq|) AS actual FROM aqorders |
| 218 |
WHERE budget_id = ? AND |
219 |
WHERE budget_id = ? AND |
| 219 |
entrydate like "$cell->{'authvalue'}%" | |
220 |
entrydate like "$cell->{'authvalue'}%" | |
| 220 |
); |
221 |
); |
|
Lines 223-229
sub GetBudgetsPlanCell {
Link Here
|
| 223 |
# get the actual amount |
224 |
# get the actual amount |
| 224 |
$sth = $dbh->prepare( qq| |
225 |
$sth = $dbh->prepare( qq| |
| 225 |
|
226 |
|
| 226 |
SELECT SUM(ecost_tax_included) FROM aqorders |
227 |
SELECT SUM(| . $roundsql . qq|) FROM aqorders |
| 227 |
LEFT JOIN aqorders_items |
228 |
LEFT JOIN aqorders_items |
| 228 |
ON (aqorders.ordernumber = aqorders_items.ordernumber) |
229 |
ON (aqorders.ordernumber = aqorders_items.ordernumber) |
| 229 |
LEFT JOIN items |
230 |
LEFT JOIN items |
|
Lines 235-241
sub GetBudgetsPlanCell {
Link Here
|
| 235 |
# get the actual amount |
236 |
# get the actual amount |
| 236 |
$sth = $dbh->prepare( qq| |
237 |
$sth = $dbh->prepare( qq| |
| 237 |
|
238 |
|
| 238 |
SELECT SUM( ecost_tax_included * quantity) AS actual |
239 |
SELECT SUM( | . $roundsql . qq| * quantity) AS actual |
| 239 |
FROM aqorders JOIN biblioitems |
240 |
FROM aqorders JOIN biblioitems |
| 240 |
ON (biblioitems.biblionumber = aqorders.biblionumber ) |
241 |
ON (biblioitems.biblionumber = aqorders.biblionumber ) |
| 241 |
WHERE aqorders.budget_id = ? and itemtype = ? | |
242 |
WHERE aqorders.budget_id = ? and itemtype = ? | |
|
Lines 248-254
sub GetBudgetsPlanCell {
Link Here
|
| 248 |
# get the actual amount |
249 |
# get the actual amount |
| 249 |
$sth = $dbh->prepare( qq| |
250 |
$sth = $dbh->prepare( qq| |
| 250 |
|
251 |
|
| 251 |
SELECT SUM(ecost_tax_included * quantity) AS actual |
252 |
SELECT SUM(| . $roundsql . qq| * quantity) AS actual |
| 252 |
FROM aqorders |
253 |
FROM aqorders |
| 253 |
JOIN aqbudgets ON (aqbudgets.budget_id = aqorders.budget_id ) |
254 |
JOIN aqbudgets ON (aqbudgets.budget_id = aqorders.budget_id ) |
| 254 |
WHERE aqorders.budget_id = ? AND |
255 |
WHERE aqorders.budget_id = ? AND |
|
Lines 332-338
sub GetBudgetSpent {
Link Here
|
| 332 |
# unitprice_tax_included should always been set here |
333 |
# unitprice_tax_included should always been set here |
| 333 |
# we should not need to retrieve ecost_tax_included |
334 |
# we should not need to retrieve ecost_tax_included |
| 334 |
my $sth = $dbh->prepare(qq| |
335 |
my $sth = $dbh->prepare(qq| |
| 335 |
SELECT SUM( COALESCE(unitprice_tax_included, ecost_tax_included) * quantity ) AS sum FROM aqorders |
336 |
SELECT SUM( | . _get_rounding_sql("COALESCE(unitprice_tax_included, ecost_tax_included)") . qq| * quantity ) AS sum FROM aqorders |
| 336 |
WHERE budget_id = ? AND |
337 |
WHERE budget_id = ? AND |
| 337 |
quantityreceived > 0 AND |
338 |
quantityreceived > 0 AND |
| 338 |
datecancellationprinted IS NULL |
339 |
datecancellationprinted IS NULL |
|
Lines 363-369
sub GetBudgetOrdered {
Link Here
|
| 363 |
my ($budget_id) = @_; |
364 |
my ($budget_id) = @_; |
| 364 |
my $dbh = C4::Context->dbh; |
365 |
my $dbh = C4::Context->dbh; |
| 365 |
my $sth = $dbh->prepare(qq| |
366 |
my $sth = $dbh->prepare(qq| |
| 366 |
SELECT SUM(ecost_tax_included * quantity) AS sum FROM aqorders |
367 |
SELECT SUM(| . _get_rounding_sql(qq|ecost_tax_included|) . qq| * quantity) AS sum FROM aqorders |
| 367 |
WHERE budget_id = ? AND |
368 |
WHERE budget_id = ? AND |
| 368 |
quantityreceived = 0 AND |
369 |
quantityreceived = 0 AND |
| 369 |
datecancellationprinted IS NULL |
370 |
datecancellationprinted IS NULL |
|
Lines 1341-1346
sub MoveOrders {
Link Here
|
| 1341 |
return \@report; |
1342 |
return \@report; |
| 1342 |
} |
1343 |
} |
| 1343 |
|
1344 |
|
|
|
1345 |
=head1 INTERNAL FUNCTIONS |
| 1346 |
|
| 1347 |
=cut |
| 1348 |
|
| 1349 |
=head3 _get_rounding_sql |
| 1350 |
|
| 1351 |
$rounding_sql = _get_rounding_sql("mysql_variable_to_round_string"); |
| 1352 |
|
| 1353 |
returns the correct SQL routine based on OrderPriceRounding system preference. |
| 1354 |
|
| 1355 |
=cut |
| 1356 |
|
| 1357 |
sub _get_rounding_sql { |
| 1358 |
my $to_round = shift; |
| 1359 |
my $rounding_pref = C4::Context->preference('OrderPriceRounding'); |
| 1360 |
if ($rounding_pref eq 'nearest_cent') { return "CAST($to_round*100 AS INTEGER)/100"; } |
| 1361 |
else { return "$to_round"; } |
| 1362 |
} |
| 1363 |
|
| 1344 |
END { } # module clean-up code here (global destructor) |
1364 |
END { } # module clean-up code here (global destructor) |
| 1345 |
|
1365 |
|
| 1346 |
1; |
1366 |
1; |