From 82f80bf8b9214d7e24bbda682c4310f050016ae3 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 | 5 +++++ 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/C4/Serials.pm b/C4/Serials.pm index 3cf09cd..bbf4b3b 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 b4d9bae..99985a9 100755 --- a/catalogue/detail.pl +++ b/catalogue/detail.pl @@ -36,6 +36,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); @@ -172,6 +173,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}; @@ -183,12 +194,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 3819628..367d952 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt @@ -505,6 +505,7 @@ [% 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 | html %]

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

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

@@ -513,6 +514,8 @@ + + [% FOREACH latestserial IN subscription.latestserials %] @@ -534,6 +537,8 @@ [% IF ( latestserial.status7 ) %]Claimed[% END %] [% IF ( latestserial.status8 ) %]Stopped[% END %] + + [% END %] -- 2.1.4
Date arrived Date published StatusIssue priceSubscription cost Note
[% latestserial.price | html %][% latestserial.total | html %] [% latestserial.notes | html %]