From 22719051f0ab477655e2a6f9bdf9652656c8a53d Mon Sep 17 00:00:00 2001 From: Alex Buckley Date: Mon, 12 Aug 2019 11:00:03 +1200 Subject: [PATCH] Bug 23450: Display subscription and issue cost in subscription interface of the catalouge/detail.pl Displays the serial issue price (from 952$g), and subscription cost (calculated from the Acquisition order the subscription is linked to). Test plan: 1. Create a subscription (making sure to select 'Create an item record when receiving this serial') and then go to Acquisitions module and create the following if they don't already exist: * Currency * Budget * Fund * Vendor * Basket 2. Add to the basket: Add to basket > From a subscription 3. Search for and select the subscription made in step #1 4. Set quantity, vendor price, and replacement price and 'Save' 5. Search for the serial biblio and view its catalogue/detail.pl page Click on the 'Subscriptions' tab and notice there is no 'Total cost of the subscription' text And no 'Issue price' and 'Subscription cost' columns in the issue table in the subscription tab which is currently empty 6. Select the 'Subscription details' link and select 'Receive' changing the status from 'Expected' to 'Arrived' 7. Repeat step 5 and notice the issues table in the Subscriptions tab still does not have 'Issue price' or 'Subscription cost' columns 8. Apply patches on bug 23352 and 23450 9. Update your database and restart memcached and plack 10. Refresh the catalogue/detail.pl page you were on in step 7 and notice the following has been added: Total cost of the subscription is: Issue price and Subscription cost columns in the issue table in the subscription tab. Sponsored-By: Brimbank Library, Australia --- C4/Serials.pm | 4 +++- catalogue/detail.pl | 20 ++++++++++++++++++++ .../prog/en/modules/catalogue/detail.tt | 6 ++++++ 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/C4/Serials.pm b/C4/Serials.pm index ae1e8fc140..84e82d76fa 100644 --- a/C4/Serials.pm +++ b/C4/Serials.pm @@ -772,8 +772,10 @@ sub GetLatestSerials { my $dbh = C4::Context->dbh; my $statuses = join( ',', ( ARRIVED, MISSING_STATUSES ) ); - my $strsth = "SELECT serialid,serialseq, status, planneddate, publisheddate, notes + my $strsth = "SELECT serial.serialid,serialseq, status, planneddate, publisheddate, notes, price FROM serial + INNER JOIN serialitems ON (serial.serialid=serialitems.serialid) + INNER JOIN items ON (serialitems.itemnumber=items.itemnumber) WHERE subscriptionid = ? AND status IN ($statuses) ORDER BY publisheddate DESC LIMIT 0,$limit diff --git a/catalogue/detail.pl b/catalogue/detail.pl index 85782ecc71..b4fa18bd05 100755 --- a/catalogue/detail.pl +++ b/catalogue/detail.pl @@ -37,6 +37,7 @@ use C4::Search; # enabled_staff_search_views use C4::Tags qw(get_tags); use C4::XSLT; use C4::Images; +use C4::Acquisition; use Koha::DateUtils; use C4::HTML5Media; use C4::CourseReserves qw(GetItemCourseReservesInfo); @@ -210,6 +211,16 @@ my @subscriptions = SearchSubscriptions({ biblionumber => $biblionumber, o my @subs; foreach my $subscription (@subscriptions) { + + #Get the order associated with this subscription to calculate and display subscription cost + my $lastOrder; + if ( subscriptionCurrentlyOnOrder $subscription->{subscriptionid} ) { + $lastOrder = GetLastOrderNotReceivedFromSubscriptionid( $subscription->{subscriptionid} ); + } else { + $lastOrder = GetLastOrderReceivedFromSubscriptionid( $subscription->{subscriptionid} ); + } + my $subscriptioncost = sprintf( "%.2f", ($lastOrder->{ecost} || 0) * ($lastOrder->{quantity} || 0) ); + my %cell; my $serials_to_display; $cell{subscriptionid} = $subscription->{subscriptionid}; @@ -221,12 +232,21 @@ foreach my $subscription (@subscriptions) { $cell{callnumber} = $subscription->{callnumber}; $cell{location} = $subscription->{location}; $cell{closed} = $subscription->{closed}; + $cell{subscriptioncost} = $subscriptioncost; #get the three latest serials. $serials_to_display = $subscription->{staffdisplaycount}; $serials_to_display = C4::Context->preference('StaffSerialIssueDisplayCount') unless $serials_to_display; $cell{staffdisplaycount} = $serials_to_display; $cell{latestserials} = GetLatestSerials( $subscription->{subscriptionid}, $serials_to_display ); + + #Add the subscription cost to each of the latest serials for display + my $i = 0; + while ( $cell{latestserials}[$i] ) { + $cell{latestserials}[$i]{total} = $subscriptioncost; + $i++; + } + push @subs, \%cell; } diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt index 6ef518489b..db50b9c1ec 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt @@ -6,6 +6,7 @@ [% USE Branches %] [% USE Biblio %] [% USE ColumnsSettings %] +[% USE Price %] [% SET AdlibrisEnabled = Koha.Preference('AdlibrisCoversEnabled') %] [% SET AdlibrisURL = Koha.Preference('AdlibrisCoversURL') %] @@ -567,6 +568,7 @@ Note that permanent location is a code, and location may be an authval. [% IF ( subscription.subscriptionnotes ) %]

[% subscription.subscriptionnotes | html | html_line_break %]

[% END %] [% IF ( subscription.missinglist ) %]

Missing issues: [% subscription.missinglist | html %]

[% END %] [% IF ( subscription.librariannote ) %]

([% subscription.librariannote | html %])

[% END %] + [% IF ( subscription.subscriptioncost ) %]

Total cost of the subscription is: [% subscription.subscriptioncost | $Price %]

[% END %] [% IF ( subscription.latestserials ) %]

The [% subscription.staffdisplaycount | html %] latest issues related to this subscription:

@@ -575,6 +577,8 @@ Note that permanent location is a code, and location may be an authval. + + [% FOREACH latestserial IN subscription.latestserials %] @@ -596,6 +600,8 @@ Note that permanent location is a code, and location may be an authval. [% IF ( latestserial.status7 ) %]Claimed[% END %] [% IF ( latestserial.status8 ) %]Stopped[% END %] + + [% END %] -- 2.11.0
Date arrived Date published StatusIssue priceSubscription cost Note
[% latestserial.price | $Price %][% latestserial.total | $Price %] [% latestserial.notes | html %]