-
-
-
- | . $locale->text('Payments') . qq| |
-
-|;
+ # note rows
+ $form->{rows} = max 2,
+ $form->numtextrows($form->{notes}, 26, 8),
+ $form->numtextrows($form->{intnotes}, 35, 8);
- if ($form->{currency} eq $form->{defaultcurrency}) {
- @column_index = qw(datepaid source memo paid AP_paid);
- } else {
- @column_index = qw(datepaid source memo paid exchangerate AP_paid);
- }
- $column_data{datepaid} = "" . $locale->text('Date') . " | ";
- $column_data{paid} = "" . $locale->text('Amount') . " | ";
- $column_data{exchangerate} = "" . $locale->text('Exch') . " | ";
- $column_data{AP_paid} = "" . $locale->text('Account') . " | ";
- $column_data{source} = "" . $locale->text('Source') . " | ";
- $column_data{memo} = "" . $locale->text('Memo') . " | ";
+ # tax, total and subtotal calculations
+ my ($tax, $subtotal);
+ $form->{taxaccounts_array} = [ split / /, $form->{taxaccounts} ];
- print qq|
-
-|;
- map { print "$column_data{$_}\n" } @column_index;
- print qq|
-
-|;
-
- $form->{paidaccounts}++ if ($form->{"paid_$form->{paidaccounts}"});
- for $i (1 .. $form->{paidaccounts}) {
-
- print qq|
-
-|;
-
- $form->{"selectAP_paid_$i"} = $form->{selectAP_paid};
- $form->{"selectAP_paid_$i"} =~
- s/option>\Q$form->{"AP_paid_$i"}\E/option selected>$form->{"AP_paid_$i"}/;
-
- # format amounts
- $form->{"paid_$i"} =
- $form->format_amount(\%myconfig, $form->{"paid_$i"}, 2);
- $form->{"exchangerate_$i"} =
- $form->format_amount(\%myconfig, $form->{"exchangerate_$i"});
-
- $exchangerate = qq| |;
- if ($form->{currency} ne $form->{defaultcurrency}) {
- if ($form->{"forex_$i"}) {
- $exchangerate =
- qq|{"exchangerate_$i"}>$form->{"exchangerate_$i"}|;
+ foreach my $item (@{ $form->{taxaccounts_array} }) {
+ if ($form->{"${item}_base"}) {
+ if ($form->{taxincluded}) {
+ $form->{"${item}_total"} = $form->round_amount( ($form->{"${item}_base"} * $form->{"${item}_rate"}
+ / (1 + $form->{"${item}_rate"})), 2);
+ $form->{"${item}_netto"} = $form->round_amount( ($form->{"${item}_base"} - $form->{"${item}_total"}), 2);
} else {
- $exchangerate =
- qq|{"exchangerate_$i"}>|;
+ $form->{"${item}_total"} = $form->round_amount( $form->{"${item}_base"} * $form->{"${item}_rate"}, 2);
+ $form->{invtotal} += $form->{"${item}_total"};
}
}
- $exchangerate .= qq|
-{"forex_$i"}>
-|;
-
- $column_data{"paid_$i"} =
- qq|{"paid_$i"}> | |;
- $column_data{"exchangerate_$i"} = qq|$exchangerate | |;
- $column_data{"AP_paid_$i"} =
- qq| | |;
- $column_data{"datepaid_$i"} =
- qq|{"datepaid_$i"}> | |;
- $column_data{"source_$i"} =
- qq|{"source_$i"}> | |;
- $column_data{"memo_$i"} =
- qq|{"memo_$i"}> | |;
-
- map { print qq|$column_data{"${_}_$i"}\n| } @column_index;
-
- print qq|
-
-|;
}
- print qq|
- {oldinvtotal}>
- {paidaccounts}>
-
-
- |
-
-