Bug 35717 - Link suggestions to orders by adding ordernumber to suggestions table
Summary: Link suggestions to orders by adding ordernumber to suggestions table
Status: Failed QA
Alias: None
Product: Koha
Classification: Unclassified
Component: Acquisitions (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement
Assignee: Nick Clemens (kidclamp)
QA Contact: Tomás Cohen Arazi (tcohen)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-01-05 18:54 UTC by Nick Clemens (kidclamp)
Modified: 2024-10-25 12:20 UTC (History)
3 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:


Attachments
Bug 35717: DB changes (3.56 KB, patch)
2024-01-05 18:57 UTC, Nick Clemens (kidclamp)
Details | Diff | Splinter Review
Bug 35717: DBIC schema changes (3.17 KB, patch)
2024-01-05 18:57 UTC, Nick Clemens (kidclamp)
Details | Diff | Splinter Review
Bug 35717: Add link between suggestions and orders (24.35 KB, patch)
2024-01-05 18:57 UTC, Nick Clemens (kidclamp)
Details | Diff | Splinter Review
Bug 35717: Remove GetSuggestionInfoFromBiblionumber (5.39 KB, patch)
2024-01-05 18:57 UTC, Nick Clemens (kidclamp)
Details | Diff | Splinter Review
Bug 35717: Replace GetSuggestionFromBiblionumber (1.68 KB, patch)
2024-01-05 18:57 UTC, Nick Clemens (kidclamp)
Details | Diff | Splinter Review
Bug 35717: Remove GetSuggestionFromBiblionumber (4.09 KB, patch)
2024-01-05 18:57 UTC, Nick Clemens (kidclamp)
Details | Diff | Splinter Review
Bug 35717: Adjust other calls (2.49 KB, patch)
2024-01-05 18:57 UTC, Nick Clemens (kidclamp)
Details | Diff | Splinter Review
Bug 35717: Tidy (5.77 KB, patch)
2024-01-05 18:57 UTC, Nick Clemens (kidclamp)
Details | Diff | Splinter Review
Bug 35717: DB changes (3.56 KB, patch)
2024-04-12 12:08 UTC, Nick Clemens (kidclamp)
Details | Diff | Splinter Review
Bug 35717: DBIC schema changes (3.17 KB, patch)
2024-04-12 12:08 UTC, Nick Clemens (kidclamp)
Details | Diff | Splinter Review
Bug 35717: Add link between suggestions and orders (24.66 KB, patch)
2024-04-12 12:08 UTC, Nick Clemens (kidclamp)
Details | Diff | Splinter Review
Bug 35717: Remove GetSuggestionInfoFromBiblionumber (5.39 KB, patch)
2024-04-12 12:09 UTC, Nick Clemens (kidclamp)
Details | Diff | Splinter Review
Bug 35717: Replace GetSuggestionFromBiblionumber (1.68 KB, patch)
2024-04-12 12:09 UTC, Nick Clemens (kidclamp)
Details | Diff | Splinter Review
Bug 35717: Remove GetSuggestionFromBiblionumber (4.09 KB, patch)
2024-04-12 12:09 UTC, Nick Clemens (kidclamp)
Details | Diff | Splinter Review
Bug 35717: Adjust other calls (2.87 KB, patch)
2024-04-12 12:09 UTC, Nick Clemens (kidclamp)
Details | Diff | Splinter Review
Bug 35717: DB changes (3.60 KB, patch)
2024-10-17 13:48 UTC, Tomás Cohen Arazi (tcohen)
Details | Diff | Splinter Review
Bug 35717: Add link between suggestions and orders (24.66 KB, patch)
2024-10-17 13:48 UTC, Tomás Cohen Arazi (tcohen)
Details | Diff | Splinter Review
Bug 35717: Remove GetSuggestionInfoFromBiblionumber (5.40 KB, patch)
2024-10-17 13:48 UTC, Tomás Cohen Arazi (tcohen)
Details | Diff | Splinter Review
Bug 35717: Replace GetSuggestionFromBiblionumber (1.68 KB, patch)
2024-10-17 13:48 UTC, Tomás Cohen Arazi (tcohen)
Details | Diff | Splinter Review
Bug 35717: Remove GetSuggestionFromBiblionumber (4.11 KB, patch)
2024-10-17 13:48 UTC, Tomás Cohen Arazi (tcohen)
Details | Diff | Splinter Review
Bug 35717: DBIC schema [DO NOT PUSH] (3.18 KB, patch)
2024-10-17 13:48 UTC, Tomás Cohen Arazi (tcohen)
Details | Diff | Splinter Review
Bug 35717: Adjust other calls (2.88 KB, patch)
2024-10-17 13:48 UTC, Tomás Cohen Arazi (tcohen)
Details | Diff | Splinter Review
Bug 35717: (QA follow-up) ->suggestions() always returns a resultset (3.03 KB, patch)
2024-10-17 13:48 UTC, Tomás Cohen Arazi (tcohen)
Details | Diff | Splinter Review
Bug 35717: Fix typo in basket.tt (1.79 KB, patch)
2024-10-17 15:14 UTC, Tomás Cohen Arazi (tcohen)
Details | Diff | Splinter Review
Bug 35717: Fix rebase issue after bug 34478 (2.60 KB, patch)
2024-10-17 15:14 UTC, Tomás Cohen Arazi (tcohen)
Details | Diff | Splinter Review
Bug 35717: JS fixes (4.12 KB, patch)
2024-10-17 15:14 UTC, Tomás Cohen Arazi (tcohen)
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Nick Clemens (kidclamp) 2024-01-05 18:54:28 UTC
This is bug 28844 reworked with the relationship defined in the reverse way.

There can be multiple suggestions for the same title currently (the check for duplicate suggestions includes the suggestedby field in the search, so only a single patron is prevented from requesting the same book twice)

While we can order only from a single suggestion, bug 19358 and 31632 seek to allow linking multiple suggestions to an order, I believe we need to define the relationship this way now, to allow for future changes.
Comment 1 Nick Clemens (kidclamp) 2024-01-05 18:57:01 UTC
Created attachment 160576 [details] [review]
Bug 35717: DB changes

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Comment 2 Nick Clemens (kidclamp) 2024-01-05 18:57:03 UTC
Created attachment 160577 [details] [review]
Bug 35717: DBIC schema changes
Comment 3 Nick Clemens (kidclamp) 2024-01-05 18:57:05 UTC
Created attachment 160578 [details] [review]
Bug 35717: Add link between suggestions and orders

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Comment 4 Nick Clemens (kidclamp) 2024-01-05 18:57:07 UTC
Created attachment 160579 [details] [review]
Bug 35717: Remove GetSuggestionInfoFromBiblionumber

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Comment 5 Nick Clemens (kidclamp) 2024-01-05 18:57:09 UTC
Created attachment 160580 [details] [review]
Bug 35717: Replace GetSuggestionFromBiblionumber

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Comment 6 Nick Clemens (kidclamp) 2024-01-05 18:57:10 UTC
Created attachment 160581 [details] [review]
Bug 35717: Remove GetSuggestionFromBiblionumber

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Comment 7 Nick Clemens (kidclamp) 2024-01-05 18:57:12 UTC
Created attachment 160582 [details] [review]
Bug 35717: Adjust other calls

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Comment 8 Nick Clemens (kidclamp) 2024-01-05 18:57:14 UTC
Created attachment 160583 [details] [review]
Bug 35717: Tidy
Comment 9 Andrew Fuerste-Henry 2024-01-05 21:06:47 UTC
Test plan:
1 - apply patch, reset_all
2 - create purchase suggestion
3 - accept purchase suggestion
4 - create and receive order from suggestion
5 - confirm that notices were generated as suggestion is accepted, ordered, received
6 - confirm that order number is present in suggestions data

Anything else I need to check here?
Comment 10 Andrew Fuerste-Henry 2024-01-05 21:35:11 UTC
Test plan:
1 - apply patch, reset_all
2 - create purchase suggestion
3 - accept purchase suggestion
4 - create and receive order from suggestion
5 - confirm that notices were generated as suggestion is accepted, ordered, received
6 - confirm that order number is present in suggestions data
7 - submit a second suggestion, accept it, create order from it
8 - cancel order from suggestion, confirm suggestion status reverts from "Ordered" to "Accepted" and order number is removed from suggestion
Comment 11 Andrew Fuerste-Henry 2024-01-05 21:35:53 UTC
Hi these patches applied, I'm getting an error when attempting to receive an order tied to a suggestion. It looks like maybe an undefined basket number?
Comment 12 Lucas Gass (lukeg) 2024-01-17 23:03:52 UTC
(In reply to Andrew Fuerste-Henry from comment #11)
> Hi these patches applied, I'm getting an error when attempting to receive an
> order tied to a suggestion. It looks like maybe an undefined basket number?

I don't recreate this. Did you updatedatabase after applying the patch?
Comment 13 Andrew Fuerste-Henry 2024-01-18 15:24:27 UTC
(In reply to Lucas Gass from comment #12)
> (In reply to Andrew Fuerste-Henry from comment #11)
> > Hi these patches applied, I'm getting an error when attempting to receive an
> > order tied to a suggestion. It looks like maybe an undefined basket number?
> 
> I don't recreate this. Did you updatedatabase after applying the patch?

I'm getting this error on a sandbox that was provisioned with the patch applied from the start. My understanding is that inherently includes an updatedatabase, and I can see via SQL that the suggestions table *does* include the ordernumber field.
Comment 14 Katrin Fischer 2024-01-28 13:23:02 UTC
(In reply to Andrew Fuerste-Henry from comment #11)
> Hi these patches applied, I'm getting an error when attempting to receive an
> order tied to a suggestion. It looks like maybe an undefined basket number?

Was the suggestion created before or after applying the patch?
Comment 15 Andrew Fuerste-Henry 2024-01-29 16:16:39 UTC
(In reply to Katrin Fischer from comment #14)
> (In reply to Andrew Fuerste-Henry from comment #11)
> > Hi these patches applied, I'm getting an error when attempting to receive an
> > order tied to a suggestion. It looks like maybe an undefined basket number?
> 
> Was the suggestion created before or after applying the patch?

After. I tested this on a sandbox with the patch applied from creation.
Comment 16 Katrin Fischer 2024-01-29 20:41:10 UTC
I guess that was wishful thinking. I hope Nick will have time to have a look soon.
Comment 17 Nick Clemens (kidclamp) 2024-04-12 12:08:53 UTC
Created attachment 164834 [details] [review]
Bug 35717: DB changes

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Comment 18 Nick Clemens (kidclamp) 2024-04-12 12:08:55 UTC
Created attachment 164835 [details] [review]
Bug 35717: DBIC schema changes
Comment 19 Nick Clemens (kidclamp) 2024-04-12 12:08:58 UTC
Created attachment 164836 [details] [review]
Bug 35717: Add link between suggestions and orders

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Comment 20 Nick Clemens (kidclamp) 2024-04-12 12:09:01 UTC
Created attachment 164837 [details] [review]
Bug 35717: Remove GetSuggestionInfoFromBiblionumber

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Comment 21 Nick Clemens (kidclamp) 2024-04-12 12:09:04 UTC
Created attachment 164838 [details] [review]
Bug 35717: Replace GetSuggestionFromBiblionumber

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Comment 22 Nick Clemens (kidclamp) 2024-04-12 12:09:06 UTC
Created attachment 164839 [details] [review]
Bug 35717: Remove GetSuggestionFromBiblionumber

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Comment 23 Nick Clemens (kidclamp) 2024-04-12 12:09:08 UTC
Created attachment 164840 [details] [review]
Bug 35717: Adjust other calls

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Comment 24 Jonathan Druart 2024-09-03 08:23:53 UTC
And bug 31632? Can we maybe all discuss and move toward a single direction at the same time?...
Comment 25 Tomás Cohen Arazi (tcohen) 2024-10-16 21:35:49 UTC
I'm looking at this one. Had to recreate a patch and some patches are in the wrong order?
Comment 26 Tomás Cohen Arazi (tcohen) 2024-10-17 13:48:41 UTC
Created attachment 172871 [details] [review]
Bug 35717: DB changes

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Comment 27 Tomás Cohen Arazi (tcohen) 2024-10-17 13:48:44 UTC
Created attachment 172872 [details] [review]
Bug 35717: Add link between suggestions and orders

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Comment 28 Tomás Cohen Arazi (tcohen) 2024-10-17 13:48:47 UTC
Created attachment 172873 [details] [review]
Bug 35717: Remove GetSuggestionInfoFromBiblionumber

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Comment 29 Tomás Cohen Arazi (tcohen) 2024-10-17 13:48:49 UTC
Created attachment 172874 [details] [review]
Bug 35717: Replace GetSuggestionFromBiblionumber

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Comment 30 Tomás Cohen Arazi (tcohen) 2024-10-17 13:48:52 UTC
Created attachment 172875 [details] [review]
Bug 35717: Remove GetSuggestionFromBiblionumber

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Comment 31 Tomás Cohen Arazi (tcohen) 2024-10-17 13:48:54 UTC
Created attachment 172876 [details] [review]
Bug 35717: DBIC schema [DO NOT PUSH]
Comment 32 Tomás Cohen Arazi (tcohen) 2024-10-17 13:48:57 UTC
Created attachment 172877 [details] [review]
Bug 35717: Adjust other calls

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Comment 33 Tomás Cohen Arazi (tcohen) 2024-10-17 13:48:59 UTC
Created attachment 172878 [details] [review]
Bug 35717: (QA follow-up) ->suggestions() always returns a resultset

This patch acknowledges the fact a one to many relationship always
returns an iterator (even an empty one) so there's no point in having a
codepath for it not returning a resultset.

The tests are simplified for readability too.

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 34 Tomás Cohen Arazi (tcohen) 2024-10-17 14:01:13 UTC
(In reply to Jonathan Druart from comment #24)
> And bug 31632? Can we maybe all discuss and move toward a single direction
> at the same time?...

Aleisha and Nick are on the same page. I'll take a look at that one after this one.
Comment 35 Tomás Cohen Arazi (tcohen) 2024-10-17 15:14:06 UTC
Created attachment 172899 [details] [review]
Bug 35717: Fix typo in basket.tt

This patch fixes a stray `%]` displaying in basket.pl when the order is
linked to a suggestion.

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 36 Tomás Cohen Arazi (tcohen) 2024-10-17 15:14:09 UTC
Created attachment 172900 [details] [review]
Bug 35717: Fix rebase issue after bug 34478

Some code was introduced and the block setting the `ordernumber` for the
suggestion when creating an order from a suggestion got located before
the actual order is created, and as such the suggestion got is
ordernumber set as NULL.
Comment 37 Tomás Cohen Arazi (tcohen) 2024-10-17 15:14:12 UTC
Created attachment 172901 [details] [review]
Bug 35717: JS fixes

Bug 37018 added validation to queries and `{"in":...}` is no longer
valid. `{"-in":...}` is so this patch tweaks that.

The previous patch fixes actual linking orders to suggestions. But not
having orders linked highlighted the code explode because an empty array
evaluates to `true` in Javascript. This patch fixes that too.

The links generated by this patchset also get their components correctly
escaped.
Comment 38 Tomás Cohen Arazi (tcohen) 2024-10-21 12:13:45 UTC
This was already signed.
Comment 39 Katrin Fischer 2024-10-25 12:11:49 UTC
I have just started to review the code here.

1) Migration

I notice that there is no migration script for existing suggestions.
You remove GetSuggestionFromBiblionumber and replace it with a lookup by ordernumber, but this will be empty for all existing suggestions after update.

I hope I didn't miss it, but there seems to be no fallback.

For the users this means they won't receive an AVAILABLE notice once the suggestion is received.

For the people working in ACQ they will no longer be able to tell which old orders have been ordered from suggestions.

How do we deal with that?

Joubu and I had discussed that at length on bug 28844.
Comment 40 Katrin Fischer 2024-10-25 12:20:20 UTC
The patches don't include any test plans and Andrew's test plan is great, but missing something:

-1 - Create at least 2 suggestions
0 - Create order from one of the suggestions
> 1 - apply patch, reset_all
> 2 - create purchase suggestion
> 3 - accept purchase suggestion
> 4 - create and receive order from suggestion
> 5 - confirm that notices were generated as suggestion is accepted, ordered,
> received
> 6 - confirm that order number is present in suggestions data
7 - Confirm the old order from suggestion
* displays suggestor still and switches to suggestion status to AVAILABLE when received