Bug 28640: Expose EDI Status on basket details page

This patch adds the edi_order relationship method to
Koha::Acquisition::Basket to return the most recently attached
edi_message of type 'ORDER' for the basket.

NOTE: EDI currently returns raw DBIC results. I have opted to maintain
that approach here, but would like to work on upgradeing the
Koha::EDIFACT::Order class to be a subclass of Koha::Object at a later
date.

We then use this new relationship in acqui/basket to display the EDI
status for such baskets.

Test plan
1/ Setup a vendor with EDI Ordering enabled
2/ Add a new basket for the vendor.
3/ Note the new 'EDI status' field displays and reads 'Not ordered'
4/ Close the basker
5/ The 'EDI status' should continue to display 'Not ordered'
6/ Re-open the basket
7/ Close the basket via 'Create EDIFACT order'
8/ Navigate back to the now closed basket
9/ Note the 'EDI status' field now displays 'Pending' and the transfer
date.
10/ Progress the EDI order by running the edi_cron.pl script
11/ The EDI status field should now reflect that the message has been
sent.

Signed-off-by: Benjamin Veasey <B.T.Veasey@lboro.ac.uk>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Martin Renvoize 2021-06-30 12:37:59 +01:00 committed by Jonathan Druart
parent b17b691e01
commit 33dd62d661
3 changed files with 42 additions and 0 deletions

View file

@ -96,6 +96,30 @@ sub orders {
return Koha::Acquisition::Orders->_new_from_dbic( $orders_rs );
}
=head3 edi_order
my $edi_order = $basket->edi_order;
Returns the most recently attached EDI order object if one exists for the basket.
NOTE: This currently returns a bare DBIx::Class result or undefined. This is consistent with the rest of EDI;
However it would be beneficial to convert these to full fledge Koha::Objects in the future.
=cut
sub edi_order {
my ($self) = @_;
my $order_rs = $self->_result->edifact_messages(
{
message_type => 'ORDERS',
deleted => 0
},
{ order_by => { '-desc' => 'transfer_date' }, rows => 1 }
);
return $order_rs->single;
}
=head3 effective_create_items
Returns C<create_items> for this basket, falling back to C<AcqCreateItem> if unset.

View file

@ -377,6 +377,9 @@ if ( $op eq 'list' ) {
last;
}
my $basket_obj = Koha::Acquisition::Baskets->find($basketno);
my $edi_order = $basket_obj->edi_order;
$template->param(
basketno => $basketno,
basket => $basket,
@ -388,6 +391,7 @@ if ( $op eq 'list' ) {
basketcontractname => $contract->{contractname},
branches_loop => \@branches_loop,
creationdate => $basket->{creationdate},
edi_order => $edi_order,
authorisedby => $basket->{authorisedby},
authorisedbyname => $basket->{authorisedbyname},
users_ids => join(':', @basketusers_ids),

View file

@ -314,6 +314,20 @@
[% IF ( closedate ) %]
<li><span class="label">Closed on:</span> [% closedate | $KohaDates %]</li>
[% END %]
[% IF ( ediaccount ) %]
[%- BLOCK edi_status -%]
[%- SWITCH edi_order.status -%]
[%- CASE 'Pending' -%]Pending
[%- CASE 'Sent' -%]Sent
[%- CASE 'Processed' -%]Processed
[%- END -%]
[%- END -%]
[% IF ( edi_order ) %]
<li><span class="label">EDI status:</span> [%- PROCESS edi_status edi_order=edi_order -%] ([% edi_order.transfer_date | $KohaDates %])</li>
[% ELSE %]
<li><span class="label">EDI status:</span> Not ordered</li>
[% END %]
[% END %]
[% IF ( estimateddeliverydate ) %]
<li><span class="label">Estimated delivery date:</span> [% estimateddeliverydate | $KohaDates %]</li>
[% END %]