From a308dbcffd16aaee3db54b3d4eecbe5c17987110 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Tue, 30 Apr 2019 07:53:50 -0400 Subject: [PATCH] Bug 22809: Move "INVOICE" from template to a slip 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 Signed-off-by: Martin Renvoize Signed-off-by: Nick Clemens --- .../data/mysql/atomicupdate/bug_22809.perl | 61 +++++++++++++++++++ .../mysql/en/mandatory/sample_notices.sql | 55 +++++++++++++++++ .../prog/en/modules/members/printinvoice.tt | 54 +--------------- members/printinvoice.pl | 22 +++++-- 4 files changed, 133 insertions(+), 59 deletions(-) create mode 100644 installer/data/mysql/atomicupdate/bug_22809.perl diff --git a/installer/data/mysql/atomicupdate/bug_22809.perl b/installer/data/mysql/atomicupdate/bug_22809.perl new file mode 100644 index 0000000000..cbee8090da --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_22809.perl @@ -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', ' + [% IF ( LibraryName ) %] + + + + [% END %] + + + + + + + + + + + + + + + + + + + [% FOREACH account IN accounts %] + + + + + [% IF ( account.amountcredit ) %] + [% IF ( account.amountoutstandingcredit ) %] + + [% END %] + + + + + [% IF ( totalcredit ) %] + + +
+

[% LibraryName | html %]

+
+

INVOICE

+
+

[% Branches.GetName( patron.branchcode ) | html %]

+
+ Bill to: [% patron.firstname | html %] [% patron.surname | html %]
+ Card number: [% patron.cardnumber | html %]
+
DateDescription of chargesNoteAmountAmount outstanding
[% account.date | $KohaDates%] + [% PROCESS account_type_description account=account %] + [%- IF account.description %], [% account.description | html %][% END %] + [% account.note | html %][% ELSE %][% END %][% account.amount | $Price %][% ELSE %][% END %][% account.amountoutstanding | $Price %]
Total outstanding dues as on date: [% ELSE %][% END %][% total | $Price %]
', 'print', 'default'); + }); + SetVersion( $DBversion ); + print "Upgrade to $DBversion done (Bug XXXXX - description)\n"; +} diff --git a/installer/data/mysql/en/mandatory/sample_notices.sql b/installer/data/mysql/en/mandatory/sample_notices.sql index 80b5fa0612..0f38c53b70 100644 --- a/installer/data/mysql/en/mandatory/sample_notices.sql +++ b/installer/data/mysql/en/mandatory/sample_notices.sql @@ -233,5 +233,60 @@ INSERT INTO `letter` (`module`, `code`, `branchcode`, `name`, `is_html`, `title` ', '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', ' + [% IF ( LibraryName ) %] + + + + [% END %] + + + + + + + + + + + + + + + + + + + [% FOREACH account IN accounts %] + + + + + [% IF ( account.amountcredit ) %] + [% IF ( account.amountoutstandingcredit ) %] + + [% END %] + + + + + [% IF ( totalcredit ) %] + + +
+

[% LibraryName | html %]

+
+

INVOICE

+
+

[% Branches.GetName( patron.branchcode ) | html %]

+
+ Bill to: [% patron.firstname | html %] [% patron.surname | html %]
+ Card number: [% patron.cardnumber | html %]
+
DateDescription of chargesNoteAmountAmount outstanding
[% account.date | $KohaDates%] + [% PROCESS account_type_description account=account %] + [%- IF account.description %], [% account.description | html %][% END %] + [% account.note | html %][% ELSE %][% END %][% account.amount | $Price %][% ELSE %][% END %][% account.amountoutstanding | $Price %]
Total outstanding dues as on date: [% ELSE %][% END %][% total | $Price %]
', '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'); diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/printinvoice.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/printinvoice.tt index a28ac03e34..f4c25f4e30 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/printinvoice.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/printinvoice.tt @@ -17,59 +17,7 @@
- - -[% IF ( LibraryName ) %] - - - -[% END %] - - - - - - - - - - - - - - - - - - [% FOREACH account IN accounts %] - - - - - [% IF ( account.amountcredit ) %] - [% IF ( account.amountoutstandingcredit ) %] - - - [% END %] - - - - [% IF ( totalcredit ) %] - - -
-

[% LibraryName | html %]

-
-

INVOICE

-
-

[% Branches.GetName( patron.branchcode ) | html %]

-
- Bill to: [% patron.firstname | html %] [% patron.surname | html %]
- Card number: [% patron.cardnumber | html %]
-
DateDescription of chargesNoteAmountAmount outstanding
[% account.date | $KohaDates%] - [% PROCESS account_type_description account=account %] - [%- IF account.description %], [% account.description | html %][% END %] - [% account.note | html %][% ELSE %][% END %][% account.amount | $Price %][% ELSE %][% END %][% account.amountoutstanding | $Price %]
Total outstanding dues as on date: [% ELSE %][% END %][% total | $Price %]
+ [% letter.content | evaltt %]
[% MACRO jsinclude BLOCK %] diff --git a/members/printinvoice.pl b/members/printinvoice.pl index 81b5b9f54e..98ff1c50fd 100755 --- a/members/printinvoice.pl +++ b/members/printinvoice.pl @@ -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; -- 2.39.5