Merge remote-tracking branch 'origin/new/bug_8597'
[koha.git] / C4 / Budgets.pm
index e9732ac..d07dc75 100644 (file)
@@ -314,9 +314,19 @@ sub GetBudgetSpent {
             quantityreceived > 0 AND
             datecancellationprinted IS NULL
     |);
-
        $sth->execute($budget_id);
        my $sum =  $sth->fetchrow_array;
+
+    $sth = $dbh->prepare(qq|
+        SELECT SUM(shipmentcost) AS sum
+        FROM aqinvoices
+        WHERE shipmentcost_budgetid = ?
+          AND closedate IS NOT NULL
+    |);
+    $sth->execute($budget_id);
+    my ($shipmentcost_sum) = $sth->fetchrow_array;
+    $sum += $shipmentcost_sum;
+
        return $sum;
 }
 
@@ -330,9 +340,19 @@ sub GetBudgetOrdered {
             quantityreceived = 0 AND
             datecancellationprinted IS NULL
     |);
-
        $sth->execute($budget_id);
        my $sum =  $sth->fetchrow_array;
+
+    $sth = $dbh->prepare(qq|
+        SELECT SUM(shipmentcost) AS sum
+        FROM aqinvoices
+        WHERE shipmentcost_budgetid = ?
+          AND closedate IS NULL
+    |);
+    $sth->execute($budget_id);
+    my ($shipmentcost_sum) = $sth->fetchrow_array;
+    $sum += $shipmentcost_sum;
+
        return $sum;
 }