[Koha-patches] [PATCH] bug4438/MT5496 budget Exceeds total allocation

Henri-Damien LAURENT henridamien.laurent at biblibre.com
Fri Feb 18 11:01:03 CET 2011


This is a followup :
When editing a budget, the check for the total allocation would take into account the budget itself.
Showing an improper error message
---
 admin/check_parent_total.pl |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/admin/check_parent_total.pl b/admin/check_parent_total.pl
index cb62f0d..fb78179 100755
--- a/admin/check_parent_total.pl
+++ b/admin/check_parent_total.pl
@@ -75,10 +75,16 @@ if ($parent) {
 # ELSE , IF NO PARENT PASSED, THEN CHECK UNALLOCATED FOR PERIOD, IF NOT THEN RETURN 2
 else {
     my $query = qq| SELECT SUM(budget_amount) as sum
-                FROM aqbudgets WHERE budget_period_id = ? and budget_parent_id IS NULL|;
+                FROM aqbudgets WHERE budget_period_id = ? and budget_parent_id IS NULL |;
+    my @sql_params;
+    push @sql_params, $period_id;
+    if ($budget_id){
+        $query.=qq| and budget_id <> ? |;
+        push @sql_params,$budget_id;
+    }
 
     my $sth = $dbh->prepare($query);
-    $sth->execute($period_id);
+    $sth->execute(@sql_params);
     $period_sum = $sth->fetchrow_hashref;
     $sth->finish;
     $budget_period_unalloc = $period->{'budget_period_total'} - $period_sum->{'sum'} if $period->{'budget_period_total'};
-- 
1.7.1



More information about the Koha-patches mailing list