From 484061a44e068a5a130941ac28d8a187cb238ad3 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Tue, 21 Apr 2020 15:54:45 +0100 Subject: [PATCH] Bug 22393: (follow-up) Corrections for QA feedback We correct the behviour of 'amount' being passed back to the template and add a work around for the existance of deleted_items alongside a FK to items in the accountlines table. Signed-off-by: Victor Grousset/tuxayo Signed-off-by: Katrin Fischer Signed-off-by: Jonathan Druart --- .../prog/en/modules/members/maninvoice.tt | 2 ++ members/maninvoice.pl | 11 +++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/maninvoice.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/maninvoice.tt index dfbc5e2338..028bbf1ed6 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/maninvoice.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/maninvoice.tt @@ -104,8 +104,10 @@ this.form.desc.value = this.options[this.selectedIndex].value; this.form.amount.value = type_fees[this.options[this.selectedIndex].value]; }); + [% UNLESS amount.defined %] $("#maninvoice #desc").val($("#maninvoice #type option:selected").text()); $("#maninvoice #amount").val(type_fees[$("#maninvoice #type option:selected").val()]); + [% END %] $("#maninvoice #type").change(function(){ $("#maninvoice #desc").val($(this).find("option:selected").text()); $("#maninvoice #amount").val(type_fees[$(this).val()]); diff --git a/members/maninvoice.pl b/members/maninvoice.pl index 3b4736d8d3..c6c28ee9b4 100755 --- a/members/maninvoice.pl +++ b/members/maninvoice.pl @@ -109,6 +109,7 @@ if ($add) { # If barcode is passed, attempt to find the associated item my $failed; my $item_id; + my $olditem; # FIXME: When items and deleted_items are merged, we can remove this my $issue_id; if ($barcode) { my $item = Koha::Items->find( { barcode => $barcode } ); @@ -116,9 +117,11 @@ if ($add) { $item_id = $item->itemnumber; } else { - $item = Koha::Old::Items->find( { barcode => $barcode } ); - if ($item) { - $item_id = $item->itemnumber; + $item = Koha::Old::Items->search( { barcode => $barcode }, + { order_by => { -desc => 'timestamp' }, rows => 1 } ); + if ($item->count) { + $item_id = $item->next->itemnumber; + $olditem = 1; } else { $template->param( error => 'itemnumber' ); @@ -158,7 +161,7 @@ if ($add) { interface => 'intranet', library_id => $library_id, type => $debit_type, - item_id => $item_id, + ( $olditem ? () : ( item_id => $item_id ) ), issue_id => $issue_id } ); -- 2.39.5