From b5abb3df53ff5970bb422f731663fbef17190954 Mon Sep 17 00:00:00 2001 From: einhverfr Date: Mon, 30 Oct 2006 05:08:55 +0000 Subject: Fixing IR, IS, and CT bugs git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@382 4979c152-3d1c-0410-bac9-87ea11338e46 --- LedgerSMB/CT.pm | 11 +++++++++-- LedgerSMB/Form.pm | 4 ++-- LedgerSMB/IR.pm | 26 +++++++++++++++++--------- LedgerSMB/IS.pm | 8 ++++---- 4 files changed, 32 insertions(+), 17 deletions(-) (limited to 'LedgerSMB') diff --git a/LedgerSMB/CT.pm b/LedgerSMB/CT.pm index 884e453c..f3df8113 100755 --- a/LedgerSMB/CT.pm +++ b/LedgerSMB/CT.pm @@ -316,7 +316,7 @@ sub save_customer { phone = ?, fax = ?, email = ?, - cc = '?, + cc = ?, bcc = ?, notes = ?, discount = ?, @@ -337,6 +337,12 @@ sub save_customer { WHERE id = ?|; $sth = $dbh->prepare($query); + if (!$form->{startdate}){ + undef $form->{startdate}; + } + if (!$form->{enddate}){ + undef $form->{enddate}; + } $sth->execute( $form->{customernumber}, $form->{name}, $form->{address1}, $form->{address2}, $form->{city}, $form->{state}, @@ -345,7 +351,8 @@ sub save_customer { $form->{bcc}, $form->{notes}, $form->{discount}, $form->{creditlimit}, $form->{terms}, $form->{taxincluded}, $business_id, $form->{taxnumber}, $form->{sic_code}, - $form->{iban}, $form->{bic}, $employee_id, $language_code, + $form->{iban}, $form->{bic}, $employee_id, $pricegroup_id, + $language_code, $form->{curr}, $form->{startdate}, $form->{enddate}, $form->{id}) || $form->dberror($query); diff --git a/LedgerSMB/Form.pm b/LedgerSMB/Form.pm index 835ea471..4e1d5aad 100755 --- a/LedgerSMB/Form.pm +++ b/LedgerSMB/Form.pm @@ -2868,8 +2868,8 @@ sub update_defaults { sub db_prepare_vars { for (@_){ - if (!$self->{$_} and $self->{$_} != 0){ - $self->{$_} = undef; + if (!$self->{$_} and $self->{$_} ne "0"){ + undef $self->{$_}; } } } diff --git a/LedgerSMB/IR.pm b/LedgerSMB/IR.pm index 76fef000..60c8abe3 100755 --- a/LedgerSMB/IR.pm +++ b/LedgerSMB/IR.pm @@ -42,6 +42,12 @@ sub post_invoice { my $dbh = $form->{dbh}; + for (1 .. $form->{rowcount}){ + unless ($form->{"deliverydate_$_"}){ + $form->{"deliverydate_$_"} = $form->{transdate}; + } + + } my $query; my $sth; my $ref; @@ -169,7 +175,6 @@ sub post_invoice { $pth->finish; # project - $project_id = 'NULL'; if ($form->{"projectnumber_$i"} ne "") { ($null, $project_id) = @@ -257,6 +262,8 @@ sub post_invoice { WHERE description = '$uid'|; ($invoice_id) = $dbh->selectrow_array($query); + $form->debug; + $query = qq| UPDATE invoice SET trans_id = ?, @@ -472,10 +479,10 @@ sub post_invoice { $query = qq| INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, project_id, invoice_id) - VALUES (?, ?, ? * -1, ?, ?, ?)|; - $sth = $dbh->do($query); + VALUES (?, ?, ?, ?, ?, ?)|; + $sth = $dbh->prepare($query); $sth->execute( - $form->{id}, $ref->{chart_id}, $amount, + $form->{id}, $ref->{chart_id}, $amount * -1, $form->{transdate}, $ref->{project_id}, $ref->{invoice_id}) || $form->dberror($query); $diff = 0; @@ -500,7 +507,7 @@ sub post_invoice { $query = qq| INSERT INTO acc_trans (trans_id, chart_id, amount, transdate) - VALUES ?, (SELECT id FROM chart WHERE accno = ?), + VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?)|; $sth = $dbh->prepare($query); $sth->execute( @@ -737,10 +744,10 @@ sub post_invoice { $item = $dbh->quote($item); $query = qq| UPDATE parts - SET avgcost = avgcost(?), - lastcost = lastcost(?) - WHERE id = ?|; - $dbh->do($query) || $form->dberror($query); + SET avgcost = avgcost($item), + lastcost = lastcost($item) + WHERE id = $item|; + $dbh->prepare($query) || $form->dberror($query); $dbh->commit; } @@ -1137,6 +1144,7 @@ sub retrieve_invoice { sub retrieve_item { my ($self, $myconfig, $form) = @_; + $dbh = $form->{dbh}; my $i = $form->{rowcount}; my $null; my $var; diff --git a/LedgerSMB/IS.pm b/LedgerSMB/IS.pm index e8c09671..74b35352 100755 --- a/LedgerSMB/IS.pm +++ b/LedgerSMB/IS.pm @@ -907,7 +907,6 @@ sub post_invoice { $pth->finish; # project - $project_id = 'NULL'; if ($form->{"projectnumber_$i"}) { ($null, $project_id) = split /--/, @@ -1055,7 +1054,10 @@ sub post_invoice { SELECT id FROM invoice WHERE description = '$uid'|; ($invoice_id) = $dbh->selectrow_array($query); - + + unless ($form->{"deliverydate_$i"}){ + undef $form->{"deliverydate_$i"}; + } $query = qq| UPDATE invoice SET trans_id = ?, @@ -1361,8 +1363,6 @@ sub post_invoice { $form->{terms} *= 1; $form->{taxincluded} *= 1; - # if this is from a till - my $till = ($form->{till}) ? qq|'$form->{till}'| : "NULL"; $form->{invnumber} = $form->update_defaults($myconfig, "sinumber", $dbh) -- cgit v1.2.3