From 7085772e8de25fe49b77555e318cc03ab6bcb33b 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 --- C4/Budgets.pm | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/C4/Budgets.pm b/C4/Budgets.pm index b97e19db37..6c7e9460e7 100644 --- a/C4/Budgets.pm +++ b/C4/Budgets.pm @@ -134,6 +134,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; } @@ -633,6 +634,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; } @@ -643,6 +646,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