[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
SF.net SVN: ledger-smb:[3973] branches/1.3
- Subject: SF.net SVN: ledger-smb:[3973] branches/1.3
- From: ..hidden..
- Date: Thu, 10 Nov 2011 12:48:50 +0000
Revision: 3973
http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=3973&view=rev
Author: tshvr
Date: 2011-11-10 12:48:50 +0000 (Thu, 10 Nov 2011)
Log Message:
-----------
add parse format statements,additional deletes,commit at highest sub-level,remove duplicate delete
Modified Paths:
--------------
branches/1.3/LedgerSMB/IR.pm
branches/1.3/bin/ir.pl
Modified: branches/1.3/LedgerSMB/IR.pm
===================================================================
--- branches/1.3/LedgerSMB/IR.pm 2011-11-10 11:25:31 UTC (rev 3972)
+++ branches/1.3/LedgerSMB/IR.pm 2011-11-10 12:48:50 UTC (rev 3973)
@@ -197,7 +197,7 @@
: $form->parse_amount( $myconfig, $form->{exchangerate} );
- my $taxformfound=IR->taxform_exist($form,$form->{"vendor_id"});
+ my $taxformfound=IR->taxform_exist($form,$form->{"vendor_id"});#tshvr this always returns true!!
for my $i ( 1 .. $form->{rowcount} ) {
$form->{"qty_$i"} = $form->parse_amount( $myconfig, $form->{"qty_$i"} );
@@ -620,11 +620,13 @@
for $taccno (split / /, $form->{taxaccounts}){
my $taxamount;
my $taxbasis;
+ my $taxrate;
my $fx = $form->{exchangerate} || 1;
$taxamount = $form->parse_amount($myconfig,
$form->{"mt_amount_$taccno"});
$taxbasis = $form->parse_amount($myconfig,
$form->{"mt_basis_$taccno"});
+ $taxrate=$form->parse_amount($myconfig,$form->{"mt_rate_$taccno"});
my $fx_taxamount = $taxamount * $fx;
my $fx_taxbasis = $taxbasis * $fx;
$form->{payables} += $fx_taxamount;
@@ -632,7 +634,7 @@
$ac_sth->execute($taccno, $form->{id}, $fx_taxamount * -1,
$form->{"mt_ref_$taccno"},
$form->{"mt_desc_$taccno"});
- $tax_sth->execute($fx_taxbasis * -1, $form->{"mt_rate_$taccno"});
+ $tax_sth->execute($fx_taxbasis * -1, $taxrate);
}
$ac_sth->finish;
$tax_sth->finish;
@@ -981,6 +983,28 @@
}
$sth->finish;
+ #tshvr delete tax_extended invoice_tax_form
+ $query=qq|SELECT entry_id FROM acc_trans ac JOIN tax_extended t using(entry_id) WHERE ac.trans_id = ?|;
+ $sth = $dbh->prepare($query);
+ $sth->execute($form->{id}) || $form->dberror($query);
+ while ( my $entry_id=$sth->fetchrow_array ) {
+ my $query1="DELETE FROM tax_extended WHERE entry_id=?";
+ my $sth1 = $dbh->prepare($query1);
+ $sth1->execute($entry_id) || $form->dberror($query);
+ $sth1->finish;
+ }#while entry_id
+ $sth->finish;
+ $query=qq|select id from invoice WHERE trans_id=?|;
+ $sth = $dbh->prepare($query);
+ $sth->execute($form->{id}) || $form->dberror($query);
+ while(my $invoice_id=$sth->fetchrow()){
+ my $query1=qq|delete from invoice_tax_form where invoice_id=?|;
+ my $sth1 = $dbh->prepare($query1);
+ $sth1->execute($invoice_id) || $form->dberror($query);
+ $sth1->finish;
+ }#while invoice_id
+ $sth->finish;
+ #tshvr delete tax_extended invoice_tax_form end
# delete acc_trans
$query = qq|DELETE FROM acc_trans WHERE trans_id = ?|;
$sth = $dbh->prepare($query);
@@ -995,7 +1019,7 @@
$sth = $dbh->prepare($query);
$sth->execute( $form->{id} ) || $form->dberror($query);
- $dbh->commit;
+ #$dbh->commit;#tshvr lower-level sub should not commit on behalf of higher-level sub
}
@@ -1067,9 +1091,9 @@
if $spoolfile;
}
}
- $query = "DELETE FROM invoice WHERE trans_id = ?";
- $sth = $dbh->prepare($query);
- $sth->execute($form->{id});
+ #$query = "DELETE FROM invoice WHERE trans_id = ?";#tshvr already done in reverse_invoice
+ #$sth = $dbh->prepare($query);
+ #$sth->execute($form->{id});
# delete AP record
$query = qq|DELETE FROM ap WHERE id = ?|;
$sth = $dbh->prepare($query);
@@ -1098,11 +1122,12 @@
WHERE ac.trans_id = ?|);
$tax_sth->execute($form->{id});
while (my $taxref = $tax_sth->fetchrow_hashref('NAME_lc')){
+ $form->db_parse_numeric(sth=>$tax_sth,hashref=>$taxref);
$form->{manual_tax} = 1;
my $taccno = $taxref->{accno};
- $form->{"mt_amount_$taccno"} = $taxref->{amount} * -1;
+ $form->{"mt_amount_$taccno"} = Math::BigFloat->new($taxref->{amount} * -1);
$form->{"mt_rate_$taccno"} = $taxref->{rate};
- $form->{"mt_basis_$taccno"} = $taxref->{tax_basis} * -1;
+ $form->{"mt_basis_$taccno"} = Math::BigFloat->new($taxref->{tax_basis} * -1);
$form->{"mt_memo_$taccno"} = $taxref->{memo};
$form->{"mt_ref_$taccno"} = $taxref->{source};
}
@@ -1638,7 +1663,7 @@
$sth->execute($invoice_id,$report) || $form->dberror("$query");
}
- $dbh->commit();
+ #$dbh->commit();#tshvr lower-level sub should not commit on behalf of higher-level sub
}
Modified: branches/1.3/bin/ir.pl
===================================================================
--- branches/1.3/bin/ir.pl 2011-11-10 11:25:31 UTC (rev 3972)
+++ branches/1.3/bin/ir.pl 2011-11-10 12:48:50 UTC (rev 3973)
@@ -571,16 +571,28 @@
!defined $form->{"mt_rate_$item"}){
$form->{"mt_rate_$item"} = $form->{tax_obj}{$item}->rate;
}
+ else
+ {
+ $form->{"mt_rate_$item"}=$form->parse_amount(\%myconfig,$form->{"mt_rate_$item"});
+ }
if ($form->{"mt_basis_$item"} eq '' or
!defined $form->{"mt_basis_$item"}){
$form->{"mt_basis_$item"} = $form->{taxbasis}{$item};
}
+ else
+ {
+ $form->{"mt_basis_$item"}=$form->parse_amount(\%myconfig,$form->{"mt_basis_$item"});
+ }
if ($form->{"mt_amount_$item"} eq '' or
!defined $form->{"mt_amount_$item"}){
$form->{"mt_amount_$item"} =
$form->{"mt_rate_$item"}
* $form->{"mt_basis_$item"};
}
+ else
+ {
+ $form->{"mt_amount_$item"}=$form->parse_amount(\%myconfig,$form->{"mt_amount_$item"});
+ }
$form->{invtotal} += $form->round_amount(
$form->{"mt_amount_$item"}, 2);
# Setting this up as a table
@@ -591,13 +603,13 @@
<th align=right>$form->{"${taccno}_description"}</th>
<td><input type="text" name="mt_amount_$item"
id="mt-amount-$item" value="|
- .$form->{"mt_amount_$item"} .qq|" size="10"/></td>
+ .$form->format_amount(\%myconfig,$form->{"mt_amount_$item"}).qq|" size="10"/></td>
<td><input type="text" name="mt_rate_$item"
id="mt-rate-$item" value="|
- .$form->{"mt_rate_$item"} .qq|" size="6"/></td>
+ .$form->format_amount(\%myconfig,$form->{"mt_rate_$item"}).qq|" size="6"/></td>
<td><input type="text" name="mt_basis_$item"
id="mt-basis-$item" value="|
- .$form->{"mt_basis_$item"} .qq|" size="10" /></td>
+ .$form->format_amount(\%myconfig,$form->{"mt_basis_$item"}).qq|" size="10" /></td>
<td><input type="text" name="mt_ref_$item"
id="mt-ref-$item" value="|
.$form->{"mt_ref_$item"} .qq|" size="10"/></td>
@@ -1372,12 +1384,14 @@
{
IR->update_invoice_tax_form($form,$form->{dbh},$form->{"invoice_id_$i"},"true") if($form->{"invoice_id_$i"});
+ $form->{$dbh}->commit();#highest-level sub should commit
}
else
{
IR->update_invoice_tax_form($form,$form->{dbh},$form->{"invoice_id_$i"},"false") if($form->{"invoice_id_$i"});
+ $form->{$dbh}->commit();#highest-level sub should commit
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.