Bugzilla – Attachment 55344 Details for
Bug 17279
Edifact::Line quantity should ensure its returning invoiced quantity
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Proposed Patch
0001-Bug-17279-Distinguish-edi-quantities-based-on-qualif.patch (text/plain), 6.88 KB, created by
Colin Campbell
on 2016-09-08 14:34:00 UTC
(
hide
)
Description:
Proposed Patch
Filename:
MIME Type:
Creator:
Colin Campbell
Created:
2016-09-08 14:34:00 UTC
Size:
6.88 KB
patch
obsolete
>From c845c6709b4c91737cdbc61bd738eb52342e5fb5 Mon Sep 17 00:00:00 2001 >From: Colin Campbell <colin.campbell@ptfs-europe.com> >Date: Thu, 8 Sep 2016 14:09:38 +0100 >Subject: [PATCH] Bug 17279 Distinguish edi quantities based on qualifier > >We currently are only interested in quantity invoiced >in loading invoices, although "discreet quantity" is >used in quotes for items quoted (usu 1) >so we should check the type of >quantity we are storing/retrieving >The value 47 in the quantity qualifier indicates >'invoiced quantity' >The value 1 is discreet quantity used in >quotes as above and in credit notes > >Add a new method quantity_invoiced for invoice >processing, only the 'discrete quantity' is now >returned by the quantity method >Test for retrieval added to t/EdiInvoice.t >As Edifact.t is testing a quote ensure that >only quantity is returned > >TBD Add methods for other possible QTY types >although not presently in use will provide >documentation for the future >--- > Koha/EDI.pm | 20 ++++++++++---------- > Koha/Edifact/Line.pm | 16 ++++++++++++++-- > t/EdiInvoice.t | 4 +++- > t/Edifact.t | 5 +++-- > 4 files changed, 30 insertions(+), 15 deletions(-) > >diff --git a/Koha/EDI.pm b/Koha/EDI.pm >index f3206ff..b5afd27 100644 >--- a/Koha/EDI.pm >+++ b/Koha/EDI.pm >@@ -264,7 +264,7 @@ sub process_invoice { > foreach my $line ( @{$lines} ) { > my $ordernumber = $line->ordernumber; > $logger->trace( "Receipting order:$ordernumber Qty: ", >- $line->quantity ); >+ $line->quantity_invoiced ); > > my $order = $schema->resultset('Aqorder')->find($ordernumber); > >@@ -288,18 +288,18 @@ sub process_invoice { > > my $price = _get_invoiced_price($line); > >- if ( $order->quantity > $line->quantity ) { >+ if ( $order->quantity > $line->quantity_invoiced ) { > my $ordered = $order->quantity; > > # part receipt > $order->orderstatus('partial'); >- $order->quantity( $ordered - $line->quantity ); >+ $order->quantity( $ordered - $line->quantity_invoiced ); > $order->update; > my $received_order = $order->copy( > { > ordernumber => undef, >- quantity => $line->quantity, >- quantityreceived => $line->quantity, >+ quantity => $line->quantity_invoiced, >+ quantityreceived => $line->quantity_invoiced, > orderstatus => 'complete', > unitprice => $price, > invoiceid => $invoiceid, >@@ -312,7 +312,7 @@ sub process_invoice { > $received_order->ordernumber ); > } > else { # simple receipt all copies on order >- $order->quantityreceived( $line->quantity ); >+ $order->quantityreceived( $line->quantity_invoiced ); > $order->datereceived($msg_date); > $order->invoiceid($invoiceid); > $order->unitprice($price); >@@ -343,8 +343,8 @@ sub _get_invoiced_price { > my $price = $line->price_net; > if ( !defined $price ) { # no net price so generate it from lineitem amount > $price = $line->amt_lineitem; >- if ( $price and $line->quantity > 1 ) { >- $price /= $line->quantity; # div line cost by qty >+ if ( $price and $line->quantity_invoiced > 1 ) { >+ $price /= $line->quantity_invoiced; # div line cost by qty > } > } > return $price; >@@ -353,7 +353,7 @@ sub _get_invoiced_price { > sub receipt_items { > my ( $schema, $inv_line, $ordernumber ) = @_; > my $logger = Log::Log4perl->get_logger(); >- my $quantity = $inv_line->quantity; >+ my $quantity = $inv_line->quantity_invoiced; > > # itemnumber is not a foreign key ??? makes this a bit cumbersome > my @item_links = $schema->resultset('AqordersItem')->search( >@@ -413,7 +413,7 @@ sub transfer_items { > my ( $schema, $inv_line, $order_from, $order_to ) = @_; > > # Transfer x items from the orig order to a completed partial order >- my $quantity = $inv_line->quantity; >+ my $quantity = $inv_line->quantity_invoiced; > my $gocc = 0; > my %mapped_by_branch; > while ( $gocc < $quantity ) { >diff --git a/Koha/Edifact/Line.pm b/Koha/Edifact/Line.pm >index 7fdd305..5f27d34 100644 >--- a/Koha/Edifact/Line.pm >+++ b/Koha/Edifact/Line.pm >@@ -64,7 +64,14 @@ sub _parse_lines { > push @item_description, $s; > } > elsif ( $s->tag eq 'QTY' ) { >- $d->{quantity} = $s->elem( 0, 1 ); >+ if ( $s->elem( 0, 0 ) eq '47' ) { >+ $d->{quantity_invoiced} = $s->elem( 0, 1 ); >+ } >+ elsif ( $s->elem( 0, 0 ) eq '1' ) >+ { # In quotes used for copies quoted >+ # Used elsewhere as well (e.g. credit notes ) >+ $d->{discrete_quantity} = $s->elem( 0, 1 ); >+ } > } > elsif ( $s->tag eq 'DTM' ) { > if ( $s->elem( 0, 0 ) eq '44' ) { >@@ -374,9 +381,14 @@ sub monetary_amount { > return $self->{monetary_amount}; > } > >+sub quantity_invoiced { >+ my $self = shift; >+ return $self->{quantity_invoiced}; >+} >+ > sub quantity { > my $self = shift; >- return $self->{quantity}; >+ return $self->{discrete_quantity}; > } > > sub price { >diff --git a/t/EdiInvoice.t b/t/EdiInvoice.t >index 14e7596..a22083a 100755 >--- a/t/EdiInvoice.t >+++ b/t/EdiInvoice.t >@@ -3,7 +3,7 @@ use strict; > use warnings; > use FindBin qw( $Bin ); > >-use Test::More tests => 19; >+use Test::More tests => 20; > > BEGIN { use_ok('Koha::Edifact') } > >@@ -73,3 +73,5 @@ is( $lineprice, 4.55, 'correct net line price returned' ); > my $tax = $lines->[7]->tax; > > is( $tax, 0, 'correct tax amount returned' ); >+ >+is( $lines->[7]->quantity_invoiced, 1, 'line quantity invoiced returned' ); >diff --git a/t/Edifact.t b/t/Edifact.t >index cc20539..01ee8d5 100755 >--- a/t/Edifact.t >+++ b/t/Edifact.t >@@ -3,7 +3,7 @@ use strict; > use warnings; > use FindBin qw( $Bin ); > >-use Test::More tests => 34; >+use Test::More tests => 35; > > BEGIN { use_ok('Koha::Edifact') } > >@@ -50,7 +50,8 @@ my $test_line = $lin->[-1]; > > is( $test_line->line_item_number, 18, 'correct line number returned' ); > is( $test_line->item_number_id, '9780273761006', 'correct ean returned' ); >-is( $test_line->quantity, 1, 'quantity returned' ); >+is( $test_line->quantity_invoiced, undef, 'quantity invoiced not returned as expected' ); >+is( $test_line->quantity, 1, 'discrete quantity returned' ); > > my $test_title = 'International business [electronic resource]'; > my $marcrec = $test_line->marc_record; >-- >2.7.4 >
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 17279
: 55344