Bugzilla – Attachment 61601 Details for
Bug 18267
Update price and tax fields in EDI to reflect DB changes
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Proposed patch
0002-Bug-18267-Use-new-price-fields-in-EDI-processing.patch (text/plain), 4.54 KB, created by
Colin Campbell
on 2017-03-24 10:04:56 UTC
(
hide
)
Description:
Proposed patch
Filename:
MIME Type:
Creator:
Colin Campbell
Created:
2017-03-24 10:04:56 UTC
Size:
4.54 KB
patch
obsolete
>From 1a34ec396d3ee43a925ea12f539f49980701c530 Mon Sep 17 00:00:00 2001 >From: Colin Campbell <colin.campbell@ptfs-europe.com> >Date: Fri, 17 Mar 2017 16:10:33 +0000 >Subject: [PATCH 2/3] Bug 18267 Use new price fields in EDI processing > >--- > Koha/EDI.pm | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- > 1 file changed, 59 insertions(+), 1 deletion(-) > >diff --git a/Koha/EDI.pm b/Koha/EDI.pm >index 1a15507..6f0680c 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 populate_order_with_prices ); > use C4::Suggestions qw( ModSuggestion ); > use C4::Items qw(AddItem); > use C4::Biblio qw( AddBiblio TransformKohaToMarc GetMarcBiblio ); >@@ -307,6 +307,13 @@ sub process_invoice { > datereceived => $msg_date, > } > ); >+ my $p_updates = >+ update_price_from_invoice( $received_order, >+ $invoice_message->vendor_id ); >+ if ( keys %{$p_updates} ) { >+ $received_order->set_columns($p_updates); >+ $received_order->update; >+ } > transfer_items( $schema, $line, $order, > $received_order ); > receipt_items( $schema, $line, >@@ -318,6 +325,11 @@ sub process_invoice { > $order->invoiceid($invoiceid); > $order->unitprice($price); > $order->orderstatus('complete'); >+ my $p_updates = update_price_from_invoice( $order, >+ $invoice_message->vendor_id ); >+ foreach my $col ( keys %{$p_updates} ) { >+ $order->set_column( $col, $p_updates->{$col} ); >+ } > $order->update; > receipt_items( $schema, $line, $ordernumber ); > } >@@ -351,6 +363,44 @@ sub _get_invoiced_price { > return $price; > } > >+sub update_price_from_invoice { >+ my $ord = shift; >+ my $booksellerid = shift; >+ >+ # wrapper around populate_order_with_prices as we are using dbic Row objects >+ my $ord_hash_ref = { >+ discount => $ord->discount, >+ tax_rate_on_receiving => $ord->tax_rate_on_receiving, >+ tax_value_on_receiving => $ord->tax_value_on_receiving, >+ tax_rate => $ord->tax_rate_bak, >+ unitprice => $ord->unitprice, >+ ecost_tax_included => $ord->ecost_tax_included, >+ ecost_tax_excluded => $ord->ecost_tax_excluded, >+ unitprice_tax_included => $ord->unitprice_tax_included, >+ unitprice_tax_excluded => $ord->unitprice_tax_excluded, >+ quantity => $ord->quantity, >+ }; >+ my %pre_hash = %{$ord_hash_ref}; >+ $ord_hash_ref = populate_order_with_prices( >+ { >+ order => $ord_hash_ref, >+ booksellerid => $booksellerid, >+ receiving => 1, >+ } >+ ); >+ foreach my $k ( keys %pre_hash ) { >+ if ( !defined $ord_hash_ref->{$k} >+ || $ord_hash_ref->{$k} == $pre_hash{$k} ) >+ { >+ delete $ord_hash_ref->{$k}; >+ } >+ } >+ delete $ord_hash_ref->{quantity}; >+ delete $ord_hash_ref->{discount}; >+ >+ return $ord_hash_ref; >+} >+ > sub receipt_items { > my ( $schema, $inv_line, $ordernumber ) = @_; > my $logger = Log::Log4perl->get_logger(); >@@ -592,6 +642,7 @@ sub quote_item { > order_internalnote => $order_note, > rrp => $item->price, > ecost => _discounted_price( $quote->vendor->discount, $item->price ), >+ discount => $quote->vendor->discount, > uncertainprice => 0, > sort1 => q{}, > sort2 => q{}, >@@ -655,6 +706,13 @@ sub quote_item { > > if ( !$skip ) { > $order_hash->{budget_id} = $budget->budget_id; >+ $order_hash = populate_order_with_prices( >+ { >+ order => $order_hash, >+ booksellerid => $quote->vendor_id, >+ ordering => 1, >+ } >+ ); > my $first_order = $schema->resultset('Aqorder')->create($order_hash); > my $o = $first_order->ordernumber(); > $logger->trace("Order created :$o"); >-- >2.9.3 >
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 18267
:
61600
|
61601
|
61602
|
61605
|
61606
|
65244
|
65245
|
65246
|
65250
|
65251
|
65252
|
65253
|
65254
|
68536
|
68707
|
68708
|
68709
|
68710
|
68711
|
68712
|
68713
|
68714
|
113569
|
113597
|
113897