Bug 7288: (follow-up) set a boolean if the invoice if linked to subscriptions
authorJonathan Druart <jonathan.druart@biblibre.com>
Tue, 11 Mar 2014 10:17:18 +0000 (11:17 +0100)
committerGalen Charlton <gmc@esilibrary.com>
Mon, 21 Apr 2014 05:02:48 +0000 (05:02 +0000)
If an invoice is linked to subscription, we need to set a boolean to
true in order to filter them in the interface.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
C4/Acquisition.pm
koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoices.tt
t/db_dependent/Acquisition/Invoices.t

index c7d0951..a597937 100644 (file)
@@ -2587,6 +2587,13 @@ sub GetInvoices {
               NULL
             )
           ) AS receivedbiblios,
+          COUNT(
+             DISTINCT IF(
+              aqorders.subscriptionid IS NOT NULL,
+              aqorders.subscriptionid,
+              NULL
+            )
+          ) AS is_linked_to_subscriptions,
           SUM(aqorders.quantityreceived) AS receiveditems
         FROM aqinvoices
           LEFT JOIN aqbooksellers ON aqbooksellers.id = aqinvoices.booksellerid
index 21625a5..8f0c21d 100644 (file)
@@ -12,7 +12,6 @@ $(document).ready(function() {
     var resultst = $("#resultst").dataTable($.extend(true, {}, dataTablesDefaults, {
         sDom: "t",
         bPaginate: false,
-        bFilter: false,
         bInfo: false,
         "aoColumns": [
             null,null,null,{ "sType": "title-string" },null,null,null,null
@@ -27,7 +26,7 @@ $(document).ready(function() {
 
     $("#show_only_subscription").click(function(){
         if ( $(this).attr("checked") ) {
-            resultst.fnFilter( "[0-9]+", 0, true );
+            resultst.fnFilter( "1", 0, true );
         } else {
             resultst.fnFilter( '', 0 );
         }
@@ -121,7 +120,7 @@ $(document).ready(function() {
             <tbody>
               [% FOREACH invoice IN invoices %]
                 <tr data-invoiceid="[% invoice.invoiceid %]" data-booksellerid="[% invoice.booksellerid %]" data-shipmentdate="[% invoice.shipmentdate | $KohaDates %]" data-billingdate="[% invoice.billingdate | $KohaDates %]" data-shipmentcost="[% invoice.shipmentcost %]" data-shipment_budgetid="[% invoice.shipmentcost_budgetid %]" data-closedate="[% invoice.closedate | $KohaDates %]">
-                  <td>[% invoice.subscriptionid %]</td>
+                  <td>[% invoice.is_linked_to_subscriptions %]</td>
                   <td><input type="checkbox" class="select-invoice" value="[% invoice.invoiceid %]"></input></td>
                   <td><a href="/cgi-bin/koha/acqui/invoice.pl?invoiceid=[% invoice.invoiceid %]">[% invoice.invoicenumber %]</a></td>
                   <td><a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% invoice.booksellerid %]">[% invoice.suppliername %]</a></td>
index 3b86a54..3862926 100644 (file)
@@ -179,6 +179,13 @@ DelInvoice($invoiceid3);
 is(scalar @invoices, $invoicecount - 1, 'DelInvoice deletes invoice');
 is(GetInvoice($invoiceid3), undef, 'DelInvoice deleted correct invoice');
 
+my @invoices_linked_to_subscriptions = map{
+    $_->{linked_to_subscriptions}
+    ? $_
+    : ()
+} @invoices;
+is_deeply( \@invoices_linked_to_subscriptions, [], "GetInvoices return linked_to_subscriptions: there is no invoices linked to subscriptions yet" )
+
 END {
     $dbh and $dbh->rollback;
 }