summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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;