Bug 39711

Summary: Migrate C4::Contract to object classes
Product: Koha Reporter: Matt Blenkinsop <matt.blenkinsop>
Component: AcquisitionsAssignee: Matt Blenkinsop <matt.blenkinsop>
Status: Needs Signoff --- QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low CC: jonathan.druart, martin.renvoize
Version: Main   
Hardware: All   
OS: All   
See Also: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39758
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39759
GIT URL: Change sponsored?: ---
Patch complexity: --- Documentation contact:
Documentation submission: Text to go in the release notes:
Version(s) released in:
Circulation function:
Bug Depends on: 38010    
Bug Blocks:    
Attachments: Bug 39711: Add koha objects for the aqcontract table
Bug 39711: Update all calls to GetContracts
Bug 39711: Update all calls to GetContract
Bug 39711: Update call to AddContract
Bug 39711: Update call to ModContract and improve error handling
Bug 39711: Update call to DelContract
Bug 39711: Add unit tests
Bug 39711: Delete old C4::Contract code and tests
Bug 39711: Delete old C4::Contract code and tests
Bug 39711: Delete old C4::Contract code and tests
Bug 39711: Fix 500 when viewing a basket without contract
Bug 39711: Remove ->store
Bug 39711: Fix 500 when creating a new order for a basket without contract
Bug 39711: Use ->contract for basketheader
Bug 39711: (bugfix) Show contract of the basket if inactive
Bug 39711: Order by contract name
Bug 39711: (bugfix) Allow to clear basket's contract

Description Matt Blenkinsop 2025-04-23 15:23:01 UTC
We should migrate this ahead of the new acquisitions work and because it is a relatively small module to migrate
Comment 1 Matt Blenkinsop 2025-04-24 14:40:56 UTC
Created attachment 181453 [details] [review]
Bug 39711: Add koha objects for the aqcontract table
Comment 2 Matt Blenkinsop 2025-04-24 14:40:58 UTC
Created attachment 181454 [details] [review]
Bug 39711: Update all calls to GetContracts
Comment 3 Matt Blenkinsop 2025-04-24 14:41:01 UTC
Created attachment 181455 [details] [review]
Bug 39711: Update all calls to GetContract
Comment 4 Matt Blenkinsop 2025-04-24 14:41:03 UTC
Created attachment 181456 [details] [review]
Bug 39711: Update call to AddContract
Comment 5 Matt Blenkinsop 2025-04-24 14:41:05 UTC
Created attachment 181457 [details] [review]
Bug 39711: Update call to ModContract and improve error handling
Comment 6 Matt Blenkinsop 2025-04-24 14:41:08 UTC
Created attachment 181458 [details] [review]
Bug 39711: Update call to DelContract
Comment 7 Matt Blenkinsop 2025-04-24 14:41:10 UTC
Created attachment 181459 [details] [review]
Bug 39711: Add unit tests
Comment 8 Matt Blenkinsop 2025-04-24 14:41:12 UTC
Created attachment 181460 [details] [review]
Bug 39711: Delete old C4::Contract code and tests
Comment 9 Matt Blenkinsop 2025-04-24 14:47:23 UTC
Created attachment 181461 [details] [review]
Bug 39711: Delete old C4::Contract code and tests

Test plan:
1) prove t/db_dependent/Koha/Acquisition/*
2) Navigate to a vendor record and access the contracts area
3) Test all CRUD elements for the contracts section
4) Navigate to the baskets for the vendor
5) Test the available CRUD options for a basket
6) All pages should work as expected
Comment 10 Jonathan Druart 2025-04-28 09:47:05 UTC
Created attachment 181580 [details] [review]
Bug 39711: Delete old C4::Contract code and tests

Test plan:
1) prove t/db_dependent/Koha/Acquisition/*
2) Navigate to a vendor record and access the contracts area
3) Test all CRUD elements for the contracts section
4) Navigate to the baskets for the vendor
5) Test the available CRUD options for a basket
6) All pages should work as expected
Comment 11 Jonathan Druart 2025-04-28 09:47:19 UTC
(In reply to Jonathan Druart from comment #10)
> Created attachment 181580 [details] [review] [review]
> Bug 39711: Delete old C4::Contract code and tests

Simple rebase.
Comment 12 Jonathan Druart 2025-04-28 09:48:49 UTC
Created attachment 181581 [details] [review]
Bug 39711: Fix 500 when viewing a basket without contract

Can't call method "contractname" on an undefined value at /kohadevbox/koha/acqui/basket.pl line 462.

Use Koha::Acq::Basket->contract
Comment 13 Jonathan Druart 2025-04-28 09:50:39 UTC
Created attachment 181582 [details] [review]
Bug 39711: Remove ->store

It's NOT NULL at the DB level, we don't need to deal with that
constraint here.
Comment 14 Jonathan Druart 2025-04-28 10:24:14 UTC
Created attachment 181583 [details] [review]
Bug 39711: Fix 500 when creating a new order for a basket without contract
Comment 15 Jonathan Druart 2025-04-28 10:24:17 UTC
Created attachment 181584 [details] [review]
Bug 39711: Use ->contract for basketheader
Comment 16 Jonathan Druart 2025-04-28 10:25:06 UTC
Found a bug, that is in main already. You cannot empty a contact when editing a basket.
TODO later.
Comment 17 Jonathan Druart 2025-04-28 10:31:56 UTC
Found another bug, in main as well: if you edit a basket that has an inactive contract, it does not appear in the dropdown list.
Comment 18 Jonathan Druart 2025-04-28 10:41:15 UTC
Created attachment 181586 [details] [review]
Bug 39711: (bugfix) Show contract of the basket if inactive

If the contract is inactive it should be displayed on the basket edit
view.
Comment 19 Jonathan Druart 2025-04-28 10:41:18 UTC
Created attachment 181587 [details] [review]
Bug 39711: Order by contract name
Comment 20 Jonathan Druart 2025-04-28 10:51:28 UTC
Created attachment 181588 [details] [review]
Bug 39711: (bugfix) Allow to clear basket's contract
Comment 21 Jonathan Druart 2025-04-28 10:53:58 UTC
(In reply to Jonathan Druart from comment #20)
> Created attachment 181588 [details] [review] [review]
> Bug 39711: (bugfix) Allow to clear basket's contract

Opened bug 39758 for stable releases.

(In reply to Jonathan Druart from comment #18)
> Created attachment 181586 [details] [review] [review]
> Bug 39711: (bugfix) Show contract of the basket if inactive
> 
> If the contract is inactive it should be displayed on the basket edit
> view.

And bug 39759 for this one.