summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xLedgerSMB/CT.pm11
-rwxr-xr-xLedgerSMB/Form.pm4
-rwxr-xr-xLedgerSMB/IR.pm26
-rwxr-xr-xLedgerSMB/IS.pm8
-rwxr-xr-xsql/Pg-tables.sql6
-rw-r--r--sql/Pg-upgrade-2.6.18-2.6.19.sql69
6 files changed, 106 insertions, 18 deletions
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)
diff --git a/sql/Pg-tables.sql b/sql/Pg-tables.sql
index 6e5130eb..d490110f 100755
--- a/sql/Pg-tables.sql
+++ b/sql/Pg-tables.sql
@@ -50,6 +50,10 @@ CREATE TABLE gifi (
);
--
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 @@ CREATE TABLE defaults (
glnumber text,
projectnumber text
);
---
+-- */
CREATE TABLE acc_trans (
trans_id int,
chart_id int NOT NULL REFERENCES chart (id),
diff --git a/sql/Pg-upgrade-2.6.18-2.6.19.sql b/sql/Pg-upgrade-2.6.18-2.6.19.sql
index 924bd0ba..b2328844 100644
--- a/sql/Pg-upgrade-2.6.18-2.6.19.sql
+++ b/sql/Pg-upgrade-2.6.18-2.6.19.sql
@@ -1,3 +1,5 @@
+BEGIN;
+
ALTER TABLE ap ADD PRIMARY KEY (id);
ALTER TABLE ar ADD PRIMARY KEY (id);
@@ -206,3 +208,70 @@ CREATE FUNCTION update_user(int4,text) RETURNS int4 AS $$
$$ 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;