From cb3ed4ec17fbe42bad05f94946bc033678f09019 Mon Sep 17 00:00:00 2001 From: einhverfr Date: Sat, 21 Jul 2007 17:15:06 +0000 Subject: Correcting cumulative tax display issues, bug 1745757 git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@1434 4979c152-3d1c-0410-bac9-87ea11338e46 --- bin/io.pl | 34 ++++++++++++++++++++++++++++++++++ bin/ir.pl | 23 +++++++---------------- bin/is.pl | 28 ++++++++++------------------ bin/pos.pl | 22 +++++++--------------- 4 files changed, 58 insertions(+), 49 deletions(-) (limited to 'bin') diff --git a/bin/io.pl b/bin/io.pl index 13b646ef..f066b6be 100644 --- a/bin/io.pl +++ b/bin/io.pl @@ -84,6 +84,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 b0840827..623d9283 100644 --- a/bin/ir.pl +++ b/bin/ir.pl @@ -469,7 +469,7 @@ sub form_header { } sub form_footer { - + _calc_taxes(); $form->{invtotal} = $form->{invsubtotal}; if ( ( $rows = $form->numtextrows( $form->{notes}, 35, 8 ) ) < 2 ) { @@ -483,7 +483,7 @@ sub form_footer { qq||; $intnotes = qq||; - + $tax = ""; $form->{taxincluded} = ( $form->{taxincluded} ) ? "checked" : ""; $taxincluded = ""; @@ -495,26 +495,17 @@ qq|