+ for my $row (@loop1) {
+ my @array = (
+ $row->{'branch'}, $row->{'datetime'},
+ $row->{'surname'}, $row->{'firstname'},
+ $row->{'description'}, $row->{'accounttype'},
+ $row->{'amount'}, $row->{'type'},
+ $row->{'value'}
+ );
+
+ $csv->combine(@array);
+ my $string = $csv->string(@array);
+ print $string, "\n";
+ }
+ print ",,,,,,,\n";
+ print
+"Branch, Date/time, Surname, Firstname, Description, Charge Type, Invoice Amount\n";
+
+ for my $row (@loop2) {
+
+ my @array = (
+ $row->{'creditbranch'}, $row->{'creditdate'},
+ $row->{'creditsurname'}, $row->{'creditfirstname'},
+ $row->{'creditdescription'}, $row->{'creditaccounttype'},
+ $row->{'creditamount'}
+ );
+
+ $csv->combine(@array);
+ my $string = $csv->string(@array);
+ print $string, "\n";
+ }
+ print ",,,,,,,\n";
+ print
+"Branch, Date/time, Surname, Firstname, Description, Charge Type, Invoice Amount\n";
+
+ for my $row (@loop3) {
+ my @array = (
+ $row->{'refundbranch'}, $row->{'refunddate'},
+ $row->{'refundsurname'}, $row->{'refundfirstname'},
+ $row->{'refunddescription'}, $row->{'refundaccounttype'},
+ $row->{'refundamount'}
+ );
+
+ $csv->combine(@array);
+ my $string = $csv->string(@array);
+ print $string, "\n";
+
+ }
+
+ print ",,,,,,,\n";
+ print ",,,,,,,\n";
+ print ",,Total Amount Paid, $totalpaid\n";
+ print ",,Total Number Written, $totalwritten\n";
+ print ",,Total Amount Credits, $totalcredits\n";
+ print ",,Total Amount Refunds, $totalrefunds\n";