[Bug 43948] New: Add method to get effective replacement cost for an item
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43948 Bug ID: 43948 Summary: Add method to get effective replacement cost for an item Initiative type: --- Sponsorship --- status: Product: Koha Version: Main Hardware: All OS: All Status: NEW Severity: enhancement Priority: P5 - low Component: Notices Assignee: koha-bugs@lists.koha-community.org Reporter: andrew@bywatersolutions.com QA Contact: testopia@bugs.koha-community.org CC: martin.renvoize@openfifth.co.uk Target Milestone: --- When putting an item's replacement cost into a notice, if useDefaultReplacementCost is on then one must check for a value in the item and if that's null look for a value in the itemtype. It would be simpler to add a sub to the item object for get effective replacementprice so that [% item.effective_replacement_price %] would check the item for a value, then check the system preference and if enabled check the itemtype. -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43948 Andrew Fuerste-Henry <andrew@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|koha-bugs@lists.koha-commun |lucas@bywatersolutions.com |ity.org | -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43948 Andrew Fuerste-Henry <andrew@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- See Also| |https://bugs.koha-community | |.org/bugzilla3/show_bug.cgi | |?id=43941 -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43948 --- Comment #1 from Lucas Gass (lukeg) <lucas@bywatersolutions.com> --- Some libraries like to use items.price in a notice, others like items.replacementprice. It should be configurable between the two. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43948 --- Comment #2 from Lucas Gass (lukeg) <lucas@bywatersolutions.com> --- (In reply to Lucas Gass (lukeg) from comment #1)
Some libraries like to use items.price in a notice, others like items.replacementprice. It should be configurable between the two.
After speaking with Andrew we decided using price doesn't make any sense. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43948 Lucas Gass (lukeg) <lucas@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |Needs Signoff -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43948 --- Comment #3 from Lucas Gass (lukeg) <lucas@bywatersolutions.com> --- Created attachment 209971 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=209971&action=edit Bug 43948: Add effective_replacement_price method to Koha/Item.pm to test: 1. APPLY PATCH, restart_all 2. Find or create some items and add a replacementprice value for them. Note the item type. this is ITEM1 3. Find a a different item, with a different item type, and make sure it does not have a replacementprice value. this is ITEM2 4. For the 2nd item/itemtype configure a defualt replacement price value in Item type administration 5. Ensure useDefaultReplacementCost is set to 'Don't use' 6. Check both items out to a patron ( ITEM1 and ITEM2 ) 7. In the ISSSUESLIP, add the follwoing code: [% USE Price %] [% FOREACH c IN borrower.checkouts %] [% c.item.effective_replacement_price | $Price %] [% END %] 8. Print the issueslip. For ITEM1 you should see the value set in step 2. For ITEM2 you should see 0. 9. Set useDefaultReplacementCost to 'Use' 10. Print the issueslip again, For ITEM1 you should see the value set in step 2. For ITEM2 you should see the default item type replacement cost set in step 4. 11. prove t/db_dependent/Koha/Item.t -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43948 --- Comment #4 from Lucas Gass (lukeg) <lucas@bywatersolutions.com> --- Created attachment 209972 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=209972&action=edit Bug 43948: Add unit tests -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43948 --- Comment #5 from Lucas Gass (lukeg) <lucas@bywatersolutions.com> --- Created attachment 209973 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=209973&action=edit Bug 43948: Add POD -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43948 Andrew Fuerste-Henry <andrew@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |Signed Off -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43948 Andrew Fuerste-Henry <andrew@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #209971|0 |1 is obsolete| | Attachment #209972|0 |1 is obsolete| | Attachment #209973|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43948 --- Comment #6 from Andrew Fuerste-Henry <andrew@bywatersolutions.com> --- Created attachment 210127 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=210127&action=edit Bug 43948: Add effective_replacement_price method to Koha/Item.pm to test: 1. APPLY PATCH, restart_all 2. Find or create some items and add a replacementprice value for them. Note the item type. this is ITEM1 3. Find a a different item, with a different item type, and make sure it does not have a replacementprice value. this is ITEM2 4. For the 2nd item/itemtype configure a defualt replacement price value in Item type administration 5. Ensure useDefaultReplacementCost is set to 'Don't use' 6. Check both items out to a patron ( ITEM1 and ITEM2 ) 7. In the ISSSUESLIP, add the follwoing code: [% USE Price %] [% FOREACH c IN borrower.checkouts %] [% c.item.effective_replacement_price | $Price %] [% END %] 8. Print the issueslip. For ITEM1 you should see the value set in step 2. For ITEM2 you should see 0. 9. Set useDefaultReplacementCost to 'Use' 10. Print the issueslip again, For ITEM1 you should see the value set in step 2. For ITEM2 you should see the default item type replacement cost set in step 4. 11. prove t/db_dependent/Koha/Item.t Signed-off-by: Barbara Johnson <Barbara.Johnson@bedfordtx.gov> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43948 --- Comment #7 from Andrew Fuerste-Henry <andrew@bywatersolutions.com> --- Created attachment 210128 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=210128&action=edit Bug 43948: Add unit tests Signed-off-by: Barbara Johnson <Barbara.Johnson@bedfordtx.gov> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43948 --- Comment #8 from Andrew Fuerste-Henry <andrew@bywatersolutions.com> --- Created attachment 210129 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=210129&action=edit Bug 43948: Add POD Signed-off-by: Barbara Johnson <Barbara.Johnson@bedfordtx.gov> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43948 Paul Derscheid <paul.derscheid@lmscloud.de> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Signed Off |Passed QA -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43948 Paul Derscheid <paul.derscheid@lmscloud.de> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #210127|0 |1 is obsolete| | Attachment #210128|0 |1 is obsolete| | Attachment #210129|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43948 --- Comment #9 from Paul Derscheid <paul.derscheid@lmscloud.de> --- Created attachment 210960 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=210960&action=edit Bug 43948: Add effective_replacement_price method to Koha/Item.pm to test: 1. APPLY PATCH, restart_all 2. Find or create some items and add a replacementprice value for them. Note the item type. this is ITEM1 3. Find a a different item, with a different item type, and make sure it does not have a replacementprice value. this is ITEM2 4. For the 2nd item/itemtype configure a defualt replacement price value in Item type administration 5. Ensure useDefaultReplacementCost is set to 'Don't use' 6. Check both items out to a patron ( ITEM1 and ITEM2 ) 7. In the ISSSUESLIP, add the follwoing code: [% USE Price %] [% FOREACH c IN borrower.checkouts %] [% c.item.effective_replacement_price | $Price %] [% END %] 8. Print the issueslip. For ITEM1 you should see the value set in step 2. For ITEM2 you should see 0. 9. Set useDefaultReplacementCost to 'Use' 10. Print the issueslip again, For ITEM1 you should see the value set in step 2. For ITEM2 you should see the default item type replacement cost set in step 4. 11. prove t/db_dependent/Koha/Item.t Signed-off-by: Barbara Johnson <Barbara.Johnson@bedfordtx.gov> Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43948 --- Comment #10 from Paul Derscheid <paul.derscheid@lmscloud.de> --- Created attachment 210961 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=210961&action=edit Bug 43948: Add unit tests Signed-off-by: Barbara Johnson <Barbara.Johnson@bedfordtx.gov> Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43948 --- Comment #11 from Paul Derscheid <paul.derscheid@lmscloud.de> --- Created attachment 210962 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=210962&action=edit Bug 43948: Add POD Signed-off-by: Barbara Johnson <Barbara.Johnson@bedfordtx.gov> Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43948 --- Comment #12 from Paul Derscheid <paul.derscheid@lmscloud.de> --- Created attachment 210963 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=210963&action=edit Bug 43948: (QA follow-up) Fix spelling in test comment Assisted-by: Opus 5.5 (Anthropic) Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43948 --- Comment #13 from Paul Derscheid <paul.derscheid@lmscloud.de> --- Created attachment 210964 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=210964&action=edit Bug 43948: (QA follow-up) Fix typos in effective_replacement_price POD Assisted-by: Opus 5.5 (Anthropic) Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43948 --- Comment #14 from Paul Derscheid <paul.derscheid@lmscloud.de> --- Created attachment 210965 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=210965&action=edit Bug 43948: (QA follow-up) Test effective_replacement_price without item type default - Cover useDefaultReplacementCost on with neither item nor item type price Test plan: 1. prove -v /kohadevbox/koha/t/db_dependent/Koha/Item.t 2. Tests pass Assisted-by: Opus 5.5 (Anthropic) Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43948 Paul Derscheid <paul.derscheid@lmscloud.de> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |paul.derscheid@lmscloud.de QA Contact|testopia@bugs.koha-communit |paul.derscheid@lmscloud.de |y.org | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43948 --- Comment #15 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 212015 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=212015&action=edit Bug 43948: (RM follow-up) Do not die when the item type cannot be resolved effective_replacement_price fell back to the item type default with $self->itemtype->defaultreplacecost. Koha::Item->itemtype is a find on the effective item type, which returns undef when the item has no item type or its code is not in the itemtypes table. Neither items.itype nor biblioitems.itemtype is a foreign key, and Koha ships a data inconsistency check for items without or with an invalid item type, so this happens on migrated data. The method then died with 'Can't call method "defaultreplacecost" on an undefined value', for exactly the items the fallback is meant for: price empty or 0 with useDefaultReplacementCost on. The method is meant for notice templates, and C4::Letters croaks with "ERROR PROCESSING TEMPLATE" when a template fails, so one such item broke the whole notice and whatever generated it. Only use the item type default when the item type can be resolved. The method returns the item's own price, or 0, as it does when the item type has no default. To test: 1. Enable useDefaultReplacementCost 2. Add this to the ISSUESLIP notice [% USE Price %][% FOREACH c IN borrower.checkouts %][% c.item.effective_replacement_price | $Price %] [% END %] 3. Make an item with no replacement price and no item type: UPDATE items SET itype=NULL, replacementprice=NULL WHERE barcode='...'; UPDATE biblioitems SET itemtype=NULL WHERE biblionumber=...; 4. Check the item out to a patron and print the checkout slip => Before the patch: the slip fails with ERROR PROCESSING TEMPLATE => After the patch: the slip prints 0.00 for that item 5. prove t/db_dependent/Koha/Item.t Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43948 --- Comment #16 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 212016 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=212016&action=edit Bug 43948: (RM follow-up) Test the item type that gives the default replacement cost The tests of effective_replacement_price mocked item-level_itypes to 1 only and built an item whose item type and biblio item type could coincide, so nothing showed that the default comes from the effective item type. Add the cases that were missing: * item-level_itypes on: the default of the item type of the item is used when it differs from the one of its biblio * item-level_itypes off: the default of the item type of the biblio is used * an item type default of 0 gives 0 * a price on the item is used when useDefaultReplacementCost is off To test: 1. prove t/db_dependent/Koha/Item.t => All tests pass 2. Make effective_replacement_price use the item type of the item whatever item-level_itypes says, for instance by replacing $self->itemtype with Koha::ItemTypes->find( $self->itype ) => The test for item-level_itypes off fails Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43948 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Version(s)| |26.11.00 released in| | Status|Passed QA |Pushed to main --- Comment #17 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Pushed to main for 26.11 with permission from Release Manager as RM assistant.. going through the last PQA from before the hard freeze -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43948 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Blocks| |44165 Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44165 [Bug 44165] Use Koha::Item->effective_replacement_price for every default replacement cost fallback -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43948 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Text to go in the| |Items have a new release notes| |`effective_replacement_pric | |e` method for notice | |templates, for example `[% | |c.item.effective_replacemen | |t_price %]` inside | |`borrower.checkouts`. It | |returns the item's | |replacement price. If that | |is empty or 0 and | |`useDefaultReplacementCost` | |is enabled, it returns the | |default replacement cost of | |the item type. Otherwise it | |returns 0. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43948 Lucas Gass (lukeg) <lucas@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Pushed to main |Needs documenting --- Comment #18 from Lucas Gass (lukeg) <lucas@bywatersolutions.com> --- Enhancement, no 26.05.x backport. -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org