[wiaflos-devel] COMMIT - r265 - trunk/wiaflos/server
svn at linuxrulz.org
svn at linuxrulz.org
Thu Dec 25 07:29:26 GMT 2008
Author: nkukard
Date: 2008-12-25 07:29:26 +0000 (Thu, 25 Dec 2008)
New Revision: 265
Modified:
trunk/wiaflos/server/GL.pm
Log:
* Added StartDate, EndDate and AccountID optional params to getGLTransactions
Modified: trunk/wiaflos/server/GL.pm
===================================================================
--- trunk/wiaflos/server/GL.pm 2008-12-25 07:25:53 UTC (rev 264)
+++ trunk/wiaflos/server/GL.pm 2008-12-25 07:29:26 UTC (rev 265)
@@ -634,18 +634,59 @@
}
+## @fn getGLTransactions($data)
# Return an array of general ledger transactions
+#
+# @param data Parameter hash ref
+# @li AccountID Limit transactions to those relating to this account
+# @li StartDate Optional start date
+# @li EndDate Optional end date
+#
+# @returns Array ref of hash refs
+# @li ID GL entry ID
+# @li TransactionDate Transaction date
+# @li Reference GL entry reference
+# @li Posted 0 if unposted, 1 if posted
sub getGLTransactions
{
+ my $data = shift;
+
my @transactions = ();
+ # Extra SQL we may need
+ my $extraSQL = "";
+ my $extraTables = "";
+ my $extraEndSQL = "";
+
+ # Check if we have an account ID
+ if (defined($data->{'AccountID'}) && $data->{'AccountID'} > 0) {
+ $extraTables .= ", gl_entries";
+ $extraSQL .= "AND gl_entries.GLAccountID = ".DBQuote($data->{'AccountID'})." ";
+ $extraSQL .= "AND gl_entries.GLTransactionID = gl_transactions.ID ";
+ $extraEndSQL .= "GROUP BY gl_transactions.ID ";
+ }
+
+ # Check if we must use the start date
+ if (defined($data->{'StartDate'}) && $data->{'StartDate'} ne "") {
+ $extraSQL .= "AND gl_transactions.TransactionDate >= ".DBQuote($data->{'StartDate'})." ";
+ }
+ # Check if we must use the end date
+ if (defined($data->{'EndDate'}) && $data->{'EndDate'} ne "") {
+ $extraSQL .= "AND gl_transactions.TransactionDate <= ".DBQuote($data->{'EndDate'})." ";
+ }
+
# Return list of GL transactions
my $sth = DBSelect("
SELECT
- gl_transactions.ID, gl_transactions.TransactionDate, gl_transactions.Reference, gl_transactions.Posted
+ gl_transactions.ID, gl_transactions.TransactionDate, gl_transactions.Reference,
+ gl_transactions.Posted
FROM
- gl_transactions
+ gl_transactions $extraTables
+ WHERE
+ 1 = 1
+ $extraSQL
+ $extraEndSQL
");
if (!$sth) {
setError(wiaflos::server::dblayer::Error());
More information about the wiaflos-devel
mailing list