-
-
-
-|;
-
- map { print "\n$column_header{$_}" } @column_index;
-
- print qq|
-
-|;
-
- # add sort and escape callback
- $form->{callback} = "$callback&sort=$form->{sort}";
- $callback = $form->escape($form->{callback});
-
- if (@{ $form->{AP} }) {
- $sameitem = $form->{AP}->[0]->{ $form->{sort} };
- }
-
- # sums and tax on reports by Antonio Gallardo
- #
foreach $ap (@{ $form->{AP} }) {
+ $ap->{tax} = $ap->{amount} - $ap->{netamount};
+ $ap->{due} = $ap->{amount} - $ap->{paid};
- if ($form->{l_subtotal} eq 'Y') {
- if ($sameitem ne $ap->{ $form->{sort} }) {
- &ap_subtotal;
- $sameitem = $ap->{ $form->{sort} };
- }
- }
+ map { $subtotals{$_} += $ap->{$_};
+ $totals{$_} += $ap->{$_} } @subtotal_columns;
- $column_data{netamount} =
- ""
- . $form->format_amount(\%myconfig, $ap->{netamount}, 2, " ")
- . " | ";
- $column_data{tax} = ""
- . $form->format_amount(\%myconfig, $ap->{amount} - $ap->{netamount},
- 2, " ")
- . " | ";
- $column_data{amount} =
- ""
- . $form->format_amount(\%myconfig, $ap->{amount}, 2, " ") . " | ";
- $column_data{paid} =
- ""
- . $form->format_amount(\%myconfig, $ap->{paid}, 2, " ") . " | ";
- $column_data{due} = ""
- . $form->format_amount(\%myconfig, $ap->{amount} - $ap->{paid},
- 2, " ")
- . " | ";
-
- $totalnetamount += $ap->{netamount};
- $totalamount += $ap->{amount};
- $totalpaid += $ap->{paid};
- $totaldue += ($ap->{amount} - $ap->{paid});
-
- $subtotalnetamount += $ap->{netamount};
- $subtotalamount += $ap->{amount};
- $subtotalpaid += $ap->{paid};
- $subtotaldue += ($ap->{amount} - $ap->{paid});
-
- $column_data{transdate} = "$ap->{transdate} | ";
- $column_data{duedate} = "$ap->{duedate} | ";
- $column_data{datepaid} = "$ap->{datepaid} | ";
-
- $module = ($ap->{invoice}) ? "ir.pl" : $form->{script};
-
- $column_data{invnumber} =
- qq|$ap->{invnumber} | |;
- $column_data{id} = "$ap->{id} | ";
- $column_data{ordnumber} = "$ap->{ordnumber} | ";
- $column_data{name} = "$ap->{name} | ";
- $ap->{notes} =~ s/\r\n/ /g;
- $column_data{notes} = "$ap->{notes} | ";
- $column_data{employee} = "$ap->{employee} | ";
-
- $i++;
- $i %= 2;
- print "
-
-";
+ map { $ap->{$_} = $form->format_amount(\%myconfig, $ap->{$_}, 2) } qw(netamount tax amount paid due);
- map { print "\n$column_data{$_}" } @column_index;
+ $ap->{type} =
+ $ap->{invoice} ? $locale->text("Invoice (one letter abbreviation)") :
+ $locale->text("AP Transaction (abbreviation)");
- print qq|
-
-|;
-
- }
-
- if ($form->{l_subtotal} eq 'Y') {
- &ap_subtotal;
- }
-
- # print totals
- print qq|
-
-|;
+ my $row = { };
- map { $column_data{$_} = " | " } @column_index;
-
- $column_data{netamount} =
- ""
- . $form->format_amount(\%myconfig, $totalnetamount, 2, " ") . " | ";
- $column_data{tax} = ""
- . $form->format_amount(\%myconfig, $totalamount - $totalnetamount,
- 2, " ")
- . " | ";
- $column_data{amount} =
- ""
- . $form->format_amount(\%myconfig, $totalamount, 2, " ") . " | ";
- $column_data{paid} =
- ""
- . $form->format_amount(\%myconfig, $totalpaid, 2, " ") . " | ";
- $column_data{due} =
- ""
- . $form->format_amount(\%myconfig, $totaldue, 2, " ") . " | ";
-
- map { print "$column_data{$_}\n" } @column_index;
-
- print qq|
-
-
- |
-
-