[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SF.net SVN: ledger-smb: [382] trunk



Revision: 382
          http://svn.sourceforge.net/ledger-smb/?rev=382&view=rev
Author:   einhverfr
Date:     2006-10-29 21:08:55 -0800 (Sun, 29 Oct 2006)

Log Message:
-----------
Fixing IR, IS, and CT bugs

Modified Paths:
--------------
    trunk/LedgerSMB/CT.pm
    trunk/LedgerSMB/Form.pm
    trunk/LedgerSMB/IR.pm
    trunk/LedgerSMB/IS.pm
    trunk/sql/Pg-tables.sql
    trunk/sql/Pg-upgrade-2.6.18-2.6.19.sql

Modified: trunk/LedgerSMB/CT.pm
===================================================================
--- trunk/LedgerSMB/CT.pm	2006-10-30 04:07:28 UTC (rev 381)
+++ trunk/LedgerSMB/CT.pm	2006-10-30 05:08:55 UTC (rev 382)
@@ -316,7 +316,7 @@
 		       phone = ?,
 		       fax = ?,
 		       email = ?,
-		       cc = '?,
+		       cc = ?,
 		       bcc = ?,
 		       notes = ?,
 		       discount = ?,
@@ -337,6 +337,12 @@
 		 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 @@
 		$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);

Modified: trunk/LedgerSMB/Form.pm
===================================================================
--- trunk/LedgerSMB/Form.pm	2006-10-30 04:07:28 UTC (rev 381)
+++ trunk/LedgerSMB/Form.pm	2006-10-30 05:08:55 UTC (rev 382)
@@ -2868,8 +2868,8 @@
 
 sub db_prepare_vars {
 	for (@_){
-		if (!$self->{$_} and $self->{$_} != 0){
-			$self->{$_} = undef;
+		if (!$self->{$_} and $self->{$_} ne "0"){
+			undef $self->{$_};
 		}
 	}
 }

Modified: trunk/LedgerSMB/IR.pm
===================================================================
--- trunk/LedgerSMB/IR.pm	2006-10-30 04:07:28 UTC (rev 381)
+++ trunk/LedgerSMB/IR.pm	2006-10-30 05:08:55 UTC (rev 382)
@@ -42,6 +42,12 @@
   
 	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 @@
 			$pth->finish;
       
 	 	 	# project
-	 	   	$project_id = 'NULL';
 
 			if ($form->{"projectnumber_$i"} ne "") {
 				($null, $project_id) = 
@@ -257,6 +262,8 @@
 				 WHERE description = '$uid'|;
 			($invoice_id) = $dbh->selectrow_array($query);
 
+				$form->debug;
+
 			$query = qq|
 				UPDATE invoice 
 				   SET trans_id = ?,
@@ -472,10 +479,10 @@
 		$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 @@
 		$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 @@
 		$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_item {
 	my ($self, $myconfig, $form) = @_;
 
+	$dbh = $form->{dbh};
 	my $i = $form->{rowcount};
 	my $null;
 	my $var;

Modified: trunk/LedgerSMB/IS.pm
===================================================================
--- trunk/LedgerSMB/IS.pm	2006-10-30 04:07:28 UTC (rev 381)
+++ trunk/LedgerSMB/IS.pm	2006-10-30 05:08:55 UTC (rev 382)
@@ -907,7 +907,6 @@
 			$pth->finish;
 
 			# project
-			$project_id = 'NULL';
 			if ($form->{"projectnumber_$i"}) {
 				($null, $project_id) 
 					= split /--/, 
@@ -1055,7 +1054,10 @@
 				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 @@
 	$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) 

Modified: trunk/sql/Pg-tables.sql
===================================================================
--- trunk/sql/Pg-tables.sql	2006-10-30 04:07:28 UTC (rev 381)
+++ trunk/sql/Pg-tables.sql	2006-10-30 05:08:55 UTC (rev 382)
@@ -50,6 +50,10 @@
 );
 --
 CREATE TABLE defaults (
+  setting_key text primary key,
+  value text
+);
+/*
   inventory_accno_id int,
   income_accno_id int,
   expense_accno_id int,
@@ -76,7 +80,7 @@
   glnumber text,
   projectnumber text
 );
---
+-- */
 CREATE TABLE acc_trans (
   trans_id int,
   chart_id int NOT NULL REFERENCES chart (id),

Modified: trunk/sql/Pg-upgrade-2.6.18-2.6.19.sql
===================================================================
--- trunk/sql/Pg-upgrade-2.6.18-2.6.19.sql	2006-10-30 04:07:28 UTC (rev 381)
+++ trunk/sql/Pg-upgrade-2.6.18-2.6.19.sql	2006-10-30 05:08:55 UTC (rev 382)
@@ -1,3 +1,5 @@
+BEGIN;
+
 ALTER TABLE ap ADD PRIMARY KEY (id);
 
 ALTER TABLE ar ADD PRIMARY KEY (id);
@@ -206,3 +208,70 @@
    $$ LANGUAGE 'SQL';
 
 COMMENT ON FUNCTION update_user(int4,text) IS $$ Takes int4 which is users.id and text which is username. Will update username based on id. Username is unique $$;
+
+ALTER TABLE defaults RENAME TO old_defaults;
+
+CREATE TABLE defaults (
+	setting_key TEXT PRIMARY KEY,
+	value TEXT
+);
+
+COMMENT ON TABLE defaults IS $$This table replaces the old one column per value system with a simple key => value table$$;
+
+
+INSERT INTO defaults (setting_key, value) 
+SELECT 'inventory_accno_id', inventory_accno_id FROM old_defaults
+UNION
+SELECT 'income_accno_id', income_accno_id FROM old_defaults
+UNION
+SELECT 'expense_accno_id', expense_accno_id FROM old_defaults
+UNION
+SELECT 'fxloss_accno_id', fxloss_accno_id FROM old_defaults
+UNION
+SELECT 'fxgain_accno_id', fxgain_accno_id FROM old_defaults
+UNION
+SELECT 'sinumber', sinumber FROM old_defaults
+UNION
+SELECT 'sonumber', sonumber FROM old_defaults
+UNION
+SELECT 'yearend', yearend FROM old_defaults
+UNION
+SELECT 'weightunit', weightunit FROM old_defaults
+UNION
+SELECT 'businessnumber', businessnumber FROM old_defaults
+UNION
+SELECT 'version', '1.2.0'
+UNION
+SELECT 'curr', curr FROM old_defaults
+UNION
+SELECT 'closedto', closedto FROM old_defaults
+UNION
+SELECT 'revtrans', revtrans FROM old_defaults
+UNION
+SELECT 'ponumber', ponumber FROM old_defaults
+UNION
+SELECT 'sqnumber', sqnumber FROM old_defaults
+UNION
+SELECT 'rfqnumber', rfqnumber FROM old_defaults
+UNION
+SELECT 'audittrail', audittrail FROM old_defaults
+UNION
+SELECT 'vinumber', vinumber FROM old_defaults
+UNION
+SELECT 'employeenumber', employeenumber FROM old_defaults
+UNION
+SELECT 'partnumber', partnumber FROM old_defaults
+UNION
+SELECT 'customernumber', customernumber FROM old_defaults
+UNION
+SELECT 'vendornumber', vendornumber FROM old_defaults
+UNION
+SELECT 'glnumber', glnumber FROM old_defaults
+UNION
+SELECT 'projectnumber', projectnumber FROM old_defaults
+UNION
+SELECT 'appname', 'LedgerSMB';
+
+DROP TABLE old_defaults;
+
+COMMIT;


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.