Bug 9993 - On editing basket group delivery place resets to logged in library
Summary: On editing basket group delivery place resets to logged in library
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Acquisitions (show other bugs)
Version: Main
Hardware: All All
: P5 - low normal (vote)
Assignee: Owen Leonard
QA Contact:
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-04-07 08:00 UTC by Katrin Fischer
Modified: 2021-06-14 21:28 UTC (History)
6 users (show)

See Also:
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


Attachments
Bug 9993: On editing basket group delivery place resets to logged in branch (1.00 KB, patch)
2019-11-20 17:20 UTC, Owen Leonard
Details | Diff | Splinter Review
Bug 9993: On editing basket group delivery place resets to logged in branch (2.33 KB, patch)
2019-11-26 12:46 UTC, Owen Leonard
Details | Diff | Splinter Review
Bug 9993: On editing basket group delivery place resets to logged in branch (2.37 KB, patch)
2020-02-01 21:19 UTC, David Nind
Details | Diff | Splinter Review
Bug 9993: On editing basket group delivery place resets to logged in branch (2.43 KB, patch)
2020-02-04 07:20 UTC, Katrin Fischer
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
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 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 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