[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
SF.net SVN: ledger-smb: [1985] trunk/LedgerSMB
- Subject: SF.net SVN: ledger-smb: [1985] trunk/LedgerSMB
- From: ..hidden..
- Date: Wed, 19 Dec 2007 17:25:01 -0800
Revision: 1985
http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=1985&view=rev
Author: einhverfr
Date: 2007-12-19 17:25:01 -0800 (Wed, 19 Dec 2007)
Log Message:
-----------
Fixing flawed invoice behavior
Modified Paths:
--------------
trunk/LedgerSMB/AA.pm
trunk/LedgerSMB/Form.pm
trunk/LedgerSMB/IR.pm
trunk/LedgerSMB/IS.pm
Modified: trunk/LedgerSMB/AA.pm
===================================================================
--- trunk/LedgerSMB/AA.pm 2007-12-20 00:07:59 UTC (rev 1984)
+++ trunk/LedgerSMB/AA.pm 2007-12-20 01:25:01 UTC (rev 1985)
@@ -337,7 +337,7 @@
SET invnumber = ?,
ordnumber = ?,
transdate = ?,
- entity_id = ?,
+ entity_credit_account = ?,
taxincluded = ?,
amount = ?,
duedate = ?,
@@ -1040,10 +1040,10 @@
c.language_code, $duedate AS duedate,
b.discount AS tradediscount,
b.description AS business
- FROM $form->{vc} c
+ FROM entity_credit_account c
JOIN entity ON (entity.id = c.entity_id)
LEFT JOIN business b ON (b.id = c.business_id)
- WHERE c.entity_id = ?|;
+ WHERE c.id = ?|;
# TODO: Add location join
@queryargs = ( $form->{"$form->{vc}_id"} );
Modified: trunk/LedgerSMB/Form.pm
===================================================================
--- trunk/LedgerSMB/Form.pm 2007-12-20 00:07:59 UTC (rev 1984)
+++ trunk/LedgerSMB/Form.pm 2007-12-20 01:25:01 UTC (rev 1985)
@@ -1653,8 +1653,8 @@
my $where;
if ($transdate) {
$where = qq|
- AND (startdate IS NULL OR startdate <= ?)
- AND (enddate IS NULL OR enddate >= ?)|;
+ AND (c.startdate IS NULL OR c.startdate <= ?)
+ AND (c.enddate IS NULL OR c.enddate >= ?)|;
@queryargs = ( $transdate, $transdate );
}
@@ -1664,15 +1664,19 @@
$self->error('Invalid name source');
}
# Company name is stored in $self->{vendor} or $self->{customer}
+ if ($self->{"${table}number"} eq ''){
+ $self->{"${table}number"} = $self->{$table};
+ }
my $name = $self->like( lc $self->{$table} );
# Vendor and Customer are now views into entity_credit_account.
- my $query = qq|
- SELECT * FROM $table t
- JOIN entity e ON t.entity_id = e.id
- WHERE (lower(e.name) LIKE ? OR t.${table}number LIKE ?)
+ my $query = qq/
+ SELECT c.*, e.name FROM entity_credit_account c
+ JOIN entity e ON c.entity_id = e.id
+ WHERE (lower(e.name) LIKE ?
+ AND c.meta_number LIKE ?)
$where
- ORDER BY e.name|;
+ ORDER BY e.name/;
unshift( @queryargs, $name, $self->like($self->{"${table}number"}) );
my $sth = $self->{dbh}->prepare($query);
@@ -1726,16 +1730,17 @@
$self->{vc_class} = 2;
$vc = 'vendor';
}
- my $query = qq|SELECT count(*) FROM entity_credit_account where entity_class = ?|;
+ my $query = qq|SELECT count(*) FROM entity_credit_account ec
+ where ec.entity_class = ?|;
my $where;
my @queryargs2 = ($self->{vc_class});
my @queryargs;
if ($transdate) {
- $query .= qq| AND (startdate IS NULL OR startdate <= ?)
- AND (enddate IS NULL OR enddate >= ?)|;
- $where = qq| (startdate IS NULL OR startdate <= ?)
- AND (enddate IS NULL OR enddate >= ?)
- AND entity_class = ?|;
+ $query .= qq| AND (ec.startdate IS NULL OR ec.startdate <= ?)
+ AND (ec.enddate IS NULL OR ec.enddate >= ?)|;
+ $where = qq| (ec.startdate IS NULL OR ec.startdate <= ?)
+ AND (ec.enddate IS NULL OR ec.enddate >= ?)
+ AND ec.entity_class = ?|;
push (@queryargs, $transdate, $transdate, $self->{vc_class});
push (@queryargs2, $transdate, $transdate);
} else {
@@ -1755,21 +1760,15 @@
$self->{"${vc}_id"} *= 1;
- $query = qq|SELECT id, name
- FROM entity
- WHERE id IN (select entity_id
- FROM
- entity_credit_account
- WHERE
- $where)
+ # TODO: Alter this so that it pulls up the entity_credit_account
+ # instead of the entity_id. --CT
+ $query = qq|
+ SELECT ec.id, e.name
+ FROM entity e
+ JOIN entity_credit_account ec ON (ec.entity_id = e.id)
+ WHERE ec.id = ? OR $where
+ ORDER BY name|;
- UNION
-
- SELECT id,name
- FROM entity
- WHERE id = ?
- ORDER BY name|;
-
push( @queryargs, $self->{"${vc}_id"} );
$sth = $dbh->prepare($query);
@@ -2192,7 +2191,8 @@
$query = qq|
SELECT a.invnumber, a.transdate,
- a.entity_id, a.datepaid, a.duedate, a.ordnumber,
+ a.entity_credit_account AS entity_id,
+ a.datepaid, a.duedate, a.ordnumber,
a.taxincluded, a.curr AS currency, a.notes,
a.intnotes, ce.name AS $vc, a.department_id,
d.description AS department,
Modified: trunk/LedgerSMB/IR.pm
===================================================================
--- trunk/LedgerSMB/IR.pm 2007-12-20 00:07:59 UTC (rev 1984)
+++ trunk/LedgerSMB/IR.pm 2007-12-20 01:25:01 UTC (rev 1985)
@@ -760,7 +760,7 @@
ordnumber = ?,
quonumber = ?,
transdate = ?,
- vendor_id = ?,
+ entity_credit_account = ?,
amount = ?,
netamount = ?,
paid = ?,
Modified: trunk/LedgerSMB/IS.pm
===================================================================
--- trunk/LedgerSMB/IS.pm 2007-12-20 00:07:59 UTC (rev 1984)
+++ trunk/LedgerSMB/IS.pm 2007-12-20 01:25:01 UTC (rev 1985)
@@ -1412,7 +1412,7 @@
ordnumber = ?,
quonumber = ?,
transdate = ?,
- entity_id = ?,
+ entity_credit_account = ?,
amount = ?,
netamount = ?,
paid = ?,
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.