-# You should have received a copy of the GNU General Public License along
-# with Koha; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-
-use strict;
-use warnings;
-
-use C4::Auth;
-use C4::Output;
-use C4::Dates qw/format_date/;
-use CGI;
-use C4::Members;
-use C4::Branch;
-use C4::Accounts;
-
-my $input=new CGI;
-
-
-my ($template, $loggedinuser, $cookie)
- = get_template_and_user({template_name => "members/printinvoice.tmpl",
- query => $input,
- type => "intranet",
- authnotrequired => 0,
- flagsrequired => {borrowers => 1, updatecharges => 1},
- debug => 1,
- });
-
-my $borrowernumber=$input->param('borrowernumber');
-my $action = $input->param('action') || '';
-my $accountno = $input->param('accountno');
-my $accountlines_id = $input->param('accountlines_id');
-
-#get borrower details
-my $data=GetMember('borrowernumber' => $borrowernumber);
-
-if ( $action eq 'print' ) {
-# ReversePayment( $borrowernumber, $input->param('accountno') );
-}
-
-if ( $data->{'category_type'} eq 'C') {
- my ( $catcodes, $labels ) = GetborCatFromCatType( 'A', 'WHERE category_type = ?' );
- my $cnt = scalar(@$catcodes);
- $template->param( 'CATCODE_MULTI' => 1) if $cnt > 1;
- $template->param( 'catcode' => $catcodes->[0]) if $cnt == 1;
-}
-
-#get account details
-my ($total,$accts,$numaccts)=GetMemberAccountRecords($borrowernumber);
-my $totalcredit;
-if($total <= 0){
- $totalcredit = 1;
-}
-my @accountrows; # this is for the tmpl-loop
-
-my $toggle;
-for (my $i=0;$i<$numaccts;$i++){
- next if ($accts->[$i]{'accountno'} ne $accountno);
- if($i%2){
- $toggle = 0;
- } else {
- $toggle = 1;
+# You should have received a copy of the GNU General Public License
+# along with Koha; if not, see <http://www.gnu.org/licenses>.
+
+use Modern::Perl;
+
+use C4::Auth qw( get_template_and_user );
+use C4::Output qw( output_and_exit_if_error output_and_exit output_html_with_http_headers );
+use CGI qw ( -utf8 );
+use C4::Letters;
+use Koha::Account::Lines;
+
+my $input = CGI->new;
+
+my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
+ {
+ template_name => "members/printinvoice.tt",
+ query => $input,
+ type => "intranet",
+ flagsrequired => {
+ borrowers => 'edit_borrowers',
+ updatecharges => 'remaining_permissions'
+ }