Bug 9993

Summary: On editing basket group delivery place resets to logged in library
Product: Koha Reporter: Katrin Fischer <katrin.fischer>
Component: AcquisitionsAssignee: Owen Leonard <oleonard>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P5 - low CC: 1joynelson, hayleypelham, jonathan.druart, lucas, marjorie.barry-vila, mathsabypro
Version: Main   
Hardware: All   
OS: All   
See Also: http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=7449
Change sponsored?: --- Patch complexity: Small patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
20.05.00, 19.11.03, 19.05.08, 18.11.14
Circulation function:
Attachments: Bug 9993: On editing basket group delivery place resets to logged in branch
Bug 9993: On editing basket group delivery place resets to logged in branch
Bug 9993: On editing basket group delivery place resets to logged in branch
Bug 9993: On editing basket group delivery place resets to logged in branch

Description Katrin Fischer 2013-04-07 08:00:47 UTC
When editing a basket group the selected options for delivery address don't match what's saved in the database.

To reproduce:

1) Create a new basket group, set delivery place to "-"
2) Add a delivery address in the text box.
3) Save.
4) Edit basket group - delivery place is set to my current branch instead
   of "-"

Comment from Fridolyn on this behaviour (bug 7996):

Creating a new basketgroup and editing one uses the same page and operation : acqui/basketgroup.pl?op=add&booksellerid=x&basketgroupid=x
So when you edit an existing basketgroup, selected branches are librarian branch.
Comment 1 Mathieu Saby 2013-10-22 07:58:56 UTC
There should definitly be a syspref for choosing if we want to take the branch of the user, or the branch of the basket!

Mathieu
Comment 2 Katrin Fischer 2013-10-27 02:44:28 UTC
I see the current behaviour as a bug. If I select a specific value and save that, Koha should respect that and on edit show what has been selected before and saved to the database.
Comment 3 Jonathan Druart 2015-04-14 11:17:33 UTC
Actually the code confirms it's a feature:

  # determine default billing and delivery places depending on librarian homebranch and existing basketgroup data


The following code could do the trick, but not sure if it's needed

% git diff
diff --git a/acqui/basketgroup.pl b/acqui/basketgroup.pl
index 9c57f69..b3fa964 100755
--- a/acqui/basketgroup.pl
+++ b/acqui/basketgroup.pl
@@ -254,12 +254,12 @@ if ( $op eq "add" ) {
         $freedeliveryplace = $basketgroup->{freedeliveryplace};
         $template->param( closedbg => ($basketgroup ->{'closed'}) ? 1 : 0);
     } else {
+        # determine default billing and delivery places depending on librarian homebranch
+        my $borrower = GetMember( ( 'borrowernumber' => $loggedinuser ) );
+        $billingplace  = $borrower->{'branchcode'};
+        $deliveryplace = $borrower->{'branchcode'};
         $template->param( closedbg => 0);
     }
-    # determine default billing and delivery places depending on librarian homebranch and existing basketgroup data
-    my $borrower = GetMember( ( 'borrowernumber' => $loggedinuser ) );
-    $billingplace  = $billingplace  || $borrower->{'branchcode'};
-    $deliveryplace = $deliveryplace || $borrower->{'branchcode'};
 
     my $branches = C4::Branch::GetBranchesLoop( $billingplace );
     $template->param( billingplaceloop => $branches );


On the other hand I agree the behavior is odd :)
Comment 4 Katrin Fischer 2015-04-14 11:22:55 UTC
Hi Jonathan,

I'd agree to 'feature' if it only preselected before saving it the first time - but it should display what is saved in the database when you open it again later - even if I have left the field empty on purpose.
Comment 5 Katrin Fischer 2015-04-14 11:23:32 UTC
Otherwise... we should not offer the empty option in the first place! :)
Comment 6 Owen Leonard 2019-11-20 17:20:17 UTC Comment hidden (obsolete)
Comment 7 Katrin Fischer 2019-11-24 14:43:57 UTC
Hi Owen, something seems to have gone wrong with the patch file - can you have a look please?
Comment 8 Owen Leonard 2019-11-26 12:46:14 UTC Comment hidden (obsolete)
Comment 9 David Nind 2020-02-01 21:19:55 UTC Comment hidden (obsolete)
Comment 10 Katrin Fischer 2020-02-04 07:20:17 UTC
Created attachment 98364 [details] [review]
Bug 9993: On editing basket group delivery place resets to logged in branch

This patch modifies basketgroups.pl so that existing data about a basket
group's billing and delivery place are correctly preselected in the edit
form. These fields shouldn't reset to the logged-in user's home branch
just because they have an empty value.

To test, apply the patch and go to Acquisitions -> Vendor -> Basket
groups.

When adding or editing a basket group the pre-selected value for
"Billing place" and "Delivery place" should be correct:

   - When creating a new basket group: The logged-in user's library
     should be pre-selected.

   - When editing a basket group which has a library defined for either
     the billing or delivery places, the correct library should be
     pre-selected.

   - When editing a basket group which has no library defined for either
     the billing or delivery place there should be no library
     pre-selected (the "--" option should be pre-selected).

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 11 Katrin Fischer 2020-02-04 07:20:35 UTC
Reported this in 2013 - so happy to see it fixed!
Comment 12 Martin Renvoize (ashimema) 2020-02-04 10:22:01 UTC
Nice work everyone!

Pushed to master for 20.05
Comment 13 Joy Nelson 2020-02-11 00:10:17 UTC
Pushed to 19.11.x branch for 19.11.03
Comment 14 Lucas Gass (lukeg) 2020-02-14 21:31:33 UTC
backported to 19.05.x for 19.05.08
Comment 15 Hayley Pelham 2020-02-20 00:22:34 UTC
Backported to 18.11.x for 18.11.14