Bug 22541: Invoice adjustments should show invoice number and include link on ordered...
authorNick Clemens <nick@bywatersolutions.com>
Mon, 25 Mar 2019 12:55:03 +0000 (12:55 +0000)
committerNick Clemens <nick@bywatersolutions.com>
Thu, 11 Apr 2019 11:45:24 +0000 (11:45 +0000)
To test:
 1 - Find a vendor in acquisitions
 2 - Click 'receive shipment'
 3 - Create an invoice
 4 - Click 'Finish receiving'
 5 - Add an adjustment that encumbers while open and update adjustments
 6 - Go to acqui-home and click on the ordered total for the fund with the adjustment
 7 - Note the invoice adjustment shows the invoice id and does not link
 8 - Add another invoice and another adjustment, but close the invoice this time
 9 - Go to acqui-home and click on the spent total for the fund with the adjustment
10 - Note the invoice adjustment shows the invoice id and does not link
11 - Apply patch
12 - Visit the spent and ordered pages and note the adjustments show invoicenumber and are links
13 - prove -v t/db_dependent/Koha/Acquisition/Invoice/Adjustments.t

Signed-off-by: Liz Rea <wizzyrea@gmail.com>

Signed-off-by: Liz Rea <wizzyrea@gmail.com>

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

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

C4/Acquisition.pm
Koha/Acquisition/Invoice/Adjustment.pm
acqui/ordered.pl
acqui/spent.pl
koha-tmpl/intranet-tmpl/prog/en/modules/acqui/ordered.tt
koha-tmpl/intranet-tmpl/prog/en/modules/acqui/spent.tt
t/db_dependent/Koha/Acquisition/Invoice/Adjustments.t

index de85953..6a8df02 100644 (file)
@@ -1893,7 +1893,6 @@ cancelled.
 
 sub DelOrder {
     my ( $bibnum, $ordernumber, $delete_biblio, $reason ) = @_;
-
     my $error;
     my $dbh = C4::Context->dbh;
     my $query = "
index e3d0bc2..4d87a94 100644 (file)
@@ -20,6 +20,7 @@ use Modern::Perl;
 use Carp;
 
 use Koha::Database;
+use Koha::Acquisition::Invoice;
 
 use base qw(Koha::Object);
 
@@ -33,6 +34,20 @@ Koha::Acquisition::Invoice::Adjustment - Koha Invoice Adjustment class
 
 =cut
 
+=head3 invoice
+
+my $invoice = $adjustment->invoice;
+
+Return the invoice for this adjustment
+
+=cut
+
+sub invoice {
+    my ( $self ) = @_;
+    my $invoice_rs = $self->_result->invoiceid;
+    return Koha::Acquisition::Invoice->_new_from_dbic( $invoice_rs );
+}
+
 =head3 type
 
 =cut
index 09fd607..ebf89e8 100755 (executable)
@@ -107,7 +107,7 @@ while ( my $data = $sth->fetchrow_hashref ) {
     }
 }
 
-my $adjustments = Koha::Acquisition::Invoice::Adjustments->search({budget_id => $fund_id, closedate => undef, encumber_open => 1 }, { join => 'invoiceid' } );
+my $adjustments = Koha::Acquisition::Invoice::Adjustments->search({budget_id => $fund_id, closedate => undef, encumber_open => 1 }, { prefetch => 'invoiceid' } );
 while ( my $adj = $adjustments->next ){
     $total += $adj->adjustment;
 }
index 75b495b..20d2b13 100755 (executable)
@@ -135,7 +135,7 @@ while (my $data = $sth->fetchrow_hashref) {
 }
 $sth->finish;
 
-my $adjustments = Koha::Acquisition::Invoice::Adjustments->search({budget_id => $bookfund, closedate => { '!=' => undef } }, { join => 'invoiceid' } );
+my $adjustments = Koha::Acquisition::Invoice::Adjustments->search({budget_id => $bookfund, closedate => { '!=' => undef } }, { prefetch => 'invoiceid' },  );
 while ( my $adj = $adjustments->next ){
     $total += $adj->adjustment;
 }
index 6e20dfb..5685d7e 100644 (file)
             [% FOREACH adjustment IN adjustments %]
                 <tr>
                     <td></td>
-                    <td colspan="6">Adjustment cost for invoice [% adjustment.invoiceid | html %]</td>
+                    <td colspan="6">Adjustment cost for invoice
+                        <a href="/cgi-bin/koha/acqui/invoice.pl?invoiceid=[% adjustment.invoiceid | uri %]">
+                            [% adjustment.invoice.invoicenumber | html %]
+                        </a>
+                    </td>
                     <td class="data total">[% adjustment.adjustment | $Price %]</td>
                 </tr>
             [% END %]
index 78cf32e..2e5ca3f 100644 (file)
             [% FOREACH shipmentcost IN shipmentcosts %]
                 <tr>
                     <td></td>
-                    <td colspan="8">Shipping cost for invoice [% shipmentcost.invoicenumber | html %]</td>
+                    <td colspan="8">Shipping cost for invoice
+                        <a href="/cgi-bin/koha/acqui/invoice.pl?invoiceid=[% shipmentcode.invoiceid | uri %]">
+                             [% shipmentcost.invoicenumber | html %]
+                        </a>
+                    </td>
                     <td class="data total">[% shipmentcost.shipmentcost | $Price %]</td>
                 </tr>
             [% END %]
             [% FOREACH adjustment IN adjustments %]
                 <tr>
                     <td></td>
-                    <td colspan="8">Adjustment cost for invoice [% adjustment.invoiceid | html %]</td>
+                    <td colspan="8">Adjustment cost for invoice
+                        <a href="/cgi-bin/koha/acqui/invoice.pl?invoiceid=[% adjustment.invoiceid | uri %]">
+                            [% adjustment.invoice.invoicenumber | html %]
+                        </a>
+                    </td>
                     <td class="data total">[% adjustment.adjustment | $Price %]</td>
                 </tr>
             [% END %]
index 4c970e2..d5e2309 100644 (file)
@@ -19,7 +19,7 @@
 
 use Modern::Perl;
 
-use Test::More tests => 6;
+use Test::More tests => 7;
 
 use Koha::Database;
 
@@ -64,4 +64,12 @@ is( $retrieved_adj->reason, $new_adj->reason, 'Find an adjustment by id should r
 $retrieved_adj->delete;
 is( Koha::Acquisition::Invoice::Adjustments->search->count, $nb_of_adjs + 1, 'Delete should have deleted the adjustment' );
 
+subtest 'invoice' => sub {
+    plan tests => 2;
+
+    my $invoice = $retrieved_adj->invoice;
+    is( ref( $invoice ), 'Koha::Acquisition::Invoice', 'Koha::Acquisition::Invoice::Adjustment->invoice should return a Koha::Acquisition::Invoice' );
+    is( $invoice->invoiceid, $retrieved_adj->invoiceid, 'Koha::Acquisition::Invoice::Adjustment->invoice should return the correct invoice' );
+};
+
 $schema->storage->txn_rollback;