[Koha-patches] [PATCH] Bug 14803: Reload checkouts table on renewal

Srdjan srdjan at catalyst.net.nz
Fri Jun 10 02:59:31 CEST 2016


svc/checkouts: get real rental charges for patron, rather than itemtype
indication
---
 koha-tmpl/intranet-tmpl/prog/js/checkouts.js |  2 ++
 svc/checkouts                                | 14 ++++++++++----
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/koha-tmpl/intranet-tmpl/prog/js/checkouts.js b/koha-tmpl/intranet-tmpl/prog/js/checkouts.js
index bf419d7..9643d0e 100644
--- a/koha-tmpl/intranet-tmpl/prog/js/checkouts.js
+++ b/koha-tmpl/intranet-tmpl/prog/js/checkouts.js
@@ -2,6 +2,7 @@ $(document).ready(function() {
     $.ajaxSetup ({ cache: false });
 
     var barcodefield = $("#barcode");
+    var issuesTable;
 
     // Handle the select all/none links for checkouts table columns
     $("#CheckAllRenewals").on("click",function(){
@@ -96,6 +97,7 @@ $(document).ready(function() {
 
                 var content = "";
                 if ( data.renew_okay ) {
+                    issuesTable.api().ajax.reload();
                     content = CIRCULATION_RENEWED_DUE + " " + data.date_due;
                     $('#date_due_' + data.itemnumber).replaceWith( data.date_due );
                 } else {
diff --git a/svc/checkouts b/svc/checkouts
index e613126..5cabdee 100755
--- a/svc/checkouts
+++ b/svc/checkouts
@@ -63,7 +63,7 @@ binmode STDOUT, ":encoding(UTF-8)";
 print $input->header( -type => 'text/plain', -charset => 'UTF-8' );
 
 my @parameters;
-my $sql = '
+my $sql = <<EOQ;
     SELECT
         issuedate,
         date_due,
@@ -98,6 +98,8 @@ my $sql = '
         damaged,
         location,
 
+        acc.amountoutstanding,
+
         DATEDIFF( issuedate, CURRENT_DATE() ) AS not_issued_today
     FROM issues
         LEFT JOIN items USING ( itemnumber )
@@ -105,8 +107,13 @@ my $sql = '
         LEFT JOIN biblioitems USING ( biblionumber )
         LEFT JOIN borrowers USING ( borrowernumber )
         LEFT JOIN branches ON ( issues.branchcode = branches.branchcode )
+        LEFT OUTER JOIN (
+            SELECT borrowernumber, itemnumber, SUM(amountoutstanding) AS amountoutstanding
+            FROM accountlines WHERE accounttype = 'Rent'
+            GROUP BY borrowernumber, itemnumber
+        ) acc USING ( borrowernumber, itemnumber )
     WHERE borrowernumber
-';
+EOQ
 
 if ( @borrowernumber == 1 ) {
     $sql .= '= ?';
@@ -127,7 +134,6 @@ my $item_level_itypes = C4::Context->preference('item-level_itypes');
 my @checkouts_today;
 my @checkouts_previous;
 while ( my $c = $sth->fetchrow_hashref() ) {
-    my ($charge) = GetIssuingCharges( $c->{itemnumber}, $c->{borrowernumber} );
     my $fine = GetFine( $c->{itemnumber}, $c->{borrowernumber} );
 
     my ( $can_renew, $can_renew_error ) =
@@ -159,7 +165,7 @@ while ( my $c = $sth->fetchrow_hashref() ) {
         branchcode           => $c->{branchcode},
         branchname           => $c->{branchname},
         itemcallnumber => $c->{itemcallnumber}   || q{},
-        charge         => $charge,
+        charge         => $c->{amountoutstanding} || 0.00,
         fine           => $fine,
         price          => $c->{replacementprice} || q{},
         can_renew      => $can_renew,
-- 
2.7.4


More information about the Koha-patches mailing list