Created attachment 187161 [details] [review] Bug 38195: Add Koha::EDI::Account and Koha::EDI::Accounts object classes This patch introduces Koha::Object-based classes for managing vendor EDI accounts, replacing direct DBIx::Class result access with proper Koha object wrappers. New classes: - Koha::EDI::Account: Object class representing a single EDI account - Koha::EDI::Accounts: Objects class for collections of EDI accounts The Koha::EDI::Account class provides accessor methods for all related objects following modern Koha naming conventions: - vendor() - Returns the associated Koha::Acquisition::Bookseller - file_transport() - Returns the associated Koha::File::Transport - shipment_fund() - Returns the Koha::Acquisition::Fund for shipment fund - files() - Returns Koha::Edifact::Files (EDIFACT interchange files) The Schema Result class has been updated with koha_object_class() and koha_objects_class() helper methods to enable automatic object inflation. This modernization enables cleaner code in controllers and provides a consistent API for working with EDI accounts throughout the codebase.
Created attachment 187162 [details] [review] Bug 38195: Convert admin/edi_accounts.pl to use Koha::EDI::Account(s) This patch modernizes the EDI accounts administration controller to use the new Koha::EDI::Account(s) object classes instead of raw DBIx::Class result access. Changes to admin/edi_accounts.pl: - Replaced Aqbookseller searches with Koha::Acquisition::Booksellers - Replaced FileTransport searches with Koha::File::Transports - Updated account save operations to use Koha::EDI::Account->new/set/store - Updated account delete to use Koha::EDI::Accounts->find->delete - Simplified display logic using to_api with embed parameter for automatic relationship inflation and JSON status decoding - Leverages Koha::File::Transport->to_api which handles JSON decoding of the status field automatically Benefits: - Much cleaner, more maintainable code following modern Koha patterns - Automatic relationship inflation via to_api embed parameter - Status decoding handled automatically by Koha::File::Transport->to_api - Single line conversion using map and to_api - Consistent API representation across the codebase - No manual JSON decoding or data transformation in controller
Created attachment 187163 [details] [review] Bug 38195: Modernise Koha::Edifact::Transport to use Koha::Objects This patch updates Koha::Edifact::Transport to use the new Koha::EDI::Accounts and Koha::Edifact::Files object classes instead of raw DBIx::Class objects. Changes: - Replaced $schema->resultset('VendorEdiAccount')->find() with Koha::EDI::Accounts->find() - Replaced resultset('EdifactMessage')->find( { filename => $f, } ); with Koha::Edifact::Files->search( { filename => $f }); - Simplified file_transport retrieval by using the relationship method from Koha::EDI::Account->file_transport() - Removed conditional logic as the relationship method handles undef cases automatically Benefits: - Cleaner code using Koha object patterns - Automatic relationship handling via accessor methods - More maintainable and consistent with rest of codebase
Created attachment 187164 [details] [review] Bug 38195: Convert Koha::EDI to use Koha object classes This patch updates Koha::EDI to use modern Koha object classes instead of raw DBIx::Class access. Changes to vendor_edi_accounts access: - Added use Koha::EDI::Accounts; - Replaced three instances of $schema->resultset('VendorEdiAccount') with Koha::EDI::Accounts in: 1. create_edi_order() - Finding vendor account by vendor_id 2. process_invoice() - Finding vendor account by SAN 3. process_quote() - Finding vendor account for auto_orders check Changes to aqorders access: - Added use Koha::Acquisition::Orders; - Converted five instances from raw DBIx::Class to Koha::Objects: 1. create_edi_order() - Changed from ->all array to resultset with ->count, ->next, ->reset, and ->_resultset->all for iteration 2. process_invoice() - Changed ->find to use Koha::Acquisition::Orders 3-4. process_quote() - Changed two ->create calls to use Koha::Acquisition::Order->new()->store pattern 5. process_quote() - Changed ->find to use Koha::Acquisition::Orders Additional improvements: - Used idiomatic Koha::Objects patterns (->count, ->next, ->reset) - Maintained backward compatibility with existing code expectations - Cleaner variable naming (e.g., $vendor -> $edi_account) Benefits: - Consistent use of Koha object patterns throughout EDI code - Enables use of relationship methods from Koha objects - More maintainable and testable code - Better integration with Koha's ORM layer
Created attachment 187178 [details] [review] Bug 38195: Add Koha::EDI::Account and Koha::EDI::Accounts object classes This patch introduces Koha::Object-based classes for managing vendor EDI accounts, replacing direct DBIx::Class result access with proper Koha object wrappers. New classes: - Koha::EDI::Account: Object class representing a single EDI account - Koha::EDI::Accounts: Objects class for collections of EDI accounts The Koha::EDI::Account class provides accessor methods for all related objects following modern Koha naming conventions: - vendor() - Returns the associated Koha::Acquisition::Bookseller - file_transport() - Returns the associated Koha::File::Transport - shipment_fund() - Returns the Koha::Acquisition::Fund for shipment fund - files() - Returns Koha::Edifact::Files (EDIFACT interchange files) The Schema Result class has been updated with koha_object_class() and koha_objects_class() helper methods to enable automatic object inflation. This modernization enables cleaner code in controllers and provides a consistent API for working with EDI accounts throughout the codebase.
Created attachment 187179 [details] [review] Bug 38195: Convert admin/edi_accounts.pl to use Koha::EDI::Account(s) This patch modernizes the EDI accounts administration controller to use the new Koha::EDI::Account(s) object classes instead of raw DBIx::Class result access. Changes to admin/edi_accounts.pl: - Replaced Aqbookseller searches with Koha::Acquisition::Booksellers - Replaced FileTransport searches with Koha::File::Transports - Updated account save operations to use Koha::EDI::Account->new/set/store - Updated account delete to use Koha::EDI::Accounts->find->delete - Simplified display logic using to_api with embed parameter for automatic relationship inflation and JSON status decoding - Leverages Koha::File::Transport->to_api which handles JSON decoding of the status field automatically Benefits: - Much cleaner, more maintainable code following modern Koha patterns - Automatic relationship inflation via to_api embed parameter - Status decoding handled automatically by Koha::File::Transport->to_api - Single line conversion using map and to_api - Consistent API representation across the codebase - No manual JSON decoding or data transformation in controller
Created attachment 187180 [details] [review] Bug 38195: Modernise Koha::Edifact::Transport to use Koha::Objects This patch updates Koha::Edifact::Transport to use the new Koha::EDI::Accounts and Koha::Edifact::Files object classes instead of raw DBIx::Class objects. Changes: - Replaced $schema->resultset('VendorEdiAccount')->find() with Koha::EDI::Accounts->find() - Replaced resultset('EdifactMessage')->find( { filename => $f, } ); with Koha::Edifact::Files->search( { filename => $f }); - Simplified file_transport retrieval by using the relationship method from Koha::EDI::Account->file_transport() - Removed conditional logic as the relationship method handles undef cases automatically Benefits: - Cleaner code using Koha object patterns - Automatic relationship handling via accessor methods - More maintainable and consistent with rest of codebase
Created attachment 187181 [details] [review] Bug 38195: Convert Koha::EDI to use Koha object classes This patch updates Koha::EDI to use modern Koha object classes instead of raw DBIx::Class access. Changes to vendor_edi_accounts access: - Added use Koha::EDI::Accounts; - Replaced three instances of $schema->resultset('VendorEdiAccount') with Koha::EDI::Accounts in: 1. create_edi_order() - Finding vendor account by vendor_id 2. process_invoice() - Finding vendor account by SAN 3. process_quote() - Finding vendor account for auto_orders check Changes to aqorders access: - Added use Koha::Acquisition::Orders; - Converted five instances from raw DBIx::Class to Koha::Objects: 1. create_edi_order() - Changed from ->all array to resultset with ->count, ->next, ->reset, and ->_resultset->all for iteration 2. process_invoice() - Changed ->find to use Koha::Acquisition::Orders 3-4. process_quote() - Changed two ->create calls to use Koha::Acquisition::Order->new()->store pattern 5. process_quote() - Changed ->find to use Koha::Acquisition::Orders Additional improvements: - Used idiomatic Koha::Objects patterns (->count, ->next, ->reset) - Maintained backward compatibility with existing code expectations - Cleaner variable naming (e.g., $vendor -> $edi_account) Benefits: - Consistent use of Koha object patterns throughout EDI code - Enables use of relationship methods from Koha objects - More maintainable and testable code - Better integration with Koha's ORM layer