From be3fec7132e015f241fa0f1ef95e0b95eebaaee8 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 18 Oct 2018 18:10:19 -0300 Subject: [PATCH] Bug 21604: Fix add/edit fund/budget [Strict SQL modes context] For insert aqbudgetperiods: Incorrect integer value: '' for column 'budget_period_id' For insert/update aqbudgets Incorrect integer value: '' for column 'budget_owner_id' Incorrect decimal value: '' for column 'budget_encumb' Test plan: Add/edit budgets and funds A good example of why we should use Koha::Object for all our objects Signed-off-by: Pierre-Marc Thibault Signed-off-by: Marcel de Rooy Signed-off-by: Nick Clemens (cherry picked from commit 7085772e8de25fe49b77555e318cc03ab6bcb33b) Signed-off-by: Martin Renvoize --- C4/Budgets.pm | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/C4/Budgets.pm b/C4/Budgets.pm index d66cc0e43f..9f9afe4069 100644 --- a/C4/Budgets.pm +++ b/C4/Budgets.pm @@ -133,6 +133,7 @@ sub AddBudgetPeriod { my ($budgetperiod) = @_; return unless($budgetperiod->{budget_period_startdate} && $budgetperiod->{budget_period_enddate}); + undef $budgetperiod->{budget_period_id}; my $resultset = Koha::Database->new()->schema->resultset('Aqbudgetperiod'); return $resultset->create($budgetperiod)->id; } @@ -622,6 +623,8 @@ sub AddBudget { my ($budget) = @_; return unless ($budget); + undef $budget->{budget_encumb} if $budget->{budget_encumb} eq ''; + undef $budget->{budget_owner_id} if $budget->{budget_owner_id} eq ''; my $resultset = Koha::Database->new()->schema->resultset('Aqbudget'); return $resultset->create($budget)->id; } @@ -632,6 +635,8 @@ sub ModBudget { my $result = Koha::Database->new()->schema->resultset('Aqbudget')->find($budget); return unless($result); + undef $budget->{budget_encumb} if $budget->{budget_encumb} eq ''; + undef $budget->{budget_owner_id} if $budget->{budget_owner_id} eq ''; $result = $result->update($budget); return $result->in_storage; } -- 2.39.5