Bug 26693

Summary: Add option to update dateaccessioned when receiving an order
Product: Koha Reporter: Andrew Fuerste-Henry <andrewfh>
Component: AcquisitionsAssignee: Tomás Cohen Arazi <tomascohen>
Status: CLOSED WORKSFORME QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low CC: m.de.rooy, tomascohen
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Bug Depends on: 27671    
Bug Blocks:    
Attachments: Bug 26693: Add AcqItemSetDateAccessionedsWhenReceived syspref
Bug 26693: Add option to update dateaccessioned when receiving an order

Description Andrew Fuerste-Henry 2020-10-15 13:03:48 UTC
For libraries that create item records when placing an order, the dateaccessioned field gets set with the date on which the record was created, which may be several months prior to when the item actually arrives at the library. Once the item arrives and enters circulation, it may be more useful for collection management purposes to record a dateaccessioned linked to when the item actually arrived at the library.

I'd like to see a new Acquisitions syspref to give the option to re-set the dateaccessioned when marking an item received. This would only apply to items that were created at time or ordering and are therefore linked to an order. In these cases, the acq data is already remembering when the order was placed so we're really not losing anything by changing dateaccessioned.
Comment 1 Katrin Fischer 2020-10-15 23:31:17 UTC
+1
Comment 2 Tomás Cohen Arazi 2021-02-04 23:15:17 UTC
What about a checkbox about this when adding the items to the orderlines?
Comment 3 Andrew Fuerste-Henry 2021-02-04 23:22:03 UTC
(In reply to Tomás Cohen Arazi from comment #2)
> What about a checkbox about this when adding the items to the orderlines?

When you say "adding items to orderlines" do you mean when adding an order to a basket and creating items then? Or do you mean when creating items on receiving? We've got at least those two possible workflows that need to be accommodated. And it really needs to have some global default selection.
Comment 4 Tomás Cohen Arazi 2021-02-04 23:25:50 UTC
(In reply to Andrew Fuerste-Henry from comment #3)
> (In reply to Tomás Cohen Arazi from comment #2)
> > What about a checkbox about this when adding the items to the orderlines?
> 
> When you say "adding items to orderlines" do you mean when adding an order
> to a basket and creating items then? Or do you mean when creating items on
> receiving? We've got at least those two possible workflows that need to be
> accommodated. And it really needs to have some global default selection.

I mean in the context items are created, I was thinking when adding items to a basket, but really meant any step in the workflow there items are created. So the user marks the order marked to update the items on receiving.
Comment 5 Katrin Fischer 2021-02-06 17:55:52 UTC
I think it's probably only needed when items are created on order, then we would want to update on receive. So maybe the checkbox should be on the receive page when linked items exist?

Also totally agree with Andrew about the global default setting!
Comment 6 Tomás Cohen Arazi 2021-02-06 18:04:26 UTC
So a global setting, and the option to change that global default on receiving?
Comment 7 Katrin Fischer 2021-02-06 18:05:26 UTC
(In reply to Tomás Cohen Arazi from comment #6)
> So a global setting, and the option to change that global default on
> receiving?

I think so. Andrew, do you agree or did we miss something?
Comment 8 Andrew Fuerste-Henry 2021-02-07 12:37:26 UTC
(In reply to Katrin Fischer from comment #7)
> (In reply to Tomás Cohen Arazi from comment #6)
> > So a global setting, and the option to change that global default on
> > receiving?
> 
> I think so. Andrew, do you agree or did we miss something?

Sounds good to me!
Comment 9 Tomás Cohen Arazi 2021-02-11 13:24:42 UTC
Ok, I implemented this all:
- Syspref
- Checkboxes per item, set by default using the syspref
- Tweaked finishreceive.pl so it reads the checkboxes and updates dateaccessioned when required.

Coool.

BUT disabling the date didn't work. So I tried without any patches:

MariaDB [koha_kohadev]> SELECT items.itemnumber, dateaccessioned FROM items WHERE itemnumber IN (SELECT itemnumber FROM aqorders_items WHERE ordernumber IN (SELECT ordernumber FROM aqorders WHERE basketno=1));
+------------+-----------------+
| itemnumber | dateaccessioned |
+------------+-----------------+
|        973 | 2021-02-11      |
|        974 | 2021-02-11      |
+------------+-----------------+
2 rows in set (0.00 sec)

MariaDB [koha_kohadev]> UPDATE items SET dateaccessioned='2021-02-09' WHERE itemnumber IN (SELECT itemnumber FROM aqorders_items WHERE ordernumber IN (SELECT ordernumber FROM aqorders WHERE basketno=1));
Query OK, 10 rows affected (0.01 sec)
Rows matched: 10  Changed: 10  Warnings: 0

MariaDB [koha_kohadev]> SELECT items.itemnumber, dateaccessioned FROM items WHERE itemnumber IN (SELECT itemnumber FROM aqorders_items WHERE ordernumber IN (SELECT ordernumber FROM aqorders WHERE basketno=1));
+------------+-----------------+
| itemnumber | dateaccessioned |
+------------+-----------------+
|        973 | 2021-02-09      |
|        974 | 2021-02-09      |
+------------+-----------------+
2 rows in set (0.00 sec)

MariaDB [koha_kohadev]> SELECT items.itemnumber, dateaccessioned FROM items WHERE itemnumber IN (SELECT itemnumber FROM aqorders_items WHERE ordernumber IN (SELECT ordernumber FROM aqorders WHERE basketno=1));
+------------+-----------------+
| itemnumber | dateaccessioned |
+------------+-----------------+
|        973 | 2021-02-11      |
|        974 | 2021-02-11      |
+------------+-----------------+
2 rows in set (0.00 sec)

BUMMER. So the actual behavior is that dateaccessioned gets updated regardless. I will upload my patches here anyway, just in case this behavior I found is incorrect and gets fixed on another bug report, and then we come back to this!
Comment 10 Tomás Cohen Arazi 2021-02-11 13:29:41 UTC
Created attachment 116717 [details] [review]
Bug 26693: Add AcqItemSetDateAccessionedsWhenReceived syspref

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 11 Tomás Cohen Arazi 2021-02-11 13:29:46 UTC
Created attachment 116718 [details] [review]
Bug 26693: Add option to update dateaccessioned when receiving an order

This patchset adds:
- A new syspref: AcqItemSetDateAccessionedsWhenReceived
- A new column on the receive page when items are created on ordering,
  with a checkbox for choosing if they want the date updated
- The checkbox default value honours the global syspref.

To test:

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>