-
-
$jsscript
-
+
{rowcount}>
+
+
+
+
+ |
+ . $locale->text('Account') . qq| |
+ |
+ . $locale->text('Amount') . qq| |
+ |
+ . $locale->text('Tax') . qq| |
+ |
+ . $locale->text('Korrektur') . qq| |
+ |
+ . $locale->text('Taxkey') . qq| |
+ |
+ . $locale->text('Project') . qq| |
+
|;
- $form->{"tax"} = $form->format_amount(\%myconfig, $form->{"tax"}, 2);
+
$amount = $locale->text('Amount');
$project = $locale->text('Project');
- for $i (1 .. 1) {
+ for $i (1 .. $form->{rowcount}) {
# format amounts
- $form->{"amount_$i"} =
- $form->format_amount(\%myconfig, $form->{"amount_$i"}, 2);
+ $form->{"amount_$i"} = $form->format_amount(\%myconfig, $form->{"amount_$i"}, 2);
+ $form->{"tax_$i"} = $form->format_amount(\%myconfig, $form->{"tax_$i"}, 2);
+ $selectAR_amount = $selectAR_amount_unquoted;
+ $selectAR_amount =~ s/option value=\"$form->{"AR_amount_$i"}\"/option value=\"$form->{"AR_amount_$i"}\" selected/;
+ $tax = $taxchart;
+ $tax_selected = $form->{"taxchart_$i"};
+ $tax =~ s/value=\"$tax_selected\"/value=\"$tax_selected\" selected/;
+ $tax =
+ qq| | |;
print qq|
- $amount |
- {"amount_$i"}> |
- $project |
+ |
+ {"amount_$i"}> |
+ {"tax_$i"}> |
+ |
+ $tax
{"project_id_$i"}>
|
- |
|;
$amount = "";
$project = "";
}
- $taxlabel =
- ($form->{taxincluded})
- ? $locale->text('Tax Included')
- : $locale->text('Tax');
- print qq|
-
- $taxlabel |
- {"tax"}> |
- |
- |
- |
-
-|;
+
$form->{invtotal} = $form->format_amount(\%myconfig, $form->{invtotal}, 2);
print qq|
-
- | . $locale->text('Total') . qq| |
+
+
+ |
+
+
+ |
+
$form->{invtotal} |
{oldinvtotal}>
@@ -582,14 +626,19 @@ $jsscript
- |
- |
-
+ |
+
+
+ |
+
+
+
+
- | . $locale->text('Notes') . qq| |
- $notes |
+ | . $locale->text('Notes') . qq| |
+ $notes |
|
@@ -767,9 +816,9 @@ sub update {
$form->{invtotal} = 0;
- $form->{selectAR_amount} = $form->{AR_amount};
- $form->{selectAR_amount} =~
- s/value=\"$form->{AR_amountselected}\"/value=\"$form->{AR_amountselected}\" selected/;
+# $form->{selectAR_amount} = $form->{AR_amount};
+# $form->{selectAR_amount} =~
+# s/value=\"$form->{AR_amountselected}\"/value=\"$form->{AR_amountselected}\" selected/;
$form->{selectAR} = $form->{AR};
@@ -790,21 +839,38 @@ sub update {
@flds = qw(amount AR_amount projectnumber oldprojectnumber project_id);
$count = 0;
@a = ();
- for $i (1 .. 1) {
+
+ for $i (1 .. $form->{rowcount}) {
$form->{"amount_$i"} =
$form->parse_amount(\%myconfig, $form->{"amount_$i"});
+ $form->{"tax_$i"} =
+ $form->parse_amount(\%myconfig, $form->{"tax_$i"});
if ($form->{"amount_$i"}) {
push @a, {};
$j = $#a;
+ if (!$form->{"korrektur_$i"}) {
+ ($taxkey, $rate) = split(/--/, $form->{"taxchart_$i"});
+ if ($taxkey > 1) {
+ if ($form->{taxincluded}) {
+ $form->{"tax_$i"} = $form->{"amount_$i"} / ($rate + 1) * $rate;
+ } else {
+ $form->{"tax_$i"} = $form->{"amount_$i"} * $rate;
+ }
+ } else {
+ $form->{"tax_$i"} = 0;
+ }
+ }
+ $form->{"tax_$i"} = $form->round_amount($form->{"tax_$i"}, 2);
+ $totaltax += $form->{"tax_$i"};
map { $a[$j]->{$_} = $form->{"${_}_$i"} } @flds;
$count++;
}
}
$form->redo_rows(\@flds, \@a, $count, $form->{rowcount});
-
- map { $form->{invtotal} += $form->{"amount_$_"} } (1 .. 1);
+ $form->{rowcount} = $count + 1;
+ map { $form->{invtotal} += $form->{"amount_$_"} } (1 .. $form->{rowcount});
$form->{exchangerate} = $exchangerate
if (
@@ -821,37 +887,6 @@ sub update {
&check_project;
-TAXCALC:
-
- # recalculate taxes
-
- @taxaccounts = split / /, $form->{taxaccounts};
-
- $form->{"tax"} = $form->parse_amount(\%myconfig, $form->{"tax"});
-
- if ($form->{taxincluded} && $form->{"rate"}) {
- $taxrate = $form->{"rate"};
- $withholdingrate = 0;
-
- $amount =
- $form->round_amount(
- ($form->{invtotal} - ($form->{invtotal} / ($taxrate + 1))),
- 2);
- $form->{"tax"} = $form->round_amount($amount, 2);
- $taxdiff += ($amount - $form->{"tax"});
-
- if (abs $taxdiff >= 0.005) {
- $form->{"tax"} += $form->round_amount($taxdiff, 2);
- $taxdiff = 0;
- }
- $totaltax += $form->{"tax"};
-
- } else {
- $form->{"tax"} =
- $form->round_amount($form->{invtotal} * $form->{"rate"}, 2);
- $totaltax += $form->{"tax"};
-
- }
$form->{invtotal} =
($form->{taxincluded}) ? $form->{invtotal} : $form->{invtotal} + $totaltax;
|