From 05da6d6c38bffc5e09e08dec55951346bc62b9d8 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Fri, 29 Dec 2017 16:16:23 +0000 Subject: [PATCH] Bug 18639 - Add replacementprice field to acquisitions workflow To test: 0 - Apply patches and updatedatabase 1 - Add an order to a basket 2 - You should note new 'Retail price field' 3 - You should have a separate 'Replacement price' field 4 - Enter values and ensure they are saved as expected 5 - In the basket you should see the replacement price 6 - Modify order and ensure value is loaded and saved correctly 7 - Add and cancle an order and esure replacement price shows/saves 8 - Close basket 9 - Receive an order 10 - You should be able to edit replacement price 11 - 'retail price' field is not editable 12 - Check associated item, replacement price in item should be updated 13 - Cancel receipt, check item. receive again with new replacement price, check item 14 - Price should be correctly updated 15 - Finish receipt, value should show in table 16 - Test with receive from file Signed-off-by: Martin Renvoize --- C4/Acquisition.pm | 8 + acqui/addorderiso2709.pl | 8 +- acqui/finishreceive.pl | 6 +- acqui/neworderempty.pl | 2 + acqui/orderreceive.pl | 1 + .../intranet-tmpl/prog/en/modules/acqui/basket.tt | 6 + .../intranet-tmpl/prog/en/modules/acqui/invoice.tt | 5 + .../prog/en/modules/acqui/neworderempty.tt | 8 +- .../prog/en/modules/acqui/orderreceive.tt | 6 +- .../intranet-tmpl/prog/en/modules/acqui/parcel.tt | 179 +++++++++++---------- 10 files changed, 137 insertions(+), 92 deletions(-) diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm index a257017..384b598 100644 --- a/C4/Acquisition.pm +++ b/C4/Acquisition.pm @@ -1508,6 +1508,10 @@ sub ModReceiveOrder { |; $query .= q| + , replacementprice = ? + | if defined $order->{replacementprice}; + + $query .= q| , unitprice = ?, unitprice_tax_included = ?, unitprice_tax_excluded = ? | if defined $order->{unitprice}; @@ -1528,6 +1532,10 @@ sub ModReceiveOrder { my $sth = $dbh->prepare( $query ); my @params = ( $quantrec, $datereceived, $invoice->{invoiceid}, ( $budget_id ? $budget_id : $order->{budget_id} ) ); + if ( defined $order->{replacementprice} ) { + push @params, $order->{replacementprice}; + } + if ( defined $order->{unitprice} ) { push @params, $order->{unitprice}, $order->{unitprice_tax_included}, $order->{unitprice_tax_excluded}; } diff --git a/acqui/addorderiso2709.pl b/acqui/addorderiso2709.pl index db0c66b..91d8321 100755 --- a/acqui/addorderiso2709.pl +++ b/acqui/addorderiso2709.pl @@ -262,6 +262,7 @@ if ($op eq ""){ ); my $price = $infos->{price}; + my $replacementprice = $infos->{replacementprice}; if ($price){ # in France, the cents separator is the , but sometimes, ppl use a . # in this case, the price will be x100 when unformatted ! Replace the . by a , to get a proper price calculation @@ -283,6 +284,7 @@ if ($op eq ""){ } else { $orderinfo{listprice} = 0; } + $orderinfo{replacementprice} = $replacementprice || 0; # remove uncertainprice flag if we have found a price in the MARC record $orderinfo{uncertainprice} = 0 if $orderinfo{listprice}; @@ -511,8 +513,9 @@ sub import_biblios_list { my ( $marcblob, $encoding ) = GetImportRecordMarc( $biblio->{'import_record_id'} ); my $marcrecord = MARC::Record->new_from_usmarc($marcblob) || die "couldn't translate marc information"; - my $infos = get_infos_syspref('MarcFieldsToOrder', $marcrecord, ['price', 'quantity', 'budget_code', 'discount', 'sort1', 'sort2']); + my $infos = get_infos_syspref('MarcFieldsToOrder', $marcrecord, ['price', 'quantity', 'budget_code', 'discount', 'sort1', 'sort2','replacementprice']); my $price = $infos->{price}; + my $replacementprice = $infos->{replacementprice}; my $quantity = $infos->{quantity}; my $budget_code = $infos->{budget_code}; my $discount = $infos->{discount}; @@ -573,7 +576,7 @@ sub import_biblios_list { 'quantity' => $item_quantity, 'budget_id' => $item_budget_id || $budget_id, 'itemprice' => $item_price || $price, - 'replacementprice' => $item_replacement_price, + 'replacementprice' => $item_replacement_price || $replacementprice, 'itemcallnumber' => $item_callnumber, ); $all_items_quantity++; @@ -590,6 +593,7 @@ sub import_biblios_list { if ($alliteminfos == -1 || scalar(@$alliteminfos) == 0) { $cellrecord{price} = $price || ''; + $cellrecord{replacementprice} = $replacementprice || ''; $cellrecord{quantity} = $quantity || ''; $cellrecord{budget_id} = $budget_id || ''; $cellrecord{discount} = $discount || ''; diff --git a/acqui/finishreceive.pl b/acqui/finishreceive.pl index 8c1439c..c9870ac 100755 --- a/acqui/finishreceive.pl +++ b/acqui/finishreceive.pl @@ -48,6 +48,7 @@ my $origquantityrec = $input->param('origquantityrec'); my $quantityrec = $input->param('quantityrec'); my $quantity = $input->param('quantity'); my $unitprice = $input->param('unitprice'); +my $replacementprice = $input->param('replacementprice'); my $datereceived = $input->param('datereceived'), my $invoiceid = $input->param('invoiceid'); my $invoice = GetInvoice($invoiceid); @@ -59,6 +60,8 @@ my $order = GetOrder($ordernumber); my $new_ordernumber = $ordernumber; $unitprice = Koha::Number::Price->new( $unitprice )->unformat(); +$replacementprice = Koha::Number::Price->new( $replacementprice )->unformat(); +warn "Replacement $replacementprice"; my $basket = Koha::Acquisition::Orders->find( $ordernumber )->basket; #need old receivedate if we update the order, parcel.pl only shows the right parcel this way FIXME @@ -85,6 +88,7 @@ if ($quantityrec > $origquantityrec ) { $order->{order_internalnote} = $input->param("order_internalnote"); $order->{tax_rate_on_receiving} = $input->param("tax_rate"); + $order->{replacementprice} = $replacementprice; $order->{unitprice} = $unitprice; $order = C4::Acquisition::populate_order_with_prices( @@ -156,7 +160,7 @@ ModItem( dateaccessioned => $datereceived, datelastseen => $datereceived, price => $unitprice, - replacementprice => $order->{rrp}, + replacementprice => $replacementprice, replacementpricedate => $datereceived, }, $biblionumber, diff --git a/acqui/neworderempty.pl b/acqui/neworderempty.pl index 6326eaf..0e6f2c1 100755 --- a/acqui/neworderempty.pl +++ b/acqui/neworderempty.pl @@ -371,6 +371,7 @@ if ( defined $from_subscriptionid ) { $data->{tax_rate} = $lastOrderReceived->{tax_rate_on_ordering}; $data->{discount} = $lastOrderReceived->{discount}; $data->{rrp} = $lastOrderReceived->{rrp}; + $data->{replacementprice} = $lastOrderReceived->{replacementprice}; $data->{ecost} = $lastOrderReceived->{ecost}; $data->{quantity} = $lastOrderReceived->{quantity}; $data->{unitprice} = $lastOrderReceived->{unitprice}; @@ -454,6 +455,7 @@ $template->param( quantity => $quantity, quantityrec => $quantity, rrp => $data->{'rrp'}, + replacementprice => $data->{'replacementprice'}, gst_values => \@gst_values, tax_rate => $data->{tax_rate_on_ordering} ? $data->{tax_rate_on_ordering}+0.0 : $bookseller->tax_rate ? $bookseller->tax_rate+0.0 : 0, listprice => sprintf( "%.2f", $data->{listprice} || $data->{price} || $listprice), diff --git a/acqui/orderreceive.pl b/acqui/orderreceive.pl index 4dbb5f0..91c6e35 100755 --- a/acqui/orderreceive.pl +++ b/acqui/orderreceive.pl @@ -213,6 +213,7 @@ $template->param( quantityreceivedplus1 => $order->{'quantityreceived'} + 1, quantityreceived => $order->{'quantityreceived'}, rrp => $rrp, + replacementprice => $order->{'replacementprice'}, ecost => $ecost, unitprice => $unitprice, tax_rate => $tax_rate, diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt index ec4ed9a..b870d83 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt @@ -358,6 +358,7 @@ ecost tax exc. RRP tax inc. ecost tax inc. + Replacement price Qty. Total tax exc. ([% currency | html %]) Total tax inc. ([% currency | html %]) @@ -382,6 +383,7 @@       +   [% foot_loo.quantity | html %] [% foot_loo.total_tax_excluded | $Price | html %] [% foot_loo.total_tax_included | $Price | html %] @@ -404,6 +406,7 @@       +   [% total_quantity | html %] [% total_tax_excluded | $Price | html %] [% total_tax_included | $Price | html %] @@ -479,6 +482,7 @@ [% books_loo.ecost_tax_excluded | $Price | html %] [% books_loo.rrp_tax_included | $Price | html %] [% books_loo.ecost_tax_included | $Price | html %] + [% books_loo.replacementprice | $Price | html %] [% books_loo.quantity | html %] [% books_loo.total_tax_excluded | $Price | html %] [% books_loo.total_tax_included | $Price | html %] @@ -541,6 +545,7 @@ ecost tax exc. RRP tax inc. ecost tax inc. + Replacement price Qty. Total tax exc. ([% currency | html %]) Total tax inc. ([% currency | html %]) @@ -593,6 +598,7 @@ [% order.ecost_tax_excluded | $Price | html %] [% order.rrp_tax_included | $Price | html %] [% order.ecost_tax_included | $Price | html %] + [% order.replacementprice | $Price | html %] [% order.quantity | html %] [% order.total_tax_excluded | $Price | html %] [% order.total_tax_included | $Price | html %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoice.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoice.tt index aa5770f..0389bad 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoice.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoice.tt @@ -244,6 +244,7 @@ Library Actual cost tax exc. Actual cost tax inc. + Replacement price Qty. Total tax exc. ([% currency.symbol | html %]) Total tax inc. ([% currency.symbol | html %]) @@ -274,6 +275,7 @@

[% order.branchcode | html %]

[% order.unitprice_tax_excluded | $Price | html %] [% order.unitprice_tax_included | $Price | html %] + [% order.replacementprice | $Price | html %] [% order.quantity | html %] [% order.total_tax_excluded | $Price | html %] [% order.total_tax_included | $Price | html %] @@ -289,6 +291,7 @@ Total (GST [% tf.tax_rate * 100 | html %] %) + [% tf.quantity | html %] [% tf.total_tax_excluded | $Price | html %] [% tf.total_tax_included | $Price | html %] @@ -301,6 +304,7 @@ Total ([% currency.symbol | html %]) + [% total_quantity | html %] [% total_tax_excluded | $Price | html %] [% total_tax_included | $Price | html %] @@ -312,6 +316,7 @@ Total + Adjustments + Shipment cost ([% currency.symbol | html %]) + [% total_quantity | html %] [% total_tax_excluded_shipment + total_adj | $Price | html %] [% total_tax_included_shipment | $Price | html %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt index cd90a0e..007df0a 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt @@ -434,14 +434,18 @@
  • [% IF ( close ) %] - Replacement cost: + Retail price: [% rrp | html %] (adjusted for [% cur_active | html %], [% IF (listincgst == 1) %]tax inc.[% ELSE %]tax exc.[% END %]) [% ELSE %] - + (adjusted for [% cur_active | html %], [% IF (listincgst == 1) %]tax inc.[% ELSE %]tax exc.[% END %]) [% END %]
  • + + +
  • +
  • [% IF (listincgst == 1) %](tax inc.)[% ELSE %](tax exc.)[% END %]
  • diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt index 6fc9291..1814aab 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt @@ -240,7 +240,11 @@ [% END %] -
  • [% rrp | $Price | html %]
  • +
  • [% rrp | $Price | html %]
  • +
  • + + +
  • [% ecost | $Price | html %]
  • diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt index a2ac542..d37a041 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt @@ -103,6 +103,7 @@ Order line search Summary search   + Replacement price search Quantity search Unit cost search Order cost search @@ -116,6 +117,7 @@ Order line Summary More + Replacement price Quantity Unit cost Order cost @@ -168,6 +170,7 @@ MARC
    Card + [% loop_order.replacementprice | $Price | html %] [% loop_order.quantity | html %] [% loop_order.ecost | $Price | html %] [% loop_order.total | $Price | html %] @@ -228,6 +231,7 @@ Holds Summary More + Replacement price Quantity Fund Est cost @@ -319,6 +323,7 @@ MARC
    Card + [% order.replacementprice | $Price | html %] [% order.quantityreceived | html %] [% order.budget.budget_name | html %] [% order.ecost | $Price | html %] @@ -443,90 +448,92 @@ var sticky_filters = [% sticky_filters | html %]; $(document).ready(function(){ - if ( $("#pendingt").length ) { - var pendingt = $("#pendingt").dataTable($.extend(true, {}, dataTablesDefaults, { - "bStateSave": true, - "iCookieDuration": 60*60*24*1000, // 1000 days - "iDisplayLength": 10, - "aLengthMenu": [[5, 10, 20, 50, 100, -1], [5, 10, 20, 50, 100, _("All")]], - "aoColumnDefs": [ - { "aTargets": [ 4, 9, 10 ], "bSortable": false, "bSearchable": false }, - ], - "aoColumns": [ - { "sType": "html" }, - { "sType": "html" }, - { "sType": "num-html" }, - { "sType": "anti-the" }, - null, - null, - null, - null, - null, - null, - null, - ], - 'bAutoWidth': false, - "sPaginationType": "four_button" - }) - ).columnFilter({ - sPlaceHolder: "head:after", - aoColumns: [ - { type: "text" }, - { type: "text" }, - { type: "text" }, - { type: "text" }, - null, - { type: "text" }, - { type: "text" }, - { type: "text" }, - { type: "text" }, - null, - null - ] - }); - } + if ( $("#pendingt").length ) { + var pendingt = $("#pendingt").dataTable($.extend(true, {}, dataTablesDefaults, { + "bStateSave": true, + "iCookieDuration": 60*60*24*1000, // 1000 days + "iDisplayLength": 10, + "aLengthMenu": [[5, 10, 20, 50, 100, -1], [5, 10, 20, 50, 100, _("All")]], + "aoColumnDefs": [ + { "aTargets": [ 4, 9, 10 ], "bSortable": false, "bSearchable": false }, + ], + "aoColumns": [ + { "sType": "html" }, + { "sType": "html" }, + { "sType": "num-html" }, + { "sType": "anti-the" }, + null, + null, + null, + null, + null, + null, + null, + null, + ], + 'bAutoWidth': false, + "sPaginationType": "four_button" + } ) + ).columnFilter({ + sPlaceHolder: "head:after", + aoColumns: [ + { type: "text" }, + { type: "text" }, + { type: "text" }, + { type: "text" }, + null, + { type: "text" }, + { type: "text" }, + { type: "text" }, + { type: "text" }, + { type: "text" }, + null, + null + ] + }); + } + + if ( $("#receivedt").length ) { + var receivedt = $("#receivedt").dataTable($.extend(true, {}, dataTablesDefaults, { + "bStateSave": true, + "iCookieDuration": 60*60*24*1000, // 1000 days + "iDisplayLength": 10, + "aLengthMenu": [[5, 10, 20, 50, 100, -1], [5, 10, 20, 50, 100, _("All")]], + "aoColumnDefs": [ + { "aTargets": [ 5, -1 ], "bSortable": false, "bSearchable": false }, + ], + "aoColumns": [ + { "sType": "html" }, + { "sType": "html" }, + { "sType": "html" }, + { "sType": "num-html" }, + { "sType": "anti-the" }, + null, + null, + null, + null, + null, + null, + null + ], + "sPaginationType": "four_button" + })); + } - if ( $("#receivedt").length ) { - var receivedt = $("#receivedt").dataTable($.extend(true, {}, dataTablesDefaults, { - "bStateSave": true, - "iCookieDuration": 60*60*24*1000, // 1000 days - "iDisplayLength": 10, - "aLengthMenu": [[5, 10, 20, 50, 100, -1], [5, 10, 20, 50, 100, _("All")]], - "aoColumnDefs": [ - { "aTargets": [ 5, -1 ], "bSortable": false, "bSearchable": false }, - ], - "aoColumns": [ - { "sType": "html" }, - { "sType": "html" }, - { "sType": "html" }, - { "sType": "num-html" }, - { "sType": "anti-the" }, - null, - null, - null, - null, - null, - null, - null - ], - "sPaginationType": "four_button" - })); - } + // Keep filters from finishreceive.pl to parcel.pl + $.cookie("filter_parcel_summary", $("#summaryfilter").val()); + $.cookie("filter_parcel_basketname", $("#basketfilter").val()); + $.cookie("filter_parcel_orderno", $("#orderfilter").val()); + $.cookie("filter_parcel_basketgroupname", $("#basketgroupnamefilter").val()); + $.cookie("filter_parcel_ean", $("#eanfilter").val()); - // Keep filters from finishreceive.pl to parcel.pl + $("#filterform").on('submit', function(){ $.cookie("filter_parcel_summary", $("#summaryfilter").val()); $.cookie("filter_parcel_basketname", $("#basketfilter").val()); $.cookie("filter_parcel_orderno", $("#orderfilter").val()); $.cookie("filter_parcel_basketgroupname", $("#basketgroupnamefilter").val()); $.cookie("filter_parcel_ean", $("#eanfilter").val()); - - $("#filterform").on('submit', function(){ - $.cookie("filter_parcel_summary", $("#summaryfilter").val()); - $.cookie("filter_parcel_basketname", $("#basketfilter").val()); - $.cookie("filter_parcel_orderno", $("#orderfilter").val()); - $.cookie("filter_parcel_basketgroupname", $("#basketgroupnamefilter").val()); - $.cookie("filter_parcel_ean", $("#eanfilter").val()); - }); + }); $(".previewData").on("click", function(e){ e.preventDefault(); @@ -543,21 +550,21 @@ }); - // Case-insensitive version of jquery's contains function - jQuery.extend(jQuery.expr[':'], { - icontains : "jQuery(a).text().toUpperCase().indexOf(m[3].toUpperCase())>=0" - }); + // Case-insensitive version of jquery's contains function + jQuery.extend(jQuery.expr[':'], { + icontains : "jQuery(a).text().toUpperCase().indexOf(m[3].toUpperCase())>=0" + }); // Contains exactly function - jQuery.extend(jQuery.expr[':'], { - containsExactly: "$(a).text() == m[3]" - }); + jQuery.extend(jQuery.expr[':'], { + containsExactly: "$(a).text() == m[3]" + }); - function transfer_order_popup(ordernumber) { + function transfer_order_popup(ordernumber) { var url = "/cgi-bin/koha/acqui/transferorder.pl?" + "ordernumber=" + ordernumber window.open(url, 'TransferOrder'); - } + } [% END %] -- 2.1.4