-
-
-
-$jsscript
+
+
+
+ |
+ . $locale->text('Account') . qq| |
+ |
+ . $locale->text('Amount') . qq| |
+ |
+ . $locale->text('Tax') . qq| |
+ |
+ . $locale->text('Korrektur') . qq| |
+ |
+ . $locale->text('Taxkey') . qq| |
+ |
+ . $locale->text('Project') . qq| |
+
|;
$amount = $locale->text('Amount');
$project = $locale->text('Project');
- for $i (1 .. 1) {
-
- # $form->{"selectAP_amount"} =~ s/ selected//;
- # $form->{"selectAP_amount"} =~ s/option>\Q$form->{"AP_amount_$i"}\E/option selected>$form->{"AP_amount_$i"}/;
+ for $i (1 .. $form->{rowcount}) {
# format amounts
$form->{"amount_$i"} =
$form->format_amount(\%myconfig, $form->{"amount_$i"}, 2);
+ $form->{"tax_$i"} = $form->format_amount(\%myconfig, $form->{"tax_$i"}, 2);
+ $selectAP_amount = $selectAP_amount_unquoted;
+ $selectAP_amount =~
+ s/option value=\"$form->{"AP_amount_$i"}\"/option value=\"$form->{"AP_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"} $readonly> |
- $project |
+ |
+ {"amount_$i"}> |
+ {"tax_$i"}> |
+ |
+ $tax
{"project_id_$i"}>
|
- |
|;
$amount = "";
@@ -539,39 +567,37 @@ $jsscript
? $locale->text('Tax Included')
: $locale->text('Tax');
- # format and reverse tax
- $form->{"tax"} = $form->format_amount(\%myconfig, $form->{"tax"}, 2);
+ $form->{invtotal} = $form->format_amount(\%myconfig, $form->{invtotal}, 2);
print qq|
- ${taxlabel} |
- {"tax"} $readonly> |
- |
- | . $locale->text('Correct Tax') . qq| |
- |
+
+
+ |
-|;
-
- $form->{invtotal} = $form->format_amount(\%myconfig, $form->{invtotal}, 2);
-
- print qq|
- | . $locale->text('Total') . qq| |
- $form->{invtotal} |
+ |
+
+ $form->{invtotal} |
{oldinvtotal}>
{oldtotalpaid}>
- |
- |
-
+ |
-
-
- | . $locale->text('Notes') . qq| |
- $notes |
+
+
+
+ |
+
+
+
+
+
+ | . $locale->text('Notes') . qq| |
+ $notes |
|
@@ -746,9 +772,9 @@ sub update {
$form->{invtotal} = 0;
- $form->{selectAP_amount} = $form->{AP_amount};
- $form->{selectAP_amount} =~
- s/value=\"$form->{AP_amountselected}\"/value=\"$form->{AP_amountselected}\" selected/;
+ # $form->{selectAP_amount} = $form->{AP_amount};
+ # $form->{selectAP_amount} =~
+ # s/value=\"$form->{AP_amountselected}\"/value=\"$form->{AP_amountselected}\" selected/;
$form->{selectAP} = $form->{AP};
$form->{selectAP} =~
@@ -767,19 +793,35 @@ sub update {
@flds = qw(amount AP_amount projectnumber oldprojectnumber project_id);
$count = 0;
- 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, {};
- my $j = $#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});
- $form->{invtotal} += $form->{"amount_1"};
+ map { $form->{invtotal} += $form->{"amount_$_"} } (1 .. $form->{rowcount});
$form->{exchangerate} = $exchangerate
if (
@@ -795,38 +837,7 @@ sub update {
$form->{AP} = $save_AP;
&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->{rowcount} = $count + 1;
$form->{invtotal} =
($form->{taxincluded}) ? $form->{invtotal} : $form->{invtotal} + $totaltax;
@@ -1019,14 +1030,12 @@ sub search {
$button1 = qq|
text('button')
- . qq|> |
+ . $locale->text('button') . qq|>
|;
$button2 = qq|
text('button')
- . qq|> |
+ . $locale->text('button') . qq|>
|;
#write Trigger
@@ -1241,10 +1250,9 @@ sub ap_transactions {
$option .= $locale->text('Closed');
}
- @columns =
- $form->sort_columns(
+ @columns = $form->sort_columns(
qw(transdate id invnumber ordnumber name netamount tax amount paid datepaid due duedate notes employee)
- );
+ );
foreach $item (@columns) {
if ($form->{"l_$item"} eq "Y") {
--
2.20.1
|