Bugzilla – Attachment 184379 Details for
Bug 40387
t/db_dependent/Koha/EDI.t generates warnings
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 40387: Fix undefined tax rate warnings in EDI invoice processing
Bug-40387-Fix-undefined-tax-rate-warnings-in-EDI-i.patch (text/plain), 2.79 KB, created by
Martin Renvoize (ashimema)
on 2025-07-18 13:48:20 UTC
(
hide
)
Description:
Bug 40387: Fix undefined tax rate warnings in EDI invoice processing
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2025-07-18 13:48:20 UTC
Size:
2.79 KB
patch
obsolete
>From 7ebf7344568dd586d3e8b2bd03e79f3d91112773 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@openfifth.co.uk> >Date: Fri, 18 Jul 2025 13:55:42 +0100 >Subject: [PATCH] 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. >--- > Koha/EDI.pm | 11 +++++++---- > 1 file changed, 7 insertions(+), 4 deletions(-) > >diff --git a/Koha/EDI.pm b/Koha/EDI.pm >index 6b485bf864c..4a36f15b384 100644 >--- a/Koha/EDI.pm >+++ b/Koha/EDI.pm >@@ -414,8 +414,10 @@ sub process_invoice { > unitprice_tax_excluded => $price_excl_tax, > invoiceid => $invoiceid, > datereceived => $msg_date, >- tax_rate_on_receiving => $tax_rate->{rate}, >- tax_value_on_receiving => $quantity * $price_excl_tax * $tax_rate->{rate}, >+ tax_rate_on_receiving => $tax_rate ? $tax_rate->{rate} : 0, >+ tax_value_on_receiving => $quantity * >+ $price_excl_tax * >+ ( $tax_rate ? $tax_rate->{rate} : 0 ), > } > ); > transfer_items( $schema, $line, $order, $received_order, $quantity ); >@@ -430,8 +432,9 @@ sub process_invoice { > $order->unitprice($price); > $order->unitprice_tax_excluded($price_excl_tax); > $order->unitprice_tax_included($price); >- $order->tax_rate_on_receiving( $tax_rate->{rate} ); >- $order->tax_value_on_receiving( $quantity * $price_excl_tax * $tax_rate->{rate} ); >+ $order->tax_rate_on_receiving( $tax_rate ? $tax_rate->{rate} : 0 ); >+ $order->tax_value_on_receiving( >+ $quantity * $price_excl_tax * ( $tax_rate ? $tax_rate->{rate} : 0 ) ); > $order->orderstatus('complete'); > $order->update; > receipt_items( $schema, $line, $ordernumber, $quantity, $invoice_message ); >-- >2.50.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 40387
:
184379
|
184380
|
184381
|
184382
|
184414
|
184415
|
184416
|
184417
|
184539
|
184544
|
184545
|
184546
|
184547
|
184548