Bug 13007: Special case budgetid == ''
authorJonathan Druart <jonathan.druart@biblibre.com>
Tue, 18 Nov 2014 09:20:56 +0000 (10:20 +0100)
committerTomas Cohen Arazi <tomascohen@gmail.com>
Mon, 9 Feb 2015 18:49:57 +0000 (15:49 -0300)
In this special case (the suggestion is linked to "all funds"), the
budgetid value should be NULL in DB.

Signed-off-by: Paola Rossi <paola.rossi@cineca.it>
Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Works as described, passes old and new tests.

Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
C4/Suggestions.pm
t/db_dependent/Suggestions.t

index 5470fe0..f34c942 100644 (file)
@@ -437,6 +437,7 @@ sub NewSuggestion {
         accepteddate
         rejectedby
         rejecteddate
+        budgetid
     ) ) {
         # Set the fields to NULL if not given.
         $suggestion->{$field} ||= undef;
@@ -475,6 +476,7 @@ sub ModSuggestion {
         accepteddate
         rejectedby
         rejecteddate
+        budgetid
     ) ) {
         # Set the fields to NULL if not given.
         $suggestion->{$field} = undef
index 73f10e6..7e12df9 100644 (file)
@@ -25,7 +25,7 @@ use C4::Budgets;
 
 use Koha::DateUtils qw( dt_from_string );
 
-use Test::More tests => 102;
+use Test::More tests => 104;
 use Test::Warn;
 
 BEGIN {
@@ -352,6 +352,13 @@ is(@$itemtypes2, 8, "Purchase suggestion itemtypes collected, default AdvancedSe
 
 is_deeply($itemtypes1, $itemtypes2, 'same set of purchase suggestion formats retrieved');
 
-$dbh->rollback;
+# Test budgetid fk
+$my_suggestion->{budgetid} = ''; # If budgetid == '', NULL should be set in DB
+my $my_suggestionid_test_budgetid = NewSuggestion($my_suggestion);
+$suggestion = GetSuggestion($my_suggestionid_test_budgetid);
+is( $suggestion->{budgetid}, undef, 'NewSuggestion Should set budgetid to NULL if equals an empty string' );
 
-done_testing;
+$my_suggestion->{budgetid} = ''; # If budgetid == '', NULL should be set in DB
+ModSuggestion( $my_suggestion );
+$suggestion = GetSuggestion($my_suggestionid_test_budgetid);
+is( $suggestion->{budgetid}, undef, 'NewSuggestion Should set budgetid to NULL if equals an empty string' );