Bugzilla – Attachment 65245 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]
patch to populate price fields using new methods
0002-Bug-18267-Populate-new-price-fields-in-EDI-Processin.patch (text/plain), 7.65 KB, created by
Colin Campbell
on 2017-07-25 15:39:53 UTC
(
hide
)
Description:
patch to populate price fields using new methods
Filename:
MIME Type:
Creator:
Colin Campbell
Created:
2017-07-25 15:39:53 UTC
Size:
7.65 KB
patch
obsolete
>From 1fd608f9ec0c91fe0ac7a58f289b4c8f5312cf39 Mon Sep 17 00:00:00 2001 >From: Colin Campbell <colin.campbell@ptfs-europe.com> >Date: Mon, 10 Jul 2017 15:29:02 +0100 >Subject: [PATCH 2/7] Bug 18267 Populate new price fields in EDI Processing > >New price fields have been added to aqorders with the result >that sites using EDI found prices appearing as zero in >displays as the prices were not duplicated to the >nrew fields as in manual acquisitions. > >Invoicing now records values using the standard >populate_order_with_prices routine from C4::Acquisitions > >However when creating an order from an edifact quote the >routine makes invalid assumptions about what data is available. >In a quote prices are always tax inclusive, and no information >is supplied on the tax rate and amount, these appear in the invoice >message on receipting. Koha::EDI therefore sets the relevant >fields directly in order creation. > >To clarify the field used, we now call the price_info method rather than >the older price method. > >When calculating discount, we now check if a discounted price >has been supplied. (In practice we dont see this but we are >prepared if it occurs ) >--- > Koha/EDI.pm | 74 ++++++++++++++++++++++++++++++++++++++++++++++------ > Koha/Edifact/Line.pm | 2 +- > 2 files changed, 67 insertions(+), 9 deletions(-) > >diff --git a/Koha/EDI.pm b/Koha/EDI.pm >index 1a15507171..75db70770e 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(); >@@ -579,19 +629,24 @@ sub quote_item { > $order_quantity = 1; # attempts to create an orderline for each gir > } > my $vendor = Koha::Acquisition::Booksellers->find( $quote->vendor_id ); >+ my $ecost = _discounted_price( $quote->vendor->discount, >+ $item->price_info, $item->price_info_inclusive ); > > # database definitions should set some of these defaults but dont > my $order_hash = { > biblionumber => $bib->{biblionumber}, > entrydate => DateTime->now( time_zone => 'local' )->ymd(), > basketno => $basketno, >- listprice => $item->price, >+ listprice => $item->price_info, > quantity => $order_quantity, > quantityreceived => 0, > order_vendornote => q{}, > order_internalnote => $order_note, >- rrp => $item->price, >- ecost => _discounted_price( $quote->vendor->discount, $item->price ), >+ rrp => $item->price_info, >+ rrp_tax_included => $item->price_info, >+ ecost => $ecost, >+ ecost_tax_included => $ecost, >+ discount => $quote->vendor->discount, > uncertainprice => 0, > sort1 => q{}, > sort2 => q{}, >@@ -802,8 +857,8 @@ sub quote_item { > notforloan => -1, > cn_sort => q{}, > cn_source => 'ddc', >- price => $item->price, >- replacementprice => $item->price, >+ price => $item->price_info, >+ replacementprice => $item->price_info, > itype => > $item->girfield( 'stock_category', $occurrence ), > location => >@@ -847,7 +902,10 @@ sub get_edifact_ean { > > # We should not need to have a routine to do this here > sub _discounted_price { >- my ( $discount, $price ) = @_; >+ my ( $discount, $price, $discounted_price ) = @_; >+ if (defined $discounted_price) { >+ return $discounted_price; >+ } > return $price - ( ( $discount * $price ) / 100 ); > } > >@@ -997,7 +1055,7 @@ sub _create_item_from_quote { > cn_sort => q{}, > }; > $item_hash->{booksellerid} = $quote->vendor_id; >- $item_hash->{price} = $item_hash->{replacementprice} = $item->price; >+ $item_hash->{price} = $item_hash->{replacementprice} = $item->price_info; > $item_hash->{itype} = $item->girfield('stock_category'); > $item_hash->{location} = $item->girfield('collection_code'); > >diff --git a/Koha/Edifact/Line.pm b/Koha/Edifact/Line.pm >index 5f51284156..213cd394e6 100644 >--- a/Koha/Edifact/Line.pm >+++ b/Koha/Edifact/Line.pm >@@ -792,7 +792,7 @@ sub price_info { > # information price incl tax,allowances, charges > sub price_info_inclusive { > my $self = shift; >- my $p = $self->pri_price('AAE'); >+ my $p = $self->pri_price('AAF'); > if ( defined $p ) { > return $p->{price}; > } >-- >2.13.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