[wiaflos-devel] COMMIT - r282 - in trunk: . contrib/templates/reports wiaflos/server
svn at linuxrulz.org
svn at linuxrulz.org
Sat May 16 14:23:06 GMT 2009
Author: nkukard
Date: 2009-05-16 14:23:06 +0000 (Sat, 16 May 2009)
New Revision: 282
Modified:
trunk/TEMPLATES
trunk/contrib/templates/reports/balancesheet1.tt2
trunk/wiaflos/server/Reporting.pm
Log:
* Fixed up templating system
- Added more documentation
- Added support for the yearend transactions in reporting
Modified: trunk/TEMPLATES
===================================================================
--- trunk/TEMPLATES 2009-05-15 10:29:42 UTC (rev 281)
+++ trunk/TEMPLATES 2009-05-16 14:23:06 UTC (rev 282)
@@ -183,3 +183,147 @@
[%# placing the '#' immediately inside the directive
tag comments out the entire directive
%]
+
+
+
+VARIABLE FUNCTIONS:
+ api_variable_new($name,$type)
+ $name - variable name
+ $type - variable type, ONLY 'float' is currently supported!
+
+ api_variable_add($name,$value)
+ Add $value to variable named with $name
+
+ api_variable_subtract($name,$value)
+ Add $value to variable named with $name
+
+ api_variable_get($name)
+ Return the value of the variable
+ 'float' - formatted %.2f , 2 decimal places
+
+ api_variable_getraw($name)
+ Return raw value of the variable
+
+ api_bitwise_and($var1,$var2,$var3... $varN)
+ Bitwise all arguments
+
+
+
+CONSTANTS:
+ WiaflosString
+ Generated by Wiaflos string
+
+ StartDate
+ Start date of report, or "-" if there is no start date
+
+ EndDate
+ End date of report, or "CURRENT" if there is no end date
+
+
+
+FLAGS:
+ API_RPT_BALANCE_BF
+ Bitwise constant, this is a flag and will signify the backend to return a balance brought forward psuedo transaction
+
+ API_RPT_INCLUDE_YEAREND
+ Include yearend transactions , this is a flag and will signify the backend to return the hidden yearend transactions
+
+
+
+
+FUNCTIONS:
+
+ api_account_balances
+ Return a complex account balance structure
+ {'AccountBalances}{[ACCOUNT_NUMBER]} => hash of hashes {
+ Number - Account Number
+ Name - Account Name
+
+ DebitBalance - Debit balance for entire period
+ CreditBalance - Credit balance or entire period
+ Balance - Debit & credit or entire period
+
+ CreditAmount - Total of all credits for period
+ DebitAmount - Total of all debits for period
+ ReportWriterCategoryCode - Report writer category code
+
+ Children - Link to children accounts
+
+ If REPORT_BALANCE_BF is specified:
+ OpeningDebitBalance
+ OpeningCreditBalance
+ OpeningBalance
+ ClosingBalance
+ }
+ {'ReportWriterCategoryToAccounts'}{CATEGORY_CODE} => array of accounts above
+
+
+ api_gl_transactions
+ Return list of transactions
+ {'Transactions'} = array of hashes {
+ ID
+ TransactionDate
+ Reference
+ Entries = array of hashes {
+ ID
+ GLAccountID
+ GLAccountName
+ GLAccountNumber
+ Amount
+ Reference
+ }
+ }
+
+
+ api_account_entries
+ Return account entries
+ {'Account'} = hash {
+ ID
+ Number
+ ParentGLAccountID
+ Name
+ FinCatCode
+ FinCatDescription
+ RwCatCode
+ RwCatDescription
+ }
+ {'Entries'} = array (
+ ID
+ GLTransactionID
+ Reference
+ Amount
+ Balance
+ TransactionDate
+ TransactionReference
+ )
+
+
+
+ api_inventory_stock_balances
+ Return stock balances.
+
+ {'StockItemBalances'}->{[ITEM_CODE]}->{[ITEM_SERIAL]} = {
+ TotalQuantity - Total quantity of all items with this serial
+ TotalValue - Total value of all items with this serial
+ }
+
+ {'StockBalances'}->{[ITEM_CODE]} = {
+ TotalQuantity - Quantity of all items with this stock code
+ TotalValue - Value of all items with this stock code
+ }
+
+ {'TotalValue'} = Total floating point stock value
+
+
+
+ api_format_amount($amount,$options)
+ Format $amount according to the $options below:
+ API_FMT_REVERSE - bitwise option, reverse the amount before formatting (ie. multiply by -1)
+ API_FMT_NEGBRACKET - bitwise option, put negatives in brackets
+
+
+ api_dump($variable)
+ Dump to server console
+
+
+
Modified: trunk/contrib/templates/reports/balancesheet1.tt2
===================================================================
--- trunk/contrib/templates/reports/balancesheet1.tt2 2009-05-15 10:29:42 UTC (rev 281)
+++ trunk/contrib/templates/reports/balancesheet1.tt2 2009-05-16 14:23:06 UTC (rev 282)
@@ -8,7 +8,7 @@
<body>
[% # Pull account balances from backend
- SET data = api_account_balances(API_RPT_BALANCE_BF)
+ SET data = api_account_balances( api_bitwise_and(API_RPT_BALANCE_BF,API_RPT_INCLUDE_YEAREND) )
%]
<table id="page" width="100%">
Modified: trunk/wiaflos/server/Reporting.pm
===================================================================
--- trunk/wiaflos/server/Reporting.pm 2009-05-15 10:29:42 UTC (rev 281)
+++ trunk/wiaflos/server/Reporting.pm 2009-05-16 14:23:06 UTC (rev 282)
@@ -42,12 +42,14 @@
@ISA = qw(Exporter);
@EXPORT = qw(
REPORT_BALANCE_BF
+ REPORT_INCLUDE_YEAREND
);
@EXPORT_OK = ();
use constant {
REPORT_BALANCE_BF => 1,
+ REPORT_INCLUDE_YEAREND => 2,
};
@@ -87,12 +89,12 @@
#
# @param flags Flags of what we returned, options are below, use || (OR)
# @li REPORT_BALANCE_BF - Return balance brought forward for each account
+# @li REPORT_INCLUDE_YEAREND - Get balances and include yearend transactions
#
# @param data Parameter hash ref
# @li StartDate - Optional statement start date
# @li EndDate - Optional statement end date
# @li Levels - Optional depth to go into on each parent account
-# @li AccountNumberList - Optional list of account numbers to return balances for, comma/semicolon separated
#
# @returns Array ref of hash refs containing the accounts and their balances
# @li ID - Account ID
@@ -125,7 +127,13 @@
$search->{'StartDate'} = $data->{'StartDate'};
$search->{'EndDate'} = $data->{'EndDate'};
$search->{'Levels'} = $data->{'Levels'};
+ $search->{'Type'} = 1;
+ # Check if we must include yearend transactions
+ if (($flags & REPORT_INCLUDE_YEAREND) == REPORT_INCLUDE_YEAREND) {
+ $search->{'Type'} |= 2;
+ }
+
# Loop with the parent accounts, remember they're top level
foreach my $account (@{$res}) {
@@ -166,6 +174,7 @@
my $info;
$info->{'StartDate'} = $search->{'StartDate'};
$info->{'EndDate'} = $search->{'EndDate'};
+ $info->{'Type'} = $search->{'Type'};
$info->{'AccountID'} = $paccount->{'ID'};
# Get our own account balance
my $res = wiaflos::server::GL::getGLAccountBalance($info);
@@ -189,6 +198,7 @@
my $bfinfo;
$bfinfo->{'EndDate'} = $search->{'StartDate'};
$bfinfo->{'EndDateExcl'} = 1;
+ $bfinfo->{'Type'} = $search->{'Type'};
$bfinfo->{'AccountID'} = $paccount->{'ID'};
# Pull in balance brought forward
$res = wiaflos::server::GL::getGLAccountBalance($bfinfo);
@@ -520,7 +530,7 @@
# Generate closing balance entry
my $entry;
$entry->{'ID'} = -99;
- $entry->{'TransactionID'} = -99;
+ $entry->{'GLTransactionID'} = -99;
$entry->{'Reference'} = "* Closing Balance *";
$entry->{'Balance'} = sprintf('%.2f',$closingBalance->bstr());
$entry->{'TransactionDate'} = $detail->{'EndDate'};
@@ -696,6 +706,21 @@
}
+ # Reporting API function to logical AND all variables
+ sub api_bitwise_and
+ {
+ my @vars = @_;
+
+ # AND up all the values
+ my $res = 0;
+ foreach my $val (@vars) {
+ $res |= $val;
+ }
+
+ return $res;
+ }
+
+
# Dump contents of parameters on server
sub api_format_amount
{
@@ -758,6 +783,7 @@
# API
'api_account_balances' => \&api_account_balances,
'API_RPT_BALANCE_BF' => REPORT_BALANCE_BF,
+ 'API_RPT_INCLUDE_YEAREND' => REPORT_INCLUDE_YEAREND,
'api_account_entries' => \&api_account_entries,
@@ -769,6 +795,8 @@
'api_variable_subtract' => \&api_variable_subtract,
'api_variable_get' => \&api_variable_get,
'api_variable_getraw' => \&api_variable_getraw,
+
+ 'api_bitwise_and' => \&api_bitwise_and,
'api_format_amount' => \&api_format_amount,
'API_FMT_REVERSE' => API_FMT_REVERSE,
More information about the wiaflos-devel
mailing list