summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoreinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2007-07-21 17:14:15 +0000
committereinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2007-07-21 17:14:15 +0000
commit65e1d575e4fec9395074525e8f1cff8ee1899d13 (patch)
treef9d16f1c7828684043a9fa141cf96528d060833d
parented1d4414cb15a901ecca5e5f96c88f44025c34ec (diff)
Correcting cumulative tax display issues, bug 1745757
git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/branches/1.2@1433 4979c152-3d1c-0410-bac9-87ea11338e46
-rwxr-xr-xbin/io.pl34
-rwxr-xr-xbin/ir.pl23
-rwxr-xr-xbin/is.pl28
-rwxr-xr-xbin/pos.pl22
4 files changed, 58 insertions, 49 deletions
diff --git a/bin/io.pl b/bin/io.pl
index cbcc9e73..8fbfb31e 100755
--- a/bin/io.pl
+++ b/bin/io.pl
@@ -81,6 +81,40 @@ if ( -f "bin/custom/$form->{login}_io.pl" ) {
# $locale->text('Nov')
# $locale->text('Dec')
+sub _calc_taxes {
+ for $i (1 .. $form->{rowcount}){
+ my $linetotal =
+ $form->parse_amount(\%myconfig, $form->{"sellprice_$i"})
+ * $form->parse_amount(\%myconfig, $form->{"qty_$i"})
+ * (1 - $form->parse_amount(\%myconfig, $form->{"discount_$i"})
+ / 100);
+ @taxaccounts = Tax::init_taxes(
+ $form, $form->{"taxaccounts_$i"},
+ $form->{'taxaccounts'}
+ );
+ my $tax;
+ my $fxtax;
+ my $amount;
+ if ( $form->{taxincluded} ) {
+ $tax += $amount =
+ Tax::calculate_taxes( \@taxaccounts, $form, $linetotal, 1 );
+
+ $form->{"sellprice_$i"} -= $amount / $form->{"qty_$i"};
+ }
+ else {
+ $tax += $amount =
+ Tax::calculate_taxes( \@taxaccounts, $form, $linetotal, 0 );
+ $fxtax +=
+ Tax::calculate_taxes( \@taxaccounts, $form, $fxlinetotal, 0 )
+ if $fxlinetotal;
+ }
+ for (@taxaccounts) {
+ $form->{taxes}{$_->account} = 0 if ! $form->{taxes}{$_->account};
+ $form->{taxes}{$_->account} += $_->value;
+ }
+ }
+}
+
sub display_row {
my $numrows = shift;
diff --git a/bin/ir.pl b/bin/ir.pl
index e2a9a7f6..4cb435a5 100755
--- a/bin/ir.pl
+++ b/bin/ir.pl
@@ -457,7 +457,7 @@ sub form_header {
}
sub form_footer {
-
+ _calc_taxes();
$form->{invtotal} = $form->{invsubtotal};
if ( ( $rows = $form->numtextrows( $form->{notes}, 35, 8 ) ) < 2 ) {
@@ -471,7 +471,7 @@ sub form_footer {
qq|<textarea name=notes rows=$rows cols=35 wrap=soft>$form->{notes}</textarea>|;
$intnotes =
qq|<textarea name=intnotes rows=$rows cols=35 wrap=soft>$form->{intnotes}</textarea>|;
-
+ $tax = "";
$form->{taxincluded} = ( $form->{taxincluded} ) ? "checked" : "";
$taxincluded = "";
@@ -483,26 +483,17 @@ qq|<textarea name=intnotes rows=$rows cols=35 wrap=soft>$form->{intnotes}</texta
}
if ( !$form->{taxincluded} ) {
- my @taxset = Tax::init_taxes( $form, $form->{taxaccounts} );
- foreach $taxobj (@taxset) {
- $item = $taxobj->account;
- $form->{invtotal} += $form->round_amount(
- $form->{"${item}_rate"} * $form->{"${item}_base"}, 2);
- $form->{"${item}_total"} =
- $form->format_amount( \%myconfig,
- $form->{"${item}_rate"} * $form->{"${item}_base"}, 2 );
- if ( $form->{"${item}_base"} ) {
- $form->{"${item}_total"} =
- $form->format_amount( \%myconfig,
- $form->round_amount( $taxobj->value, 2 ), 2 );
-
+ foreach $item (keys %{$form->{taxes}}) {
+ my $taccno = $item;
+ $form->{invtotal} += $form->round_amount($form->{taxes}{$item}, 2);
+ $form->{"${taccno}_total"} =
+ $form->round_amount($form->{taxes}{$item}, 2);
$tax .= qq|
<tr>
<th align=right>$form->{"${item}_description"}</th>
<td align=right>$form->{"${item}_total"}</td>
</tr>
|;
- }
}
$form->{invsubtotal} =
diff --git a/bin/is.pl b/bin/is.pl
index 0ad26029..52e29a58 100755
--- a/bin/is.pl
+++ b/bin/is.pl
@@ -507,7 +507,7 @@ sub form_header {
}
sub form_footer {
-
+ _calc_taxes();
$form->{invtotal} = $form->{invsubtotal};
if ( ( $rows = $form->numtextrows( $form->{notes}, 35, 8 ) ) < 2 ) {
@@ -538,20 +538,17 @@ qq|<textarea name=intnotes rows=$rows cols=35 wrap=soft>$form->{intnotes}</texta
}
if ( !$form->{taxincluded} ) {
- my @taxes = Tax::init_taxes( $form, $form->{taxaccounts} );
- foreach $item (@taxes) {
- my $taccno = $item->account;
- $form->{invtotal} += $form->round_amount(
- $form->{"${taccno}_rate"} * $form->{"${taccno}_base"}, 2);
+ foreach $item (keys %{$form->{taxes}}) {
+ my $taccno = $item;
+ $form->{invtotal} += $form->round_amount($form->{taxes}{$item}, 2);
$form->{"${taccno}_total"} =
- $form->format_amount( \%myconfig,
- $form->{"${taccno}_rate"} * $form->{"${taccno}_base"}, 2 );
+ $form->format_amount( \%myconfig,
+ $form->round_amount( $form->{taxes}{$item}, 2 ), 2 );
$tax .= qq|
<tr>
<th align=right>$form->{"${taccno}_description"}</th>
<td align=right>$form->{"${taccno}_total"}</td>
- </tr>
- | if $form->{"${taccno}_base"};
+ </tr>|;
}
$form->{invsubtotal} =
@@ -811,7 +808,7 @@ qq|<td align=center><input name="memo_$i" size=11 value="$form->{"memo_$i"}"></t
}
sub update {
-
+ $form->{taxes} = {};
$form->{exchangerate} =
$form->parse_amount( \%myconfig, $form->{exchangerate} );
@@ -988,13 +985,8 @@ sub update {
for ( split / /, $form->{"taxaccounts_$i"} ) {
$form->{"${_}_base"} += $amount;
}
- if ( !$form->{taxincluded} ) {
- my @taxes =
- Tax::init_taxes( $form, $form->{"taxaccounts_$i"},
- $form->{taxaccounts} );
- $amount +=
- Tax::calculate_taxes( \@taxes, $form, $amount, 0 );
- }
+
+
$form->{creditremaining} -= $amount;
diff --git a/bin/pos.pl b/bin/pos.pl
index cba70d04..caad92a3 100755
--- a/bin/pos.pl
+++ b/bin/pos.pl
@@ -396,7 +396,7 @@ sub form_header {
}
sub form_footer {
-
+ _calc_taxes();
$form->{invtotal} = $form->{invsubtotal};
$form->{taxincluded} = ( $form->{taxincluded} ) ? "checked" : "";
@@ -415,25 +415,17 @@ sub form_footer {
if ( !$form->{taxincluded} ) {
- my @taxset = Tax::init_taxes( $form, $form->{taxaccounts} );
- foreach $taxobj (@taxset) {
- $item = $taxobj->account;
- $form->{invtotal} += $form->round_amount(
- $form->{"${item}_rate"} * $form->{"${item}_base"}, 2);
- $form->{"${item}_total"} =
- $form->format_amount( \%myconfig,
- $form->{"${item}_rate"} * $form->{"${item}_base"}, 2 );
- if ( $form->{"${item}_base"} ) {
- $form->{"${item}_total"} =
+ foreach $item (keys %{$form->{taxes}}) {
+ my $taccno = $item;
+ $form->{invtotal} += $form->round_amount($form->{taxes}{$item}, 2);
+ $form->{"${taccno}_total"} =
$form->format_amount( \%myconfig,
- $form->round_amount( $taxobj->value, 2 ), 2 );
+ $form->round_amount( $form->{taxes}{$item}, 2 ), 2 );
$tax .= qq|
<tr>
<th align=right>$form->{"${item}_description"}</th>
<td align=right>$form->{"${item}_total"}</td>
- </tr>
-|;
- }
+ </tr>|;
}
$form->{invsubtotal} =