https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43755

            Bug ID: 43755
           Summary: EDI invoices without GIR segments leave items
                    unmatched and part receipts without items
   Initiative type: ---
        Sponsorship ---
            status:
           Product: Koha
           Version: Main
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P5 - low
         Component: Acquisitions
          Assignee: [email protected]
          Reporter: [email protected]
        QA Contact: [email protected]
  Target Milestone: ---

Koha::EDI::receipt_items and Koha::EDI::transfer_items locate the items that
belong to an invoice line using the branch given in the GIR segments (GIR ...
:LLO). If the invoice line has no GIR segments, the branch is undefined and no
item can be matched.

Many suppliers send no GIR on invoices (the segment is conditional on the
invoice message). Koha then records errors and leaves the items untouched:

Reproduced on main (vendor EDI account without plugin, basket with
create_items=ordering, items linked in aqorders_items, no GIR on the invoice
line):

1. Full receipt, order for 2, invoice for 2, no GIR:
   - order is marked complete, but 2 edifact_errors are written: "No matching
item found for invoice line 1:0 at branch  (order N has items at: , XXX)..."
(the branch in the message is empty)
   - the items are not touched (so anything done at receipt, such as
AcqItemSetSubfieldsWhenReceived, is not applied)
   - Perl warnings: Use of uninitialized value $branch in hash element at
Koha/EDI.pm line 591 (and others)

2. Part receipt, order for 3, invoice for 1, no GIR:
   - the original order drops to quantity 2 (partial) and a new complete order
is created for 1 copy
   - transfer_items moves nothing, because no item homebranch matches an
undefined branch: all 3 items stay linked to the original order and the new
completed order has no items
   - receipt_items then logs "No matching item found ... (order M has items at:
none)"

The same invoice with matching GIR segments works as expected (1 item is moved
to the new order).

Proposed fix: when the invoice line has no GIR (or a GIR occurrence has no
LLO), fall back to the items already linked to the order, in itemnumber order,
taking as many as the invoiced quantity. Transfer those to the new order on a
part receipt, then receive them.

Test plan:
1. Create a vendor with an EDI account (no plugin) and a basket with
AcqCreateItem=ordering. Order 3 copies of a record, so 3 items are linked to
the order.
2. Process an INVOIC for that order with QTY+47:1 and no GIR segments.
3. Without the patch: the new completed order (1 copy) has no linked items, the
3 items stay on the original order, and edifact_errors contains "No matching
item found".
4. With the patch: 1 item is moved to the completed order and received, 2 stay
on the original order, and there are no errors.
5. Repeat with QTY+47:3 (full receipt) and confirm the 3 items are received
without errors.
6. Repeat with matching GIR+LLO segments and confirm behaviour is unchanged.

-- 
You are receiving this mail because:
You are the assignee for the bug.
You are watching all bug changes.
_______________________________________________
Koha-bugs mailing list -- [email protected]
To unsubscribe send an email to [email protected]
website : http://www.koha-community.org/
git : http://git.koha-community.org/
bugs : http://bugs.koha-community.org/

Reply via email to