Bug 22393: (follow-up) Corrections for QA feedback
authorMartin Renvoize <martin.renvoize@ptfs-europe.com>
Tue, 21 Apr 2020 14:54:45 +0000 (15:54 +0100)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Tue, 18 Aug 2020 15:39:48 +0000 (17:39 +0200)
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 <victor@tuxayo.net>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

koha-tmpl/intranet-tmpl/prog/en/modules/members/maninvoice.tt
members/maninvoice.pl

index dfbc5e2..028bbf1 100644 (file)
                 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()]);
index 3b4736d..c6c28ee 100755 (executable)
@@ -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
                 }
             );