This patch adds a handy accessor for a basket's orders. It can be used
to embed orders on an API call or be used in controller scripts to
replace C4::* methods.
To test:
1. Apply this patches
2. Run:
$ kshell
k$ prove t/db_dependent/Koha/Acquisition/Basket.t
=> SUCCESS: Tests pass!
3. Sign off :-D
Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
use Koha::Database;
use Koha::DateUtils qw( dt_from_string );
use Koha::Acquisition::BasketGroups;
use Koha::Database;
use Koha::DateUtils qw( dt_from_string );
use Koha::Acquisition::BasketGroups;
+use Koha::Acquisition::Orders;
use Koha::Patrons;
use base qw( Koha::Object Koha::Object::Mixin::AdditionalFields );
use Koha::Patrons;
use base qw( Koha::Object Koha::Object::Mixin::AdditionalFields );
return Koha::Acquisition::BasketGroup->_new_from_dbic( $basket_group_rs );
}
return Koha::Acquisition::BasketGroup->_new_from_dbic( $basket_group_rs );
}
+=head3 orders
+
+ my $orders = $basket->orders;
+
+Returns a Koha::Acquisition::Orders resultset, with the orders linked
+to this basket.
+
+=cut
+
+sub orders {
+ my ($self) = @_;
+
+ my $orders_rs = $self->_result->orders;
+ return Koha::Acquisition::Orders->_new_from_dbic( $orders_rs );
+}
+
=head3 effective_create_items
Returns C<create_items> for this basket, falling back to C<AcqCreateItem> if unset.
=head3 effective_create_items
Returns C<create_items> for this basket, falling back to C<AcqCreateItem> if unset.
+__PACKAGE__->has_many(
+ "orders",
+ "Koha::Schema::Result::Aqorder",
+ { "foreign.basketno" => "self.basketno" },
+ { cascade_copy => 0, cascade_delete => 0 },
+);
+
sub koha_object_class {
'Koha::Acquisition::Basket';
}
sub koha_object_class {
'Koha::Acquisition::Basket';
}