Commit Graph

60 Commits

Author SHA1 Message Date
Martin Renvoize 04809de849
Bug 42764: Fix spelling errors across the codebase
Correct genuine spelling errors identified by the codespell 2.4.x
full scan after the KTD container OS upgrade. Changes are in
comments, POD, strings, and template text across 55 files.

"SAN Ouest Provence" (the French library co-operative and Koha
sponsor) is preserved as a proper noun. Perl copyright lines
receive an inline # codespell:ignore annotation; about.tt files
(contributor attribution pages) are added to the Koha::Devel::Files
codespell exception list so that future uses of "Provence" as a
typo for "Province" are still caught in all other files.

Notable user-visible fixes:
- "submiting" -> "submitting" in authority and bibliographic merge screens
- "deleteable" -> "deletable" in patron exception messages
- "Acquistions" -> "Acquisitions" in reports dictionary

Test plan:
1. Apply patches
2. In the staff interface, go to Cataloguing > Merge records and
   confirm the submit button reads "Submitting" (not "Submiting")
3. In the staff interface, go to Authorities > Merge and confirm
   the same correction
4. Attempt to delete a patron with outstanding issues and confirm
   the error message reads "deletable" (not "deleteable")
5. prove xt/author/codespell.t
=> All tests pass

Signed-off-by: Pedro Amorim <pedro.amorim@openfifth.co.uk>
2026-06-03 16:09:04 +00:00
Martin Renvoize 76c2523b12
Bug 40391: Add support for GIR:LSL (Library Sub-Location) in EDIFACT processing
This implements support for the new EDItEUR/BiC GIR:LSL (Library Sub-Location)
field to complement the existing GIR:LSQ (Library Sequence) functionality,
allowing flexible mapping of both fields to location and collection item fields.

Changes:
- Add LSL mapping to GIR field extraction in Koha::Edifact::Line
- Update gir_segments() in Koha::Edifact::Order to handle both LSL and LSQ preferences independently
- Add validation functions in Koha::EDI using Koha::AuthorisedValues for location/collection codes
- Add EdifactLSL system preference for independent LSL field mapping
- Update EdifactLSQ to include empty option for ignore functionality
- Add admin interface configuration for LSL preference

The implementation provides maximum flexibility:
- EdifactLSQ can be set to: location, ccode, or empty (ignore)
- EdifactLSL can be set to: location, ccode, or empty (ignore)
- Both fields can be mapped independently or to same target field
- Validation ensures codes exist in LOC/CCODE authorised values
- Maintains full backwards compatibility with existing LSQ-only setups

Test plan:
1. Apply both patches
2. Update database: installer/data/mysql/updatedatabase.pl
3. Verify new system preferences in Administration > System preferences > Acquisitions:
   - EdifactLSQ: "Map EDI sequence code (GIR+LSQ) to Koha Item field"
   - EdifactLSL: "Map EDI sub-location code (GIR+LSL) to Koha Item field"
4. Create test authorised values:
   - LOC category: Add values like FICTION, REFERENCE
   - CCODE category: Add values like ADULT, CHILD
5. Set preferences to test combinations:
   - EdifactLSQ=location, EdifactLSL=ccode
   - EdifactLSQ=ccode, EdifactLSL=location
   - EdifactLSQ=location, EdifactLSL="" (empty)
6. Process EDIFACT messages containing GIR+LSL and GIR+LSQ segments
7. Verify items created with correct location/ccode values per preferences
8. Test invalid codes generate appropriate error messages
9. Confirm existing LSQ-only configurations continue working unchanged
10. Run: prove t/Edifact.t t/db_dependent/Koha/EDI.t t/db_dependent/Koha/Edifact/Order.t

Sponsored-by: Westminster City Council <https://www.westminster.gov.uk/>
Sponsored-by: Royal Borough of Kensington and Chelsea <https://www.rbkc.gov.uk/>
Sponsored-by: OpenFifth <https://openfifth.co.uk/>
Signed-off-by: Hannah Dunne-Howrie <hdunne-howrie@westminster.gov.uk>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2026-01-12 10:53:29 -07:00
Jonathan Druart beac9eae8f
Bug 40680: Move EXPORT_OK right after Modern::Perl
So it is done before the other use statements.

Also uniformize the pattern, must now be:
```
use Modern::Perl;
use base 'Exporter';
BEGIN {
    our @EXPORT_OK = qw(subroutine list);
}
```

Rebased-by: Victor Grousset/tuxayo <victor@tuxayo.net>
  Bug38936 exported redirect_if_opac_suppressed
Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2025-12-01 08:33:56 -07:00
Martin Renvoize ebfca0edb4
Bug 20253: (follow-up) Fix undefined variable $b and test plan count
In bug 40587 we renamed a variable from $b to $basketno. After rebasing,
the auto-orders blocking code had a bug where it referenced an undefined
variable $b instead of $basketno when checking for PO number conflicts.
This caused warnings: "Use of uninitialized value $Koha::EDI::b in exists"

This patch:
- Renames $b to $basketno throughout the conflict checking code
- Updates test plan from 7 to 8 to match actual subtest count

Test plan:
1. Run prove t/db_dependent/Koha/EDI.t
2. Verify all tests pass without warnings
3. Confirm auto-orders blocking works correctly for duplicate PO numbers

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2025-11-03 14:13:40 -07:00
Martin Renvoize 943bfe097e
Bug 20253: (follow-up) Block auto_orders and UI ordering for duplicate PO numbers
When po_is_basketname is enabled for a vendor, duplicate purchase order
numbers should prevent both automatic ordering (auto_orders) and manual
UI-triggered ordering to avoid conflicts with existing baskets.

This patch implements blocking functionality that:

1. Auto-orders blocking:
   - Tracks baskets with PO number conflicts during quote processing
   - Skips auto-ordering for baskets with duplicate PO numbers
   - Logs clear warnings about blocked baskets

2. UI basket ordering blocking:
   - Adds duplicate checking in create_edi_order function
   - Returns detailed error information when conflicts detected
   - Prevents EDI order creation for conflicting baskets

3. User-friendly error handling:
   - Updates basket.pl to handle duplicate PO number errors
   - Stays on basket page to display error messages
   - Provides clear messaging about conflicts and resolution steps

4. Template messaging:
   - Adds clear error message explaining duplicate PO conflicts
   - Shows which existing basket uses the same PO number
   - Guides users on next steps to resolve the issue

This ensures data integrity and prevents order processing conflicts
while providing clear feedback to users about duplicate PO number
issues.

Test plan:
1. Set up a vendor with EDI account and enable "po_is_basketname"
2. Create a basket with a specific name (e.g., "PO12345")
3. Process an EDIFACT quote that contains the same PO number:
   - If auto_orders is enabled: verify the new basket is created but NOT automatically ordered
   - Check the logs show "Auto-order blocked" message
4. For UI testing, create another basket manually with the same name
5. Try to generate EDI order via "Generate EDI order" button
6. Verify: Error message appears stating duplicate PO number conflict
7. Verify: Basket remains open (not closed)
8. Verify: Error message shows which existing basket uses the PO number
9. Test with po_is_basketname disabled: verify normal operation continues
10. Test with unique PO numbers: verify orders process normally

Signed-off-by: Hannah Dunne-Howrie <hdunne-howrie@westminster.gov.uk>
Sponsored-by: Westminster City Council <https://www.westminster.gov.uk/>
Sponsored-by: Royal Borough of Kensington and Chelsea <https://www.rbkc.gov.uk/>
Sponsored-by: OpenFifth <https://openfifth.co.uk/>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2025-11-03 14:13:39 -07:00
Martin Renvoize 458608b9c4
Bug 20253: (follow-up) Add duplicate purchase order number validation
When processing EDI quotes with purchase order numbers, validate that the
purchase order number is unique for the vendor to prevent operational
confusion. The validation:

- Checks for existing baskets with the same purchase order number and vendor
- Includes both open and closed baskets in the uniqueness check
- Logs an error with the raw RFF+ON segment and details to the edifact_errors table
- Continues processing (non-blocking) to prevent data loss
- Provides system log warnings for monitoring

The error logging includes:
- Section: Raw RFF+ON segment (e.g., "RFF+ON:orders 23/1")
- Details: Clear description of the duplicate purchase order number issue

This ensures administrators can identify and resolve duplicate purchase order
numbers while maintaining system functionality and audit trails.

Signed-off-by: Hannah Dunne-Howrie <hdunne-howrie@westminster.gov.uk>
Sponsored-by: Westminster City Council <https://www.westminster.gov.uk/>
Sponsored-by: Royal Borough of Kensington and Chelsea <https://www.rbkc.gov.uk/>
Sponsored-by: OpenFifth <https://openfifth.co.uk/>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2025-11-03 14:13:37 -07:00
Martin Renvoize 4179211ce8
Bug 20253: Optionally use buyer's purchase order number from EDIFACT quote as basket name
This enhancement allows libraries to configure vendors to use the buyer's
purchase order number (from RFF+ON segments) as the basket name instead of
the EDIFACT filename, improving searchability and reference tracking.

Backend Changes:
- Added purchase_order_number() method to Koha::Edifact::Message to extract
  RFF+ON segments from message-level data (before first LIN segment)
- Modified process_quote() in Koha::EDI to use purchase order number for
  basket naming when configured, with fallback to filename

Frontend Changes:
- Updated admin/edi_accounts.pl to handle po_is_basketname parameter
- Added "Use purhase order numbers" option to EDI accounts template

Test Plan:
1. Apply patches and run database update
2. Go to Administration > Acquisitions > EDI accounts
3. Create or edit a vendor EDI account
4. Verify "Use purchase order numbers" option appears
5. Enable "Use purchase order numbers" and save
6. Process an EDIFACT quote file that contains RFF+ON segments
7. Verify the created basket name uses the purchase order number instead of filename
8. Process a quote file without RFF+ON segments
9. Verify the basket name falls back to the filename
10. Test with "Use purchase order numbers" disabled
11. Verify basket names use filenames regardless of RFF+ON presence
12. Run tests: prove t/Edifact.t t/db_dependent/Koha/EDI.t

The feature is optional and backward compatible - existing behavior is
unchanged unless explicitly configured.

Signed-off-by: Hannah Dunne-Howrie <hdunne-howrie@westminster.gov.uk>
Sponsored-by: Westminster City Council <https://www.westminster.gov.uk/>
Sponsored-by: Royal Borough of Kensington and Chelsea <https://www.rbkc.gov.uk/>
Sponsored-by: OpenFifth <https://openfifth.co.uk/>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2025-11-03 14:13:37 -07:00
Martin Renvoize 47546f0849
Bug 40587: Auto-select EAN from QUOTE message when creating EDIFACT orders
When a basket is generated via an EDI QUOTE message, the QUOTE message
includes a library's EAN code (buyer_ean). This patch makes the 'Create
EDIFACT order' button automatically use the EAN from the original QUOTE
message instead of requiring manual EAN selection.

This patch also fixes a bug in process_quote where all baskets in
multi-message QUOTE transports incorrectly used the first message's
buyer_ean, even when subsequent messages had different EANs.

Changes made:

1. Fixed Koha/EDI.pm process_quote auto-order creation to use the correct
   buyer_ean for each message/basket pair in multi-message transports
2. Enhanced acqui/basket.pl to extract and provide the quote_ean from
   QUOTE messages, handling both single and multi-message scenarios
3. Updated basket.tt template to automatically select the EAN from the
   original QUOTE message when available and matching

Test plan:
1. Create a vendor with EDI account and multiple EANs configured
2. Process a QUOTE message that creates a basket
3. Go to the basket page and click "Create EDIFACT order"
4. Verify it automatically uses the EAN from the QUOTE message
   (shows tooltip "Using EAN from original QUOTE message")
5. Test with multi-message QUOTE files to ensure each basket uses
   the correct EAN from its corresponding message
6. Verify fallback behavior when no QUOTE EAN matches available EANs

Sponsored-by: OpenFifth <https://openfifth.co.uk/>
Signed-off-by: Hannah Dunne-Howrie <hdunne-howrie@westminster.gov.uk>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2025-10-09 14:58:37 -06:00
Tomas Cohen Arazi 1873d97c07
Bug 40163: Fix several http addresses in the code docs
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Brendan Lawlor <blawlor@clamsnet.org>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2025-09-23 16:21:29 -06:00
Martin Renvoize ac3eced5d3
Bug 40387: Add Test::NoWarnings and replace carp with Koha::Logger
This patch adds Test::NoWarnings to our EDI unit tests. In doing so, it
reminded me that we still had some old carp style error handling in the
process_quote section and that we shoudl replace those with calls to
Koha::Logger instead.

Changes made:
1. Added Test::NoWarnings import to catch any warnings
2. Replace 'carp "Message"' appropriately with
   '$logger->warn("Message")'

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2025-07-23 16:36:34 -06:00
Martin Renvoize 68aa216317
Bug 40387: Fix undefined tax rate warnings in EDI invoice processing
When processing EDI invoices without TAX segments, warnings were
generated due to undefined tax rates in multiplication operations.

The tax_rate() method in Koha::Edifact::Line correctly returns undef
when no TAX segments are present in the EDI message. However, the
invoice processing code in Koha::EDI didn't handle this case properly.

This patch fixes the issue by:
- Adding checks for undefined tax rates before using them in calculations
- Defaulting to 0 tax rate when no tax information is present
- Ensuring tax_value calculations use 0 instead of undefined values

This eliminates "Use of uninitialized value in multiplication" warnings
while maintaining correct processing of invoices without tax information.

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2025-07-23 16:36:33 -06:00
Jonathan Druart 1d844a7d2f
Bug 39325: Automatic fix
Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2025-04-28 18:51:22 +02:00
Martin Renvoize be9d6b7469
Bug 38689: Add section to output
We attempt to add the relevant part of the EDI message to the 'section'
field of the edifact_errors record and then display this alongside the
error details.

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2025-02-21 16:41:22 +01:00
Martin Renvoize c1dacd1b95
Bug 38689: Add logging tests for process_quote
This adds missing tests for the Koha::Logger based logging of messages
in the process_quote process.  We also tidy up the log lines a tiny bit
for consistency.

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2025-02-21 16:41:22 +01:00
Martin Renvoize 7a686e3f66
Bug 38689: Record errors on quote processing
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2025-02-21 16:41:21 +01:00
Martin Renvoize d8943c28b4
Bug 38689: Record errors on invoice processing
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

error message improvement

Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2025-02-21 16:41:19 +01:00
Koha Development Team d659526b5a
Bug 38664: Tidy the whole codebase
This commit is generated using:
  % perl misc/devel/tidy.pl
*within* ktd, to get the same version of perltidy than what will be used
by our CI (currently v20230309).

Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2025-02-11 14:58:24 +01:00
Martin Renvoize 210e0cb18b
Bug 38423: Add unit tests
Sponsored-by: PTFS Europe <https://ptfs-europe.com>
Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2025-01-10 19:19:15 +01:00
Martin Renvoize af19a0f553
Bug 38423: Code more defensively in process_invoice
We re-arrange the logic of process_invoice a little here to ensure we
skip order lines in invoices that do not have corresponding bib records.

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2025-01-10 19:19:14 +01:00
Kyle M Hall 7fb78e4a5d
Bug 22415: (QA follow-up) Fix misc qa issues
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2025-01-10 19:19:14 +01:00
Martin Renvoize 7f6c186831
Bug 22415: Update EDI to use Koha::Logger
This patch updates the EDI code to use the Koha::Logger wrapper in
preference to the bare Log::Log4perl module.

Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2025-01-10 19:19:13 +01:00
Kyle M Hall 0f68688b58
Bug 38271: (QA follow-up) Tidy code
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2024-10-29 08:46:39 +01:00
Matt Blenkinsop b00fb3d557
Bug 38271: Handle missing 008 fields in EDI
This patch adds handling to create a default 008 field on MARC records that are missing one when created through EDI.

Test plan:
1) prove t/db_dependent/Koha/EDI.t

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2024-10-29 08:46:38 +01:00
Marcel de Rooy d6011d6ae9
Bug 19097: Adjust some GetMarcFromKohaField calls
We need to:
[1] Remove obsolete framework parameters if any (yes there are).
[2] Check scalar context calls if any (most probably not).

Ad 1:
How to find them? Git grep and look at each hit. You will need the -C
parameter to add a few context lines around the call even.

Found one in C4/Biblio.pm and six in Suggestions.t with ''.
Found one in C4/Items on a second line. Similar one in Koha/EDI.
Note: sub receipt_items in EDI has no unit tests yet.

Also did a few git searches like:
git grep GetMarcFromKohaField | grep -v -P "GetMarcFromKohaField.*;"| grep -P "GetMarcFromKohaField\s*\("
Note: Seeing still three lines; they are all fine. Last line comes from
testing to trigger the warn.

Ad 2:
Have been looking at each git grep line and did not spot any
scalar context call. Before this report, we had an example in
POD and the Biblio test only.

Try to find them by performing smarter git searches?
Did look again at results for:
git grep GetMarcFromKohaField | grep -v -P "\)\s*=\s*&?(C4::Biblio::)?GetMarcFromKohaField" | grep -v -P "use "
The tests from this grep are included in the last test plan line.

Test plan:
Read the patch.
Run t/db_dependent/Biblio/TransformHtmlToMarc.t
Run t/db_dependent/Items.t
Run t/db_dependent/Suggestions.t
Run prove t/Biblio2.t t/db_dependent/Biblio.t t/db_dependent/Filter_MARC_ViewPolicy.t t/db_dependent/Koha/Authorities.t t/db_dependent/Koha/Biblio/Metadata.t t/db_dependent/Koha/Filter/EmbedItemsAvailability.t t/db_dependent/Koha/SearchEngine/Search.t t/db_dependent/XISBN.t

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2024-04-29 09:35:47 +02:00
Kyle M Hall ab7a8db43d
Bug 35398: (QA follow-up) Tidy code
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2024-03-07 15:02:47 +01:00
Martin Renvoize 783a58a9d3
Bug 35398: Fix LRP support for EDI orders with single items
This patch corrects a mistake in the original implementaiton of bug
20595 where we introduced support for the LRP segments being used to
automatically assign items ordered via EDI to stock rotation plans.

Signed-off-by: Sophie Halden <sophie.halden@cheshiresharedservices.gov.uk>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2024-03-07 15:02:47 +01:00
Kyle Hall 8939c58a86
Bug 28672: (QA follow-up) Method calls cannot be interpolated directly
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
2023-02-07 15:39:31 -03:00
Martin Renvoize c89c25d81a
Bug 28672: Pass itemnumber instead of item object
The warn call here was passing the full item object which leads to
HASH() in the logs.. this patch updates it to pass the itemnumber which
is more helpful.

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
2023-02-07 15:39:31 -03:00
Kyle Hall e714213359
Bug 27017: (QA follow-up) Don't die if aqorders.biblionumber is null
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
2022-10-27 15:03:49 -03:00
Colin Campbell c009c3fa81
Bug 27017: Code more defensively in process_invoice
This patch adds a check for ordernumber precence in the EDI Invoice
message lines and skips process if one is not found.

We log the failure as a trace log to allow administrators the oportunity
to track down the issue further.

We also add a trace log to entries to show which bib the invoice line
is receipting to.

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
2022-10-27 15:03:49 -03:00
Kyle Hall 181b0c16fe
Bug 31054: Manual importing for EDIFACT invoices fails with a 500 error page
Error in plack log is: Can't locate object method "new" via package
"Koha::Plugin::Com::ByWaterSolutions::MyEdifactPlugin" (perhaps you
forgot to load "Koha::Plugin::Com::ByWaterSolutions::MyEdifactPlugin"?)
at /usr/share/koha/lib/Koha/EDI.pm line 219.

Test Plan:
1) Set EdifactInvoiceImport to "Don't"
2) Configure an EDI vendor to use an EDIFACT plugin
3) Attempt to import an invoice file
4) You will be shown an error page
5) Apply this patch
6) Restart all the things!
7) Attempt to import another invoice file
8) It works!

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
2022-07-11 18:23:12 -03:00
Martin Renvoize 509aebd60e Bug 30135: Add EdifactLSQ mapping preference
This patch adds a new system preference, EdifactLSQ, to allow
configuration of the ambiguous LSQ, sequence code, field included in the
EDIFACT specifications.

Originally the field was hard coded to map to 'location', but as per the
specification it could have been mapped to 'ccode'.

From the specification:

A code or other designation which identifies stock which is to be
shelved in a specified sequence or collection.

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
2022-04-13 15:55:39 +02:00
Martin Renvoize 51f978696e Bug 28960: Explicitly call get_column
This patch adds get_column to ensure we are returning a string value of
a field rather than accidentally triggering a relationship accessor.

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2021-09-20 12:06:53 +02:00
Jonathan Druart 9d6d641d1f Bug 17600: Standardize our EXPORT_OK
On bug 17591 we discovered that there was something weird going on with
the way we export and use subroutines/modules.
This patch tries to standardize our EXPORT to use EXPORT_OK only.

That way we will need to explicitely define the subroutine we want to
use from a module.

This patch is a squashed version of:
Bug 17600: After export.pl
Bug 17600: After perlimport
Bug 17600: Manual changes
Bug 17600: Other manual changes after second perlimports run
Bug 17600: Fix tests

And a lot of other manual changes.

export.pl is a dirty script that can be found on bug 17600.

"perlimport" is:
git clone https://github.com/oalders/App-perlimports.git
cd App-perlimports/
cpanm --installdeps .
export PERL5LIB="$PERL5LIB:/kohadevbox/koha/App-perlimports/lib"
find . \( -name "*.pl" -o -name "*.pm" \) -exec perl App-perlimports/script/perlimports --inplace-edit --no-preserve-unused --filename {} \;

The ideas of this patch are to:
* use EXPORT_OK instead of EXPORT
* perltidy the EXPORT_OK list
* remove '&' before the subroutine names
* remove some uneeded use statements
* explicitely import the subroutines we need within the controllers or
modules

Note that the private subroutines (starting with _) should not be
exported (and not used from outside of the module except from tests).

EXPORT vs EXPORT_OK (from
https://www.thegeekstuff.com/2010/06/perl-exporter-examples/)
"""
Export allows to export the functions and variables of modules to user’s namespace using the standard import method. This way, we don’t need to create the objects for the modules to access it’s members.

@EXPORT and @EXPORT_OK are the two main variables used during export operation.

@EXPORT contains list of symbols (subroutines and variables) of the module to be exported into the caller namespace.

@EXPORT_OK does export of symbols on demand basis.
"""

If this patch caused a conflict with a patch you wrote prior to its
push:
* Make sure you are not reintroducing a "use" statement that has been
removed
* "$subroutine" is not exported by the C4::$MODULE module
means that you need to add the subroutine to the @EXPORT_OK list
* Bareword "$subroutine" not allowed while "strict subs"
means that you didn't imported the subroutine from the module:
  - use $MODULE qw( $subroutine list );
You can also use the fully qualified namespace: C4::$MODULE::$subroutine

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2021-07-16 08:58:47 +02:00
Colin Campbell 33c8d6f175 Bug 27793: Store FTX free text in vendor note
This is important for proquest ordering to distinguish types of
material.

FTX segment from quote is stored as vendor note.
Contents of vendornote are included in the order FTX segment.

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2021-05-07 14:44:00 +02:00
Jonathan Druart 7e2679528e Bug 23971: Rename pref with AcquisitionLog
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2021-04-23 11:58:49 +02:00
Andrew Isherwood 9bd5a3c398 Bug 23971: (follow-up) Log entire objects
As requested by Tomás and Jonathan, we now log the entire basket object
when logging an action.

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2021-04-23 11:58:49 +02:00
Andrew Isherwood 7fd3eaa247 Bug 23971: (follow-up) Respond to feedback
As requested by Jonathan in commit #28:

- We now no longer pass a flag to CloseBasket indicating if the closure
was due to an EDI basket approval, we log the closure and approval as
separate events.

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

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2021-04-23 11:58:49 +02:00
Colin Campbell 36d46c6510 Bug 18267: Refactored Edifact Price Calculations
Refactored the price calculations for Quotes and Invoices
This takes in to account various combinations used by different
vendors. Makes the extraction of basic price, quantity and tax
information more reliable. Tests are in Edifact.t and EdiInvoice.t

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2020-11-16 13:46:48 +01:00
Tomas Cohen Arazi a851aaeebf Bug 26584: Remove unused C4::Acquisition::CloseBasket function
This patch makes code use the new Koha::Acquisition::Basket->close
method and makes CloseBasket obsolete.

It then removes it, and adapts the few places in which it was used.

1. Apply this patch
2. Run:
   $ kshell
  k$ git diff origin/master --name-only | grep -e '\.t$' | xargs prove
=> SUCCESS: Tests pass!
3. Try playing with baskets, closing them
=> SUCCESS: All works as expected!
4. Sign off :-D

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2020-11-05 15:24:20 +01:00
Colin Campbell 647e05d826 Bug 26438: Rename temporary Koha::Item variables to avoid conflict
Returns from Koha::Item calls were stored in temporary variables
called $item. Unfortunately they occur in routines already with
an $item variable holding a lineitem and hide that variable although
only required for two lines of code. An error occurs if girfield
is called on the wrong variable. Renamed all three occurences
of $item to $kitem to avoid the error

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2020-09-28 10:09:57 +02:00
Kyle M Hall 85405a2143 Bug 23682: Dedup plugin calls my moving to a single call in process_invoice()
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2020-09-03 15:00:48 +02:00
Colin Campbell b5a36c20a2 Bug 26082: Call store on new items to update itemnumber
Need to add call to store to Koha::Item->new so that itemnumber
is returned - otherwise is not defined and causes an error
Bug is a side-effect of Bug 23463 as this was implicitly
done in AddItem

Also set biblioitemnumber explicitly for item adds this also
used to be done explicitly but can now cause an FK error

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2020-08-20 10:23:59 +02:00
Nick Clemens 6ac037f817
Bug 24840: Replace DateTime->now with dt_from_string
We should use Koha::DateUtils instead of Date::Time directly

This patch simplay replaces calls to now() with a call to dt_from_string()
which does effectively the same thing.

Probably reading the code and verifying changes is sufficient but...

To test:
1 - confirm the files all compile
2 - confirm all tests pass
3 - confirm Koha still works

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
2020-04-08 11:54:23 +01:00
Jonathan Druart 2075a22ed3
Bug 23463: Replace AddItem calls with Koha::Item->store
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
2020-03-23 09:26:26 +00:00
Martin Renvoize 1d275e64f0
Bug 20595: Add handling for LRP field in EDI
* EDI.pm - Add handling of the LRP EDI field to automatically add an
item to a stockrotation rota.

Signed-off-by: Brendan Gallagher <brendan@bywatersolutions.com>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
2019-10-28 09:58:16 +00:00
Martin Renvoize df32a48c27
Bug 20780: (follow-up) Use Koha::Object
Signed-off-by: Brendan Gallagher <brendan@bywatersolutions.com>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
2019-10-10 08:24:31 +01:00
Martin Renvoize 8a579e5c61
Bug 20780: Add handling for AcqItemSetSubfieldsWhenRecieved in EDI
Signed-off-by: Brendan Gallagher <brendan@bywatersolutions.com>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
2019-10-10 08:24:24 +01:00
Colin Campbell 248373506e
Bug 21580: Pass buyer_ean to create_edi_order
create_edi_order requires two parameters to be passed
but if vendor was set to auto_order the subroutine
was called with basketno only resulting in the error
'no basket or ean passed' - pass the buyer_ean as
passed in the quotes message

Signed-off-by: Brendan Gallagher <brendan@bywatersolutions.com>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
2019-10-10 08:23:12 +01:00
Martin Renvoize b604e9c4fc
Bug 22294: Check return of as_isbn10 before calling methods on it
Signed-off-by: Brendan Gallagher <brendan@bywatersolutions.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
2019-10-08 14:33:34 +01:00