Bugzilla – Attachment 57071 Details for
Bug 17536
Remove Duplication of receipting code in EDI
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Proposed patch
0001-Bug-17536-Use-ModReceiveOrder-for-item-receipting.patch (text/plain), 8.39 KB, created by
Colin Campbell
on 2016-11-02 10:35:34 UTC
(
hide
)
Description:
Proposed patch
Filename:
MIME Type:
Creator:
Colin Campbell
Created:
2016-11-02 10:35:34 UTC
Size:
8.39 KB
patch
obsolete
>From cef3c1feefe18e36366e244bfebb649ed5fa91a0 Mon Sep 17 00:00:00 2001 >From: Colin Campbell <colin.campbell@ptfs-europe.com> >Date: Mon, 31 Oct 2016 15:45:50 +0000 >Subject: [PATCH] Bug 17536 Use ModReceiveOrder for item receipting > >As ModReceiveOrders interface was in flux Koha::EDI did not >use the routine, but duplicated the processing. The change >reverts to using the standard interface and removes the >duplication of logic allowing better integration. >--- > Koha/EDI.pm | 150 ++++++++++++++---------------------------------------------- > 1 file changed, 35 insertions(+), 115 deletions(-) > >diff --git a/Koha/EDI.pm b/Koha/EDI.pm >index f3206ff..5356ae9 100644 >--- a/Koha/EDI.pm >+++ b/Koha/EDI.pm >@@ -27,7 +27,7 @@ use Business::ISBN; > use DateTime; > use C4::Context; > use Koha::Database; >-use C4::Acquisition qw( NewBasket CloseBasket ModOrder); >+use C4::Acquisition qw( NewBasket CloseBasket ModOrder ModReceiveOrder); > use C4::Suggestions qw( ModSuggestion ); > use C4::Items qw(AddItem); > use C4::Biblio qw( AddBiblio TransformKohaToMarc GetMarcBiblio ); >@@ -270,56 +270,26 @@ sub process_invoice { > > # ModReceiveOrder does not validate that $ordernumber exists validate here > if ($order) { >+ my $received_items = >+ receipt_items( $schema, $line, $ordernumber ); > >- # check suggestions >- my $s = $schema->resultset('Suggestion')->search( >+ my $price = _get_invoiced_price($line); >+ ModReceiveOrder( > { > biblionumber => $order->biblionumber->biblionumber, >+ ordernumber => $ordernumber, >+ quantityreceived => $line->quantity, >+ cost => $price, >+ ecost => $order->ecost, >+ invoiceid => $invoiceid, >+ rrp => $order->rrp, >+ budget_id => $order->budget_id, >+ datereceived => $msg_date, >+ received_items => $received_items, >+ order_internalnote => $order->order_internalnote, >+ order_vendornote => $order->order_vendornote, > } >- )->single; >- if ($s) { >- ModSuggestion( >- { >- suggestionid => $s->suggestionid, >- STATUS => 'AVAILABLE', >- } >- ); >- } >- >- my $price = _get_invoiced_price($line); >- >- if ( $order->quantity > $line->quantity ) { >- my $ordered = $order->quantity; >- >- # part receipt >- $order->orderstatus('partial'); >- $order->quantity( $ordered - $line->quantity ); >- $order->update; >- my $received_order = $order->copy( >- { >- ordernumber => undef, >- quantity => $line->quantity, >- quantityreceived => $line->quantity, >- orderstatus => 'complete', >- unitprice => $price, >- invoiceid => $invoiceid, >- datereceived => $msg_date, >- } >- ); >- transfer_items( $schema, $line, $order, >- $received_order ); >- receipt_items( $schema, $line, >- $received_order->ordernumber ); >- } >- else { # simple receipt all copies on order >- $order->quantityreceived( $line->quantity ); >- $order->datereceived($msg_date); >- $order->invoiceid($invoiceid); >- $order->unitprice($price); >- $order->orderstatus('complete'); >- $order->update; >- receipt_items( $schema, $line, $ordernumber ); >- } >+ ); > } > else { > $logger->error( >@@ -366,20 +336,29 @@ sub receipt_items { > my $item = $schema->resultset('Item')->find( $ilink->itemnumber ); > if ( !$item ) { > my $i = $ilink->itemnumber; >- $logger->warn( >- "Cannot find aqorder item for $i :Order:$ordernumber"); >+ $logger->warn("Cannot find item for $i : Order:$ordernumber"); > next; > } > my $b = $item->homebranch->branchcode; >+ if ( !defined $b ) { >+ $b = 'undef'; >+ } > if ( !exists $branch_map{$b} ) { > $branch_map{$b} = []; > } > push @{ $branch_map{$b} }, $item; > } >+ >+ my $received_items = []; > my $gir_occurrence = 0; > while ( $gir_occurrence < $quantity ) { >- my $branch = $inv_line->girfield( 'branch', $gir_occurrence ); >- my $item = shift @{ $branch_map{$branch} }; >+ my $branch = $inv_line->girfield( 'branch', $gir_occurrence ); >+ my $barcode = $inv_line->girfield( 'barcode', $gir_occurrence ); >+ my $item = shift @{ $branch_map{$branch} }; >+ if ( !defined $item ) { >+ $item = shift @{ $branch_map{undef} }; >+ } >+ > if ($item) { > my $barcode = $inv_line->girfield( 'barcode', $gir_occurrence ); > if ( $barcode && !$item->barcode ) { >@@ -398,6 +377,7 @@ sub receipt_items { > } > } > >+ push @{$received_items}, $item->itemnumber; > $item->update; > } > else { >@@ -405,59 +385,8 @@ sub receipt_items { > } > ++$gir_occurrence; > } >- return; >- >-} >- >-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 $gocc = 0; >- my %mapped_by_branch; >- while ( $gocc < $quantity ) { >- my $branch = $inv_line->girfield( 'branch', $gocc ); >- if ( !exists $mapped_by_branch{$branch} ) { >- $mapped_by_branch{$branch} = 1; >- } >- else { >- $mapped_by_branch{$branch}++; >- } >- ++$gocc; >- } >- my $logger = Log::Log4perl->get_logger(); >- my $o1 = $order_from->ordernumber; >- my $o2 = $order_to->ordernumber; >- $logger->warn("transferring $quantity copies from order $o1 to order $o2"); >- >- my @item_links = $schema->resultset('AqordersItem')->search( >- { >- ordernumber => $order_from->ordernumber, >- } >- ); >- foreach my $ilink (@item_links) { >- my $ino = $ilink->itemnumber; >- my $item = $schema->resultset('Item')->find( $ilink->itemnumber ); >- my $i_branch = $item->homebranch; >- if ( exists $mapped_by_branch{$i_branch} >- && $mapped_by_branch{$i_branch} > 0 ) >- { >- $ilink->ordernumber( $order_to->ordernumber ); >- $ilink->update; >- --$quantity; >- --$mapped_by_branch{$i_branch}; >- $logger->warn("Transferred item $item"); >- } >- else { >- $logger->warn("Skipped item $item"); >- } >- if ( $quantity < 1 ) { >- last; >- } >- } >+ return $received_items; > >- return; > } > > sub process_quote { >@@ -1080,19 +1009,10 @@ Koha::EDI > > receipt_items( schema_obj, invoice_line, ordernumber) > >- receipts the items recorded on this invoice line >- >- no meaningful return >- >-=head2 transfer_items >- >- transfer_items(schema, invoice_line, originating_order, receiving_order) >- >- Transfer the items covered by this invoice line from their original >- order to another order recording the partial fulfillment of the original >- order >+ checks the items recorded on this invoice line, updating their barcodes if supplied >+ by the vendor > >- no meaningful return >+ returns an arrayref of matched itemnumbers > > =head2 get_edifact_ean > >-- >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 17536
: 57071