Bug 24157: Add new method Acq::Invoice::Adjustement->fund
Moving to its own commit in case we want to cherry-pick or move it to its own bug report. Sponsored-by: Galway-Mayo Institute of Technology Signed-off-by: Owen Leonard <oleonard@myacpl.org> Signed-off-by: Alex Arnaud <alex.arnaud@biblibre.com> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
parent
d3c8b8fe54
commit
41c6940fcd
|
|
@ -20,7 +20,8 @@ use Modern::Perl;
|
|||
use Carp;
|
||||
|
||||
use Koha::Database;
|
||||
use Koha::Acquisition::Invoice;
|
||||
use Koha::Acquisition::Invoices;
|
||||
use Koha::Acquisition::Funds;
|
||||
|
||||
use base qw(Koha::Object);
|
||||
|
||||
|
|
@ -48,6 +49,21 @@ sub invoice {
|
|||
return Koha::Acquisition::Invoice->_new_from_dbic( $invoice_rs );
|
||||
}
|
||||
|
||||
=head3 fund
|
||||
|
||||
my $fund = $adjustment->fund;
|
||||
|
||||
Return the fund for this adjustment
|
||||
|
||||
=cut
|
||||
|
||||
sub fund {
|
||||
my ( $self ) = @_;
|
||||
my $fund_rs = $self->_result->budget;
|
||||
return unless $fund_rs;
|
||||
return Koha::Acquisition::Fund->_new_from_dbic( $fund_rs );
|
||||
}
|
||||
|
||||
=head3 type
|
||||
|
||||
=cut
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
use Modern::Perl;
|
||||
|
||||
use Test::More tests => 7;
|
||||
use Test::More tests => 8;
|
||||
|
||||
use Koha::Database;
|
||||
|
||||
|
|
@ -72,4 +72,12 @@ subtest 'invoice' => sub {
|
|||
is( $invoice->invoiceid, $retrieved_adj->invoiceid, 'Koha::Acquisition::Invoice::Adjustment->invoice should return the correct invoice' );
|
||||
};
|
||||
|
||||
subtest 'fund' => sub {
|
||||
plan tests => 2;
|
||||
|
||||
my $fund = $retrieved_adj->fund;
|
||||
is( ref( $fund ), 'Koha::Acquisition::Fund', 'Koha::Acquisition::Invoice::Adjustment->fund should return a Koha::Acquisition::Fund' );
|
||||
is( $fund->budget_id, $retrieved_adj->budget_id, 'Koha::Acquisition::Invoice::Adjustment->fund should return the correct fund ' );
|
||||
};
|
||||
|
||||
$schema->storage->txn_rollback;
|
||||
|
|
|
|||
Loading…
Reference in New Issue