summaryrefslogtreecommitdiff
path: root/LedgerSMB
diff options
context:
space:
mode:
authoreinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2007-04-09 19:43:31 +0000
committereinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2007-04-09 19:43:31 +0000
commitd3f27376d7ec8e8c157021189787dd1dff302479 (patch)
tree404f161fd3572e9f37da98a6af1c6370f2a828ca /LedgerSMB
parent5f87c41f16ab2c9da14f85f1b2d7e7b771059c10 (diff)
Fixing sales tax posting issues not taking contact into consideration
git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/branches/1.2@1044 4979c152-3d1c-0410-bac9-87ea11338e46
Diffstat (limited to 'LedgerSMB')
-rwxr-xr-xLedgerSMB/IR.pm3
-rwxr-xr-xLedgerSMB/IS.pm6
-rwxr-xr-xLedgerSMB/OE.pm3
-rwxr-xr-xLedgerSMB/Tax.pm16
4 files changed, 23 insertions, 5 deletions
diff --git a/LedgerSMB/IR.pm b/LedgerSMB/IR.pm
index a1e0a8d9..6effad33 100755
--- a/LedgerSMB/IR.pm
+++ b/LedgerSMB/IR.pm
@@ -218,7 +218,8 @@ sub post_invoice {
$fxdiff += $amount - $linetotal;
@taxaccounts = Tax::init_taxes(
- $form, $form->{"taxaccounts_$i"});
+ $form, $form->{"taxaccounts_$i"},
+ $form->{'taxaccounts'});
$tax = Math::BigFloat->bzero();
$fxtax = Math::BigFloat->bzero();
diff --git a/LedgerSMB/IS.pm b/LedgerSMB/IS.pm
index c1594338..a04a6dcf 100755
--- a/LedgerSMB/IS.pm
+++ b/LedgerSMB/IS.pm
@@ -354,7 +354,8 @@ sub invoice_details {
push(@{ $form->{linetotal} }, $form->{"linetotal_$i"});
@taxaccounts = Tax::init_taxes(
- $form, $form->{"taxaccounts_$i"});
+ $form, $form->{"taxaccounts_$i"},
+ $form->{"taxaccounts"});
my $ml = 1;
my @taxrates = ();
@@ -950,7 +951,8 @@ sub post_invoice {
my $linetotal = $form->round_amount($amount, 2);
$fxdiff += $amount - $linetotal;
@taxaccounts = Tax::init_taxes(
- $form, $form->{"taxaccounts_$i"});
+ $form, $form->{"taxaccounts_$i"},
+ $form->{"taxaccounts"});
$ml = 1;
$tax = Math::BigFloat->bzero();
$fxtax = Math::BigFloat->bzero();
diff --git a/LedgerSMB/OE.pm b/LedgerSMB/OE.pm
index 6fd5aeca..cb0526ef 100755
--- a/LedgerSMB/OE.pm
+++ b/LedgerSMB/OE.pm
@@ -423,7 +423,8 @@ sub save {
);
@taxaccounts = Tax::init_taxes($form,
- $form->{"taxaccounts_$i"});
+ $form->{"taxaccounts_$i"},
+ $form->{taxaccounts});
if ($form->{taxincluded}) {
$taxamount = Tax::calculate_taxes(\@taxaccounts,
$form, $linetotal, 1);
diff --git a/LedgerSMB/Tax.pm b/LedgerSMB/Tax.pm
index 6d4c7956..6ff21459 100755
--- a/LedgerSMB/Tax.pm
+++ b/LedgerSMB/Tax.pm
@@ -30,10 +30,23 @@ package Tax;
use Math::BigFloat;
sub init_taxes {
- my ($form, $taxaccounts) = @_;
+ my ($form, $taxaccounts, $taxaccounts2) = @_;
my $dbh = $form->{dbh};
@taxes = ();
my @accounts = split / /, $taxaccounts;
+ if (defined $taxaccounts2){
+ my @tmpaccounts = @accounts;
+ $#accounts = 0;
+ for my $acct (split / /, $taxaccounts2){
+ if ($taxaccounts =~ /$acct/){
+ push @accounts, $acct;
+ }
+ }
+
+ }
+ if (! scalar @accounts){
+ return @accounts;
+ }
my $query = qq|SELECT t.taxnumber, c.description,
t.rate, t.chart_id, t.pass, m.taxmodulename
FROM tax t INNER JOIN chart c ON (t.chart_id = c.id)
@@ -41,6 +54,7 @@ sub init_taxes {
WHERE c.accno = ?|;
my $sth = $dbh->prepare($query);
foreach $taxaccount (@accounts) {
+ next if (! defined $taxaccount);
$sth->execute($taxaccount) || $form->dberror($query);
my $ref = $sth->fetchrow_hashref;