sub DelOrder {
my ( $bibnum, $ordernumber, $delete_biblio, $reason ) = @_;
-
my $error;
my $dbh = C4::Context->dbh;
my $query = "
use Carp;
use Koha::Database;
+use Koha::Acquisition::Invoice;
use base qw(Koha::Object);
=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
}
}
-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;
}
}
$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;
}
[% 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 %]
[% 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 %]
use Modern::Perl;
-use Test::More tests => 6;
+use Test::More tests => 7;
use Koha::Database;
$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;