Bug 22809: Move "INVOICE" from template to a slip
authorKyle M Hall <kyle@bywatersolutions.com>
Tue, 30 Apr 2019 11:53:50 +0000 (07:53 -0400)
committerNick Clemens <nick@bywatersolutions.com>
Fri, 10 May 2019 14:39:39 +0000 (14:39 +0000)
Just as bug 22761 moves the "Fee receipt" to the ACCOUNT_CREDIT slip, we need to move the "INVOICE" to an ACCOUNT_DEBIT slip.

Test Plan:
1) Apply this patch set
2) Restart all the things
3) Use the "print" button beside a *fee*
4) You should not see any difference from before the patches were applied

Signed-off-by: Liz Rea <wizzyrea@gmail.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

installer/data/mysql/atomicupdate/bug_22809.perl [new file with mode: 0644]
installer/data/mysql/en/mandatory/sample_notices.sql
koha-tmpl/intranet-tmpl/prog/en/modules/members/printinvoice.tt
members/printinvoice.pl

diff --git a/installer/data/mysql/atomicupdate/bug_22809.perl b/installer/data/mysql/atomicupdate/bug_22809.perl
new file mode 100644 (file)
index 0000000..cbee809
--- /dev/null
@@ -0,0 +1,61 @@
+$DBversion = 'XXX'; # will be replaced by the RM
+if( CheckVersion( $DBversion ) ) {
+    $dbh->do(q{
+INSERT IGNORE INTO `letter` (`module`, `code`, `branchcode`, `name`, `is_html`, `title`, `content`, `message_transport_type`, `lang`) VALUES
+('circulation', 'ACCOUNT_DEBIT', '', 'Account fee', 0, 'Account fee', '<table>
+  [% IF ( LibraryName ) %]
+    <tr>
+      <th colspan="5" class="centerednames">
+        <h3>[% LibraryName | html %]</h3>
+      </th>
+    </tr>
+  [% END %]
+
+  <tr>
+    <th colspan="5" class="centerednames">
+      <h2><u>INVOICE</u></h2>
+    </th>
+  </tr>
+  <tr>
+    <th colspan="5" class="centerednames">
+      <h2>[% Branches.GetName( patron.branchcode ) | html %]</h2>
+    </th>
+  </tr>
+  <tr>
+    <th colspan="5" >
+      Bill to: [% patron.firstname | html %] [% patron.surname | html %] <br />
+      Card number: [% patron.cardnumber | html %]<br />
+    </th>
+  </tr>
+  <tr>
+    <th>Date</th>
+    <th>Description of charges</th>
+    <th>Note</th>
+    <th style="text-align:right;">Amount</th>
+    <th style="text-align:right;">Amount outstanding</th>
+  </tr>
+
+  [% FOREACH account IN accounts %]
+    <tr class="highlight">
+      <td>[% account.date | $KohaDates%]</td>
+      <td>
+        [% PROCESS account_type_description account=account %]
+        [%- IF account.description %], [% account.description | html %][% END %]
+      </td>
+      <td>[% account.note | html %]</td>
+      [% IF ( account.amountcredit ) %]<td class="credit">[% ELSE %]<td class="debit">[% END %][% account.amount | $Price %]</td>
+      [% IF ( account.amountoutstandingcredit ) %]<td class="credit">[% ELSE %]<td class="debit">[% END %][% account.amountoutstanding | $Price %]</td>
+    </tr>
+  [% END %]
+
+  <tfoot>
+    <tr>
+      <td colspan="4">Total outstanding dues as on date: </td>
+      [% IF ( totalcredit ) %]<td class="credit">[% ELSE %]<td class="debit">[% END %][% total | $Price %]</td>
+    </tr>
+  </tfoot>
+</table>', 'print', 'default');
+    });
+    SetVersion( $DBversion );
+    print "Upgrade to $DBversion done (Bug XXXXX - description)\n";
+}
index 80b5fa0..0f38c53 100644 (file)
@@ -233,5 +233,60 @@ INSERT INTO `letter` (`module`, `code`, `branchcode`, `name`, `is_html`, `title`
 </tfoot>
 </table>', 'print', 'default');
 
+INSERT IGNORE INTO `letter` (`module`, `code`, `branchcode`, `name`, `is_html`, `title`, `content`, `message_transport_type`, `lang`) VALUES
+('circulation', 'ACCOUNT_DEBIT', '', 'Account fee', 0, 'Account fee', '<table>
+  [% IF ( LibraryName ) %]
+    <tr>
+      <th colspan="5" class="centerednames">
+        <h3>[% LibraryName | html %]</h3>
+      </th>
+    </tr>
+  [% END %]
+
+  <tr>
+    <th colspan="5" class="centerednames">
+      <h2><u>INVOICE</u></h2>
+    </th>
+  </tr>
+  <tr>
+    <th colspan="5" class="centerednames">
+      <h2>[% Branches.GetName( patron.branchcode ) | html %]</h2>
+    </th>
+  </tr>
+  <tr>
+    <th colspan="5" >
+      Bill to: [% patron.firstname | html %] [% patron.surname | html %] <br />
+      Card number: [% patron.cardnumber | html %]<br />
+    </th>
+  </tr>
+  <tr>
+    <th>Date</th>
+    <th>Description of charges</th>
+    <th>Note</th>
+    <th style="text-align:right;">Amount</th>
+    <th style="text-align:right;">Amount outstanding</th>
+  </tr>
+
+  [% FOREACH account IN accounts %]
+    <tr class="highlight">
+      <td>[% account.date | $KohaDates%]</td>
+      <td>
+        [% PROCESS account_type_description account=account %]
+        [%- IF account.description %], [% account.description | html %][% END %]
+      </td>
+      <td>[% account.note | html %]</td>
+      [% IF ( account.amountcredit ) %]<td class="credit">[% ELSE %]<td class="debit">[% END %][% account.amount | $Price %]</td>
+      [% IF ( account.amountoutstandingcredit ) %]<td class="credit">[% ELSE %]<td class="debit">[% END %][% account.amountoutstanding | $Price %]</td>
+    </tr>
+  [% END %]
+
+  <tfoot>
+    <tr>
+      <td colspan="4">Total outstanding dues as on date: </td>
+      [% IF ( totalcredit ) %]<td class="credit">[% ELSE %]<td class="debit">[% END %][% total | $Price %]</td>
+    </tr>
+  </tfoot>
+</table>', 'print', 'default');
+
 INSERT INTO `letter` (`module`, `code`, `branchcode`, `name`, `is_html`, `title`, `content`, `message_transport_type`) VALUES
 ('circulation', 'SR_SLIP', '', 'Stock rotation slip', 0, 'Stock rotation report', 'Stock rotation report for [% branch.name %]:\r\n\r\n[% IF branch.items.size %][% branch.items.size %] items to be processed for this branch.\r\n[% ELSE %]No items to be processed for this branch\r\n[% END %][% FOREACH item IN branch.items %][% IF item.reason != \'in-demand\' %]Title: [% item.title %]\r\nAuthor: [% item.author %]\r\nCallnumber: [% item.callnumber %]\r\nLocation: [% item.location %]\r\nBarcode: [% item.barcode %]\r\nOn loan?: [% item.onloan %]\r\nStatus: [% item.reason %]\r\nCurrent library: [% item.branch.branchname %] [% item.branch.branchcode %]\r\n\r\n[% END %][% END %]', 'email');
index a28ac03..f4c25f4 100644 (file)
 <body id="printinvoice" class="pat">
 
 <div id="receipt">
-<!-- The table with the account items -->
-<table>
-[% IF ( LibraryName ) %]
-  <tr>
-    <th colspan="5" class="centerednames">
-               <h3>[% LibraryName | html %]</h3>
-       </th>
-  </tr>
-[% END %]
-  <tr>
-    <th colspan="5" class="centerednames">
-               <h2><u>INVOICE</u></h2>
-       </th>
-  </tr>
-  <tr>
-    <th colspan="5" class="centerednames">
-        <h2>[% Branches.GetName( patron.branchcode ) | html %]</h2>
-       </th>
-  </tr>
-  <tr>
-    <th colspan="5" >
-        Bill to: [% patron.firstname | html %] [% patron.surname | html %] <br />
-        Card number: [% patron.cardnumber | html %]<br />
-       </th>
-  </tr>
-  <tr>
-       <th>Date</th>
-    <th>Description of charges</th>
-    <th>Note</th>
-    <th style="text-align:right;">Amount</th>
-    <th style="text-align:right;">Amount outstanding</th>
- </tr>
-
-  [% FOREACH account IN accounts %]
-<tr class="highlight">
-      <td>[% account.date | $KohaDates%]</td>
-       <td>
-        [% PROCESS account_type_description account=account %]
-        [%- IF account.description %], [% account.description | html %][% END %]
-      </td>
-      <td>[% account.note | html %]</td>
-      [% IF ( account.amountcredit ) %]<td class="credit">[% ELSE %]<td class="debit">[% END %][% account.amount | $Price %]</td>
-      [% IF ( account.amountoutstandingcredit ) %]<td class="credit">[% ELSE %]<td class="debit">[% END %][% account.amountoutstanding | $Price %]</td>
-    </tr>
-
-  [% END %]
-<tfoot>
-  <tr>
-    <td colspan="4">Total outstanding dues as on date: </td>
-    [% IF ( totalcredit ) %]<td class="credit">[% ELSE %]<td class="debit">[% END %][% total | $Price %]</td>
-  </tr>
-  </tfoot>
-</table>
+    [% letter.content | evaltt %]
 </div>
 
 [% MACRO jsinclude BLOCK %]
index 81b5b9f..98ff1c5 100755 (executable)
@@ -55,7 +55,8 @@ output_and_exit_if_error( $input, $cookie, $template, { module => 'members', log
 
 #get account details
 my $total = $patron->account->balance;
-my $accountline = Koha::Account::Lines->find($accountlines_id)->unblessed;
+my $accountline_object = Koha::Account::Lines->find($accountlines_id);
+my $accountline = $accountline_object->unblessed;
 
 my $totalcredit;
 if ( $total <= 0 ) {
@@ -85,12 +86,21 @@ my %row = (
     'note'      => $accountline->{'note'},
 );
 
+my @account_offsets = Koha::Account::Offsets->search( { debit_id => $accountline_object->id } );
+
+my $letter = C4::Letters::getletter( 'circulation', 'ACCOUNT_DEBIT', C4::Context::mybranch, 'print', $patron->lang );
+
 $template->param(
-    patron         => $patron,
-    finesview      => 1,
-    total          => sprintf( "%.2f", $total ),
-    totalcredit    => $totalcredit,
-    accounts       => [$accountline], # FIXME There is always only 1 row!
+    letter  => $letter,
+    patron  => $patron,
+    library => C4::Context::mybranch,
+    offsets => \@account_offsets,
+    debit   => $accountline_object,
+
+    finesview   => 1,
+    total       => sprintf( "%.2f", $total ),
+    totalcredit => $totalcredit,
+    accounts    => [$accountline],           # FIXME There is always only 1 row!
 );
 
 output_html_with_http_headers $input, $cookie, $template->output;