\section{LedgerSMB\label{LedgerSMB}\index{LedgerSMB}}


The Base class for many LedgerSMB objects, including DBObject.

\subsection*{SYNOPSIS\label{LedgerSMB_SYNOPSIS}\index{LedgerSMB!SYNOPSIS}}


This module creates a basic request handler with utility functions available
in database objects (LedgerSMB::DBObject)

\subsection*{METHODS\label{LedgerSMB_METHODS}\index{LedgerSMB!METHODS}}
\begin{description}

\item[{new ()}] \mbox{}

This method creates a new base request instance. It also validates the 
session/user credentials, as appropriate for the run mode.  Finally, it sets up 
the database connections for the user.


\item[{date\_to\_number (user =$>$ \$LedgerSMB::User,}] \textbf{date =$>$ \$string);}

This function takes the date in the format provided and returns a numeric 
string in YYMMDD format.  This may be moved to User in the future.


\item[{open\_form()}] \mbox{}

This sets a \$self-$>$\{form\_id\} to be used in later form validation (anti-XSRF 
measure).


\item[{check\_form()}] \mbox{}

This returns true if the form\_id was associated with the session, and false if 
not.  Use this if the form may be re-used (back-button actions are valid).


\item[{close\_form()}] \mbox{}

Identical with check\_form() above, but also removes the form\_id from the 
session.  This should be used when back-button actions are not valid.


\item[{debug (file =$>$ \$path);}] \mbox{}

This dumps the current object to the file if that is defined and otherwise to 
standard output.


\item[{escape (string =$>$ \$string);}] \mbox{}

This function returns the current string escaped using \%hexhex notation.


\item[{unescape (string =$>$ \$string);}] \mbox{}

This function returns the \$string encoded using \%hexhex using ordinary notation.


\item[{format\_amount (user =$>$ \$LedgerSMB::User::hash,}] \textbf{amount =$>$ \$string, precision =$>$ \$integer, neg\_format =$>$ (-$|$DRCR));}

The function takes a monetary amount and formats it according to the user 
preferences, the negative format (- or DR/CR).  Note that it may move to
LedgerSMB::User at some point in the future.


\item[{parse\_amount (user =$>$ \$LedgerSMB::User::hash,}] \textbf{amount =$>$ \$variable);}

If \$amount is a Bigfloat, it is returned as is.  If it is a string, it is 
parsed according to the user preferences stored in the LedgerSMB::User object.


\item[{is\_blank (name =$>$ \$string)}] \mbox{}

This function returns true if \$self-$>$\{\$string\} only consists of whitespace
characters or is an empty string.


\item[{is\_run\_mode ('(cli$|$cgi$|$mod\_perl)')}] \mbox{}

This function returns 1 if the run mode is what is specified.  Otherwise
returns 0.


\item[{is\_allowed\_role(\{allowed\_roles =$>$ @role\_names\})}] \mbox{}

This function returns 1 if the user's roles include any of the roles in
@role\_names.


\item[{num\_text\_rows (string =$>$ \$string, cols}] \textbf{=$>$ \$number, max =$>$ \$number);}

This function determines the likely number of rows needed to hold text in a 
textbox.  It returns either that number or max, which ever is lower.


\item[{merge (\$hashref, keys =$>$ @list, index}] \textbf{=$>$ \$number);}

This command merges the \$hashref into the current object.  If keys are 
specified, only those keys are used.  Otherwise all keys are merged.



If an index is specified, the merged keys are given a form of 
"\$key" . "\_\$index", otherwise the key is used on both sides.


\item[{redirect (msg =$>$ \$string)}] \mbox{}

This function redirects to the script and argument set determined by 
\$self-$>$\{callback\}, and if this is not set, goes to an info screen and prints
\$msg.


\item[{redo\_rows (fields =$>$ $\backslash$@list,}] \textbf{count =$>$ \$integer, [index =$>$ \$string);}

This function is undergoing serious redesign at the moment.  If index is 
defined, that field is used for ordering the rows.  If not, runningnumber is 
used.  Behavior is not defined when index points to a field containing 
non-numbers.


\item[{set (@attrs)}] \mbox{}

Copies the given key=$>$vars to \$self. Allows for finer control of 
merging hashes into self.


\item[{remove\_cgi\_globals()}] \mbox{}

Removes all elements starting with a . because these elements conflict with the
ability to hide the entire structure for things like CSV lookups.


\item[{get\_default\_value\_by\_key(\$key)}] \mbox{}

Retrieves a default value for the given key, it is just a wrapper on LedgerSMB::Setting;


\item[{call\_procedure( procname =$>$ \$procname,}] \textbf{args =$>$ \$args )}

Function that allows you to call a stored procedure by name and map the appropriate argument to the function values.



Args is an arrayref.  The members of args can be scalars or arrayrefs in which 
case they are just bound to the placeholders (arrayref to Pg array conversion
occurs automatically in DBD::Pg 2.x), or they can be hashrefs of the following
syntax: \{value =$>$ \$data, type=$>$ \$db\_type\}.  The type field is any SQL type 
DBD::Pg supports (such as 'PG\_BYTEA').


\item[{dberror()}] \mbox{}

Localizes and returns database errors and error codes within LedgerSMB


\item[{error()}] \mbox{}

Returns HTML errors in LedgerSMB. Needs refactored into a general Error class.


\item[{get\_user\_info()}] \mbox{}

Loads user configuration info from LedgerSMB::User


\item[{round\_amount()}] \mbox{}

Uses Math::Float with an amount and a set number of decimal places to round the amount and return it.



Defaults to the default decimal places setting in the LedgerSMB configuration if there is no places argument passed in.



They should be changed to allow different rules for different accounts.


\item[{sanitize\_for\_display()}] \mbox{}

Expands a hash into human-readable key =$>$ value pairs, and formats and rounds amounts, recursively expanding hashes until there are no hash members present.


\item[{take\_top\_level()}] \mbox{}

Removes blank keys and non-reference keys from a hash and returns a hash with only non-blank and referenced keys.


\item[{type()}] \mbox{}

Ensures that the \$ENV\{REQUEST\_METHOD\} is defined and either "HEAD", "GET", "POST".


\item[{finalize\_request()}] \mbox{}

This function throws a CancelFurtherProcessing exception to be caught
by the outermost processing script.  This construct allows the outer
script and intermediate levels to clean up, if required.



This construct replaces 'exit;' calls randomly scattered
around the code everywhere.

\end{description}
\subsection*{Copyright (C) 2006, The LedgerSMB core team.\label{LedgerSMB_Copyright_C_2006_The_LedgerSMB_core_team_}\index{LedgerSMB!Copyright (C) 2006, The LedgerSMB core team.}}
\begin{verbatim}
 # This work contains copyrighted information from a number of sources 
 # all used with permission.
 #
 # This file contains source code included with or based on SQL-Ledger
 # which is Copyright Dieter Simader and DWS Systems Inc. 2000-2005
 # and licensed under the GNU General Public License version 2 or, at
 # your option, any later version.  For a full list including contact
 # information of contributors, maintainers, and copyright holders, 
 # see the CONTRIBUTORS file.
 #
 # Original Copyright Notice from SQL-Ledger 2.6.17 (before the fork):
 # Copyright (C) 2000
 #
 #  Author: DWS Systems Inc.
 #     Web: http://www.sql-ledger.org
 #
 # Contributors: Thomas Bayen <bayen@gmx.de>
 #               Antti Kaihola <akaihola@siba.fi>
 #               Moritz Bunkus (tex)
 #               Jim Rawlings <jim@your-dba.com> (DB2)
 #====================================================================
=cut
\end{verbatim}


use CGI::Simple;
\$CGI::Simple::DISABLE\_UPLOADS = 0;
use LedgerSMB::PGNumber;
use LedgerSMB::PGDate;
use LedgerSMB::Sysconfig;
use Data::Dumper;
use Error;
use LedgerSMB::App\_State;
use LedgerSMB::Auth;
use LedgerSMB::Session;
use LedgerSMB::CancelFurtherProcessing;
use LedgerSMB::Template;
use LedgerSMB::Locale;
use LedgerSMB::User;
use LedgerSMB::Setting;
use LedgerSMB::Company\_Config;
use strict;
use utf8;



\$CGI::Simple::POST\_MAX = -1;



package LedgerSMB;
our \$VERSION = '1.3.999';



my \$logger = Log::Log4perl-$>$get\_logger('LedgerSMB');



sub new \{
    \#my \$type   = "" unless defined shift @\_;
    \#my \$argstr = "" unless defined shift @\_;
    (my \$package,my \$filename,my \$line)=caller;

\begin{verbatim}
    my $type   = shift @_;
    my $argstr = shift @_;
    my %cookie;
    my $self = {};
\end{verbatim}
\begin{verbatim}
    $type = "" unless defined $type;
    $argstr = "" unless defined $argstr;
\end{verbatim}
\begin{verbatim}
    $logger->debug("Begin called from \$filename=$filename \$line=$line \$type=$type \$argstr=$argstr ref argstr=".ref $argstr);
\end{verbatim}
\begin{verbatim}
    $self->{version} = $VERSION;
    $self->{dbversion} = "1.3.999";
\end{verbatim}
\begin{verbatim}
    bless $self, $type;
\end{verbatim}
\begin{verbatim}
    my $query;
    my %params=();
    if(ref($argstr) eq 'DBI::db')
    {
     $self->{dbh}=$argstr;
     $logger->info("setting dbh from argstr \$self->{dbh}=$self->{dbh}");
    }
    else
    {
     $query = ($argstr) ? new CGI::Simple($argstr) : new CGI::Simple;
     # my $params = $query->Vars; returns a tied hash with keys that
     # are not parameters of the CGI query.
     %params = $query->Vars;
     for my $p(keys %params){
         utf8::decode($params{$p});
         utf8::upgrade($params{$p});
     }
     $logger->debug("params=", Data::Dumper::Dumper(\%params));
    }
    $self->{VERSION} = $VERSION;
    $self->{_request} = $query;
\end{verbatim}
\begin{verbatim}
    $self->merge(\%params);
    $self->{have_latex} = $LedgerSMB::Sysconfig::latex;
\end{verbatim}
\begin{verbatim}
    # Adding this so that empty values are stored in the db as NULL's.  If
    # stored procedures want to handle them differently, they must opt to do so.
    # -- CT
    for (keys %$self){
        if ($self->{$_} eq ''){
            $self->{$_} = undef;
        }
    }
\end{verbatim}
\begin{verbatim}
    if ($self->is_run_mode('cgi', 'mod_perl')) {
        $ENV{HTTP_COOKIE} =~ s/;\s*/;/g;
        my @cookies = split /;/, $ENV{HTTP_COOKIE};
        foreach (@cookies) {
            my ( $name, $value ) = split /=/, $_, 2;
            $cookie{$name} = $value;
        }
    }
    #HV set _locale already to default here,so routines lower in stack can use it;e.g. login.pl
    $self->{_locale}=LedgerSMB::Locale->get_handle(${LedgerSMB::Sysconfig::language})
      or $self->error( __FILE__ . ':' . __LINE__ .": Locale not loaded: $!\n" );
\end{verbatim}
\begin{verbatim}
    $self->{action} = "" unless defined $self->{action};
    $self->{action} =~ s/\W/_/g;
    $self->{action} = lc $self->{action};
\end{verbatim}
\begin{verbatim}
    $self->{path} = "" unless defined $self->{path};
\end{verbatim}
\begin{verbatim}
    if ( $self->{path} eq "bin/lynx" ) {
        $self->{menubar} = 1;
\end{verbatim}
\begin{verbatim}
        # Applying the path is deprecated.  Use menubar instead.  CT.
        $self->{lynx} = 1;
        $self->{path} = "bin/lynx";
    }
    else {
        $self->{path} = "bin/mozilla";
\end{verbatim}
\begin{verbatim}
    }
\end{verbatim}
\begin{verbatim}
    $ENV{SCRIPT_NAME} = "" unless defined $ENV{SCRIPT_NAME};
\end{verbatim}
\begin{verbatim}
    $ENV{SCRIPT_NAME} =~ m/([^\/\\]*.pl)\?*.*$/;
    $self->{script} = $1 unless !defined $1;
    $self->{script} = "" unless defined $self->{script};
\end{verbatim}
\begin{verbatim}
    if ( ( $self->{script} =~ m#(\.\.|\\|/)# ) ) {
        $self->error("Access Denied");
    }
    if (!$self->{script}) {
        $self->{script} = 'login.pl';
    }
    $logger->debug("\$self->{script} = $self->{script} \$self->{action} = $self->{action}");
#    if ($self->{action} eq 'migrate_user'){
#        return $self;
#    }
\end{verbatim}
\begin{verbatim}
    # This is suboptimal.  We need to have a better way for 1.4
    #HV we should try to have DBI->connect in one place?
    #HV  why not trying _db_init also in case of login authenticate? quid logout-function?
    if ($self->{script} eq 'login.pl' &&
        ($self->{action} eq 'authenticate'  || $self->{action} eq '__default' 
                || !$self->{action})){
        return $self;
    }
    if ($self->{script} eq 'setup.pl'){
        return $self;
    }
    my $ccookie;
    if (!$self->{company} && $self->is_run_mode('cgi', 'mod_perl')){
         $ccookie = $cookie{${LedgerSMB::Sysconfig::cookie_name}};
         $ccookie =~ s/.*:([^:]*)$/$1/;
         if($ccookie ne 'Login') { $self->{company} = $ccookie; } 
    }
    $logger->debug("\$ccookie=$ccookie cookie.LedgerSMB::Sysconfig::cookie_name=".$cookie{${LedgerSMB::Sysconfig::cookie_name}}." \$self->{company}=$self->{company}");
\end{verbatim}
\begin{verbatim}
    if(! $cookie{${LedgerSMB::Sysconfig::cookie_name}} && $self->{action} eq 'logout')
    {
     $logger->debug("quitting because of logout and no cookie,avoid _db_init");
     return $self;
    }
\end{verbatim}
\begin{verbatim}
    #dbh may have been set elsewhere,by DBObject.pm?
    if(!$self->{dbh})
    {
     $self->_db_init;
    }
    LedgerSMB::Company_Config::initialize($self);
\end{verbatim}
\begin{verbatim}
    #TODO move before _db_init to avoid _db_init with invalid session?
    #  Can't do that:  Company_Config has to pull company data from the db --CT
    if ($self->is_run_mode('cgi', 'mod_perl') and !$ENV{LSMB_NOHEAD}) {
       #check for valid session unless this is an inital authentication
       #request -- CT
       if (!LedgerSMB::Session::check( $cookie{${LedgerSMB::Sysconfig::cookie_name}}, $self) ) {
            $logger->error("Session did not check");
            $self->_get_password("Session Expired");
            exit;
       }
       $logger->debug("session_check completed OK \$self->{session_id}=$self->{session_id} caller=\$filename=$filename \$line=$line");
    }
    $self->get_user_info;
\end{verbatim}
\begin{verbatim}
    my %date_setting = (
        'mm/dd/yy' => "SQL, US",
        'mm-dd-yy' => "POSTGRES, US",
        'dd/mm/yy' => "SQL, EUROPEAN",
        'dd-mm-yy' => "POSTGRES, EUROPEAN",
        'dd.mm.yy' => "GERMAN",
    );
\end{verbatim}
\begin{verbatim}
    $self->{dbh}->do("set DateStyle to '".$date_setting{$self->{_user}->{dateformat}}."'");
    #my $locale   = LedgerSMB::Locale->get_handle($self->{_user}->{language})
    # or $self->error(__FILE__.':'.__LINE__.": Locale not loaded: $!\n");
    #$self->{_locale} = $locale;
    $self->{_locale}=LedgerSMB::Locale->get_handle($self->{_user}->{language})
     or $self->error(__FILE__.':'.__LINE__.": Locale not loaded: $!\n");
\end{verbatim}
\begin{verbatim}
    $self->{stylesheet} = $self->{_user}->{stylesheet};
\end{verbatim}
\begin{verbatim}
    $logger->debug("End");
\end{verbatim}
\begin{verbatim}
    return $self;
\end{verbatim}


\}



sub open\_form \{
    my (\$self, \$args) = @\_;
    if (!\$ENV\{GATEWAY\_INTERFACE\})\{
        return 1;
    \}
    my @vars = \$self-$>$call\_procedure(procname =$>$ 'form\_open', 
                              args =$>$ [\$self-$>$\{session\_id\}],
                              continue\_on\_error =$>$ 1
    );
    if (\$args-$>$\{commit\})\{
       \$self-$>$\{dbh\}-$>$commit;
    \}
    \$self-$>$\{form\_id\} = \$vars[0]-$>$\{form\_open\};
\}



sub check\_form \{
    my (\$self) = @\_;
    if (!\$ENV\{GATEWAY\_INTERFACE\})\{
        return 1;
    \}
    my @vars = \$self-$>$call\_procedure(procname =$>$ 'form\_check', 
                              args =$>$ [\$self-$>$\{session\_id\}, \$self-$>$\{form\_id\}]
    );
    return \$vars[0]-$>$\{form\_check\};
\}



sub close\_form \{
    my (\$self) = @\_;
    if (!\$ENV\{GATEWAY\_INTERFACE\})\{
        return 1;
    \}
    my @vars = \$self-$>$call\_procedure(procname =$>$ 'form\_close', 
                              args =$>$ [\$self-$>$\{session\_id\}, \$self-$>$\{form\_id\}]
    );
    delete \$self-$>$\{form\_id\};
    return \$vars[0]-$>$\{form\_close\};
\}



sub get\_user\_info \{
    my (\$self) = @\_;
    \$self-$>$\{\_user\} = LedgerSMB::User-$>$fetch\_config(\$self);
\}
\#This function needs to be moved into the session handler.
sub \_get\_password \{
    my (\$self) = shift @\_;
    \$self-$>$\{sessionexpired\} = shift @\_;
    LedgerSMB::Auth::credential\_prompt();
    exit;
\}



sub debug \{
    my \$self = shift @\_;
    my \$args = shift @\_;
    my \$file;
    if (scalar keys \%\$args)\{
        \$file = \$args-$>$\{'file'\};
    \}
    my \$d    = Data::Dumper-$>$new( [\$self] );
    \$d-$>$Sortkeys(1);

\begin{verbatim}
    if ($file) {
        open( FH, '>', "$file" ) or die $!;
        print FH $d->Dump();
        close(FH);
    }
    else {
        print "\n";
        print $d->Dump();
    }
\end{verbatim}


\}



sub escape \{
    my \$self = shift;
    my \%args = @\_;
    my \$str  = \$args\{string\};
    \$str = "" unless defined \$str;

\begin{verbatim}
    my $regex = qr/([^a-zA-Z0-9_.-])/;
    $str =~ s/$regex/sprintf("%%%02x", ord($1))/ge;
    return $str;
}
\end{verbatim}


sub is\_blank \{
    my \$self = shift @\_;
    my \%args = @\_;
    my \$name = \$args\{name\};
    my \$rc;

\begin{verbatim}
    if (not defined $name){
        $self->{_locale} = LedgerSMB::Locale->get_handle('en') unless defined $self->{_locale};
        $self->error($self->{_locale}->text('Field \"Name\" Not Defined'));
    }
\end{verbatim}
\begin{verbatim}
    if ( $self->{$name} =~ /^\s*$/ ) {
        $rc = 1;
    }
    else {
        $rc = 0;
    }
    $rc;
}
\end{verbatim}


sub is\_run\_mode \{
    my \$self = shift @\_;
    \#avoid 'uninitialized' warnings in tests
    my \$mode = shift @\_;
    my \$rc   = 0;
    if(! \$mode)\{return \$rc;\}
    \$mode=lc \$mode;
    if ( \$mode eq 'cgi' \&\& \$ENV\{GATEWAY\_INTERFACE\} ) \{
        \$rc = 1;
    \}
    elsif ( \$mode eq 'cli' \&\& !( \$ENV\{GATEWAY\_INTERFACE\} $|$$|$ \$ENV\{MOD\_PERL\} ) ) \{
        \$rc = 1;
    \}
    elsif ( \$mode eq 'mod\_perl' \&\& \$ENV\{MOD\_PERL\} ) \{
        \$rc = 1;
    \}
    \$rc;
\}



sub num\_text\_rows \{
    my \$self    = shift @\_;
    my \%args    = @\_;
    my \$string  = \$args\{string\};
    my \$cols    = \$args\{cols\};
    my \$maxrows = \$args\{max\};

\begin{verbatim}
    my $rows = 0;
\end{verbatim}
\begin{verbatim}
    for ( split /\n/, $string ) {
        my $line = $_;
        while ( length($line) > $cols ) {
            my $fragment = substr( $line, 0, $cols + 1 );
            $fragment =~ s/^(.*)\W.*$/$1/;
            $line =~ s/$fragment//;
            if ( $line eq $fragment ) {    # No word breaks!
                $line = "";
            }
            ++$rows;
        }
        ++$rows;
    }
\end{verbatim}
\begin{verbatim}
    if ( !defined $maxrows ) {
        $maxrows = $rows;
    }
\end{verbatim}
\begin{verbatim}
    return ( $rows > $maxrows ) ? $maxrows : $rows;
\end{verbatim}


\}



sub redirect \{
    my \$self = shift @\_;
    my \%args = @\_;
    my \$msg  = \$args\{msg\};

\begin{verbatim}
    if ( $self->{callback} || !$msg ) {
\end{verbatim}
\begin{verbatim}
        main::redirect();
        exit;
    }
    else {
\end{verbatim}
\begin{verbatim}
        $self->info($msg);
    }
}
\end{verbatim}


\# TODO:  Either we should have an amount class with formats and such attached
\# Or maybe we should move this into the user class...
sub format\_amount \{

\begin{verbatim}
    # Based on SQL-Ledger's Form::format_amount
    my $self     = shift @_;
    my %args  = (ref($_[0]) eq 'HASH')? %{$_[0]}: @_;
    my $myconfig = $args{user} || $self->{_user};
    my $amount   = $args{amount};
    my $places   = $args{precision};
    my $dash     = $args{neg_format};
    my $format   = $args{format};
\end{verbatim}
\begin{verbatim}
    if (defined $amount and ! UNIVERSAL::isa($amount, 'LedgerSMB::PGNumber' )) {
        $amount = $self->parse_amount('user' => $myconfig, 'amount' => $amount);
    }
    $dash = undef unless defined $dash;
\end{verbatim}
\begin{verbatim}
    if (!defined $format){
       $format = $myconfig->{numberformat}
    }
    if (!defined $amount){
        return undef;
    }
    if (!defined $args{precision} and defined $args{money}){
       $places = $LedgerSMB::Sysconfig::decimal_places;
    }
\end{verbatim}
\begin{verbatim}
    return $amount->to_output({format => $format, 
                           neg_format => $args{neg_format}, 
                               places => $places,
                                money => $args{money},
           });
}
\end{verbatim}


\# For backwards compatibility only
sub parse\_amount \{
    my \$self     = shift @\_;
    my \%args     = @\_;
    my \$amount   = \$args\{amount\};
    my \$user     = (\$args\{user\})? (\$args\{user\}) : \$self-$>$\{\_user\};
    if (UNIVERSAL::isa(\$amount, 'LedgerSMB::PGNumber'))\{
        return \$amount;
    \} 
    return LedgerSMB::PGNumber-$>$from\_input(\$amount, 
                                     \{format =$>$ \$user-$>$\{numberformat\}\}
    ); 
\}



sub round\_amount \{

\begin{verbatim}
    my ( $self, $amount, $places ) = @_;
\end{verbatim}
\begin{verbatim}
    #
    # We will grab the default value, if it isnt defined
    #
    if (!defined $places){
       $places = ${LedgerSMB::Sysconfig::decimal_places};
    }
\end{verbatim}
\begin{verbatim}
    # These rounding rules follow from the previous implementation.
    # They should be changed to allow different rules for different accounts.
    if ($amount >= 0) {
        Math::BigFloat->round_mode('+inf');
    } 
    else {
        Math::BigFloat->round_mode('-inf');
    }
\end{verbatim}
\begin{verbatim}
    if ($places >= 0) {
        $amount = Math::BigFloat->new($amount)->ffround( -$places );
    } 
    else {
        $amount = Math::BigFloat->new($amount)->ffround( -( $places - 1 ) );
    } 
    $amount->precision(undef);
\end{verbatim}
\begin{verbatim}
    return $amount;
}
\end{verbatim}


sub call\_procedure \{
    my \$self     = shift @\_;
    my \%args     = @\_;
    my \$procname = \$args\{procname\};
    my \$schema   = \$args\{schema\};
    my @call\_args;
    @call\_args = @\{ \$args\{args\} \} if defined \$args\{args\};
    my \$order\_by = \$args\{order\_by\};
    my \$query\_rc;
    my \$argstr   = "";
    my @results;
    my \$dbh = \$LedgerSMB::App\_State::DBH;
    \$dbh $|$$|$= \$self-$>$\{dbh\};
    die 'Database handle not found!' if !\$dbh;

\begin{verbatim}
    if (!defined $procname){
        $self->error('Undefined function in call_procedure.');
    }
    $procname = $dbh->quote_identifier($procname);
    # Add the test for whether the schema is something useful.
    $logger->trace("\$procname=$procname");
\end{verbatim}
\begin{verbatim}
    $schema = $schema || $LedgerSMB::Sysconfig::db_namespace;
\end{verbatim}
\begin{verbatim}
    $schema = $dbh->quote_identifier($schema);
\end{verbatim}
\begin{verbatim}
    for my $arg ( @call_args ) {
        if (eval { $arg->can('to_db') }){
           $arg = $arg->to_db;
        }
        $argstr .= "?, ";
    }
    $argstr =~ s/\, $//;
    my $query = "SELECT * FROM $schema.$procname()";
    if ($order_by){
        $query .= " ORDER BY $order_by";
    }
    $query =~ s/\(\)/($argstr)/;
    my $sth = $dbh->prepare($query);
    my $place = 1;
    # API Change here to support byteas:  
    # If the argument is a hashref, allow it to define it's SQL type
    # for example PG_BYTEA, and use that to bind.  The API supports the old
    # syntax (array of scalars and arrayrefs) but extends this so that hashrefs
    # now have special meaning. I expect this to be somewhat recursive in the
    # future if hashrefs to complex types are added, but we will have to put 
    # that off for another day. --CT
    foreach my $carg (@call_args){
        if (ref($carg) eq 'HASH'){
            $sth->bind_param($place, $carg->{value}, 
                       { pg_type => $carg->{type} });
        } else {
            $sth->bind_param($place, $carg);
        }
        ++$place;
    }
    $query_rc = $sth->execute();
    if (!$query_rc){
          if ($args{continue_on_error} and  #  only for plpgsql exceptions
                          ($dbh->state =~ /^P/)){
                $@ = $dbh->errstr;
          } else {
                $self->dberror($dbh->errstr . ": " . $query);
          }
    }
\end{verbatim}
\begin{verbatim}
    my @types = @{$sth->{TYPE}};
    my @names = @{$sth->{NAME_lc}};
    while ( my $ref = $sth->fetchrow_hashref('NAME_lc') ) {
        for (0 .. $#names){
            #   numeric            float4/real
            if ($types[$_] == 3 or $types[$_] == 2) {
                $ref->{$names[$_]} = LedgerSMB::PGNumber->from_db($ref->{$names[$_]}, 'datetime') if defined $ref->{$names[$_]};
            }
            #    DATE                TIMESTAMP
            if ($types[$_] == 91 or $types[$_] == 11){
                $ref->{$names[$_]} = LedgerSMB::PGDate->from_db($ref->{$names[$_]}, 'date') if defined $ref->{$names[$_]};
            }
        }
        push @results, $ref;
    }
    return @results;
}
\end{verbatim}


\# Keeping this here due to common requirements
sub is\_allowed\_role \{
    my (\$self, \$args) = @\_;
    my @roles = @\{\$args-$>$\{allowed\_roles\}\};
    for my \$role (@roles)\{
        \$self-$>$\{\_role\_prefix\} = "lsmb\_\$self-$>$\{company\}\_\_" unless defined \$self-$>$\{\_role\_prefix\};
        my @roleset = grep m/\^{}\$self-$>$\{\_role\_prefix\}\$role\$/, @\{\$self-$>$\{\_roles\}\};
        if (scalar @roleset)\{
            return 1;
        \}
    \}
    return 0; 
\}



\# This should probably be moved to User too...
sub date\_to\_number \{

\begin{verbatim}
    #based on SQL-Ledger's Form::datetonum
    my $self     = shift @_;
    my %args     = @_;
    my $myconfig = $args{user};
    my $date     = $args{date};
\end{verbatim}
\begin{verbatim}
    $date = "" unless defined $date;
\end{verbatim}
\begin{verbatim}
    my ( $yy, $mm, $dd );
    if ( $date ne "" && $date && $date =~ /\D/ ) {
\end{verbatim}
\begin{verbatim}
        if ( $date =~ /^\d{4}-\d\d-\d\d$/ ) {
            ( $yy, $mm, $dd ) = split /\D/, $date;
        } elsif ( $myconfig->{dateformat} =~ /^yy/ ) {
            ( $yy, $mm, $dd ) = split /\D/, $date;
        } elsif ( $myconfig->{dateformat} =~ /^mm/ ) {
            ( $mm, $dd, $yy ) = split /\D/, $date;
        } elsif ( $myconfig->{dateformat} =~ /^dd/ ) {
            ( $dd, $mm, $yy ) = split /\D/, $date;
        }
\end{verbatim}
\begin{verbatim}
        $dd *= 1;
        $mm *= 1;
        $yy += 2000 if length $yy == 2;
\end{verbatim}
\begin{verbatim}
        $dd = substr( "0$dd", -2 );
        $mm = substr( "0$mm", -2 );
\end{verbatim}
\begin{verbatim}
        $date = "$yy$mm$dd";
    }
\end{verbatim}
\begin{verbatim}
    $date;
}
\end{verbatim}


sub sanitize\_for\_display \{
    my \$self = shift;
    my \$var = shift;
    \$self-$>$error('Untested API');
    if (!\$var)\{ 
	\$var = \$self;
    \}
    for my \$k (keys \%\$var)\{
	my \$type = ref(\$var);
	if (UNIVERSAL::isa(\$var-$>$\{\$k\}, 'Math::BigFloat'))\{
              \$var-$>$\{\$k\} = 
                  \$self-$>$format\_amount(\{amount =$>$ \$var-$>$\{\$k\}\});
	\}
	elsif (\$type == 'HASH')\{
               \$self-$>$sanitize\_for\_display(\$var-$>$\{\$k\});
        \}
    \}



\}



sub finalize\_request \{
    \$logger-$>$debug("throwing CancelFurtherProcessing()");\#if trying to follow flow of request
    throw CancelFurtherProcessing();
\}



\# To be replaced with a generic interface to an Error class
sub error \{

\begin{verbatim}
    my ( $self, $msg ) = @_;
\end{verbatim}
\begin{verbatim}
    if ( $ENV{GATEWAY_INTERFACE} ) {
\end{verbatim}
\begin{verbatim}
        $self->{msg}    = $msg;
        $self->{format} = "html";
        $logger->error($msg);
        $logger->error("dbversion: $self->{dbversion}, company: $self->{company}");
\end{verbatim}
\begin{verbatim}
        delete $self->{pre};
\end{verbatim}
\begin{verbatim}
        print qq|Content-Type: text/html; charset=utf-8\n\n|;
        print "<head><link rel='stylesheet' href='css/$self->{_user}->{stylesheet}' type='text/css'></head>";
        $self->{msg} =~ s/\n/<br \/>\n/;
        print
          qq|<body><h2 class="error">Error!</h2> <p><b>$self->{msg}</b></p>
             <p>dbversion: $self->{dbversion}, company: $self->{company}</p>
             </body>|;
\end{verbatim}
\begin{verbatim}
        exit;
\end{verbatim}
\begin{verbatim}
    }
    else {
\end{verbatim}
\begin{verbatim}
        if ( $ENV{error_function} ) {
            &{ $ENV{error_function} }($msg);
        }
        die "Error: $msg\n";
    }
}
# Database routines used throughout
\end{verbatim}


sub \_db\_init \{
    my \$self     = shift @\_;
    my \%args     = @\_;
    (my \$package,my \$filename,my \$line)=caller;
    if(\$self-$>$\{dbh\})
    \{
     \$logger-$>$error("dbh already set $\backslash$\$self-$>$\{dbh\}=\$self-$>$\{dbh\},called from \$filename");
    \}

\begin{verbatim}
    my $creds = LedgerSMB::Auth::get_credentials();
\end{verbatim}
\begin{verbatim}
    $self->{login} = $creds->{login};
    if (!$self->{company}){ 
        $self->{company} = $LedgerSMB::Sysconfig::default_db;
    }
    my $dbname = $self->{company};
\end{verbatim}
\begin{verbatim}
    # Note that we have to request the login/password again if the db
    # connection fails since this probably means bad credentials are entered.
    # Just in case, however, I think it is a good idea to include the DBI
    # error string.  CT
    $self->{dbh} = DBI->connect(
        "dbi:Pg:dbname=$dbname", "$creds->{login}", "$creds->{password}", { AutoCommit => 0 }
    ); 
    $logger->debug("DBI->connect dbh=$self->{dbh}");
    my $dbi_trace=$LedgerSMB::Sysconfig::DBI_TRACE;
    if($dbi_trace)
    {
     $logger->debug("\$dbi_trace=$dbi_trace");
     $self->{dbh}->trace(split /=/,$dbi_trace,2);#http://search.cpan.org/~timb/DBI-1.616/DBI.pm#TRACING
    }
\end{verbatim}
\begin{verbatim}
    if (($self->{script} eq 'login.pl') && ($self->{action} eq 
        'authenticate')){
        if (!$self->{dbh}){
            $self->{_auth_error} = $DBI::errstr;
        }
        return;
    }
    elsif (!$self->{dbh}){
        $self->_get_password;
    }
    $self->{dbh}->{pg_server_prepare} = 0;
    $self->{dbh}->{pg_enable_utf8} = 1;
    $LedgerSMB::App_State::DBH = $self->{dbh};
    $LedgerSMB::App_State::DBName = $dbname;
\end{verbatim}
\begin{verbatim}
    # This is the general version check
    my $sth = $self->{dbh}->prepare("
            SELECT value FROM defaults 
             WHERE setting_key = 'version'");
    $sth->execute;
    my ($dbversion) = $sth->fetchrow_array;
    $sth = $self->{dbh}->prepare("
            SELECT value FROM defaults 
             WHERE setting_key = 'role_prefix'");
    $sth->execute;
\end{verbatim}
\begin{verbatim}
    ($self->{_role_prefix}) = $sth->fetchrow_array;
    if ($dbversion ne $self->{dbversion}){
        $self->error("Database is not the expected version.  Was $dbversion, expected $self->{dbversion}.  Please re-run setup.pl against this database to correct.<a href='setup.pl'>setup.pl</a>");
    }
\end{verbatim}
\begin{verbatim}
    $sth = $self->{dbh}->prepare('SELECT check_expiration()');
    $sth->execute;
    ($self->{warn_expire}) = $sth->fetchrow_array;
\end{verbatim}
\begin{verbatim}
    if ($self->{warn_expire}){
        $sth = $self->{dbh}->prepare('SELECT user__check_my_expiration()');
        $sth->execute;
        ($self->{pw_expires})  = $sth->fetchrow_array;
    }
\end{verbatim}
\begin{verbatim}
    my $query = "SELECT t.extends, 
                        coalesce (t.table_name, 'custom_' || extends) 
                        || ':' || f.field_name as field_def
                FROM custom_table_catalog t
                JOIN custom_field_catalog f USING (table_id)";
    $sth = $self->{dbh}->prepare($query);
    $sth->execute;
    my $ref;
    $self->{custom_db_fields} = {};
    while ( $ref = $sth->fetchrow_hashref('NAME_lc') ) {
        push @{ $self->{custom_db_fields}->{ $ref->{extends} } },
          $ref->{field_def};
    }
\end{verbatim}
\begin{verbatim}
    # Adding role list to self 
    $self->{_roles} = [];
    $query = "select rolname from pg_roles 
               where pg_has_role(SESSION_USER, 'USAGE')";
    $sth = $self->{dbh}->prepare($query);
    $sth->execute();
    while (my @roles = $sth->fetchrow_array){
        push @{$self->{_roles}}, $roles[0];
    }
\end{verbatim}
\begin{verbatim}
    $LedgerSMB::App_State::Roles = @{$self->{_roles}};
    $LedgerSMB::App_State::Role_Prefix = $self->{_role_prefix};
    # @{$self->{_roles}} will eventually go away. --CT
\end{verbatim}
\begin{verbatim}
    $sth->finish();
    $logger->debug("end");
}
\end{verbatim}


\#private, for db connection errors
sub \_on\_connection\_error \{
    for (@\_)\{
        \$logger-$>$error("\$\_");
    \}
\}



sub dberror\{
   my \$self = shift @\_;
   my \$state\_error = \{\};
   my \$locale = \$LedgerSMB::App\_State::Locale;
   my \$dbh = \$LedgerSMB::App\_State::DBH;
   \$state\_error = \{
            '42883' =$>$ \$locale-$>$text('Internal Database Error'),
            '42501' =$>$ \$locale-$>$text('Access Denied'),
            '42401' =$>$ \$locale-$>$text('Access Denied'),
            '22008' =$>$ \$locale-$>$text('Invalid date/time entered'),
            '22012' =$>$ \$locale-$>$text('Division by 0 error'),
            '22004' =$>$ \$locale-$>$text('Required input not provided'),
            '23502' =$>$ \$locale-$>$text('Required input not provided'),
            '23505' =$>$ \$locale-$>$text('Conflict with Existing Data.  Perhaps you already entered this?'),
            'P0001' =$>$ \$locale-$>$text('Error from Function:') . "$\backslash$n" .
                    \$dbh-$>$errstr,
   \};
   \$logger-$>$error("Logging SQL State ".\$dbh-$>$state.", error ".
           \$dbh-$>$err . ", string " .\$dbh-$>$errstr);
   if (defined \$state\_error-$>$\{\$dbh-$>$state\})\{
       die \$state\_error-$>$\{\$dbh-$>$state\}
           . "$\backslash$n" . 
          \$locale-$>$text('More information has been reported in the error logs');
       \$dbh-$>$rollback;
       exit;
   \}
   die \$dbh-$>$state . ":" . \$dbh-$>$errstr;
\}



sub redo\_rows \{

\begin{verbatim}
    my $self  = shift @_;
    my %args  = @_;
    my @flds  = @{ $args{fields} };
    my $count = $args{count};
    my $index = ( $args{index} ) ? $args{index} : 'runningnumber';
\end{verbatim}
\begin{verbatim}
    my @rows;
    my $i;    # increment counter use only
    for $i ( 1 .. $count ) {
        my $temphash = { _inc => $i };
        for my $fld (@flds) {
            $temphash->{$fld} = $self->{ "$fld" . "_$i" };
        }
        push @rows, $temphash;
    }
    $i = 1;
    for my $row ( sort { $a->{$index} <=> $b->{$index} } @rows ) {
        for my $fld (@flds) {
            $self->{ "$fld" . "_$i" } = $row->{$fld};
        }
        ++$i;
    }
}
\end{verbatim}


sub merge \{
    (my \$package,my \$filename,my \$line)=caller;
    my ( \$self, \$src ) = @\_;
    \$logger-$>$debug("begin caller $\backslash$\$filename=\$filename $\backslash$\$line=\$line");
       \# Removed dbh from logging string since not used on this api call and
       \# not initialized in test cases -CT
    for my \$arg ( \$self, \$src ) \{
        shift;
    \}
    my \%args  = @\_;
    my @keys;
    if (defined \$args\{keys\})\{
         @keys  = @\{ \$args\{keys\} \};
    \}
    my \$index = \$args\{index\};
    if ( !scalar @keys ) \{
        @keys = keys \%\{\$src\};
    \}
    for my \$arg ( @keys ) \{
        my \$dst\_arg;
        if (\$index) \{
            \$dst\_arg = \$arg . "\_\$index";
        \}
        else \{
            \$dst\_arg = \$arg;
        \}
        if ( defined \$dst\_arg \&\& defined \$src-$>$\{\$arg\} )
        \{
            \$logger-$>$trace("LedgerSMB.pm: merge setting \$dst\_arg to \$src-$>$\{\$arg\}");
        \}
        elsif ( !defined \$dst\_arg \&\& defined \$src-$>$\{\$arg\} )
        \{
            \$logger-$>$trace("LedgerSMB.pm: merge setting $\backslash$\$dst\_arg is undefined $\backslash$\$src-$>$\{$\backslash$\$arg\} is defined \$src-$>$\{\$arg\}");
        \}
        elsif ( defined \$dst\_arg \&\& !defined \$src-$>$\{\$arg\} )
        \{
            \$logger-$>$trace("LedgerSMB.pm: merge setting $\backslash$\$dst\_arg is defined \$dst\_arg $\backslash$\$src-$>$\{$\backslash$\$arg\} is undefined");
        \}
        elsif ( !defined \$dst\_arg \&\& !defined \$src-$>$\{\$arg\} )
        \{
            \$logger-$>$trace("LedgerSMB.pm: merge setting $\backslash$\$dst\_arg is undefined $\backslash$\$src-$>$\{$\backslash$\$arg\} is undefined");
        \}
        \$self-$>$\{\$dst\_arg\} = \$src-$>$\{\$arg\};
    \}
    \$logger-$>$debug("end caller $\backslash$\$filename=\$filename $\backslash$\$line=\$line");
\}



sub type \{

\begin{verbatim}
    my $self = shift @_;
\end{verbatim}
\begin{verbatim}
    if (!$ENV{REQUEST_METHOD} or 
        ( !grep {$ENV{REQUEST_METHOD} eq $_} ("HEAD", "GET", "POST") ) ) {
\end{verbatim}
\begin{verbatim}
        $self->error("Request method unset or set to unknown value");
    }
\end{verbatim}
\begin{verbatim}
    return $ENV{REQUEST_METHOD};
}
\end{verbatim}


sub DESTROY \{\}



sub set \{

\begin{verbatim}
    my $self = shift @_;
    my %args = @_;
\end{verbatim}
\begin{verbatim}
    for my $arg (keys(%args)) {
        $self->{$arg} = $args{$arg};
    }
    return 1;
\end{verbatim}


\}



sub remove\_cgi\_globals \{
    my (\$self) = @\_;
    for my \$key (keys \%\$self)\{
        if (\$key =\texttt{\~{}} /\^{}$\backslash$./)\{
            delete \$self-$>$\{key\}
        \}
    \}
\}



sub take\_top\_level \{
   my (\$self) = @\_;
   my \$return\_hash = \{\};
   for my \$key (keys \%\$self)\{
       if (!ref(\$self-$>$\{\$key\}) \&\& \$key !\texttt{\~{}} /\^{}$\backslash$./)\{
          \$return\_hash-$>$\{\$key\} = \$self-$>$\{\$key\}
       \}
   \}
   return \$return\_hash;
\}



sub get\_default\_value\_by\_key 
\{
    my (\$self, \$key) = @\_;
    my \$Settings = LedgerSMB::Setting-$>$new(\{base =$>$ \$self, copy =$>$ 'base'\});
    \$Settings-$>$\{key\} = \$key;
    \$Settings-$>$get;    
    \$Settings-$>$\{value\};    
\}
1;

\section{LedgerSMB::DBObject::Business\_Unit\_Class\label{LedgerSMB::DBObject::Business_Unit_Class}\index{LedgerSMB::DBObject::Business\ Unit\ Class}}




\subsection*{SYNOPSYS\label{LedgerSMB::DBObject::Business_Unit_Class_SYNOPSYS}\index{LedgerSMB::DBObject::Business Unit Class!SYNOPSYS}}


This holds the information as to the handling of classes of buisness units.  
Business units are reporting units which can be used to classify various line 
items of transactions in different ways and include handling for departments, 
funds, and projects.

\subsection*{PROPERTIES\label{LedgerSMB::DBObject::Business_Unit_Class_PROPERTIES}\index{LedgerSMB::DBObject::Business Unit Class!PROPERTIES}}
\begin{description}

\item[{id}] \mbox{}

This is the internal id of the unit class.  It is undef when the class has not
yet been saved in the database


\item[{label}] \mbox{}

This is the human-readible label for the class.  It must be unique among
classes.


\item[{active bool}] \mbox{}

If true, indicates that this will show up on screens.  If not, it will be
hidden.


\item[{modules bool}] \mbox{}

If true, indicates that this will not show up on accounting transaction screens.
this is indivated for CRM and other applications.


\item[{ordering}] \mbox{}

The entry boxes (drop down or text entry) are set arranged from low to high
by this field on the data entry screens.

\end{description}
\subsection*{METHODS\label{LedgerSMB::DBObject::Business_Unit_Class_METHODS}\index{LedgerSMB::DBObject::Business Unit Class!METHODS}}
\begin{description}

\item[{get(\$id)}] \mbox{}

returns the business unit class that corresponds to the id requested.


\item[{save}] \mbox{}

Saves the existing buisness unit class to the database, and updates any fields 
changed in the process.


\item[{save\_modules}] \mbox{}

This saves only the module permissions.  This takes the list of modules and prepares an array for the saving and then saves the modules.  This is broken off as a public 
interface because it makes it possible to activate/deactive regarding modules after the 
fact without changing anything else.


\item[{list}] \mbox{}

Returns a list of all business unit classes.


\item[{delete}] \mbox{}

Deletes a business unit class.  Such classes may not have business units attached.

\end{description}
\subsection*{PREDEFINED CLASSES\label{LedgerSMB::DBObject::Business_Unit_Class_PREDEFINED_CLASSES}\index{LedgerSMB::DBObject::Business Unit Class!PREDEFINED CLASSES}}
\begin{description}

\item[{Department, ID: 1}] \mbox{}
\item[{Project, ID: 2}] \mbox{}
\item[{Job, ID: 3}] \mbox{}

Used for manufacturing lots


\item[{Fund, ID: 4}] \mbox{}

Used by non-profits for funds accounting


\item[{Customer, ID 5}] \mbox{}

Used in some countries/industries for multi-customer receipts


\item[{Vendor, ID 6}] \mbox{}

Used in some countries/industries for multi-vendor payments

\subsection*{COPYRIGHT\label{LedgerSMB::DBObject::Business_Unit_Class_COPYRIGHT}\index{LedgerSMB::DBObject::Business Unit Class!COPYRIGHT}}


Copyright (C) 2012 The LedgerSMB Core Team.  This module may be used under the
GNU GPL in accordance with the LICENSE file listed.

\section{LedgerSMB::DBObject::Business\_Unit\_Class\label{LedgerSMB::DBObject::Business_Unit_Class}\index{LedgerSMB::DBObject::Business\ Unit\ Class}}




\subsection*{SYNOPSYS\label{LedgerSMB::DBObject::Business_Unit_Class_SYNOPSYS}\index{LedgerSMB::DBObject::Business Unit Class!SYNOPSYS}}


This holds the information as to the handling of classes of buisness units.  
Business units are reporting units which can be used to classify various line 
items of transactions in different ways and include handling for departments, 
funds, and projects.

\subsection*{PROPERTIES\label{LedgerSMB::DBObject::Business_Unit_Class_PROPERTIES}\index{LedgerSMB::DBObject::Business Unit Class!PROPERTIES}}
\begin{description}

\item[{id}] \mbox{}

This is the internal id of the unit class.  It is undef when the class has not
yet been saved in the database


\item[{class\_id}] \mbox{}

Required. Internal id of class (1 for department, 2 for project, etc)


\item[{control\_code}] \mbox{}

This is a textual reference to the business reporting unit.  It must be unique
to the business units of its class.


\item[{description}] \mbox{}

Textual description of the reporting unit.


\item[{start\_date}] \mbox{}

The first date the business reporting unit is valid.  We use the PGDate class
here for conversion to/from input and to/from strings for the db.


\item[{end\_date}] \mbox{}

The last date the business reporting unit is valid.  We use the PGDate class
here for conversion to/from input and to/from strings for the db.


\item[{parent\_id}] \mbox{}

The internal id of the parent, if applicable.  undef means no parent.


\item[{parent}] \mbox{}

A reference to the parent business reporting unit


\item[{credit\_id}] \mbox{}

The internal id of the customer, vendor, employee, etc. attached to this 
unit.


\item[{children}] \mbox{}

The children of the current unit, if applicable, and desired.



This is not set unless get\_tree has already been called.

\end{description}
\subsection*{METHODS\label{LedgerSMB::DBObject::Business_Unit_Class_METHODS}\index{LedgerSMB::DBObject::Business Unit Class!METHODS}}
\begin{description}

\item[{get(\$id)}] \mbox{}

Returns the business reporting unit referenced by the id.


\item[{save}] \mbox{}

Saves the business reporting unit ot the database and updates changes to object.


\item[{list (\$date, \$class\_id, \$credit\_id,}] \textbf{\$strict, \$active\_on)}

Lists all business reporting units active on \$date, for \$credit\_id (or for all
credit\_ids), and of \$class.  Undef on date and credit\_id match all rows.


\item[{delete}] \mbox{}

Deletes the buisness reporting unit.  A unit can only be deleted if it has no 
children and no transactions attached.


\item[{search}] \mbox{}

Returns a list of buisness reporting units matching search criteria.


\item[{get\_tree}] \mbox{}

Retrieves children recursively from the database and populates children 
appropriately


\item[{tree\_to\_list}] \mbox{}

Returns tree as a list.

\end{description}
\subsection*{COPYRIGHT\label{LedgerSMB::DBObject::Business_Unit_Class_COPYRIGHT}\index{LedgerSMB::DBObject::Business Unit Class!COPYRIGHT}}


Copyright (C) 2012 The LedgerSMB Core Team.  This module may be used under the
GNU GPL in accordance with the LICENSE file listed.

\section{LedgerSMB::DBObject\label{LedgerSMB::DBObject}\index{LedgerSMB::DBObject}}


LedgerSMB class for building objects from db relations

\subsection*{SYOPSIS\label{LedgerSMB::DBObject_SYOPSIS}\index{LedgerSMB::DBObject!SYOPSIS}}


This module creates object instances based on LedgerSMB's in-database ORM.

\subsection*{METHODS\label{LedgerSMB::DBObject_METHODS}\index{LedgerSMB::DBObject!METHODS}}
\begin{description}

\item[{new (\$class, base =$>$ \$LedgerSMB::hash)}] \mbox{}

This is the base constructor for all child classes.  It must be used with base
argument because this is necessary for database connectivity and the like.



Of course the base object can be any object that inherits LedgerSMB, so you can
use any subclass of that.  The per-session dbh is passed between the objects 
this way as is any information that is needed.


\item[{exec\_method}] \mbox{}

(\$self, procname =$>$ \$function\_name, [args =$>$ $\backslash$@args, schema =$>$ \$schema,
continue\_on\_error=$>$\$continue\_on\_error])



Provides the basic mapping of parameters to the SQL stored procedure function 
arguments.



If $\backslash$@args is not defined, args are mapped from the object's properties, 
stripping them of their in\_ prefix.  If schema is provided, that is used 
instead of PostgreSQL's search path.  If continue\_on\_error is provided and true,
the operation will not raise an exception in the event of a database error, and 
it will be up to the application to handle any exceptions.


\item[{\_db\_array\_scalars(@elements) creates}] \textbf{a db array from scalars.}
\item[{\_db\_array\_literal(@elements) creates}] \textbf{a multiple dimension db array from 	preparsed db arrays or other data which does not need to be escaped.}
\item[{set\_ordering}] \mbox{}

Sets the ordering used by default for specific functions called by exec\_method


\item[{run\_custom\_queries}] \mbox{}

Backward-compatible with 1.2 custom query system for moving forward.

\end{description}
\subsection*{Copyright (C) 2007, The LedgerSMB core team.\label{LedgerSMB::DBObject_Copyright_C_2007_The_LedgerSMB_core_team_}\index{LedgerSMB::DBObject!Copyright (C) 2007, The LedgerSMB core team.}}


This file is licensed under the Gnu General Public License version 2, or at your
option any later version.  A copy of the license should have been included with
your software.

\section{LedgerSMB::DBObject::Budget\_Report\label{LedgerSMB::DBObject::Budget_Report}\index{LedgerSMB::DBObject::Budget\ Report}}




\subsection*{SYNOPSIS\label{LedgerSMB::DBObject::Budget_Report_SYNOPSIS}\index{LedgerSMB::DBObject::Budget Report!SYNOPSIS}}


Reporting routines for budgets.  Currently only displays a variance report.

\subsection*{INHERITANCE\label{LedgerSMB::DBObject::Budget_Report_INHERITANCE}\index{LedgerSMB::DBObject::Budget Report!INHERITANCE}}
\begin{description}

\item[{LedgerSMB}] \mbox{}
\item[{LedgerSMB::DBObject}] \mbox{}\end{description}
\subsection*{PROPERTIES\label{LedgerSMB::DBObject::Budget_Report_PROPERTIES}\index{LedgerSMB::DBObject::Budget Report!PROPERTIES}}
\begin{description}

\item[{id
The id of the budget}] \mbox{}
\item[{start\_date The start date of the budget,}] \textbf{inclusive}
\item[{end\_date The end date of the budget, inclusive}] \mbox{}
\item[{reference The reference or control code}] \textbf{of the budget}
\item[{description
Description of the budget}] \mbox{}
\item[{entered\_by entity id of the one who entered}] \textbf{the budget}
\item[{approved\_by entity id of the one who approved}] \textbf{the budget}
\item[{obsolete\_by entity id of the one who marked}] \textbf{the budget obsolete}
\item[{entered\_at Timestamp when the budget was}] \textbf{saved}
\item[{approved\_at Timestamp when the budget was}] \textbf{approved}
\item[{obsolete\_at Timestamp when the budget was}] \textbf{marked obsolete}
\item[{entered\_by\_name Name of the entity who}] \textbf{entered the budget}
\item[{approved\_by\_name Name of the entity who}] \textbf{approved the budget}
\item[{obsolete\_by\_name Name of the entity who}] \textbf{marked the budget obsolete}
\item[{department\_id The ID of the department}] \textbf{for which this budget was written}
\item[{department\_name Name of the department}] \textbf{for which this budget was written}
\item[{project\_id ID of project for which this}] \textbf{budget was written}
\item[{projectnumber Project number for which this}] \textbf{budget was written}
\item[{lines Lines of the report. Each line is}] \textbf{a hashref containing:}\begin{description}

\item[{accno Account number for the account in}] \textbf{question}
\item[{account\_label Description for the account}] \textbf{in question}
\item[{account\_id ID for the account in question}] \mbox{}
\item[{budget\_description Description for the}] \textbf{line item of the budget}
\item[{budget\_amount
The amount budgetted}] \mbox{}
\item[{used\_amount
The amount actually used}] \mbox{}
\item[{variance
budgetted - used}] \mbox{}\end{description}
\end{description}
\subsection*{METHODS\label{LedgerSMB::DBObject::Budget_Report_METHODS}\index{LedgerSMB::DBObject::Budget Report!METHODS}}
\begin{description}

\item[{run\_report(\$id);}] \mbox{}

Takes a blank (base) object and populates with the variance report data provided
by the id argument.

\end{description}
\subsection*{COPYRIGHT AND LICENSE\label{LedgerSMB::DBObject::Budget_Report_COPYRIGHT_AND_LICENSE}\index{LedgerSMB::DBObject::Budget Report!COPYRIGHT AND LICENSE}}


Copyright (C) 2011 LedgerSMB Core Team.  This file is licensed under the GNU 
General Public License version 2, or at your option any later version.  Please
see the included License.txt for details.

\section{LedgerSMB::DBObject::Budget\label{LedgerSMB::DBObject::Budget}\index{LedgerSMB::DBObject::Budget}}




\subsection*{SYNOPSIS\label{LedgerSMB::DBObject::Budget_SYNOPSIS}\index{LedgerSMB::DBObject::Budget!SYNOPSIS}}


This module provides budget management routines, such as entering budgets,
approving or rejecting them, and marking them obsolete.  It does not include
more free-form areas like reporting.  For those, see
LedgerSMB::DBObject::Budget\_Report.

\subsection*{INHERITANCE\label{LedgerSMB::DBObject::Budget_INHERITANCE}\index{LedgerSMB::DBObject::Budget!INHERITANCE}}
\begin{description}

\item[{LedgerSMB}] \mbox{}
\item[{LedgerSMB::DBObject}] \mbox{}\end{description}
\subsection*{PROPERTIES\label{LedgerSMB::DBObject::Budget_PROPERTIES}\index{LedgerSMB::DBObject::Budget!PROPERTIES}}
\begin{description}

\item[{\$id INT
   The id of the budget}] \mbox{}
\item[{\$start\_date date The start date of the}] \textbf{budget, inclusive}
\item[{\$end\_date date The end date of the budget,}] \textbf{inclusive}
\item[{\$reference text This is a text reference}] \textbf{identifier for the budget}
\item[{\$description text This is a text field}] \textbf{for the budget description. It is searchable.}
\item[{\$entered\_by int Entity id of the employee}] \textbf{or contractor who entered the budget}
\item[{\$approved\_by int Entity id of the employee}] \textbf{or contractor who approved the budget}
\item[{\$obsolete\_by int Entity id for the employee}] \textbf{or contractor who marked the budget obsolete}
\item[{\$entered\_at timestamp Time the budget}] \textbf{was entered}
\item[{\$approved\_at timestamp Time the budget}] \textbf{was approved}
\item[{\$obsolete\_at timestamp Time the budget}] \textbf{was deleted}
\item[{\$entered\_by\_name text Name of entity}] \textbf{who entered the budget.}
\item[{\$approved\_by\_name text Name of entity}] \textbf{who approved the budget}
\item[{\$obsolete\_by\_name text Name of entity}] \textbf{who obsoleted the budget}
\item[{\$department\_id int ID of department for}] \textbf{which the budget is for}
\item[{\$department\_name text Name of the department}] \textbf{for which the budget is for}
\item[{\$project\_id int ID of project of which}] \textbf{the budget is for}
\item[{\$projectnumber text Text descriptor of}] \textbf{the project of which the budget is for}
\item[{@lines These are the actual lines of the}] \textbf{budget. Each one is a hashref containing}\begin{description}

\item[{\$budget\_id int Optional. Don't use. Use}] \textbf{the \$id field of the parent instead.}
\item[{\$account\_id int The id of the chart of}] \textbf{accounts entry}
\item[{\$accno text The account number for the}] \textbf{coa entry}
\item[{\$amount numeric The amount budgetted}] \mbox{}
\item[{\$description text Description of line item}] \mbox{}\end{description}

\item[{@notes Where each note is a hashref containing}] \mbox{}\begin{description}

\item[{\$subject string
   Subject of note}] \mbox{}
\item[{\$note string
   The body of the note.}] \mbox{}
\item[{\$created timestamp This is when the note}] \textbf{was created}
\item[{\$created\_by string Username of the individual}] \textbf{who created the note at the time of its creation.}\end{description}
\end{description}
\subsection*{METHODS\label{LedgerSMB::DBObject::Budget_METHODS}\index{LedgerSMB::DBObject::Budget!METHODS}}
\begin{description}

\item[{save}] \mbox{}

Saves the current budget.


\item[{}] \mbox{}
\item[{search This method uses the object as the}] \textbf{search criteria. Nulls/undefs match all values. The properties used are:}\begin{description}

\item[{start\_date Matches the start date of the}] \textbf{budget. Full match only.}
\item[{end\_date Matches the end date of the budget.}] \textbf{Full match only}
\item[{includes\_date This date is between start}] \textbf{date and end date of budget, inclusive.}
\item[{reference Partial match on budget reference}] \mbox{}
\item[{description Full text search against description}] \mbox{}
\item[{entered\_by
Exact match of entered by.}] \mbox{}
\item[{approved\_by
Exact match of approved by}] \mbox{}
\item[{department\_id Exact match of department\_id}] \mbox{}
\item[{project\_id
Exact match of project\_id}] \mbox{}
\item[{is\_approved true lists approved budgets,}] \textbf{false lists unapproved budgets. null/undef lists all.}
\item[{is\_obsolete true lists obsolete budgets.}] \textbf{False lists non-obsolete budgets. null/undef lists all.}\end{description}

\item[{get(id) takes a new (base) object and populates}] \textbf{with info for the budget.}
\item[{approve
Marks the budget as approved.}] \mbox{}
\item[{reject
Reject and deletes the budget.}] \mbox{}
\item[{obsolete Marks the budget as obsolete/superceded.}] \mbox{}
\item[{save\_note(subject string, note string)}] \textbf{Attaches a note with this subject and content to the budget.}
\item[{list\_projects Lists all projects available}] \textbf{for the start date of the budget.}
\item[{list\_departments
Lists all departments}] \mbox{}\end{description}
\subsection*{SEE ALSO\label{LedgerSMB::DBObject::Budget_SEE_ALSO}\index{LedgerSMB::DBObject::Budget!SEE ALSO}}
\begin{description}

\item[{LedgerSMB}] \mbox{}
\item[{LedgerSMB::DBObject}] \mbox{}
\item[{LedgerSMB::DBObject::Budget\_Report}] \mbox{}\end{description}
\subsection*{COPYRIGHT AND LICENSE\label{LedgerSMB::DBObject::Budget_COPYRIGHT_AND_LICENSE}\index{LedgerSMB::DBObject::Budget!COPYRIGHT AND LICENSE}}


Copyright (C) 2011 LedgerSMB Core Team.  This file is licensed under the GNU 
General Public License version 2, or at your option any later version.  Please
see the included License.txt for details.

\section{LedgerSMB::DBObject::Budget\_Report\label{LedgerSMB::DBObject::Budget_Report}\index{LedgerSMB::DBObject::Budget\ Report}}




\subsection*{SYNOPSIS\label{LedgerSMB::DBObject::Budget_Report_SYNOPSIS}\index{LedgerSMB::DBObject::Budget Report!SYNOPSIS}}


Reporting routines for budgets.  Currently only displays a variance report.

\subsection*{INHERITANCE\label{LedgerSMB::DBObject::Budget_Report_INHERITANCE}\index{LedgerSMB::DBObject::Budget Report!INHERITANCE}}
\begin{description}

\item[{LedgerSMB}] \mbox{}
\item[{LedgerSMB::DBObject}] \mbox{}\end{description}
\subsection*{PROPERTIES\label{LedgerSMB::DBObject::Budget_Report_PROPERTIES}\index{LedgerSMB::DBObject::Budget Report!PROPERTIES}}
\begin{description}

\item[{id
The id of the budget}] \mbox{}
\item[{start\_date The start date of the budget,}] \textbf{inclusive}
\item[{end\_date The end date of the budget, inclusive}] \mbox{}
\item[{reference The reference or control code}] \textbf{of the budget}
\item[{description
Description of the budget}] \mbox{}
\item[{entered\_by entity id of the one who entered}] \textbf{the budget}
\item[{approved\_by entity id of the one who approved}] \textbf{the budget}
\item[{obsolete\_by entity id of the one who marked}] \textbf{the budget obsolete}
\item[{entered\_at Timestamp when the budget was}] \textbf{saved}
\item[{approved\_at Timestamp when the budget was}] \textbf{approved}
\item[{obsolete\_at Timestamp when the budget was}] \textbf{marked obsolete}
\item[{entered\_by\_name Name of the entity who}] \textbf{entered the budget}
\item[{approved\_by\_name Name of the entity who}] \textbf{approved the budget}
\item[{obsolete\_by\_name Name of the entity who}] \textbf{marked the budget obsolete}
\item[{department\_id The ID of the department}] \textbf{for which this budget was written}
\item[{department\_name Name of the department}] \textbf{for which this budget was written}
\item[{project\_id ID of project for which this}] \textbf{budget was written}
\item[{projectnumber Project number for which this}] \textbf{budget was written}
\item[{lines Lines of the report. Each line is}] \textbf{a hashref containing:}\begin{description}

\item[{accno Account number for the account in}] \textbf{question}
\item[{account\_label Description for the account}] \textbf{in question}
\item[{account\_id ID for the account in question}] \mbox{}
\item[{budget\_description Description for the}] \textbf{line item of the budget}
\item[{budget\_amount
The amount budgetted}] \mbox{}
\item[{used\_amount
The amount actually used}] \mbox{}
\item[{variance
budgetted - used}] \mbox{}\end{description}
\end{description}
\subsection*{METHODS\label{LedgerSMB::DBObject::Budget_Report_METHODS}\index{LedgerSMB::DBObject::Budget Report!METHODS}}
\begin{description}

\item[{run\_report(\$id);}] \mbox{}

Takes a blank (base) object and populates with the variance report data provided
by the id argument.

\end{description}
\subsection*{COPYRIGHT AND LICENSE\label{LedgerSMB::DBObject::Budget_Report_COPYRIGHT_AND_LICENSE}\index{LedgerSMB::DBObject::Budget Report!COPYRIGHT AND LICENSE}}


Copyright (C) 2011 LedgerSMB Core Team.  This file is licensed under the GNU 
General Public License version 2, or at your option any later version.  Please
see the included License.txt for details.

\section{LedgerSMB::DBObject::Budget\label{LedgerSMB::DBObject::Budget}\index{LedgerSMB::DBObject::Budget}}




\subsection*{SYNOPSIS\label{LedgerSMB::DBObject::Budget_SYNOPSIS}\index{LedgerSMB::DBObject::Budget!SYNOPSIS}}


This module provides budget management routines, such as entering budgets,
approving or rejecting them, and marking them obsolete.  It does not include
more free-form areas like reporting.  For those, see
LedgerSMB::DBObject::Budget\_Report.

\subsection*{INHERITANCE\label{LedgerSMB::DBObject::Budget_INHERITANCE}\index{LedgerSMB::DBObject::Budget!INHERITANCE}}
\begin{description}

\item[{LedgerSMB}] \mbox{}
\item[{LedgerSMB::DBObject}] \mbox{}\end{description}
\subsection*{PROPERTIES\label{LedgerSMB::DBObject::Budget_PROPERTIES}\index{LedgerSMB::DBObject::Budget!PROPERTIES}}
\begin{description}

\item[{\$id INT
   The id of the budget}] \mbox{}
\item[{\$start\_date date The start date of the}] \textbf{budget, inclusive}
\item[{\$end\_date date The end date of the budget,}] \textbf{inclusive}
\item[{\$reference text This is a text reference}] \textbf{identifier for the budget}
\item[{\$description text This is a text field}] \textbf{for the budget description. It is searchable.}
\item[{\$entered\_by int Entity id of the employee}] \textbf{or contractor who entered the budget}
\item[{\$approved\_by int Entity id of the employee}] \textbf{or contractor who approved the budget}
\item[{\$obsolete\_by int Entity id for the employee}] \textbf{or contractor who marked the budget obsolete}
\item[{\$entered\_at timestamp Time the budget}] \textbf{was entered}
\item[{\$approved\_at timestamp Time the budget}] \textbf{was approved}
\item[{\$obsolete\_at timestamp Time the budget}] \textbf{was deleted}
\item[{\$entered\_by\_name text Name of entity}] \textbf{who entered the budget.}
\item[{\$approved\_by\_name text Name of entity}] \textbf{who approved the budget}
\item[{\$obsolete\_by\_name text Name of entity}] \textbf{who obsoleted the budget}
\item[{\$department\_id int ID of department for}] \textbf{which the budget is for}
\item[{\$department\_name text Name of the department}] \textbf{for which the budget is for}
\item[{\$project\_id int ID of project of which}] \textbf{the budget is for}
\item[{\$projectnumber text Text descriptor of}] \textbf{the project of which the budget is for}
\item[{@lines These are the actual lines of the}] \textbf{budget. Each one is a hashref containing}\begin{description}

\item[{\$budget\_id int Optional. Don't use. Use}] \textbf{the \$id field of the parent instead.}
\item[{\$account\_id int The id of the chart of}] \textbf{accounts entry}
\item[{\$accno text The account number for the}] \textbf{coa entry}
\item[{\$amount numeric The amount budgetted}] \mbox{}
\item[{\$description text Description of line item}] \mbox{}\end{description}

\item[{@notes Where each note is a hashref containing}] \mbox{}\begin{description}

\item[{\$subject string
   Subject of note}] \mbox{}
\item[{\$note string
   The body of the note.}] \mbox{}
\item[{\$created timestamp This is when the note}] \textbf{was created}
\item[{\$created\_by string Username of the individual}] \textbf{who created the note at the time of its creation.}\end{description}
\end{description}
\subsection*{METHODS\label{LedgerSMB::DBObject::Budget_METHODS}\index{LedgerSMB::DBObject::Budget!METHODS}}
\begin{description}

\item[{save}] \mbox{}

Saves the current budget.


\item[{}] \mbox{}
\item[{search This method uses the object as the}] \textbf{search criteria. Nulls/undefs match all values. The properties used are:}\begin{description}

\item[{start\_date Matches the start date of the}] \textbf{budget. Full match only.}
\item[{end\_date Matches the end date of the budget.}] \textbf{Full match only}
\item[{includes\_date This date is between start}] \textbf{date and end date of budget, inclusive.}
\item[{reference Partial match on budget reference}] \mbox{}
\item[{description Full text search against description}] \mbox{}
\item[{entered\_by
Exact match of entered by.}] \mbox{}
\item[{approved\_by
Exact match of approved by}] \mbox{}
\item[{department\_id Exact match of department\_id}] \mbox{}
\item[{project\_id
Exact match of project\_id}] \mbox{}
\item[{is\_approved true lists approved budgets,}] \textbf{false lists unapproved budgets. null/undef lists all.}
\item[{is\_obsolete true lists obsolete budgets.}] \textbf{False lists non-obsolete budgets. null/undef lists all.}\end{description}

\item[{get(id) takes a new (base) object and populates}] \textbf{with info for the budget.}
\item[{approve
Marks the budget as approved.}] \mbox{}
\item[{reject
Reject and deletes the budget.}] \mbox{}
\item[{obsolete Marks the budget as obsolete/superceded.}] \mbox{}
\item[{save\_note(subject string, note string)}] \textbf{Attaches a note with this subject and content to the budget.}
\item[{list\_projects Lists all projects available}] \textbf{for the start date of the budget.}
\item[{list\_departments
Lists all departments}] \mbox{}\end{description}
\subsection*{SEE ALSO\label{LedgerSMB::DBObject::Budget_SEE_ALSO}\index{LedgerSMB::DBObject::Budget!SEE ALSO}}
\begin{description}

\item[{LedgerSMB}] \mbox{}
\item[{LedgerSMB::DBObject}] \mbox{}
\item[{LedgerSMB::DBObject::Budget\_Report}] \mbox{}\end{description}
\subsection*{COPYRIGHT AND LICENSE\label{LedgerSMB::DBObject::Budget_COPYRIGHT_AND_LICENSE}\index{LedgerSMB::DBObject::Budget!COPYRIGHT AND LICENSE}}


Copyright (C) 2011 LedgerSMB Core Team.  This file is licensed under the GNU 
General Public License version 2, or at your option any later version.  Please
see the included License.txt for details.

\section{LedgerSMB::DBObject::Budget\_Report\label{LedgerSMB::DBObject::Budget_Report}\index{LedgerSMB::DBObject::Budget\ Report}}




\subsection*{SYNOPSIS\label{LedgerSMB::DBObject::Budget_Report_SYNOPSIS}\index{LedgerSMB::DBObject::Budget Report!SYNOPSIS}}


Reporting routines for budgets.  Currently only displays a variance report.

\subsection*{INHERITANCE\label{LedgerSMB::DBObject::Budget_Report_INHERITANCE}\index{LedgerSMB::DBObject::Budget Report!INHERITANCE}}
\begin{description}

\item[{LedgerSMB}] \mbox{}
\item[{LedgerSMB::DBObject}] \mbox{}\end{description}
\subsection*{PROPERTIES\label{LedgerSMB::DBObject::Budget_Report_PROPERTIES}\index{LedgerSMB::DBObject::Budget Report!PROPERTIES}}
\begin{description}

\item[{id
The id of the budget}] \mbox{}
\item[{start\_date The start date of the budget,}] \textbf{inclusive}
\item[{end\_date The end date of the budget, inclusive}] \mbox{}
\item[{reference The reference or control code}] \textbf{of the budget}
\item[{description
Description of the budget}] \mbox{}
\item[{entered\_by entity id of the one who entered}] \textbf{the budget}
\item[{approved\_by entity id of the one who approved}] \textbf{the budget}
\item[{obsolete\_by entity id of the one who marked}] \textbf{the budget obsolete}
\item[{entered\_at Timestamp when the budget was}] \textbf{saved}
\item[{approved\_at Timestamp when the budget was}] \textbf{approved}
\item[{obsolete\_at Timestamp when the budget was}] \textbf{marked obsolete}
\item[{entered\_by\_name Name of the entity who}] \textbf{entered the budget}
\item[{approved\_by\_name Name of the entity who}] \textbf{approved the budget}
\item[{obsolete\_by\_name Name of the entity who}] \textbf{marked the budget obsolete}
\item[{department\_id The ID of the department}] \textbf{for which this budget was written}
\item[{department\_name Name of the department}] \textbf{for which this budget was written}
\item[{project\_id ID of project for which this}] \textbf{budget was written}
\item[{projectnumber Project number for which this}] \textbf{budget was written}
\item[{lines Lines of the report. Each line is}] \textbf{a hashref containing:}\begin{description}

\item[{accno Account number for the account in}] \textbf{question}
\item[{account\_label Description for the account}] \textbf{in question}
\item[{account\_id ID for the account in question}] \mbox{}
\item[{budget\_description Description for the}] \textbf{line item of the budget}
\item[{budget\_amount
The amount budgetted}] \mbox{}
\item[{used\_amount
The amount actually used}] \mbox{}
\item[{variance
budgetted - used}] \mbox{}\end{description}
\end{description}
\subsection*{METHODS\label{LedgerSMB::DBObject::Budget_Report_METHODS}\index{LedgerSMB::DBObject::Budget Report!METHODS}}
\begin{description}

\item[{run\_report(\$id);}] \mbox{}

Takes a blank (base) object and populates with the variance report data provided
by the id argument.

\end{description}
\subsection*{COPYRIGHT AND LICENSE\label{LedgerSMB::DBObject::Budget_Report_COPYRIGHT_AND_LICENSE}\index{LedgerSMB::DBObject::Budget Report!COPYRIGHT AND LICENSE}}


Copyright (C) 2011 LedgerSMB Core Team.  This file is licensed under the GNU 
General Public License version 2, or at your option any later version.  Please
see the included License.txt for details.

\section{LedgerSMB::DBObject::Budget\label{LedgerSMB::DBObject::Budget}\index{LedgerSMB::DBObject::Budget}}




\subsection*{SYNOPSIS\label{LedgerSMB::DBObject::Budget_SYNOPSIS}\index{LedgerSMB::DBObject::Budget!SYNOPSIS}}


This module provides budget management routines, such as entering budgets,
approving or rejecting them, and marking them obsolete.  It does not include
more free-form areas like reporting.  For those, see
LedgerSMB::DBObject::Budget\_Report.

\subsection*{INHERITANCE\label{LedgerSMB::DBObject::Budget_INHERITANCE}\index{LedgerSMB::DBObject::Budget!INHERITANCE}}
\begin{description}

\item[{LedgerSMB}] \mbox{}
\item[{LedgerSMB::DBObject}] \mbox{}\end{description}
\subsection*{PROPERTIES\label{LedgerSMB::DBObject::Budget_PROPERTIES}\index{LedgerSMB::DBObject::Budget!PROPERTIES}}
\begin{description}

\item[{\$id INT
   The id of the budget}] \mbox{}
\item[{\$start\_date date The start date of the}] \textbf{budget, inclusive}
\item[{\$end\_date date The end date of the budget,}] \textbf{inclusive}
\item[{\$reference text This is a text reference}] \textbf{identifier for the budget}
\item[{\$description text This is a text field}] \textbf{for the budget description. It is searchable.}
\item[{\$entered\_by int Entity id of the employee}] \textbf{or contractor who entered the budget}
\item[{\$approved\_by int Entity id of the employee}] \textbf{or contractor who approved the budget}
\item[{\$obsolete\_by int Entity id for the employee}] \textbf{or contractor who marked the budget obsolete}
\item[{\$entered\_at timestamp Time the budget}] \textbf{was entered}
\item[{\$approved\_at timestamp Time the budget}] \textbf{was approved}
\item[{\$obsolete\_at timestamp Time the budget}] \textbf{was deleted}
\item[{\$entered\_by\_name text Name of entity}] \textbf{who entered the budget.}
\item[{\$approved\_by\_name text Name of entity}] \textbf{who approved the budget}
\item[{\$obsolete\_by\_name text Name of entity}] \textbf{who obsoleted the budget}
\item[{\$department\_id int ID of department for}] \textbf{which the budget is for}
\item[{\$department\_name text Name of the department}] \textbf{for which the budget is for}
\item[{\$project\_id int ID of project of which}] \textbf{the budget is for}
\item[{\$projectnumber text Text descriptor of}] \textbf{the project of which the budget is for}
\item[{@lines These are the actual lines of the}] \textbf{budget. Each one is a hashref containing}\begin{description}

\item[{\$budget\_id int Optional. Don't use. Use}] \textbf{the \$id field of the parent instead.}
\item[{\$account\_id int The id of the chart of}] \textbf{accounts entry}
\item[{\$accno text The account number for the}] \textbf{coa entry}
\item[{\$amount numeric The amount budgetted}] \mbox{}
\item[{\$description text Description of line item}] \mbox{}\end{description}

\item[{@notes Where each note is a hashref containing}] \mbox{}\begin{description}

\item[{\$subject string
   Subject of note}] \mbox{}
\item[{\$note string
   The body of the note.}] \mbox{}
\item[{\$created timestamp This is when the note}] \textbf{was created}
\item[{\$created\_by string Username of the individual}] \textbf{who created the note at the time of its creation.}\end{description}
\end{description}
\subsection*{METHODS\label{LedgerSMB::DBObject::Budget_METHODS}\index{LedgerSMB::DBObject::Budget!METHODS}}
\begin{description}

\item[{save}] \mbox{}

Saves the current budget.


\item[{}] \mbox{}
\item[{search This method uses the object as the}] \textbf{search criteria. Nulls/undefs match all values. The properties used are:}\begin{description}

\item[{start\_date Matches the start date of the}] \textbf{budget. Full match only.}
\item[{end\_date Matches the end date of the budget.}] \textbf{Full match only}
\item[{includes\_date This date is between start}] \textbf{date and end date of budget, inclusive.}
\item[{reference Partial match on budget reference}] \mbox{}
\item[{description Full text search against description}] \mbox{}
\item[{entered\_by
Exact match of entered by.}] \mbox{}
\item[{approved\_by
Exact match of approved by}] \mbox{}
\item[{department\_id Exact match of department\_id}] \mbox{}
\item[{project\_id
Exact match of project\_id}] \mbox{}
\item[{is\_approved true lists approved budgets,}] \textbf{false lists unapproved budgets. null/undef lists all.}
\item[{is\_obsolete true lists obsolete budgets.}] \textbf{False lists non-obsolete budgets. null/undef lists all.}\end{description}

\item[{get(id) takes a new (base) object and populates}] \textbf{with info for the budget.}
\item[{approve
Marks the budget as approved.}] \mbox{}
\item[{reject
Reject and deletes the budget.}] \mbox{}
\item[{obsolete Marks the budget as obsolete/superceded.}] \mbox{}
\item[{save\_note(subject string, note string)}] \textbf{Attaches a note with this subject and content to the budget.}
\item[{list\_projects Lists all projects available}] \textbf{for the start date of the budget.}
\item[{list\_departments
Lists all departments}] \mbox{}\end{description}
\subsection*{SEE ALSO\label{LedgerSMB::DBObject::Budget_SEE_ALSO}\index{LedgerSMB::DBObject::Budget!SEE ALSO}}
\begin{description}

\item[{LedgerSMB}] \mbox{}
\item[{LedgerSMB::DBObject}] \mbox{}
\item[{LedgerSMB::DBObject::Budget\_Report}] \mbox{}\end{description}
\subsection*{COPYRIGHT AND LICENSE\label{LedgerSMB::DBObject::Budget_COPYRIGHT_AND_LICENSE}\index{LedgerSMB::DBObject::Budget!COPYRIGHT AND LICENSE}}


Copyright (C) 2011 LedgerSMB Core Team.  This file is licensed under the GNU 
General Public License version 2, or at your option any later version.  Please
see the included License.txt for details.

\section{LedgerSMB\label{LedgerSMB}\index{LedgerSMB}}


Wx Console

\subsection*{SYNOPSIS\label{LedgerSMB_SYNOPSIS}\index{LedgerSMB!SYNOPSIS}}


This is the main window, menu and handler for the LedgerSMB Wx client

\subsection*{METHODS\label{LedgerSMB_METHODS}\index{LedgerSMB!METHODS}}
\begin{description}

\item[{new()}] \mbox{}

This method creates a new Frame that will work as main window, then it uses Login package poping up
a small dialog asking for database credentials. Once the database handler is gotten, it will show
a menu.


\item[{\_load\_module()}] \mbox{}

This is the main handler. It will get from the menu \$module and \$action in order to init a \$module-$>$new(\$action).


\item[{\$self-$>$\{sesion\}}] \mbox{}

This is a hash reference that works as a container for all that variables shared by the whole program. It will be passed as argument to the modules.



Initialized by Login module:
-$>$\{user\} = User logged to database.
-$>$\{comp\} = Database name.
-$>$\{serv\} = Server ip or host where the database is listening.
-$>$\{logo\} = Wx bitmap containing LedgerSMB 200x100 logo.
-$>$\{ldb\} = LedgerSMB database interface. LSMBDP object with an active connection to database.
-$>$\{user\_info\} = User full name, etc.
-$>$\{defaults\} = This is a hash stored into note table on the database. It would be like WX user defaults and each user should have at least a warehouse assigned in order to work.



Initialized by Console:
-$>$\{nb\} = It is the NoteBook object that works as window parent.

\end{description}
\subsection*{AUTHOR\label{LedgerSMB_AUTHOR}\index{LedgerSMB!AUTHOR}}


Andres Basile (basile@gmail.com)

\section{LedgerSMB\label{LedgerSMB}\index{LedgerSMB}}


Wx LedgerSMB DataBase interface

\subsection*{SYNOPSIS\label{LedgerSMB_SYNOPSIS}\index{LedgerSMB!SYNOPSIS}}


This object provides a database abstraction layer for the modules. The idea is to provide an easy way
to select, update and insert.

\subsection*{METHODS\label{LedgerSMB_METHODS}\index{LedgerSMB!METHODS}}
\begin{description}

\item[{new (USER, PASSWORD, COMPANY, HOST)}] \mbox{}

This method must recieve database basic information to estabish a connection, then it, will be blassed
and returned.


\item[{getPartsList ([\$part\_id, \$part\_description])}] \mbox{}\end{description}
\subsection*{AUTHOR\label{LedgerSMB_AUTHOR}\index{LedgerSMB!AUTHOR}}


Andres Basile (basile@gmail.com)

\section{LedgerSMB\label{LedgerSMB}\index{LedgerSMB}}


Wx Login

\subsection*{SYNOPSIS\label{LedgerSMB_SYNOPSIS}\index{LedgerSMB!SYNOPSIS}}


This is a dialog that will pop up at start asking about user, pass and company. This credential is used to get a database handler.

\subsection*{METHODS\label{LedgerSMB_METHODS}\index{LedgerSMB!METHODS}}
\begin{description}

\item[{new ()}] \mbox{}

This method creates a new Dialog showing an intro login screen. From the class, ShowModal is used to keep the dialog up till a valid handler is created.


\item[{Login ()}] \mbox{}

It is an event function that get the text on the fields and tries a connection to the database.
If the connection is made, it will be saved under ldb key and EndModal with a return 0 code will
be trigged so the conditional on console.pm will avoid die.

\end{description}
\subsection*{AUTHOR\label{LedgerSMB_AUTHOR}\index{LedgerSMB!AUTHOR}}


Andres Basile (basile@gmail.com)

\section{LedgerSMB\label{LedgerSMB}\index{LedgerSMB}}


Wx Inventory Control

\subsection*{SYNOPSIS\label{LedgerSMB_SYNOPSIS}\index{LedgerSMB!SYNOPSIS}}


This module is on charge of inventory operations.

\subsection*{METHODS\label{LedgerSMB_METHODS}\index{LedgerSMB!METHODS}}
\begin{description}

\item[{new (\$sesion, \$action)}] \mbox{}

This will get, set and go an action from the menu that is a method of this class. It will
work as a kind of handler and will return a reference to that action.
\$sesion = It is a hash with all objects and variables needed.
\$action = Method name to invoque as String


\item[{Parts ()}] \mbox{}

This is an action that will show a panel asiking for number or description.


\item[{\_listPartsByName ()}] \mbox{}

A private function used by the Search action that invoques lsmbdb interface to get parts list from the db.

\end{description}
\subsection*{AUTHOR\label{LedgerSMB_AUTHOR}\index{LedgerSMB!AUTHOR}}


Andres Basile (basile@gmail.com)

\section{LedgerSMB::DBObject::Report::co::Balance\_y\_Mayor\label{LedgerSMB::DBObject::Report::co::Balance_y_Mayor}\index{LedgerSMB::DBObject::Report::co::Balance\ y\ Mayor}}


Colombian Balance/Ledger Rpt

\subsection*{SYNPOSIS\label{LedgerSMB::DBObject::Report::co::Balance_y_Mayor_SYNPOSIS}\index{LedgerSMB::DBObject::Report::co::Balance y Mayor!SYNPOSIS}}
\begin{verbatim}
  my $bmreport = LedgerSMB::DBObject::Report::co::Balance_y_Mayor->new(%$request);
  $bmreport->run;
  $bmreport->render($request, $format);
\end{verbatim}
\subsection*{DESCRIPTION\label{LedgerSMB::DBObject::Report::co::Balance_y_Mayor_DESCRIPTION}\index{LedgerSMB::DBObject::Report::co::Balance y Mayor!DESCRIPTION}}


This module provides Balance y Mayor reports for LedgerSMB to Colombian 
standards. This report shows total activity over a time period.

\subsection*{INHERITS\label{LedgerSMB::DBObject::Report::co::Balance_y_Mayor_INHERITS}\index{LedgerSMB::DBObject::Report::co::Balance y Mayor!INHERITS}}
\begin{description}

\item[{LedgerSMB::DBObject::Report;}] \mbox{}\end{description}
\subsection*{PROPERTIES\label{LedgerSMB::DBObject::Report::co::Balance_y_Mayor_PROPERTIES}\index{LedgerSMB::DBObject::Report::co::Balance y Mayor!PROPERTIES}}
\begin{description}

\item[{columns}] \mbox{}

Read-only accessor, returns a list of columns.

\begin{description}

\item[{accno}] \mbox{}

Account Number


\item[{description}] \mbox{}

Account name


\item[{document\_type}] \mbox{}
\item[{debits}] \mbox{}
\item[{credits}] \mbox{}\end{description}

\item[{filter\_template}] \mbox{}

Returns the template name for the filter.


\item[{name}] \mbox{}

Returns the localized template name


\item[{header\_lines}] \mbox{}

Returns the inputs to display on header.

\subsubsection*{Criteria Properties\label{LedgerSMB::DBObject::Report::co::Balance_y_Mayor_Criteria_Properties}\index{LedgerSMB::DBObject::Report::co::Balance y Mayor!Criteria Properties}}


Note that in all cases, undef matches everything.


\item[{date\_from (text)}] \mbox{}

start date for the report


\item[{date\_to}] \mbox{}

End date for the report

\subsection*{METHODS\label{LedgerSMB::DBObject::Report::co::Balance_y_Mayor_METHODS}\index{LedgerSMB::DBObject::Report::co::Balance y Mayor!METHODS}}
\begin{description}

\item[{prepare\_criteria(\$request)}] \mbox{}

Instantiates the PGDate and PGNumber inputs.


\item[{run\_report()}] \mbox{}

Runs the report, and assigns rows to \$self-$>$rows.

\subsection*{COPYRIGHT\label{LedgerSMB::DBObject::Report::co::Balance_y_Mayor_COPYRIGHT}\index{LedgerSMB::DBObject::Report::co::Balance y Mayor!COPYRIGHT}}


COPYRIGHT (C) 2012 The LedgerSMB Core Team.  This file may be re-used following
the terms of the GNU General Public License version 2 or at your option any
later version.  Please see included LICENSE.TXT for details.

\section{LedgerSMB::DBObject::Report::co::Caja\_Diaria\label{LedgerSMB::DBObject::Report::co::Caja_Diaria}\index{LedgerSMB::DBObject::Report::co::Caja\ Diaria}}


Caja Diaria Reports (Colombia)

\subsection*{SYNPOSIS\label{LedgerSMB::DBObject::Report::co::Caja_Diaria_SYNPOSIS}\index{LedgerSMB::DBObject::Report::co::Caja Diaria!SYNPOSIS}}
\begin{verbatim}
  my $cdreport = LedgerSMB::DBObject::Report::co::Caja_Diaria->new(%$request);
  $cdreport->run;
  $cdreport->render($request, $format);
\end{verbatim}
\subsection*{DESCRIPTION\label{LedgerSMB::DBObject::Report::co::Caja_Diaria_DESCRIPTION}\index{LedgerSMB::DBObject::Report::co::Caja Diaria!DESCRIPTION}}


This module provides Caja Diaria eports for LedgerSMB to Colombian standards.
These reports provide an overview of cash activity to a set of accounts for a
specific period.

\subsection*{INHERITS\label{LedgerSMB::DBObject::Report::co::Caja_Diaria_INHERITS}\index{LedgerSMB::DBObject::Report::co::Caja Diaria!INHERITS}}
\begin{description}

\item[{LedgerSMB::DBObject::Report;}] \mbox{}\end{description}
\subsection*{PROPERTIES\label{LedgerSMB::DBObject::Report::co::Caja_Diaria_PROPERTIES}\index{LedgerSMB::DBObject::Report::co::Caja Diaria!PROPERTIES}}
\begin{description}

\item[{columns}] \mbox{}

Read-only accessor, returns a list of columns.

\begin{description}

\item[{accno}] \mbox{}

Account Number


\item[{description}] \mbox{}

Account name


\item[{document\_type}] \mbox{}
\item[{debits}] \mbox{}
\item[{credits}] \mbox{}\end{description}

\item[{filter\_template}] \mbox{}

Returns the template name for the filter.


\item[{name}] \mbox{}

Returns the localized template name


\item[{header\_lines}] \mbox{}

Returns the inputs to display on header.

\subsubsection*{Criteria Properties\label{LedgerSMB::DBObject::Report::co::Caja_Diaria_Criteria_Properties}\index{LedgerSMB::DBObject::Report::co::Caja Diaria!Criteria Properties}}


Note that in all cases, undef matches everything.


\item[{date\_from (text)}] \mbox{}

start date for the report


\item[{date\_to}] \mbox{}

End date for the report


\item[{from\_accno}] \mbox{}
\item[{to\_accno}] \mbox{}\subsection*{METHODS\label{LedgerSMB::DBObject::Report::co::Caja_Diaria_METHODS}\index{LedgerSMB::DBObject::Report::co::Caja Diaria!METHODS}}
\begin{description}

\item[{prepare\_criteria(\$request)}] \mbox{}

Instantiates the PGDate and PGNumber inputs.


\item[{run\_report()}] \mbox{}

Runs the report, and assigns rows to \$self-$>$rows.

\subsection*{COPYRIGHT\label{LedgerSMB::DBObject::Report::co::Caja_Diaria_COPYRIGHT}\index{LedgerSMB::DBObject::Report::co::Caja Diaria!COPYRIGHT}}


COPYRIGHT (C) 2012 The LedgerSMB Core Team.  This file may be re-used following
the terms of the GNU General Public License version 2 or at your option any
later version.  Please see included LICENSE.TXT for details.

\section{LedgerSMB::App\_State\label{LedgerSMB::App_State}\index{LedgerSMB::App\ State}}




\subsection*{SYNPOSIS\label{LedgerSMB::App_State_SYNPOSIS}\index{LedgerSMB::App State!SYNPOSIS}}


This is a generic container class for non-web-application related state
information.  It provides a central place to track such things as localization,
user, and other application state objects.

\subsection*{OBJECTS FOR STORAGE\label{LedgerSMB::App_State_OBJECTS_FOR_STORAGE}\index{LedgerSMB::App State!OBJECTS FOR STORAGE}}


The following are objects that are expected to be stored in this namespace:

\begin{description}

\item[{Locale}] \mbox{}

Stores a LedgerSMB::Locale object for the specific user.


\item[{User}] \mbox{}

Stores a LedgerSMB::User object for the currently logged in user.


\item[{SODA}] \mbox{}

Stores the SODA database access handle.


\item[{Company\_Settings}] \mbox{}

Hashref for storing connection-specific settings for the application.


\item[{DBH}] \mbox{}

Database handle for current connection

\end{description}
\subsection*{METHODS\label{LedgerSMB::App_State_METHODS}\index{LedgerSMB::App State!METHODS}}
\begin{description}

\item[{zero()}] \mbox{}

zeroes out all majro parts.


\item[{cleanup}] \mbox{}

Deletes all objects attached here.

\end{description}
\subsection*{COPYRIGHT\label{LedgerSMB::App_State_COPYRIGHT}\index{LedgerSMB::App State!COPYRIGHT}}


Copyright (C) 2009 LedgerSMB Core Team.  This file is licensed under the GNU 
General Public License version 2, or at your option any later version.  Please
see the included License.txt for details.

\section{LedgerSMB::DBObject::Report\label{LedgerSMB::DBObject::Report}\index{LedgerSMB::DBObject::Report}}


Base Reporting Functionality for LedgerSMB

\subsection*{SYNPOSIS\label{LedgerSMB::DBObject::Report_SYNPOSIS}\index{LedgerSMB::DBObject::Report!SYNPOSIS}}


This Perl module provides base utility functions for reporting in LedgerSMB.
This is intended to be an abstract class, never having direct instances, but
instead inherited out to other modules.

\subsection*{DESCRIPTION\label{LedgerSMB::DBObject::Report_DESCRIPTION}\index{LedgerSMB::DBObject::Report!DESCRIPTION}}


LedgerSMB::DBObject::Report provides basic utility functions for reporting in
LedgerSMB.  It is an abstract class.  Individual report types MUST inherit this
out.



Subclasses MUST define the following subroutines:

\begin{description}

\item[{get\_columns}] \mbox{}

This MUST return a list of hashrefs for the columns per the dynatable block.

\end{description}


Additionally, subclasses MAY define any of the following:

\begin{description}

\item[{template}] \mbox{}

Returns the name of the template to be used.  Otherwise a generic
UI/reports/display\_report template will be used.

\end{description}
\subsection*{INHERITS\label{LedgerSMB::DBObject::Report_INHERITS}\index{LedgerSMB::DBObject::Report!INHERITS}}
\begin{description}

\item[{LedgerSMB::DBObject\_Moose}] \mbox{}\end{description}
\subsection*{PROPERTIES\label{LedgerSMB::DBObject::Report_PROPERTIES}\index{LedgerSMB::DBObject::Report!PROPERTIES}}
\begin{description}

\item[{cols}] \mbox{}

This is an array of hashrefs.  Properties for each hashref:

\begin{description}

\item[{col\_id}] \mbox{}

ID of column, alphanumeric, used in names of elements, classes, etc.  Required
for smooth operation.


\item[{name}] \mbox{}

Localized name of column for labelling purposes


\item[{type}] \mbox{}

Display type of info.  May be text, href, input\_text, checkbox, or radio.  For a
report, it will typically be text or href.


\item[{href\_base}] \mbox{}

Base for href.  Only meaningful if type is href


\item[{class}] \mbox{}

CSS class (additional) for the column.

\end{description}

\item[{rows}] \mbox{}

This is an arrayref of rows.  Each row has fields with keys equal to the col\_id
fields of the columns above.


\item[{format}] \mbox{}

This is the format, and must be one used by LedgerSMB::Template.  Options
expected for 1.4 out of the box include csv, pdf, ps, xls, and ods.  Other
formats could be supported in the future.  If undefined, defaults html.

\end{description}
\subsection*{METHODS\label{LedgerSMB::DBObject::Report_METHODS}\index{LedgerSMB::DBObject::Report!METHODS}}
\begin{description}

\item[{render}] \mbox{}

This takes no arguments and simply renders the report as is.


\item[{show\_cols}] \mbox{}

Returns a list of columns based on selected ones from the report

\end{description}
\subsection*{COPYRIGHT\label{LedgerSMB::DBObject::Report_COPYRIGHT}\index{LedgerSMB::DBObject::Report!COPYRIGHT}}


COPYRIGHT (C) 2012 The LedgerSMB Core Team.  This file may be re-used under the
terms of the LedgerSMB General Public License version 2 or at your option any
later version.  Please see enclosed LICENSE file for details.

\section{LedgerSMB::DBObject\label{LedgerSMB::DBObject}\index{LedgerSMB::DBObject}}


LedgerSMB class for building objects from db relations

\subsection*{SYOPSIS\label{LedgerSMB::DBObject_SYOPSIS}\index{LedgerSMB::DBObject!SYOPSIS}}


This module creates object instances based on LedgerSMB's in-database ORM.

\subsection*{METHODS\label{LedgerSMB::DBObject_METHODS}\index{LedgerSMB::DBObject!METHODS}}
\begin{description}

\item[{new (\$class, base =$>$ \$LedgerSMB::hash)}] \mbox{}

This is the base constructor for all child classes.  It must be used with base
argument because this is necessary for database connectivity and the like.



Of course the base object can be any object that inherits LedgerSMB, so you can
use any subclass of that.  The per-session dbh is passed between the objects 
this way as is any information that is needed.


\item[{exec\_method}] \mbox{}

(\$self, procname =$>$ \$function\_name, [args =$>$ $\backslash$@args, schema =$>$ \$schema,
continue\_on\_error=$>$\$continue\_on\_error])



Provides the basic mapping of parameters to the SQL stored procedure function 
arguments.



If $\backslash$@args is not defined, args are mapped from the object's properties, 
stripping them of their in\_ prefix.  If schema is provided, that is used 
instead of PostgreSQL's search path.  If continue\_on\_error is provided and true,
the operation will not raise an exception in the event of a database error, and 
it will be up to the application to handle any exceptions.


\item[{\_db\_array\_scalars(@elements) creates}] \textbf{a db array from scalars.}
\item[{\_db\_array\_literal(@elements) creates}] \textbf{a multiple dimension db array from 	preparsed db arrays or other data which does not need to be escaped.}
\item[{set\_ordering}] \mbox{}

Sets the ordering used by default for specific functions called by exec\_method


\item[{run\_custom\_queries}] \mbox{}

Backward-compatible with 1.2 custom query system for moving forward.

\end{description}
\subsection*{Copyright (C) 2007, The LedgerSMB core team.\label{LedgerSMB::DBObject_Copyright_C_2007_The_LedgerSMB_core_team_}\index{LedgerSMB::DBObject!Copyright (C) 2007, The LedgerSMB core team.}}


This file is licensed under the Gnu General Public License version 2, or at your
option any later version.  A copy of the license should have been included with
your software.



LedgerSMB::Report:  Stub function for custom reports.



Copyright (c) 2007.  LedgerSMB Core Team

\section{METHODS\label{METHODS}\index{METHODS}}
\section{DEFINED REPORTS\label{DEFINED_REPORTS}\index{DEFINED REPORTS}}
\section{ADDING DEFINED REPORTS\label{ADDING_DEFINED_REPORTS}\index{ADDING DEFINED REPORTS}}
\section{LedgerSMB::DBObject::Saved\_Report: Saved Report Handling for LSMB\label{LedgerSMB::DBObject::Saved_Report:_Saved_Report_Handling_for_LSMB}\index{LedgerSMB::DBObject::Saved\ Report: Saved Report Handling for LSMB}}




\subsection*{SYNOPSIS\label{LedgerSMB::DBObject::Saved_Report:_Saved_Report_Handling_for_LSMB_SYNOPSIS}\index{LedgerSMB::DBObject::Saved Report: Saved Report Handling for LSMB!SYNOPSIS}}


This module handles saving the reports and retrieving them.

\subsection*{ATTRIBUTES\label{LedgerSMB::DBObject::Saved_Report:_Saved_Report_Handling_for_LSMB_ATTRIBUTES}\index{LedgerSMB::DBObject::Saved Report: Saved Report Handling for LSMB!ATTRIBUTES}}


Objects of this package have the following attributes

\begin{description}

\item[{id int}] \mbox{}

Internal id.


\item[{description text}] \mbox{}

User-readable name.


\item[{module text}] \mbox{}

This tells which perl script runs the report.


\item[{action text}] \mbox{}

This provides the entry point on that perl script.

\end{description}


Each object may also have:

\begin{description}

\item[{attr}] \mbox{}

This is a two-dimensional text array.  Each row is two elements long.  The first
element is the attribute name and the second is the value.  These are handled
by workflow scripts.

\end{description}
\subsection*{METHODS\label{LedgerSMB::DBObject::Saved_Report:_Saved_Report_Handling_for_LSMB_METHODS}\index{LedgerSMB::DBObject::Saved Report: Saved Report Handling for LSMB!METHODS}}
\begin{description}

\item[{save}] \mbox{}

This saves the report.


\item[{list\_mine}] \mbox{}

This returns a list of blessed saved\_reports.



The returned list is also saved as @\{\$self-$>$\{search\_results\}\};


\item[{get}] \mbox{}

\$self-$>$\{id\} must be set to use this method.



It retrieves the report, provided it is from the user, and merges it into the 
current object.


\item[{delete}] \mbox{}

\$self-$>$\{id\} must be set to use this method.



This function deletes the report from the database if the id matches and
that record was created by the user.



This returns 1 if successful and 0 if not.

\end{description}
\subsection*{COPYRIGHT\label{LedgerSMB::DBObject::Saved_Report:_Saved_Report_Handling_for_LSMB_COPYRIGHT}\index{LedgerSMB::DBObject::Saved Report: Saved Report Handling for LSMB!COPYRIGHT}}


Copyright 2010, LedgerSMB Core Team.  Licensed under the GNU General Public 
License version 2.0 or, at your option, any later version.

\section{LedgerSMB::Mailer   Mail output for LedgerSMB\label{LedgerSMB::Mailer_Mail_output_for_LedgerSMB}\index{LedgerSMB::Mailer   Mail output for LedgerSMB}}




\subsection*{SYNOPSIS\label{LedgerSMB::Mailer_Mail_output_for_LedgerSMB_SYNOPSIS}\index{LedgerSMB::Mailer Mail output for LedgerSMB!SYNOPSIS}}
\subsection*{COPYRIGHT\label{LedgerSMB::Mailer_Mail_output_for_LedgerSMB_COPYRIGHT}\index{LedgerSMB::Mailer Mail output for LedgerSMB!COPYRIGHT}}
\begin{verbatim}
 #====================================================================
 # LedgerSMB
 # Small Medium Business Accounting software
 # http://www.ledgersmb.org/
 #
 # Copyright (C) 2006
 # This work contains copyrighted information from a number of sources
 # all used with permission.
 #
 # This file contains source code included with or based on SQL-Ledger
 # which # is Copyright Dieter Simader and DWS Systems Inc. 2000-2005
 # and licensed under the GNU General Public License version 2 or, at
 # your option, any later version.  For a full list including contact
 # information of contributors, maintainers, and copyright holders,
 # see the CONTRIBUTORS file.
 #
 # Original Copyright Notice from SQL-Ledger 2.6.17 (before the fork):
 # Copyright (C) 2002
 #
 #  Author: DWS Systems Inc.
 #       Web: http://www.sql-ledger.org
 #
 #  Contributors:
 #
 # Original Author and copyright holder:
 # Dieter Simader dsmimader@sql-ledger.com
 #====================================================================
\end{verbatim}
\subsection*{METHODS\label{LedgerSMB::Mailer_Mail_output_for_LedgerSMB_METHODS}\index{LedgerSMB::Mailer Mail output for LedgerSMB!METHODS}}
\subsubsection*{LedgerSMB::Mailer-$>$new(...)\label{LedgerSMB::Mailer_Mail_output_for_LedgerSMB_LedgerSMB::Mailer-_new_}\index{LedgerSMB::Mailer Mail output for LedgerSMB!LedgerSMB::Mailer-$>$new(...)}}


Create a new Mailer object.  If any arguments are passed in, a message
that uses them will be automatically prepared but not sent.

\subsubsection*{\$mail-$>$prepare\_message(to =$>$ \$to, from =$>$ \$from, ...)\label{LedgerSMB::Mailer_Mail_output_for_LedgerSMB__mail-_prepare_message_to_to_from_from_}\index{LedgerSMB::Mailer Mail output for LedgerSMB!\$mail-$>$prepare\ message(to =$>$ \$to, from =$>$ \$from, ...)}}


Prepares and encodes base message for sending or adding attachments.

\paragraph*{Arguments\label{LedgerSMB::Mailer_Mail_output_for_LedgerSMB_Arguments}\index{LedgerSMB::Mailer Mail output for LedgerSMB!Arguments}}
\begin{description}

\item[{to, from, cc, bcc}] \mbox{}

Address fields for the email.


\item[{subject}] \mbox{}

The subject for the email.


\item[{message}] \mbox{}

The message body for the email.


\item[{contenttype}] \mbox{}

The conttent type for the body of the message, not for any attachments.


\item[{notify}] \mbox{}

Sets the Disposition-Notification-To header (read receipt request) for the
message.  This header will only be added if a from address is set.

\end{description}
\subsubsection*{\$mail-$>$attach(data =$>$ \$data, filename =$>$ \$name, strip =$>$ \$strip)\label{LedgerSMB::Mailer_Mail_output_for_LedgerSMB__mail-_attach_data_data_filename_name_strip_strip_}\index{LedgerSMB::Mailer Mail output for LedgerSMB!\$mail-$>$attach(data =$>$ \$data, filename =$>$ \$name, strip =$>$ \$strip)}}


Add an attachment to the prepared message.  If \$data is specified, use the
value of that variable as the attachment value, otherwise attach the file
given by \$name.  If both a filename and data are given, the data is attached
and given the name from filename.



\$strip is an optional string to remove from the filename send with the
attachment.

\subsubsection*{\$mail-$>$send\label{LedgerSMB::Mailer_Mail_output_for_LedgerSMB__mail-_send}\index{LedgerSMB::Mailer Mail output for LedgerSMB!\$mail-$>$send}}


Sends a prepared message using the method configured in ledgersmb.conf.

\section{SYNOPSIS\label{SYNOPSIS}\index{SYNOPSIS}}


Support functions for projects, partsgroups, and parts

\section{COPYRIGHT\label{COPYRIGHT}\index{COPYRIGHT}}
\begin{verbatim}
 #====================================================================
 # LedgerSMB
 # Small Medium Business Accounting software
 # http://www.ledgersmb.org/
 #
 # Copyright (C) 2006
 # This work contains copyrighted information from a number of sources
 # all used with permission.
 #
 # This file contains source code included with or based on SQL-Ledger
 # which is Copyright Dieter Simader and DWS Systems Inc. 2000-2005
 # and licensed under the GNU General Public License version 2 or, at
 # your option, any later version.  For a full list including contact
 # information of contributors, maintainers, and copyright holders,
 # see the CONTRIBUTORS file.
 #
 # Original Copyright Notice from SQL-Ledger 2.6.17 (before the fork):
 # Copyright (C) 2003
 #
 #  Author: DWS Systems Inc.
 #     Web: http://www.sql-ledger.org
 #
 #  Contributors:
 #
 #====================================================================
 #
 # This file has undergone whitespace cleanup.
 #
 #====================================================================
 #
 # Project module
 # also used for partsgroups
 #
 #====================================================================
\end{verbatim}
\section{METHODS\label{METHODS}\index{METHODS}}
\begin{description}

\item[{PE-$>$projects(\$myconfig, \$form);}] \mbox{}

Populates the list referred to as \$form-$>$\{all\_project\} with hashes containing
details about projects.  Each hash contains the project record's fields along
with the name of any associated customer.  If \$form-$>$\{status\} is 'orphaned',
only add projects that aren't referred to in any transactions, invoices,
orders, or time cards.  If \$form-$>$\{status\} is 'active', only projects that have
not reached their enddate are added; when \$form-$>$\{status\} is 'inactive', only
add projects that have reached their enddates.  When \$form-$>$\{year\} and
\$form-$>$\{month\} are set, use their values, along with that of \$form-$>$\{interval\},
to set the startdatefrom and startdateto attributes of \$form.  These attributes
are used to prepare a date range for accepted start dates.  Both
\$form-$>$\{description\} and \$form-$>$\{projectnumber\} are used to limit the results.



Returns the number of projects added to the list.  \$myconfig is unused.


\item[{PE-$>$get\_customer(\$myconfig, \$form[,}] \textbf{\$dbh]);}

Populates the list referred to as \$form-$>$\{all\_customer\} with hashes containing
the ids and names of customers unless the number of customers added would be
greater than or equal to \$myconfig-$>$\{vclimit\}.  \$form-$>$\{startdate\} and
\$form-$>$\{enddate\} form a date range to limit the results.  If
\$form-$>$\{customer\_id\} is set, then the customer with that id will be in the
result set.


\item[{PE-$>$delete\_partsgroup(\$myconfig, \$form);}] \mbox{}

Deletes the entry in partsgroup identified by \$form-$>$\{id\} and associated
translations.



\$myconfig is unused.


\item[{PE-$>$delete\_pricegroup(\$myconfig, \$form);}] \mbox{}

Deletes the pricegroup entry identified by \$form-$>$\{id\}.



\$myconfig is unused.


\item[{PE-$>$partsgroups(\$myconfig, \$form);}] \mbox{}

Populates the list referred to as \$form-$>$\{item\_list\} with hashes containing
the id and partsgroup (name) for all the partsgroups in the database.  If
\$form-$>$\{partsgroup\} is non-empty, the results are limited to the partsgroups
that contain that value in their name (case insensitive).  If \$form-$>$\{status\}
is 'orphaned', only partsgroups that are not associated with a part are added.
The number of partsgroups added to \$form-$>$\{item\_list\} is returned.



\$myconfig is unused.


\item[{PE-$>$save\_partsgroup(\$myconfig, \$form);}] \mbox{}

Save a partsgroup record.  If \$form-$>$\{id\} is set, update the description of
the partsgroup with that id to be \$form-$>$\{partsgroup\}.  Otherwise, create a
new partsgroup with that description.



\$myconfig is unused.


\item[{PE-$>$get\_partsgroup(\$myconfig, \$form);}] \mbox{}

Sets \$form-$>$\{partsgroup\} to the description of the partsgroup identified by
\$form-$>$\{id\}.  If there are no parts entries associated with that partsgroup,
\$form-$>$\{orphaned\} is made true, otherwise it is set to false.



\$myconfig is unused.


\item[{PE-$>$pricegroups(\$myconfig, \$form);}] \mbox{}

Populates the list referred to as \$form-$>$\{item\_list\} with hashes containing
details (id and pricegroup (description)) about pricegroups.  All the groups
are added unless \$form-$>$\{pricegroup\} is set, in which case it will search for
groups with that description, or \$form-$>$\{status\} is 'orphaned', which limits
the results to those not related to any customers (partscustomer table).  The
return value is the number of pricegroups added to the list.



\$myconfig is unused.


\item[{PE-$>$save\_pricegroup(\$myconfig, \$form);}] \mbox{}

Adds or updates a pricegroup.  If \$form-$>$\{id\} is set, update the pricegroup
value using \$form-$>$\{pricegroup\}.  If \$form-$>$\{id\} is not set, adds a new
pricegroup with a pricegroup value of \$form-$>$\{pricegroup\}.



\$myconfig is unused.


\item[{PE-$>$get\_pricegroup(\$myconfig, \$form);}] \mbox{}

Sets \$form-$>$\{pricegroup\} to the description of the pricegroup identified by
\$form-$>$\{id\}.  If the pricegroup is not mentioned in partscustomer,
\$form-$>$\{orphaned\} is set true, otherwise false.


\item[{PE::description\_translations('', \$myconfig,}] \textbf{\$form);}

Populates the list referred to as \$form-$>$\{translations\} with hashes detailing
non-obsolete goods and services and their translated descriptions.  The main
details hash immediately precedes its set of translations and has the
attributes id, partnumber, and description.  The translations have the
attributes id (same as in the main hash), language, translation, and code.



When \$form-$>$\{id\} is set, only adds an entry for the item having that id, but
also populates \$form-$>$\{all\_language\} using PE::get\_language.  The attributes
partnumber and description are searchable and if set, will limit the results to
only those that match them.



\$myconfig is unused.  \$form-$>$\{trans\_id\} is set to the last encountered part id.


\item[{PE::partsgroup\_translations("", \$myconfig,}] \textbf{\$form)}

Populates the list referred to as \$form-$>$\{translations\} with hashrefs containing
details about partsgroups and their translated names.  A master hash contains
the id and description of the partsgroup and is immediately followed by its
translation hashes, which  contain the language, translation, and code of the
translation.  The list contains the details for all partsgroups unless
\$form-$>$\{description\} is set, in which case only partsgroups with a matching
description are included, or \$form-$>$\{id\} is set.  When \$form-$>$\{id\} is set, only
translations for the partgroup with that are included and \$form-$>$\{all\_language\}
is populated by get\_language.



\$myconfig is unused.  \$form-$>$\{trans\_id\} is set to the last id encountered.


\item[{PE::project\_translations("", \$myconfig,}] \textbf{\$form)}

Populates the list referred to as \$form-$>$\{translations\} with hashrefs containing
details about projects and their translated names.  A master hash contains the
id, project number, and description of the project and is immediately followed
by its translation hashes, which have the same id as the master and also
contain the language, translation, and code of the translation.  The list
contains the details for all projects unless \$form-$>$\{description\} or 
\$form-$>$\{projectnumber\} is set, in which case only projects that match the
appropriate field are included, or \$form-$>$\{id\} is set.  When \$form-$>$\{id\} is
set, only translations for the project with that id are included and
\$form-$>$\{all\_language\} is populated by get\_language.



\$myconfig is unused.  \$form-$>$\{trans\_id\} is set to the last encountered id.


\item[{PE::get\_language("", \$dbh, \$form)}] \mbox{}

Populates the list referred to as \$form-$>$\{all\_language\} with hashes containing
the code and description of all languages registered with the system in the
language table.


\item[{PE::save\_translation("", \$myconfig, \$form);}] \mbox{}

Deletes all translations with the trans\_id (part id, project id, or partsgroup
id) of \$form-$>$\{id\} then adds new entries for \$form-$>$\{id\}.  The number of
translation entries is obtained from \$form-$>$\{translation\_rows\}.  The actual
translation entries are derived from \$form-$>$\{language\_code\_\textit{i}\} and
\$form-$>$\{translation\_\textit{i}\}, where \textit{i} is some integer between 1 and
\$form-$>$\{translation\_rows\} inclusive.



\$myconfig is unused.


\item[{PE::delete\_translation("", \$myconfig,}] \textbf{\$form);}

Deletes all translation entries that have the trans\_id of \$form-$>$\{id\}.



\$myconfig is unused.


\item[{PE-$>$timecard\_get\_currency(\$form);}] \mbox{}

Sets \$form-$>$\{currency\} to the currency set for the customer who has the id
\$form-$>$\{customer\_id\}.


\item[{PE::project\_sales\_order("", \$myconfig,}] \textbf{\$form)}

Executes \$form-$>$all\_years, \$form-$>$all\_projects, and \$form-$>$all\_employees, with
a limiting transdate of the current date.


\item[{PE-$>$get\_jcitems(\$myconfig, \$form);}] \mbox{}

This function is used as part of the sales order generation accessible from the
projects interface, to generate the list of possible orders.



Populates the list referred to as \$form-$>$\{jcitems\} with hashes containing
details about sales orders that can be generated that relate to projects.  Each
of the hashes has the attributes id (timecard id), description (timecard
description), qty (unallocated chargeable hours), sellprice (hourly rate),
parts\_id (service id), customer\_id, project\_id, transdate (date on timecard),
notes, customer (customer name), projectnumber, partnumber, taxaccounts (space
separated list that contains the account numbers of taxes that apply to the
service), and amount (qty*sellprice).  If \$form-$>$\{summary\} is true, the
description field contains the service description instead of the timecard
description.



All possible, unconsolidated sales orders are normally listed.  If
\$form-$>$\{projectnumber\} is set, only orders associated with the project are
listed.  \$form-$>$\{employee\} limits the list to timecards with the given employee.
When \$form-$>$\{year\} and \$form-$>$\{month\} are set, the transdatefrom and transdateto
attributes are populated with values derived from the year, month, and interval
\$form attributes.  \$form-$>$\{transdatefrom\} is used to limit the results to
time cards checked in on or after that date.  \$form-$>$\{transdateto\} limits to
time cards checked out on or before the provided date.  \$form-$>$\{vc\} must be
'customer'.



Regardless of the values added to \$form-$>$\{jcitems\}, this function sets
\$form-$>$\{currency\} and \$form-$>$\{defaultcurrency\} to the first currency mentioned
in defaults.  It also fills  \$form-$>$\{taxaccounts\} with a space separated list
of the account numbers of all tax accounts and for each accno forms a
\$form-$>$\{\$\{accno\}\_rate\} attribute that contains the tax's rate as expressed in
the tax table.



\$myconfig is unused.


\item[{PE-$>$allocate\_projectitems(\$myconfig,}] \textbf{\$form);}

Updates the jcitems table to adjust the allocated quantities of time.  The
time cards, and allocated time, to update is obtained from the various space
separated lists \$form-$>$\{jcitems\_\textit{i}\}, where \textit{i} is between 1 and the value of
\$form-$>$\{rowcount\}.  Each element of those space separated lists is a colon
separated pair where the first element is the time card id and the second
element is the increase in allocated hours.



\$myconfig is unused.

\end{description}
\section{LedgerSMB::DBTest\label{LedgerSMB::DBTest}\index{LedgerSMB::DBTest}}


LedgerSMB commit filter for test cases.

\subsection*{SYOPSIS\label{LedgerSMB::DBTest_SYOPSIS}\index{LedgerSMB::DBTest!SYOPSIS}}


This module creates a DBI-like interface but ensures autocommit is off, 
and filters commit statements such that they don't do anything.  This can be 
used for making API test cases which involve DB commits safe for production 
environments.

\subsection*{USAGE\label{LedgerSMB::DBTest_USAGE}\index{LedgerSMB::DBTest!USAGE}}


Both LedgerSMB.pm and LedgerSMB/Form.pm assign a global database handler for all
database access within a script in the dbh property (for example,
\$request-$>$\{dbh\} or \$form-$>$\{dbh\}).  By setting this early to a
LedgerSMB::DBTest (instead of a DBI object), the tests can be made safe.



However, there are a few limitations to be aware of.  One cannot run tests
through the standard request handler and use this module. Hence this is limited
to unit tests of files in the LedgerSMB, scripts, and bin directories.



Here is an example of how this could be done:

\begin{verbatim}
 my $lsmb = LedgerSMB->new();
 $lsmb->merge($testdata);
 my $dbh = LedgerSMB::DBTest->connect("dbi:Pg:dbname=$company", "$username",
     "$password",)
 $lsmb->{dbh} = $dbh;
\end{verbatim}
\subsection*{METHODS\label{LedgerSMB::DBTest_METHODS}\index{LedgerSMB::DBTest!METHODS}}
\begin{description}

\item[{connect(\$dsn, \$user, \$pass)}] \mbox{}

Connects to the database and returns a LedgerSMB::DBTest object


\item[{commit()}] \mbox{}

Tests the current transaction (issues a 'SELECT 1;' to the database).  If this
is successful returns 1, if not, rolls back and returns false.



Note that this means all past tests are rolled back and this is inconsistent
with normal transactional behavior.


\item[{prepare()}] \mbox{}

Returns a statement handle, via the private DBI database handle.


\item[{do()}] \mbox{}

passes this statement on to the private database handle


\item[{errstr()}] \mbox{}

passes this call on to the private database handle


\item[{err()}] \mbox{}

passes this call on to the private database handle


\item[{quote()}] \mbox{}

passes this call on to the private database handle


\item[{quote\_identifier()}] \mbox{}

passes this call on to the private database handle


\item[{rollback()}] \mbox{}

passes this call on to the private database handle.  Note that this will roll
back all statements issues through this object.

\end{description}
\section{LedgerSMB::Locale\label{LedgerSMB::Locale}\index{LedgerSMB::Locale}}


Locale handling class for LedgerSMB

\subsection*{SYNOPSIS\label{LedgerSMB::Locale_SYNOPSIS}\index{LedgerSMB::Locale!SYNOPSIS}}


Locale support module for LedgerSMB.  Uses Locale::Maketext::Lexicon as a base.

\subsection*{METHODS\label{LedgerSMB::Locale_METHODS}\index{LedgerSMB::Locale!METHODS}}
\begin{description}

\item[{get\_handle (\$language\_code)}] \mbox{}

Returns a locale handle for accessing the other methods.  Inherited from 
Locale::Maketext.


\item[{text (\$string, @params)}] \mbox{}

Returns the translation for the given string.  This is a legacy wrapper that
merely calls \$self-$>$maketext.


\item[{date (\$myconfig, \$date, \$longformat)}] \mbox{}

Returns the given date after formatting it.  \$longformat is a ternary flag that
determines how the date is formatted.  If \$longformat is true, the date will be
given in the form of "\_('September') 23 2007".  If \$longformat is false but
defined, the date will be in the form of "\_('Sep') 23 2007" unless the date is
given in the form 'yyyy.mm.dd', in which case it is returned as-is.  If
\$longformat is not defined, the date will be output in the format specified by
\$myconfig-$>$\{dateformat\}.

\end{description}
\subsection*{Copyright (C) 2006, The LedgerSMB core team.\label{LedgerSMB::Locale_Copyright_C_2006_The_LedgerSMB_core_team_}\index{LedgerSMB::Locale!Copyright (C) 2006, The LedgerSMB core team.}}
\begin{verbatim}
 #====================================================================
 #
 # Locale support module for LedgerSMB
 # LedgerSMB::Locale
 #
 # LedgerSMB
 # Small Medium Business Accounting software
 # http://www.ledgersmb.org/
 #
 #
 # Copyright (C) 2006
 # This work contains copyrighted information from a number of sources
 # all used with permission.  It is released under the GNU General 
 # Public License Version 2 or, at your option, any later version.
 # See COPYRIGHT file for details.
 #
 # This file contains source code included with or based on SQL-Ledger
 # which is Copyright Dieter Simader and DWS Systems Inc. 2000-2005
 # and licensed under the GNU General Public License version 2 or, at
 # your option, any later version.  For a full list including contact
 # information of contributors, maintainers, and copyright holders,
 # see the CONTRIBUTORS file.
 #
 # Original Copyright Notice from SQL-Ledger 2.6.17 (before the fork):
 # Copyright (C) 2000
 #
 #  Author: DWS Systems Inc.
 #     Web: http://www.sql-ledger.org
 #
 # Contributors: Thomas Bayen <bayen@gmx.de>
 #               Antti Kaihola <akaihola@siba.fi>
 #               Moritz Bunkus (tex)
 #               Jim Rawlings <jim@your-dba.com> (DB2)
 #
 #====================================================================
=cut
\end{verbatim}


package LedgerSMB::Locale;



use base 'Locale::Maketext';
use Locale::Maketext::Lexicon;
use Encode;



Locale::Maketext::Lexicon-$>$import(
    \{
        '*'     =$>$ [ Gettext =$>$ "\$\{LedgerSMB::Sysconfig::localepath\}/*.po", ],
        \_auto   =$>$ 1,
        \_decode =$>$ 1,
    \}
);



sub text \{
    my ( \$self, \$text, @params ) = @\_;
    return \$self-$>$maketext( \$text, @params );
\}



\#\#sub date \{
\#\#	my (\$self, \$myconfig, \$date, \$longformat) = @\_;
\#\#	return \$date;
\#\#\}
sub date \{
    my ( \$self, \$myconfig, \$date, \$longformat ) = @\_;
    my @longmonth = (qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec));
    @longmonth = (
        "January",   "February", "March",    "April",
        "May ",      "June",     "July",     "August",
        "September", "October",  "November", "December"
    ) if \$longformat;
    my \$longdate = '';

\begin{verbatim}
    return '' if not $date;
\end{verbatim}
\begin{verbatim}
    my $spc = '';
    my $yy  = '';
    my $mm  = '';
    my $dd  = '';
\end{verbatim}
\begin{verbatim}
    # get separator
    $spc = $myconfig->{dateformat};
    $spc =~ s/\w//g;
    $spc = substr( $spc, 0, 1 );
\end{verbatim}
\begin{verbatim}
    if ( !$longformat && $date =~ /^\d{4}\D/ ) {  # reparsing date at this point
                                                  # causes problems!
        return $date;
    }
    if ( $date =~ /\D/ ) {
        if ($date  =~ /\d{4}/){ # db date in
            ( $yy, $mm, $dd ) = split /\D/, $date;
        }
        elsif ( $myconfig->{dateformat} =~ /^yy/ ) {
            ( $yy, $mm, $dd ) = split /\D/, $date;
        }
        elsif ( $myconfig->{dateformat} =~ /^mm/ ) {
            ( $mm, $dd, $yy ) = split /\D/, $date;
        }
        elsif ( $myconfig->{dateformat} =~ /^dd/ ) {
            ( $dd, $mm, $yy ) = split /\D/, $date;
        }
\end{verbatim}
\begin{verbatim}
    }
    else {
        $date = substr( $date, 2 );
        ( $yy, $mm, $dd ) = ( $date =~ /(..)(..)(..)/ );
    }
\end{verbatim}
\begin{verbatim}
    $dd *= 1;
    $yy += 2000 if length $yy == 2;
    $dd = substr( "0$dd", -2 );
    $mm = substr( "0$mm", -2 );
\end{verbatim}
\begin{verbatim}
    if ( $myconfig->{dateformat} =~ /^dd/ ) {
        $longdate = "$dd$spc$mm$spc$yy";
    }
    elsif ( $myconfig->{dateformat} =~ /^yy/ ) {
        $longdate = "$yy$spc$mm$spc$dd";
    }
    else {
        $longdate = "$mm$spc$dd$spc$yy";
    }
\end{verbatim}
\begin{verbatim}
    if ( defined $longformat ) {
        $longdate = $self->text( $longmonth[ --$mm ] ) . " $dd $yy";
    }
    $longdate;
}
\end{verbatim}


1;

\section{LedgerSMB::Auth.pm\label{LedgerSMB::Auth_pm}\index{LedgerSMB::Auth.pm}}


Provides an abstraction layer for session management and
authentication.

\subsection*{SYNOPSIS\label{LedgerSMB::Auth_pm_SYNOPSIS}\index{LedgerSMB::Auth pm!SYNOPSIS}}


This routine provides an abstraction layer for session management and
authentication.  The current application only ships with a simple authentication
layer using database-native accounts.  Other authentication methods are quite
possible though currently every LedgerSMB user must be a database user.

\subsection*{METHODS\label{LedgerSMB::Auth_pm_METHODS}\index{LedgerSMB::Auth pm!METHODS}}


Each plugin library must provide the following methods.

\begin{description}

\item[{session\_check}] \mbox{}

Check whether a session exists and handle failure appropriately.



Modules are free to define how failure should be addressed.


\item[{session\_create}] \mbox{}

Create a session


\item[{session\_destroy}] \mbox{}

Destroy a session.


\item[{get\_credentials}] \mbox{}

Get credentials and return them to the application.



Must return a hashref with the following entries:



login
password


\item[{credential\_prompt}] \mbox{}

Prompt user for credentials

\end{description}
\subsection*{METHODS PROVIDED IN COMMON\label{LedgerSMB::Auth_pm_METHODS_PROVIDED_IN_COMMON}\index{LedgerSMB::Auth pm!METHODS PROVIDED IN COMMON}}
\begin{description}

\item[{http\_error}] \mbox{}

Send an http error to the browser.

\end{description}
\subsection*{COPYRIGHT\label{LedgerSMB::Auth_pm_COPYRIGHT}\index{LedgerSMB::Auth pm!COPYRIGHT}}


\# Small Medium Business Accounting software
\# http://www.ledgersmb.org/
\#
\#
\# Copyright (C) 2006-2011
\# This work contains copyrighted information from a number of sources all used
\# with permission.  It is released under the GNU General Public License
\# Version 2 or, at your option, any later version.  See COPYRIGHT file for
\# details.

\section{LedgerSMB::Form\label{LedgerSMB::Form}\index{LedgerSMB::Form}}


Provides general legacy support functions and the central object.

\subsection*{SYNOPSIS\label{LedgerSMB::Form_SYNOPSIS}\index{LedgerSMB::Form!SYNOPSIS}}


This module provides general legacy support functions and the central object

\subsection*{STATUS\label{LedgerSMB::Form_STATUS}\index{LedgerSMB::Form!STATUS}}


Deprecated

\subsection*{COPYRIGHT\label{LedgerSMB::Form_COPYRIGHT}\index{LedgerSMB::Form!COPYRIGHT}}
\begin{verbatim}
 #====================================================================
 # LedgerSMB
 # Small Medium Business Accounting software
 # http://www.ledgersmb.org/
 #
 # Copyright (C) 2006
 # This work contains copyrighted information from a number of sources
 # all used with permission.
 #
 # This file contains source code included with or based on SQL-Ledger
 # which is Copyright Dieter Simader and DWS Systems Inc. 2000-2005
 # and licensed under the GNU General Public License version 2 or, at
 # your option, any later version.  For a full list including contact
 # information of contributors, maintainers, and copyright holders,
 # see the CONTRIBUTORS file.
 #
 # Original Copyright Notice from SQL-Ledger 2.6.17 (before the fork):
 # Copyright (C) 2000
 #
 #  Author: DWS Systems Inc.
 #     Web: http://www.sql-ledger.org
 #
 # Contributors: Thomas Bayen <bayen@gmx.de>
 #               Antti Kaihola <akaihola@siba.fi>
 #               Moritz Bunkus (tex)
 #               Jim Rawlings <jim@your-dba.com> (DB2)
 #====================================================================
 #
 # This file has undergone whitespace cleanup.
 #
 #====================================================================
 #
 # main package
 #
 #====================================================================
\end{verbatim}
\subsection*{METHODS\label{LedgerSMB::Form_METHODS}\index{LedgerSMB::Form!METHODS}}
\begin{description}

\item[{new Form([\$argstr])}] \mbox{}

Returns a reference to new Form object.  The initial set of attributes is
obtained from \$argstr, a CGI query string, or \$ARGV[0].  All the values are
run through unescape to undo any URI encoding.



The version and dbversion attributes are set to hardcoded values; action,
nextsub, path, script, and login are filtered to remove some dangerous values.
Both menubar and lynx are set if path matches lynx.



\$form-$>$error may be called to deny access on some attribute values.


\item[{open\_form()}] \mbox{}

This sets a \$self-$>$\{form\_id\} to be used in later form validation (anti-XSRF 
measure).


\item[{check\_form()}] \mbox{}

This returns true if the form\_id was associated with the session, and false if 
not.  Use this if the form may be re-used (back-button actions are valid).


\item[{close\_form()}] \mbox{}

Identical with check\_form() above, but also removes the form\_id from the 
session.  This should be used when back-button actions are not valid.


\item[{\$form-$>$debug([\$file]);}] \mbox{}

Outputs the sorted contents of \$form.  If a filename is specified, log to it,
otherwise output to STDOUT.


\item[{\$form-$>$encode\_all();}] \mbox{}

Does nothing and is unused.  Contains merely the comment \# TODO;


\item[{\$form-$>$decode\_all();}] \mbox{}

Does nothing and is unused.  Contains merely the comment \# TODO


\item[{\$form-$>$escape(\$str[, \$beenthere]);}] \mbox{}

Returns the URI-encoded \$str.  \$beenthere is a boolean that when true forces a
single encoding run.  When false, it escapes the string twice if it detects
that it is running on a version of Apache 2.0 earlier than 2.0.44.



Note that recurring transaction support depends on this function escaping ','.


\item[{\$form-$>$unescape(\$str);}] \mbox{}

Returns the unencoded form of the URI-encoded \$str.


\item[{\$form-$>$quote(\$str);}] \mbox{}

Replaces all double quotes in \$str with '\&quot;'.  Does nothing if \$str is a
reference.


\item[{\$form-$>$unquote(\$str);}] \mbox{}

Replaces all '\&quot;' in \$str with double quotes.  Does nothing if \$str is a
reference.


\item[{\$form-$>$hide\_form([...]);}] \mbox{}

Outputs hidden HTML form fields to STDOUT.  If values are passed into this
function, only those \$form values are output.  If no values are passed in, all
\$form values are output as well as deleting \$form-$>$\{header\}.  Values from the
\$form object are run through \$form-$>$quote, whereas keys/names are not.



Sample output:

\begin{verbatim}
 <input type="hidden" name="login" value="testuser" />
\end{verbatim}

\item[{\$form-$>$error(\$msg);}] \mbox{}

Output an error message, \$msg.  If a CGI environment is detected, this outputs
an HTTP and HTML header section if required, and displays the message after
running it through \$form-$>$format\_string.  If it is not a CGI environment and
\$ENV\{error\_function\} is set, call the specified function with \$msg as the sole
argument.  Otherwise, this function simply dies with \$msg.



This function does not return.  Execution is terminated at the end of the
appropriate path.


\item[{\$form-$>$finalize\_request();}] \mbox{}

Stops further processing, allowing post-request cleanup on intermediate
levels by throwing an exception.



This function replaces explicit 'exit()' calls.


\item[{\$form-$>$info(\$msg);}] \mbox{}

Output an informational message, \$msg.  If a CGI environment is detected, this
outputs an HTTP and HTML header section if required, and displays the message
in bold tags without escaping.  If it is not a CGI environment and 
\$ENV\{info\_function\} is set, call the specified function with \$msg as the sole
argument.  Otherwise, this function simply prints \$msg to STDOUT.


\item[{\$form-$>$numtextrows(\$str, \$cols[, \$maxrows]);}] \mbox{}

Returns the number of rows of \$cols columns can be formed by \$str.  If \$maxrows
is set and the number of rows is greater than \$maxrows, this returns \$maxrows.
In the determination of rowcount, newline characters, "$\backslash$n", are taken into
account while spaces are not.


\item[{\$form-$>$dberror(\$msg);}] \mbox{}

Outputs a message as in \$form-$>$error but with \$DBI::errstr automatically
appended to \$msg.


\item[{\$form-$>$isblank(\$name, \$msg);}] \mbox{}

Calls \$form-$>$error(\$msg) if the value of \$form-$>$\{\$name\} matches /\^{}$\backslash$s*\$/.


\item[{\$form-$>$header([\$init, \$headeradd]);}] \mbox{}

Outputs HTML and HTTP headers and sets \$form-$>$\{header\} to indicate that headers
have been output.  If called with \$form-$>$\{header\} set or in a non-CGI
environment, does not output anything.  \$init is ignored.  \$headeradd is data
to be added to the $<$head$>$ portion of the output headers.  \$form-$>$\{stylesheet\},
\$form-$>$\{title\}, \$form-$>$\{titlebar\}, and \$form-$>$\{pre\} all affect the output of
this function.



If the stylesheet indicated by \$form-$>$\{stylesheet\} exists, output a link tag
to reference it.  If \$form-$>$\{title\} is false, the title text is the value of
\$form-$>$\{titlebar\}.  If \$form-$>$\{title\} is true, the title text takes the form of
"\$form-$>$\{title\} - \$form-$>$\{titlebar\}".  The value of \$form-$>$\{pre\} is output 
immediately after the closing of $<$head$>$.


\item[{\$form-$>$redirect([\$msg]);}] \mbox{}

If \$form-$>$\{callback\} is set or \$msg is not set, call the redirect function in
common.pl.  If main::redirect returns, exit.



Otherwise, output \$msg as an informational message with \$form-$>$info(\$msg).


\item[{\$form-$>$sort\_columns(@columns);}] \mbox{}

Sorts the list @columns.  If \$form-$>$\{sort\} is unset, do nothing.  If the value
of \$form-$>$\{sort\} does not exist in @columns, returns the list formed by the
value of \$form-$>$\{sort\} followed by the values of @columns.  If the value of
\$form-$>$\{sort\} is in @columns, return the list formed by @columns with the value
of \$form-$>$\{sort\} moved to the head of the list.


\item[{\$form-$>$sort\_order(\$columns[, \$ordinal]);}] \mbox{}

Returns a string that contains ordering details for the columns in SQL form.
\$columns is a reference to a list of columns, \$ordinal is a reference to a hash
that maps column names to ordinal positions.  This function depends upon the
values of \$form-$>$\{direction\}, \$form-$>$\{sort\}, and \$form-$>$\{oldsort\}.



If \$form-$>$\{direction\} is false, it becomes 'ASC'.  If \$form-$>$\{direction\} is true
and \$form-$>$\{sort\} and \$form-$>$\{oldsort\} are equal, reverse the order specified by
\$form-$>$\{direction\}.  \$form-$>$\{oldsort\} is set to the same value as \$form-$>$\{sort\}



The actual sorting of \$columns happens as in \$form-$>$sort\_columns(@\$columns).



If \$ordinal is set, the positions given by it are substituted for the names of
columns returned.


\item[{\$form-$>$convert\_date(\$date, \$myconfig)}] \mbox{}

This takes a date in YYYY-MM-DD format and returns it in the format of the user.


\item[{\$form-$>$format\_amount(\$myconfig, \$amount,}] \textbf{\$places, \$dash);}

Returns \$amount as formatted in the form specified by \$form-$>$\{numberformat\}.
\$places is the number of decimal places to have in the output.  \$dash indicates
how to represent conditions surrounding values.

\begin{verbatim}
 +-------+----------+---------+------+
 | $dash | -1.00    | 1.00    | 0.00 |
 +-------+----------+---------+------+
 |   -   | (1.00)   | 1.00    |   -  |
 | DRCR  |  1.00 DR | 1.00 CR | DRCR |
 |   0   | -1.00    | 1.00    | 0.00 |
 |   x   | -1.00    | 1.00    |   x  |
 | undef | -1.00    | 1.00    |      |
 +-------+----------+---------+------+
\end{verbatim}


Sample behaviour of the formatted output of various numbers for select \$dash
values.


\item[{\$form-$>$parse\_amount(\$myconfig, \$amount);}] \mbox{}

Return a Math::BigFloat containing the value of \$amount where \$amount is
formatted as \$myconfig-$>$\{numberformat\}.  If \$amount is '' or undefined, it is
treated as zero.  DRCR and parenthesis notation is accepted in addition to
negative sign notation.



Calls \$form-$>$error if the value is NaN.


\item[{\$form-$>$round\_amount(\$amount, \$places);}] \mbox{}

Rounds the provided \$amount to \$places decimal places.


\item[{\$form-$>$db\_parse\_numeric('sth' =$>$}] \textbf{\$sth, ['arrayref' =$>$ \$arrayref, 'hashref' =$>$ \$hashref])}

Converts numeric values in the result set \$arrayref or \$hashref to
Math::BigFloat using \$sth to determine which fields are numeric.


\item[{\$form-$>$get\_my\_emp\_num(\$myconfig);}] \mbox{}

Function to get the employee number of the user \$form-$>$\{login\}.  \$myconfig is
only used to create \%myconfig.  \$form-$>$\{emp\_num\} is set to the retrieved value.



This function is currently (2007-08-02) only used by pos.conf.pl.


\item[{\$form-$>$format\_string(@fields);}] \mbox{}

Escape the values of \$form selected by @fields for the format specified by
\$form-$>$\{format\}.


\item[{\$form-$>$datetonum(\$myconfig, \$date[,}] \textbf{\$picture]);}

Converts \$date from the format \$myconfig-$>$\{dateformat\} to the format 'yyyymmdd'.
If the year extracted is only two-digits, the year given is assumed to be in the
range 2000-2099.



If \$date does not contain any non-digits, datetonum does nothing.



\$picture is ignored.


\item[{\$form-$>$add\_date(\$myconfig, \$date,}] \textbf{\$repeat, \$unit);}

Returns the date \$repeat \$units from \$date in the input format.  \$date can
either be in \$myconfig-$>$\{dateformat\} or 'yyyymmdd' (four digit year required for
this option).  The valid values for \$unit are 'days', 'weeks', 'months', and
'years'.



This function is unreliable for \$unit values other than 'days' or 'weeks' and
can die horribly.


\item[{\$form-$>$print\_button(\$button, \$name);}] \mbox{}

Outputs a submit button to STDOUT.  \$button is a hashref that contains data
about buttons, \$name is the key for the element in \$button to output.  Each
value in \$button is a reference to a hash of two elements, 'key' and 'value'.



\$name is the value of the button that gets sent to the server when clicked,
\$button-$>$\{\$name\}\{key\} is the accesskey, and \$button-$>$\{\$name\}\{value\} is the label
for the button.


\item[{test\_should\_get\_images}] \mbox{}

Returns true if images should get be retrieved for embedding in templates


\item[{\$form-$>$db\_init(\$myconfig);}] \mbox{}

Connect to the database that \$myconfig is set to use and initialise the base
parameters.  The connection handle becomes \$form-$>$\{dbh\} and
\$form-$>$\{custom\_db\_fields\} is populated.  The connection initiated has
autocommit disabled.


\item[{\$form-$>$run\_custom\_queries(\$tablename,}] \textbf{\$query\_type[, \$linenum]);}

Runs queries against custom fields for the specified \$query\_type against
\$tablename.



Valid values for \$query\_type are any casing of 'SELECT', 'INSERT', and 'UPDATE'.


\item[{\$form-$>$dbconnect(\$myconfig);}] \mbox{}

Returns an autocommit connection to the database specified in \$myconfig.


\item[{\$form-$>$dbconnect\_noauto(\$myconfig);}] \mbox{}

Returns a non-autocommit connection to the database specified in \$myconfig.


\item[{\$form-$>$dbquote(\$var);}] \mbox{}

If \$var is an empty string, return NULL, otherwise return \$var as quoted by
\$form-$>$\{dbh\}-$>$quote(\$var).


\item[{\$form-$>$update\_balance(\$dbh, \$table,}] \textbf{\$field, \$where, \$value);}

\textbf{WARNING}: This is a dangerous private function.  All apps calling it must be
careful to avoid SQL injection issues.



If \$value is set, sets the value of \$field in \$table to the sum of the current
stored value and \$value.  In order to not annihilate the values in \$table,
\$where must contain a WHERE clause that limits the UPDATE to a single row.


\item[{\$form-$>$update\_exchangerate(\$dbh, \$curr,}] \textbf{\$transdate, \$buy, \$sell);}

Updates the exchange rates \$buy and \$sell for the given \$currency on \$transdate.
If there is not yet an exchange rate for \$currency on \$transdate, an entry is
inserted.  This returns without doing anything if \$curr eq ''.



\$dbh is not used, favouring \$self-$>$\{dbh\}.


\item[{\$form-$>$save\_exchangerate(\$myconfig,}] \textbf{\$currency, \$transdate, \$rate, \$fld);}

Saves the exchange rate \$rate for the given \$currency on \$transdate for the
provided purpose in \$fld.  \$fld can be either 'buy' or 'sell'.



\$myconfig is not used.  \$self-$>$update\_exchangerate is used for the majority of
the work.


\item[{\$form-$>$get\_exchangerate(\$dbh, \$curr,}] \textbf{\$transdate, \$fld);}

Returns the exchange rate in relation to the default currency for \$currency on
\$transdate for the purpose indicated by \$fld.  \$fld can be either 'buy' or
'sell' to get usable results.



\$dbh is not used, favouring \$self-$>$\{dbh\}.


\item[{\$form-$>$check\_exchangerate(\$myconfig,}] \textbf{\$currency, \$transdate, \$fld);}

Returns some true value when an entry for \$currency on \$transdate is true for
the purpose indicated by \$fld.  \$fld can be either 'buy' or 'sell' to get
usable results.  Returns false if \$transdate is not set.



\$myconfig is not used.


\item[{\$form-$>$add\_shipto(\$dbh, \$id);}] \mbox{}

Inserts a new address into the table shipto if the value of any of the shipto
address components in \$form differs to the regular attribute in \$form.  The
inserted value of trans\_id is \$id, the other fields correspond with the shipto
address components of \$form.



\$dbh is unused.


\item[{\$form-$>$get\_employee(\$dbh);}] \mbox{}

Returns a list containing the name and id of the employee \$form-$>$\{login\}.  Any
portion of \$form-$>$\{login\} including and past '@' are ignored.



\$dbh is unused.


\item[{\$form-$>$get\_name(\$myconfig, \$table[,}] \textbf{\$transdate])}

Sets \$form-$>$\{name\_list\} to refer to a list of customers or vendors whose names
or numbers match the value found in \$form-$>$\{\$table\} and returns the number of
matches.  \$table can be 'vendor', 'customer', or 'employee'; if the optional
field \$transdate is provided, the result set is further limited to \$table
entries which were active on the provided date as determined by the start and
end dates.  The elements of \$form-$>$\{name\_list\} are references returned rows in
hashref form and are sorted by the name field.  The fields of the hash are those
of the view \$table and the table entity.



\$myconfig is unused.


\item[{\$form-$>$all\_vc(\$myconfig, \$vc, \$module,}] \textbf{\$dbh, \$transdate, \$job);}

Populates the list referred to by \$form-$>$\{all\_\$\{vc\}\} with hashes of either
vendor or customer id and name, ordered by the name.  This will be vendor
details unless \$vc is set to 'customer'.  This list can be limited to only
vendors or customers which are usable on a given day by specifying \$transdate.
As a further restriction, \$form-$>$\{all\_\$\{vc\}\} will not be populated if the
number of vendors or customers that would be present in that list exceeds, or
is equal to, \$myconfig-$>$\{vclimit\}.



In addition to the possible population of \$form-$>$\{all\_\$\{vc\}\},
\$form-$>$\{employee\_id\} is looked up if not already set, the list
\$form-$>$\{all\_language\} is populated using the language table and is sorted by the
description, and \$form-$>$all\_employees, \$form-$>$all\_departments,
\$form-$>$all\_business\_units, and \$form-$>$all\_taxaccounts are all run.



\$module and \$dbh are unused.


\item[{\$form-$>$get\_regular\_metadata(\$myconfig,}] \textbf{\$vc, \$module, \$dbh, \$transdate, \$job)}

This is API-compatible with all\_vc.  It is a handy wrapper function that calls
the following functions:
all\_employees
all\_departments
all\_business\_units
all\_taxaccounts



It is preferable to using all\_vc where the latter does not work properly due to
variable collisions, etc.



\$form-$>$\{employee\_id\} is looked up if not already set, the list
\$form-$>$\{all\_language\} is populated using the language table and is sorted by the
description, and \$form-$>$all\_employees, \$form-$>$all\_departments,
\$form-$>$all\_business\_units, and \$form-$>$all\_taxaccounts are all run.



\$module and \$dbh are unused.


\item[{\$form-$>$all\_accounts()}] \mbox{}

Sets \$form-$>$\{accounts\} to all accounts.  Returns the list as well.
Example:  my @account\_list = \$form-$>$all\_accounts();


\item[{\$form-$>$all\_taxaccounts(\$myconfig, \$dbh2[,}] \textbf{\$transdate]);}

Get the tax rates and numbers for all the taxes in \$form-$>$\{taxaccounts\}.  Does
nothing if \$form-$>$\{taxaccounts\} is false.  Taxes are listed as a space separated
list of account numbers from the chart.  The retrieved values are placed within
\$form-$>$\{\$\{accno\}\_rate\} and \$form-$>$\{\$\{accno\}\_taxnumber\}.  If \$transdate is set,
then only process taxes that were valid on \$transdate.



\$myconfig and \$dbh2 are unused.


\item[{\$form-$>$all\_employees(\$myconfig, \$dbh2,}] \textbf{\$transdate, \$sales);}

Sets \$form-$>$\{all\_employee\} to be a reference to an array referencing hashes of
employee information.  The hashes are of the form \{'id' =$>$ id, 'name' =$>$ name\}.
If \$transdate is set, the query is limited to employees who are active on that
day.  If \$sales is true, only employees with the sales flag set are added.



\$dbh2 is unused.


\item[{\$form-$>$all\_business\_units([\$transdate,}] \textbf{\$credit\_id]);}

Returns a list at bu\_class with class information, ordered by order information
and a list of units in lists at bu\_units-$>$\$class\_id.  \$transdate is used to
filter projects active at specified date.  \$credit\_id is to filter out 
units assigned to other customers.


\item[{\$form-$>$all\_languages(\$myconfig);}] \mbox{}

Set \$form-$>$\{all\_language\} to be a reference to a list of hashrefs describing
languages using the form \{'code' =$>$ code, 'description' =$>$ description\}.


\item[{\$form-$>$all\_years(\$myconfig[, \$dbh2]);}] \mbox{}

Populates the hash \$form-$>$\{all\_month\} with a mapping between a two-digit month
number and the English month name.  Populates the list \$form-$>$\{all\_years\} with
all years which contain transactions.



\$dbh2 is unused.


\item[{\$form-$>$create\_links( \{ module =$>$ \$module,     myconfig =$>$ \$myconfig, vc =$>$ \$vc, billing =$>$ \$billing [, job =$>$ \$job ] \});}] \mbox{}

Populates the hash referred to as \$form-$>$\{\$\{module\}\_links\} details about
accounts that have \$module in their link field.  The hash is keyed upon link
elements such as 'AP\_amount' and 'AR\_tax' and they refer to lists of hashes
containing accno and description for the appropriate accounts.  If the key does
not contain 'tax', the account number is appended to the space separated list
\$form-$>$\{accounts\}.  \$module is typically 'AR' or 'AP' and is the base type of
the accounts looked up.



If \$form-$>$\{id\} is not set, check \$form-$>$\{"\$form-$>$\{vc\}\_id"\}.  If neither is set,
use \$form-$>$lastname\_used to populate the details.  If \$form-$>$\{id\} is set,
populate the invnumber, transdate, \$\{vc\}\_id, datepaid, duedate, ordnumber,
taxincluded, currency, notes, intnotes, \$\{vc\}, department\_id, department,
oldinvtotal, oldtotalpaid, employee\_id, employee, language\_code, ponumber, 
reverse, printed, emailed, queued, recurring, exchangerate, and acc\_trans
attributes of \$form with details about the transaction \$form-$>$\{id\}.  All of
these attributes, save for acc\_trans, are scalar; \$form-$>$\{acc\_trans\} refers to
a hash keyed by link elements whose values are lists of references to hashes
describing acc\_trans table entries corresponding to the transaction \$form-$>$\{id\}.
The elements in the acc\_trans entry hashes are accno, description, source,
amount, memo, transdate, cleared, project\_id, projectnumber, and exchangerate.



The closedto, separate\_duties, revtrans, and currencies \$form attributes are filled with values
from the defaults table, while \$form-$>$\{current\_date\} is populated with the
current date.  If \$form-$>$\{id\} is not set, then \$form-$>$\{transdate\} also takes on
the current date.



When \$billing is provided and true, the email addresses are selected
from the billing contact classes, when available, falling back to the
normal email classes when not.



After all this, it calls \$form-$>$all\_vc to conclude.


\item[{\$form-$>$lastname\_used(\$myconfig, \$dbh2,}] \textbf{\$vc, \$module);}

Fills the name, currency, \$\{vc\}\_id, duedate, and possibly invoice\_notes
attributes of \$form with the last used values for the transaction type specified
by both \$vc and \$form-$>$\{type\}.  \$vc can be either 'vendor' or 'customer' and if
unspecified will take on the value given in \$form-$>$\{vc\}, defaulting to 'vendor'.
If \$form-$>$\{type\} matches /\_order/, the transaction type used is order, if it
matches /\_quotation/, quotations are looked through.  If \$form-$>$\{type\} does not
match either of the above, then ar or ap transactions are used.



\$myconfig, \$dbh2, and \$module are unused.


\item[{\$form-$>$current\_date(\$myconfig[, \$thisdate,}] \textbf{\$days]);}

If \$thisdate is false, get the current date from the database.



If \$thisdate is true, get the date \$days days from \$thisdate in the date
format specified by \$myconfig-$>$\{dateformat\} from the database.


\item[{\$form-$>$like(\$str);}] \mbox{}

Returns '\%\$str\%'


\item[{\$form-$>$redo\_rows(\$flds, \$new, \$count,}] \textbf{\$numrows);}

\$flds refers to a list of field names and \$new refers to a list of row detail
hashes with the elements of \$flds as keys as well as runningnumber for an order
or another multi-row item that normally expresses elements in the form
\$form-$>$\{\$\{fieldname\}\_\$\{index\}\}.



For every \$field in @\{\$flds\} populates \$form-$>$\{\$\{field\}\_\$i\} with an appropriate
value from a \$new detail hash where \$i is an index between 1 and \$count.  The
ordering of the details is done in terms of the runningnumber element of the
row detail hashes in \$new.



All \$form attributes with names of the form \$\{field\}\_\$i where the index \$i is
between \$count + 1 and \$numrows is deleted.


\item[{\$form-$>$get\_partsgroup(\$myconfig[, \$p]);}] \mbox{}

Populates the list referred to as \$form-$>$\{all\_partsgroup\}.  \$p refers to a hash
that describes which partsgroups to retrieve.  \$p-$>$\{searchitems\} can be 'part',
'service', 'assembly', 'labor', or 'nolabor' and will limit the groups to those
that contain the item type described.  \$p-$>$\{searchitems\} and \$p-$>$\{all\} conflict.
If \$p-$>$\{all\} is set and \$p-$>$\{language\_code\} is not, all partsgroups are
retrieved.  If \$p-$>$\{language\_code\} is set, also include the translation
description specified by \$p-$>$\{language\_code\} for the partsgroup.



The results in \$form-$>$\{all\_partsgroup\} are normally sorted by partsgroup name.
If a language\_code is specified, the results are then sorted by the translated
description.



\$myconfig is unused.


\item[{\$form-$>$update\_status(\$myconfig);}] \mbox{}

DELETEs all status rows which have a formname of \$form-$>$\{formname\} and a 
trans\_id of \$form-$>$\{id\}.  INSERTs a new row into status where trans\_id is
\$form-$>$\{id\}, formname is \$form-$>$\{formname\}, printed and emailed are true if
their respective \$form attributes match /\$form-$>$\{formname\}/, and spoolfile is
the file extracted from the string \$form-$>$\{queued\} or NULL if there is no entry
for \$form-$>$\{formname\}.



\$myconfig is unused.


\item[{\$form-$>$save\_status();}] \mbox{}

Clears out any old status entries for \$form-$>$\{id\} and saves new status entries.
Queued form names are extracted from \$form-$>$\{queued\}.  Printed and emailed form
names are extracted from \$form-$>$\{printed\} and \$form-$>$\{emailed\}.  The queued,
printed, and emailed fields are space separated lists.


\item[{\$form-$>$get\_recurring();}] \mbox{}

Sets \$form-$>$\{recurring\} to contain info about the recurrence schedule for the
action \$form-$>$\{id\}.  \$form-$>$\{recurring\} is of the same form used by
\$form-$>$save\_recurring(\$dbh2, \$myconfig).

\begin{verbatim}
  reference,startdate,repeat,unit,howmany,payment,print,email,message
       text      date    int text     int     int  text  text    text
\end{verbatim}

\item[{\$form-$>$save\_recurring(\$dbh2, \$myconfig);}] \mbox{}

Saves or deletes recurring transaction scheduling.  \$form-$>$\{id\} is used to
determine the id used in the various recurring tables.  A recurring transaction
schedule is deleted by having \$form-$>$\{recurring\} be false.  For adding or
updating a schedule, \$form-$>$\{recurring\} is a comma separated field with partial
subfield quoting of the form:

\begin{verbatim}
  reference,startdate,repeat,unit,howmany,payment,print,email,message
       text      date    int text     int     int  text  text    text
\end{verbatim}
\begin{description}

\item[{reference}] \mbox{}

A URI-encoded reference string for the recurrence set.


\item[{startdate}] \mbox{}

The index date for the recurrence.


\item[{repeat}] \mbox{}

The unitless repetition frequency.


\item[{unit}] \mbox{}

The interval unit used.  Can be 'days', 'weeks', 'months', or 'years',
capitalisation and pluralisation ignored.


\item[{howmany}] \mbox{}

The number of recurrences for the transaction.


\item[{payment}] \mbox{}

Flag to indicate if a payment is included in the transaction.


\item[{print}] \mbox{}

A colon separated list of formname:format:printer triplets.


\item[{email}] \mbox{}

A colon separated list of formname:format pairs.


\item[{message}] \mbox{}

A URI-encoded message for the emails to be sent.

\end{description}


Values for the nextdate and enddate columns of the recurring table are
calculated using startdate, repeat, unit, howmany, and the current database
date.  All other fields of the recurring, recurringemail, and recurringprint are
obtained directly from \$form-$>$\{recurring\}.



\textbf{WARNING}: This function does not check the validity of most subfields of
\$form-$>$\{recurring\}.



\$dbh2 is not used.


\item[{\$form-$>$save\_intnotes(\$myconfig, \$vc);}] \mbox{}

Sets the intnotes field of the entry in the table \$vc that has the id
\$form-$>$\{id\} to the value of \$form-$>$\{intnotes\}.



Does nothing if \$form-$>$\{id\} is not set.


\item[{\$form-$>$update\_defaults(\$myconfig, \$fld[,}] \textbf{\$dbh [, \$nocommit]);}

Updates the defaults entry for the setting \$fld following rules specified by
the existing value and returns the processed value that results.  If \$form is
false, such as the case when invoked as "Form::update\_defaults('',...)", \$dbh is
used as the handle.  When \$form is set, it uses \$form-$>$\{dbh\}, initialising the
connection if it does not yet exist.  The entry \$fld must exist prior to
executing this function and this update function does not handle the general
case of updating the defaults table.



Note that nocommit prevents the db from committing in this function.



\textbf{NOTE}: rules handling is currently broken.



Rules followed by this function's processing:

\begin{itemize}

\item 

If digits are found in the field, increment the left-most set.  This change,
unlike the others is reflected in the UPDATE.


\item 

Replace $<$?lsmb date ?$>$ with the date specified in \$form-$>$\{transdate\} formatted
as \$myconfig-$>$\{dateformat\}.


\item 

Replace $<$?lsmb curr ?$>$ with the value of \$form-$>$\{currency\}

\end{itemize}

\item[{\$form-$>$db\_prepare\_vars(var1, var2,}] \textbf{..., var\textit{n})}

Undefines \$form-$>$\{var\textit{m}\}, 1 $<$= \textit{m} $<$= \textit{n}, iff \$form-$<$\{var\textit{m} is both
false and not "0".


\item[{\$form-$>$split\_date(\$dateformat[, \$date]);}] \mbox{}

Returns (\$rv, \$yy, \$mm, \$dd) for the provided \$date, or the current date if no
date is provided.  \$rv is a seperator-free merging of the fields \$yy, \$mm, and
\$dd in the ordering supplied by \$dateformat.  If the supplied \$date does not
contain non-digit characters, \$rv is \$date and the other return values are
undefined.



\$yy is two digits.


\item[{\$form-$>$format\_date(\$date);}] \mbox{}

Returns \$date converted from 'yyyy-mm-dd' format to the format specified by
\$form-$>$\{db\_dateformat\}.  If the supplied date does not match /\^{}$\backslash$d\{4\}$\backslash$D/,
return the supplied date.



This function takes a four digit year and returns the date with a four digit
year.


\item[{\$form-$>$from\_to(\$yyyy, \$mm[, \$interval]);}] \mbox{}

Returns the date \$yyyy-\$mm-01 and the the last day of the month interval - 1
months from then in the form (\$form-$>$format\_date(fromdate),
\$form-$>$format\_date(later)).  If \$interval is false but defined, the later date
is the current date.



This function dies horribly when \$mm + \$interval $>$ 24


\item[{\$form-$>$audittrail(\$dbh, \$myconfig,}] \textbf{\$audittrail);}

Audit trail has been replaced by triggers which work on a very similar manner.

\end{description}
\section{LedgerSMB::File::Part\label{LedgerSMB::File::Part}\index{LedgerSMB::File::Part}}


Manages attachments to goods and services.

\subsection*{SYNOPSIS\label{LedgerSMB::File::Part_SYNOPSIS}\index{LedgerSMB::File::Part!SYNOPSIS}}


Manages attachments to goods and services.

\subsection*{INHERITS\label{LedgerSMB::File::Part_INHERITS}\index{LedgerSMB::File::Part!INHERITS}}
\begin{description}

\item[{LedgerSMB::File}] \mbox{}

Provides all properties and accessors.  This subclass provides additional 
methods only

\end{description}
\subsection*{METHODS\label{LedgerSMB::File::Part_METHODS}\index{LedgerSMB::File::Part!METHODS}}
\begin{description}

\item[{attach}] \mbox{}

Attaches or links a specific file to the given transaction.

\end{description}
\subsection*{COPYRIGHT\label{LedgerSMB::File::Part_COPYRIGHT}\index{LedgerSMB::File::Part!COPYRIGHT}}


Copyright (C) 2011 The LedgerSMB Core Team



This file is licensed under the Gnu General Public License version 2, or at your
option any later version.  A copy of the license should have been included with
your software.

\section{LedgerSMB::File::Transaction\label{LedgerSMB::File::Transaction}\index{LedgerSMB::File::Transaction}}


Manages attachments to financial transactions.

\subsection*{SYNOPSIS\label{LedgerSMB::File::Transaction_SYNOPSIS}\index{LedgerSMB::File::Transaction!SYNOPSIS}}


Manages attachments to financial transactions (in 1.3, AR, AP, and GL entries)

\subsection*{INHERITS\label{LedgerSMB::File::Transaction_INHERITS}\index{LedgerSMB::File::Transaction!INHERITS}}
\begin{description}

\item[{LedgerSMB::File}] \mbox{}

Provides all properties and accessors.  This subclass provides additional 
methods only

\end{description}
\subsection*{METHODS\label{LedgerSMB::File::Transaction_METHODS}\index{LedgerSMB::File::Transaction!METHODS}}
\begin{description}

\item[{attach([\{no\_commit =$>$ bool\}])}] \mbox{}

Attaches or links a specific file to the given transaction.


\item[{attach\_all\_from\_order(\{id = int\})}] \mbox{}

Links all files to a specific transaction from a specific order.  Note this 
only handles files that were attached to orders to start with.

\end{description}
\subsection*{COPYRIGHT\label{LedgerSMB::File::Transaction_COPYRIGHT}\index{LedgerSMB::File::Transaction!COPYRIGHT}}


Copyright (C) 2011 The LedgerSMB Core Team



This file is licensed under the Gnu General Public License version 2, or at your
option any later version.  A copy of the license should have been included with
your software.

\section{LedgerSMB::File::Order\label{LedgerSMB::File::Order}\index{LedgerSMB::File::Order}}


Manages attachments to orders.

\subsection*{SYNOPSIS\label{LedgerSMB::File::Order_SYNOPSIS}\index{LedgerSMB::File::Order!SYNOPSIS}}


Manages attachments to orders (sales orders, purchase orders, quotations and
RFQ's).

\subsection*{INHERITS\label{LedgerSMB::File::Order_INHERITS}\index{LedgerSMB::File::Order!INHERITS}}
\begin{description}

\item[{LedgerSMB::File}] \mbox{}

Provides all properties and accessors.  This subclass provides additional 
methods only

\end{description}
\subsection*{METHODS\label{LedgerSMB::File::Order_METHODS}\index{LedgerSMB::File::Order!METHODS}}
\begin{description}

\item[{attach}] \mbox{}

Attaches or links a specific file to the given transaction.


\item[{attach\_all\_from\_order(\{id = int\})}] \mbox{}

Links all files to a specific transaction from a specific order.  Note this 
only handles files that were attached to orders and transactions to start with.


\item[{attach\_all\_from\_transaction(\{id = int\})}] \mbox{}

Links all files to a specific transaction from a specific transaction.  Note 
this only handles files that were attached to orders and transactions to start 
with.

\end{description}
\subsection*{COPYRIGHT\label{LedgerSMB::File::Order_COPYRIGHT}\index{LedgerSMB::File::Order!COPYRIGHT}}


Copyright (C) 2011 The LedgerSMB Core Team



This file is licensed under the Gnu General Public License version 2, or at your
option any later version.  A copy of the license should have been included with
your software.

\section{LedgerSMB::App\_State\label{LedgerSMB::App_State}\index{LedgerSMB::App\ State}}




\subsection*{SYNPOSIS\label{LedgerSMB::App_State_SYNPOSIS}\index{LedgerSMB::App State!SYNPOSIS}}


This is a generic container class for non-web-application related state
information.  It provides a central place to track such things as localization,
user, and other application state objects.

\subsection*{OBJECTS FOR STORAGE\label{LedgerSMB::App_State_OBJECTS_FOR_STORAGE}\index{LedgerSMB::App State!OBJECTS FOR STORAGE}}


The following are objects that are expected to be stored in this namespace:

\begin{description}

\item[{Locale}] \mbox{}

Stores a LedgerSMB::Locale object for the specific user.


\item[{User}] \mbox{}

Stores a LedgerSMB::User object for the currently logged in user.


\item[{SODA}] \mbox{}

Stores the SODA database access handle.


\item[{Company\_Settings}] \mbox{}

Hashref for storing connection-specific settings for the application.


\item[{DBH}] \mbox{}

Database handle for current connection


\item[{Roles}] \mbox{}

This is a list (array) of role names for the current user.


\item[{Role\_Prefix}] \mbox{}

String of the beginning of the role.


\item[{DBName}] \mbox{}

name of the database connecting to

\end{description}
\subsection*{METHODS\label{LedgerSMB::App_State_METHODS}\index{LedgerSMB::App State!METHODS}}
\begin{description}

\item[{init(string \$username, string \$credential,}] \textbf{string \$company)}
\item[{zero()}] \mbox{}

zeroes out all majro parts.


\item[{cleanup}] \mbox{}

Deletes all objects attached here.


\item[{get\_url}] \mbox{}

Returns URL of get request or undef


\item[{all\_months(is\_short \$bool)}] \mbox{}

Returns hashref of localized date data with following members:



If \$is\_short is set and true, returns short names (Jan, Feb, etc) instead of 
long names (January, February, etc).

\begin{description}

\item[{dropdown}] \mbox{}

Month information in drop down format.


\item[{hashref}] \mbox{}

Month info in hashref format in 01 =$>$ January format

\end{description}
\end{description}
\subsection*{COPYRIGHT\label{LedgerSMB::App_State_COPYRIGHT}\index{LedgerSMB::App State!COPYRIGHT}}


Copyright (C) 2009 LedgerSMB Core Team.  This file is licensed under the GNU 
General Public License version 2, or at your option any later version.  Please
see the included License.txt for details.

\section{LedgerSMB::DBObject\label{LedgerSMB::DBObject}\index{LedgerSMB::DBObject}}


LedgerSMB class for building objects from db relations

\subsection*{SYOPSIS\label{LedgerSMB::DBObject_SYOPSIS}\index{LedgerSMB::DBObject!SYOPSIS}}


This module creates object instances based on LedgerSMB's in-database ORM.

\subsection*{METHODS\label{LedgerSMB::DBObject_METHODS}\index{LedgerSMB::DBObject!METHODS}}
\begin{description}

\item[{new (\$class, base =$>$ \$LedgerSMB::hash)}] \mbox{}

This is the base constructor for all child classes.  It must be used with base
argument because this is necessary for database connectivity and the like.



Of course the base object can be any object that inherits LedgerSMB, so you can
use any subclass of that.  The per-session dbh is passed between the objects 
this way as is any information that is needed.


\item[{exec\_method}] \mbox{}

(\$self, procname =$>$ \$function\_name, [args =$>$ $\backslash$@args, schema =$>$ \$schema,
continue\_on\_error=$>$\$continue\_on\_error])



Provides the basic mapping of parameters to the SQL stored procedure function 
arguments.



If $\backslash$@args is not defined, args are mapped from the object's properties, 
stripping them of their in\_ prefix.  If schema is provided, that is used 
instead of PostgreSQL's search path.  If continue\_on\_error is provided and true,
the operation will not raise an exception in the event of a database error, and 
it will be up to the application to handle any exceptions.


\item[{\_\_validate\_\_ is called on every new()}] \textbf{invocation. It is blank in this module but can be overridden in decendant modules.}
\item[{\_db\_array\_scalars(@elements) creates}] \textbf{a db array from scalars.}
\item[{\_db\_array\_literal(@elements) creates}] \textbf{a multiple dimension db array from 	preparsed db arrays or other data which does not need to be escaped.}
\item[{set\_ordering}] \mbox{}

Sets the ordering used by default for specific functions called by exec\_method


\item[{run\_custom\_queries}] \mbox{}

Backward-compatible with 1.2 custom query system for moving forward.

\end{description}
\subsection*{Copyright (C) 2007, The LedgerSMB core team.\label{LedgerSMB::DBObject_Copyright_C_2007_The_LedgerSMB_core_team_}\index{LedgerSMB::DBObject!Copyright (C) 2007, The LedgerSMB core team.}}


This file is licensed under the Gnu General Public License version 2, or at your
option any later version.  A copy of the license should have been included with
your software.

\section{LedgerSMB::IS\label{LedgerSMB::IS}\index{LedgerSMB::IS}}


Inventory Invoicing

\begin{description}

\item[{get\_files}] \mbox{}

Returns a list of files associated with the existing transaction.  This is 
provisional, and will change for 1.4 as the GL transaction functionality is 
                  \{ref\_key =$>$ \$self-$>$\{id\}, file\_class =$>$ 1\}
rewritten

\section{LedgerSMB::Session\label{LedgerSMB::Session}\index{LedgerSMB::Session}}




\subsection*{SYNOPSIS\label{LedgerSMB::Session_SYNOPSIS}\index{LedgerSMB::Session!SYNOPSIS}}


Routines for tracking general session actions (create, check, and destroy 
sessions).

\subsection*{METHODS\label{LedgerSMB::Session_METHODS}\index{LedgerSMB::Session!METHODS}}
\begin{description}

\item[{check}] \mbox{}

Checks to see if a session exists based on current logged in credentials.



Handles failure by creating a new session, since credentials are now separate.


\item[{create}] \mbox{}

Creates a new session, sets \$lsmb-$>$\{session\_id\} to that session, sets cookies, 
etc.


\item[{destroy}] \mbox{}

Destroys a session and removes it from the db.

\end{description}
\subsection*{COPYRIGHT\label{LedgerSMB::Session_COPYRIGHT}\index{LedgerSMB::Session!COPYRIGHT}}


\# Small Medium Business Accounting software
\# http://www.ledgersmb.org/
\# 
\#
\# Copyright (C) 2006-2011
\# This work contains copyrighted information from a number of sources all used
\# with permission.  It is released under the GNU General Public License
\# Version 2 or, at your option, any later version.  See COPYRIGHT file for
\# details.

\section{LedgerSMB::Setting\label{LedgerSMB::Setting}\index{LedgerSMB::Setting}}


LedgerSMB class for managing Business Locations

\subsection*{SYOPSIS\label{LedgerSMB::Setting_SYOPSIS}\index{LedgerSMB::Setting!SYOPSIS}}


This module creates object instances based on LedgerSMB's in-database ORM.

\subsection*{METHODS\label{LedgerSMB::Setting_METHODS}\index{LedgerSMB::Setting!METHODS}}


The following method is static:

\begin{description}

\item[{new (\$LedgerSMB object);}] \mbox{}\end{description}


The following methods are passed through to stored procedures:

\begin{description}

\item[{get (\$self-$>$\{key\})}] \mbox{}
\item[{set (\$self-$>$\{key\}, \$self-$>$\{value\})}] \mbox{}
\item[{parse\_increment (\$self-$>$\{key\})}] \mbox{}

This function updates a default entry in the database, incrimenting the last 
set of digits not including $<$?lsmb ?$>$ tags or non-digits, and then parses the 
returned value, doing tag substitution.  The final value is then returned by 
the function.

\end{description}


The above list may grow over time, and may depend on other installed modules.

\subsection*{Copyright (C) 2007, The LedgerSMB core team.\label{LedgerSMB::Setting_Copyright_C_2007_The_LedgerSMB_core_team_}\index{LedgerSMB::Setting!Copyright (C) 2007, The LedgerSMB core team.}}


This file is licensed under the Gnu General Public License version 2, or at your
option any later version.  A copy of the license should have been included with
your software.

\section{LedgerSMB::AM\label{LedgerSMB::AM}\index{LedgerSMB::AM}}


This module provides some administrative functions

\subsection*{SYNOPSIS\label{LedgerSMB::AM_SYNOPSIS}\index{LedgerSMB::AM!SYNOPSIS}}


This module provides some administrative functions

\subsection*{COPYRIGHT\label{LedgerSMB::AM_COPYRIGHT}\index{LedgerSMB::AM!COPYRIGHT}}
\begin{verbatim}
 #====================================================================
 # LedgerSMB
 # Small Medium Business Accounting software
 # http://www.ledgersmb.org/
 #
 # Copyright (C) 2006
 # This work contains copyrighted information from a number of sources
 # all used with permission.
 #
 # This file contains source code included with or based on SQL-Ledger
 # which is Copyright Dieter Simader and DWS Systems Inc. 2000-2005
 # and licensed under the GNU General Public License version 2 or, at
 # your option, any later version.  For a full list including contact
 # information of contributors, maintainers, and copyright holders,
 # see the CONTRIBUTORS file.
 #
 # Original Copyright Notice from SQL-Ledger 2.6.17 (before the fork):
 # Copyright (C) 2000
 #
 #  Author: DWS Systems Inc.
 #     Web: http://www.sql-ledger.org
 #
 #  Contributors: Jim Rawlings <jim@your-dba.com>
 #
 #====================================================================
 #
 # This file has undergone whitespace cleanup.
 #
 #====================================================================
 #
 # Administration module
 #    Chart of Accounts
 #    template routines
 #    preferences
 #
 #====================================================================
\end{verbatim}
\subsection*{METHODS\label{LedgerSMB::AM_METHODS}\index{LedgerSMB::AM!METHODS}}
\begin{description}

\item[{AM-$>$gifi\_accounts(\$myconfig, \$form);}] \mbox{}

Populates the list referred to as \$form-$>$\{ALL\} with hashes of gifi numbers and
descriptions in order of the GIFI number.  The GIFI number referred to as
'accno'.



\$myconfig is not used.


\item[{AM-$>$get\_gifi(\$myconfig, \$form);}] \mbox{}

Sets \$form-$>$\{description\} to the description of the GIFI number \$form-$>$\{accno\}.
Sets \$form-$>$\{orphaned\} to true if there are no entries in acc\_trans that refer
to this GIFI and to false otherwise.



\$myconfig is not used.


\item[{AM-$>$save\_gifi(\$myconfig, \$form);}] \mbox{}

Adds or updates a GIFI record.  If \$form-$>$\{id\} is set, update the gifi record
that has that as an account number.  The new values for an added or updated
record are stored in \$form-$>$\{accno\} and \$form-$>$\{description\}.



\$myconfig is not used.


\item[{AM-$>$delete\_gifi(\$myconfig, \$form);}] \mbox{}

Deletes the gifi record with the GIFI number \$form-$>$\{id\}.



\$myconfig is not used.


\item[{AM-$>$warehouses(\$myconfig, \$form);}] \mbox{}

Populates the list referred to as \$form-$>$\{ALL\} with hashes describing
warehouses, ordered according to the logic of \$form-$>$sort\_order.  Each hash has
an id and a description element.



\$myconfig is not used.


\item[{AM-$>$get\_warehouse(\$myconfig, \$form);}] \mbox{}

Sets \$form-$>$\{description\} to the name of the warehouse \$form-$>$\{id\}.  If no
inventory is currently linked to the warehouse, set \$form-$>$\{orphaned\} to true,
otherwise \$form-$>$\{orphaned\} is false.



\$myconfig is not used.


\item[{AM-$>$save\_warehouse(\$myconfig, \$form);}] \mbox{}

Add or update a warehouse.  If \$form-$>$\{id\} is set, that warehouse is updated
instead of adding a new warehouse.  In both cases, the description of the
warehouse is set to \$form-$>$\{description\}.



\$myconfig is not used.


\item[{AM-$>$delete\_warehouse(\$myconfig, \$form);}] \mbox{}

Deletes the warehouse with the id \$form-$>$\{id\}.



\$myconfig is not used.


\item[{AM-$>$business(\$myconfig, \$form);}] \mbox{}

Populates the list referred to as \$form-$>$\{ALL\} with hashes containing details
about all known types of business.  Each hash contains the id, description, and
discount for businesses of this type.  The discount is represented in numeric
form, such that a 10\% discount is stored and retrieved as 0.1.  The hashes are
sorted by the business description.



\$myconfig is unused.


\item[{AM-$>$get\_business(\$myconfig, \$form);}] \mbox{}

Places the description and discount for the business with an id of \$form-$>$\{id\}
into \$form-$>$\{description\} and \$form-$>$\{discount\}.



\$myconfig is unused.


\item[{AM-$>$save\_business(\$myconfig, \$form);}] \mbox{}

Adds or updates a type of business.  If \$form-$>$\{id\} is set, the business type
with a corresponding id is updated, otherwise a new type is added.  The new
description is \$form-$>$\{description\}.  The discount taken as a percentage stored
in \$form-$>$\{discount\}, which then value is divided by 100 in place and the
multiplier is stored.  As an example, if \$form-$>$\{discount\} is 10 when this
function is called, it is changed to 0.1 and stored as 0.1.



\$myconfig is unused.


\item[{AM-$>$delete\_business(\$myconfig, \$form);}] \mbox{}

Deletes the business type with the id \$form-$>$\{id\}.



\$myconfig is unused.


\item[{AM-$>$sic(\$myconfig, \$form);}] \mbox{}

Populate the list referred to as \$form-$>$\{ALL\} with hashes containing SIC (some
well known systems of which are NAICS and ISIC) data from the sic table.  code
is the actual SIC code, description is a textual description of the code, and
sictype is an indicator of whether or not the entry refers to a header.  The
hashes will be sorted by either the code or description.



\$myconfig is unused.


\item[{AM-$>$get\_sic(\$myconfig, \$form);}] \mbox{}

Retrieves the sictype and description for the SIC indicated by
\$form-$>$\{code\} and places the retrieved values into \$form-$>$\{sictype\} and
\$form-$>$\{description\}.



\$myconfig is unused


\item[{AM-$>$save\_sic(\$myconfig, \$form);}] \mbox{}

Add or update a SIC entry.  If \$form-$>$\{id\} is set, take it as the original code
to identify the entry update, otherwise treat it as a new entry.  \$form-$>$\{code\},
\$form-$>$\{description\}, and \$form-$>$\{sictype\} contain the new values.  sictype is
a single character to flag whether or not the entry is for a header ('H').



\$myconfig is unused.


\item[{AM-$>$delete\_sic(\$myconfig, \$form);}] \mbox{}

Deletes the SIC entry with the code \$form-$>$\{code\}.



\$myconfig is unused.


\item[{AM-$>$language(\$myconfig, \$form);}] \mbox{}

Populates the list referred to as \$form-$>$\{ALL\} with hashes containing the code
and description of all languages entered in the language table.  The usual set
of \$form attributes affect the order in which the hashes are entered in the
list.



These language functions are unrelated to LedgerSMB::Locale, although these
language codes are also used for non-UI templates and by LedgerSMB::PE.



\$myconfig is unused.


\item[{AM-$>$get\_language(\$myconfig, \$form);}] \mbox{}

Sets \$form-$>$\{description\} to the description of the language that has the code
\$form-$>$\{code\}.



\$myconfig is unused.


\item[{AM-$>$save\_language(\$myconfig, \$form);}] \mbox{}

Add or update a language entry.  If \$form-$>$\{id\} is set, the language entry that
has that as a code is updated, otherwise a new entry is added.  \$form-$>$\{code\}
and \$form-$>$\{description\} contain the new values for the entry.



\$myconfig is unused.


\item[{AM-$>$delete\_language(\$myconfig, \$form);}] \mbox{}

Deletes the language entry with the code \$form-$>$\{code\}.



\$myconfig is unused.


\item[{AM-$>$recurring\_transactions(\$myconfig,}] \textbf{\$form);}

Populates lists referred to in the form of \$form-$>$\{transactions\}\{\$type\}, where
the possible values for \$type are 'ar', 'ap', 'gl', 'so', and 'po', with hashes
containing details about recurring transactions of the \$type variety.  These
hashes have the fields module (the frontend script that governs the transaction
type), transaction (the transaction type), invoice (true if the transaction is
an invoice), description (a field that is a customer, vendor, or in the case of
a GL transaction, an arbitrary text field), amount (the cash value of the
transaction), id (the id of the recurring transaction), reference (the
reference value for the transaction), startdate (the date the recurring
sequence started), nextdate (the date of the next occurrence of the event),
enddate (the date the sequence ends), repeat (the number of units involved in
the recurrence frequency), unit (the base recurrence unit), howmany (how many
times the event occurs), payment (whether or not the event involves a payment),
recurringemail (a colon separated list of forms to email as part of the event),
recurringprint (a colon separated list of forms to print as part of the event),
overdue (how many days until the next repetition of the event), vc (vendor,
customer, or empty), exchangerate (the exchangerate involved on the day of the
original transaction), curr (the currency of the event), and expired (if there
will be no more recurrences).



By default, these lists are sorted in order of the date of the next occurrence
of the transaction.  This order can be affected by the usual attributes used
by \$form-$>$sort\_order.



\$myconfig is unused.


\item[{AM-$>$recurring\_details(\$myconfig, \$form,}] \textbf{\$id);}

Retrieves details about the recurring transaction \$id and places them into
attributes of \$form.  Sets id (the transaction id passed in, \$id), reference 
(a reference string for the recurring transaction), startdate (the date the
recurrence series started on), nextdate (the date of the next occurrence of the
event), enddate (the date of the final occurrence of the event), repeat (the
number of units involved in a recurrence period), unit (the recurrence unit),
howmany (the total number of recurrences in the recurrence series), payment
(whether or not the transaction is associated with a payment), arid (true if an
ar event), apid (true if an ap event), overdue (number of days an ar event was
to the duedate), paid (number of days after an ar event it was paid), req (days
until the requirement date from the transdate of an oe event), oeid (true if an
oe event), customer\_id (vendor id if sales order), vendor\_id (vendor id if
puchase order), vc ('customer' if customer\_id set, 'vendor' if vendor\_id set),
invoice (true if both arid and arinvoice set or if both apid and apinvoice set),
recurringemail (colon separated list of forms and formats to be emailed),
message (the non-attachement message body for the emails), and recurringprint 
(colon separated list of form names, formats, and printer names).



\$myconfig is unused.


\item[{AM-$>$update\_recurring(\$myconfig, \$form,}] \textbf{\$id)}

Updates nextdate for the recurring transaction \$id to the next date of the
sequence.  If the new value for nextdate is after enddate, nextdate is set to
NULL.



\$myconfig is unused.


\item[{AM-$>$check\_template\_name(\$myconfig,}] \textbf{\$form);}

Performs some sanity checking on the filename \$form-$>$\{file\} and calls
\$form-$>$error if the filename is disallowed.


\item[{AM-$>$load\_template(\$myconfig, \$form);}] \mbox{}

Populates \$form-$>$\{body\} with the contents of the file \$form-$>$\{file\}.


\item[{AM-$>$save\_template(\$myconfig, \$form);}] \mbox{}

Overwrites the file \$form-$>$\{file\} with the contents of \$form-$>$\{body\}, excluding
carriage returns.


\item[{AM-$>$save\_preferences(\$myconfig, \$form);}] \mbox{}

Saves the preferences for the current user.  New values are taken from the \$form
attributes name, email, dateformat, signature, numberformat, vclimit, tel, fax,
company, menuwidth, countrycode, address, timeout, stylesheet, printer,
password, new\_password, and old\_password.  Password updates occur when
new\_password and old\_password differ.


\item[{AM-$>$taxes(\$myconfig, \$form);}] \mbox{}

Retrieve details about all taxes in the database.  \$form-$>$\{taxrates\} refers to a
list containing hashes with the chart id (id), account number (accno),
description, rate, taxnumber, validto, pass, and taxmodulename for a tax.
\$form-$>$\{taxmodule\_\textbf{id}\}, where \textbf{id} is a taxmodule\_id, is set to that
taxmodule's name.



\$myconfig is unused.


\item[{AM-$>$save\_taxes(\$myconfig, \$form);}] \mbox{}

Deletes \textbf{all} entries from the tax table then re-inserts all taxes whose
accounts are part of the space separated list \$form-$>$\{taxaccounts\}.  Each
element of \$form-$>$\{taxaccounts\} is of the form 'chartid\_\textit{i}' where chartid is
the id of the chart entry for the tax and \textit{i} is a numeric index.  The values
inserted for each tax are chart\_id (from taxaccounts), rate (
form-$>$\{taxrate\_\textit{i}\} / 100), validto (\$form-$>$\{validto\_\textit{i}\}), taxnumber
(\$form-$>$\{taxnumber\_\textit{i}\}), pass (\$form-$>$\{pass\_\textit{i}\}), and taxmodule\_id
(\$form-$>$\{taxmodule\_id\_\textit{i}\}).


\item[{AM-$>$closedto(\$myconfig, \$form);}] \mbox{}

Populates \$form-$>$\{closedto\}, \$form-$>$\{revtrans\}, and \$form-$>$\{audittrail\} with
their values in the defaults table.



\$myconfig is unused.


\item[{AM-$>$closebooks(\$myconfig, \$form);}] \mbox{}

Updates the revtrans, closedto, and audittrail entries in the defaults table
using their corresponding \$form values.  If \$form-$>$\{removeaudittrail\} is set,
this used to remove all audittrail entries with a transdate prior to the date
given by \$form-$>$\{removeaudittrail\}, but has been disabled.



\$myconfig is unused.


\item[{AM-$>$earningsaccounts(\$myconfig, \$form);}] \mbox{}

Populates the list referred to as \$form-$>$\{chart\} with hashes containing the
account number (accno) and the description of all equity accounts, ordered by
the account number.



\$myconfig is unused.


\item[{AM-$>$post\_yearend(\$myconfig, \$form);}] \mbox{}

Posts the termination of a financial year.  Makes use of the \$form attributes
login, reference, notes, description, and transdate to populate the gl table
entry.  The id of the gl transaction is placed in \$form-$>$\{id\}.



For every accno\_\$i in \$form, where \$i is between 1 and \$form-$>$\{rowcount\}, an
acc\_trans entry will be added if credit\_\$i or debit\_\$i is non-zero.



A new yearend entry is populated with the id and transdate of the gl
transaction.



Adds an entry to the audittrail.



\$myconfig is unused.


\item[{AM-$>$get\_templates\_directories;}] \mbox{}

This functions gets all the directories from \$LedgerSMB::Sysconfig::templates to list all the possible
non-Ui templates.

\end{description}
\section{LedgerSMB::REST\_Class::Contact\label{LedgerSMB::REST_Class::Contact}\index{LedgerSMB::REST\ Class::Contact}}


Customer/vendor web servicesA

\subsection*{SYNOPSIS\label{LedgerSMB::REST_Class::Contact_SYNOPSIS}\index{LedgerSMB::REST Class::Contact!SYNOPSIS}}
\begin{verbatim}
 my $obj = LedgerSMB::REST_Class::Contact->new(%$payload);
 $obj->GET; # or PUT or POST.  DELETE not implemented for this class
\end{verbatim}
\subsection*{DESCRIPTION\label{LedgerSMB::REST_Class::Contact_DESCRIPTION}\index{LedgerSMB::REST Class::Contact!DESCRIPTION}}


This module contains the basic  handlers

\subsection*{PROPERTIES\label{LedgerSMB::REST_Class::Contact_PROPERTIES}\index{LedgerSMB::REST Class::Contact!PROPERTIES}}
\subsection*{METHODS\label{LedgerSMB::REST_Class::Contact_METHODS}\index{LedgerSMB::REST Class::Contact!METHODS}}
\begin{description}

\item[{GET}] \mbox{}

Searches or retrieves one or more records.


\item[{POST}] \mbox{}

Determines of record exists and if not creates it.  If so, throws a 400 error


\item[{PUT}] \mbox{}

Saves record, overwriting any record that was there before.


\item[{DELETE not implemented.}] \mbox{}\end{description}
\subsection*{COPYRIGHT\label{LedgerSMB::REST_Class::Contact_COPYRIGHT}\index{LedgerSMB::REST Class::Contact!COPYRIGHT}}


Copyright (C) 2012, the LedgerSMB Core Team.  This file may be re-used under 
the GNU GPL version 2 or at your option any future version.  Please see the 
accompanying LICENSE file for details.

\section{LedgerSMB::OE\label{LedgerSMB::OE}\index{LedgerSMB::OE}}


Order Entry

get\_files



Returns a list of files associated with the existing transaction.  This is 
provisional, and will change for 1.4 as the GL transaction functionality is 
                  \{ref\_key =$>$ \$self-$>$\{id\}, file\_class =$>$ 2\}
rewritten



Sets the type field for an existing order or quotation

\section{CancelFurtherProcessing\label{CancelFurtherProcessing}\index{CancelFurtherProcessing}}


A simple wrapper around Error.pm for error trapping.

\subsection*{SYNOPSIS\label{CancelFurtherProcessing_SYNOPSIS}\index{CancelFurtherProcessing!SYNOPSIS}}


A simple wrapper around Error.pm for error trapping.

\subsection*{Copyright (C) 2011 The LedgerSMB Core Team\label{CancelFurtherProcessing_Copyright_C_2011_The_LedgerSMB_Core_Team}\index{CancelFurtherProcessing!Copyright (C) 2011 The LedgerSMB Core Team}}


Licensed under the GNU General Public License version 2 or later (at your 
option).  For more information please see the included LICENSE and COPYRIGHT 
files.

\section{LedgerSMB::Company\_Config\label{LedgerSMB::Company_Config}\index{LedgerSMB::Company\ Config}}


Company-specific Configuration for LedgerSMB.

\subsection*{SYNOPSIS\label{LedgerSMB::Company_Config_SYNOPSIS}\index{LedgerSMB::Company Config!SYNOPSIS}}


This module stores the various company-specific configuration details for
LedgerSMB

\subsection*{METHODS\label{LedgerSMB::Company_Config_METHODS}\index{LedgerSMB::Company Config!METHODS}}
\begin{description}

\item[{initialize()}] \mbox{}

Initializes the \$settings hashref.

\end{description}
\subsection*{DATA\label{LedgerSMB::Company_Config_DATA}\index{LedgerSMB::Company Config!DATA}}


All data is contained in the LedgerSMB::Company\_Config::settings hashref.  
These are defined by looking at the @company\_settings list in the current 
namespace (scope of which is 'my') and setting keys as expected.

\subsection*{Copyright (C) 2006, The LedgerSMB core team.\label{LedgerSMB::Company_Config_Copyright_C_2006_The_LedgerSMB_core_team_}\index{LedgerSMB::Company Config!Copyright (C) 2006, The LedgerSMB core team.}}
\section{LedgerSMB::User\label{LedgerSMB::User}\index{LedgerSMB::User}}


Provides user support and database management functions.

\subsection*{SYNOPSIS\label{LedgerSMB::User_SYNOPSIS}\index{LedgerSMB::User!SYNOPSIS}}


This module provides user support and database management functions.

\subsection*{STATUS\label{LedgerSMB::User_STATUS}\index{LedgerSMB::User!STATUS}}


Deprecated

\subsection*{COPYRIGHT\label{LedgerSMB::User_COPYRIGHT}\index{LedgerSMB::User!COPYRIGHT}}
\begin{verbatim}
 #====================================================================
 # LedgerSMB
 # Small Medium Business Accounting software
 # http://www.ledgersmb.org/
 #
 # Copyright (C) 2006
 # This work contains copyrighted information from a number of sources
 # all used with permission.
 #
 # This file contains source code included with or based on SQL-Ledger
 # which is Copyright Dieter Simader and DWS Systems Inc. 2000-2005
 # and licensed under the GNU General Public License version 2 or, at
 # your option, any later version.  For a full list including contact
 # information of contributors, maintainers, and copyright holders,
 # see the CONTRIBUTORS file.
 #
 # Original Copyright Notice from SQL-Ledger 2.6.17 (before the fork):
 # Copyright (C) 2000
 #
 #  Author: DWS Systems Inc.
 #     Web: http://www.sql-ledger.org
 #
 #  Contributors: Jim Rawlings <jim@your-dba.com>
 #
 #====================================================================
 #
 # This file has undergone whitespace cleanup.
 #
 #====================================================================
 #
 # user related functions
 #
 #====================================================================
\end{verbatim}
\subsection*{METHODS\label{LedgerSMB::User_METHODS}\index{LedgerSMB::User!METHODS}}
\begin{description}

\item[{LedgerSMB::User-$>$new(\$login);}] \mbox{}

Create a LedgerSMB::User object.  If the user \$login exists, set the fields
with values retrieved from the database.


\item[{LedgerSMB::User-$>$country\_codes();}] \mbox{}

Returns a hash where the keys are registered locales and the values are the
textual representation of the locale name.


\item[{LedgerSMB::User-$>$fetch\_config(\$login);}] \mbox{}

Returns a reference to a hash that contains the user config for the user \$login.
If that user does not exist, output 'Access denied' if in CGI and die in all
cases.


\item[{LedgerSMB::User-$>$check\_recurring(\$form);}] \mbox{}

Disused function to return the number of current recurring events.


\item[{LedgerSMB::User::dbconnect\_vars(\$form,}] \textbf{\$db);}

Converts individual \$form values into \$form-$>$\{dboptions\} and \$form-$>$\{dbconnect\}.


\item[{LedgerSMB::User-$>$dbdrivers();}] \mbox{}

Returns a list of all drivers set up with DBI whose names end in 'Pg'.


\item[{LedgerSMB::User-$>$dbsources(\$form);}] \mbox{}

Returns a list of all databases in the same cluster as the database that \$form
is set to.  If \$form-$>$\{only\_acc\_db\} is set, only non-template databases that
have a defaults table owned by \$form-$>$\{dbuser\} are returned.


\item[{LedgerSMB::User-$>$dbcreate(\$form);}] \mbox{}

Create the database indicated by \$form-$>$\{db\} and load Pg-database.sql, the chart
indicated by \$form-$>$\{chart\} and custom tables and functions
(Pg-custom\_tables.sql and Pg-custom\_functions).


\item[{LedgerSMB::User-$>$process\_query(\$form,}] \textbf{\$dbh, \$filename);}

Load the file \$filename into the database indicated through form using psql.
\$dbh is ignored.


\item[{LedgerSMB::User-$>$dbdelete(\$form);}] \mbox{}

Disused function to drop the database \$form-$>$\{db\}.


\item[{LedgerSMB::User-$>$dbsources\_unused(\$form,}] \textbf{\$memfile);}

Disused function to identify all databases in a cluster with a defaults table
that are not mentioned in the memberfile \$memfile.


\item[{LedgerSMB::User-$>$dbneedsupdate(\$form);}] \mbox{}

Disused function to locate all databases owned by \$form-$>$\{dbuser\} that are not
a template* database which have a defaults table with a version entry.


\item[{LedgerSMB::User-$>$dbupdate(\$form);}] \mbox{}

Applies database upgrade scripts to upgrade the database to the current level.


\item[{calc\_version(\$version);}] \mbox{}

Returns a numeric form for the version passed in.  The numeric form is derived
by converting each dotted portion of the version to a three-digit number and
appending them.

\begin{verbatim}
 +----------+------------+
 | $version |   returned |
 +----------+------------+
 |   1.0.0  |    1000000 |
 |   1.2.33 |    1002033 |
 | 189.2.33 |  189002033 |
 |  1.2.3.4 | 1002003004 |
 +----------+------------+
\end{verbatim}

\item[{script\_version}] \mbox{}

Sorting function for database upgrade scripts.


\item[{\$user-$>$save\_member();}] \mbox{}

Updates the user config in the database for the user \$user.  If no config for
the user exists, the user to the database.


\item[{LedgerSMB::User-$>$delete\_login(\$form);}] \mbox{}

Disused function to delete the user \$form-$>$\{login\}.


\item[{LedgerSMB::User-$>$config\_vars();}] \mbox{}

Disused function that returns a list of user config variable names.


\item[{\$self-$>$error(\$msg);}] \mbox{}

Privately used error function.  Used in places where the more typically used
\$form-$>$error cannot be used.  Always dies.

\end{description}
\section{LedgerSMB::Auth::DB\label{LedgerSMB::Auth::DB}\index{LedgerSMB::Auth::DB}}


Standard Authentication DB module.

\subsection*{SYNOPSIS\label{LedgerSMB::Auth::DB_SYNOPSIS}\index{LedgerSMB::Auth::DB!SYNOPSIS}}


This is the standard DB-based module for authentication.  Uses HTTP basic 
authentication.

\subsection*{METHODS\label{LedgerSMB::Auth::DB_METHODS}\index{LedgerSMB::Auth::DB!METHODS}}
\begin{description}

\item[{get\_credentials}] \mbox{}

Gets credentials from the 'HTTP\_AUTHORIZATION' environment variable which must
be passed in as per the standards of HTTP basic authentication.



Returns a hashref with the keys of login and password.


\item[{credential\_prompt}] \mbox{}

Sends a 401 error to the browser popping up browser credential prompt.

\end{description}
\subsection*{COPYRIGHT\label{LedgerSMB::Auth::DB_COPYRIGHT}\index{LedgerSMB::Auth::DB!COPYRIGHT}}


\# Small Medium Business Accounting software
\# http://www.ledgersmb.org/
\#
\#
\# Copyright (C) 2006-2011
\# This work contains copyrighted information from a number of sources all used
\# with permission.  It is released under the GNU General Public License
\# Version 2 or, at your option, any later version.  See COPYRIGHT file for
\# details.

\section{LedgerSMB:GL\label{LedgerSMB:GL}\index{LedgerSMB:GL}}


General Ledger backend code

\begin{description}

\item[{get\_files}] \mbox{}

Returns a list of files associated with the existing transaction.  This is 
provisional, and wil change for 1.4 as the GL transaction functionality is 
                  \{ref\_key =$>$ \$self-$>$\{id\}, file\_class =$>$ 1\}
rewritten

\end{description}
\section{LedgerSMB::File\label{LedgerSMB::File}\index{LedgerSMB::File}}


Provides routines for managing file attachments.

\subsection*{SYNPSIS\label{LedgerSMB::File_SYNPSIS}\index{LedgerSMB::File!SYNPSIS}}


This provides routines for managing file attachments.  Subclasses may be used
to provide functionality for specific types of file attachments.

\subsection*{PROPERTIES/ACCESSORS\label{LedgerSMB::File_PROPERTIES_ACCESSORS}\index{LedgerSMB::File!PROPERTIES/ACCESSORS}}
\begin{description}

\item[{attached\_by\_id}] \mbox{}

Entity id of the individual who attached the file.


\item[{attached\_by}] \mbox{}

Entity name of individual who attached file


\item[{attached\_at}] \mbox{}

Timestamp of attachment point.


\item[{content}] \mbox{}

This stores the binary content of the file.


\item[{mime\_type\_id}] \mbox{}

ID of the MIME type.  Undef if unknown.


\item[{mime\_type\_text}] \mbox{}

Standard text code of the MIME type


\item[{file\_name}] \mbox{}

File name, user specified


\item[{description}] \mbox{}

Description, user specified


\item[{id}] \mbox{}

ID of file.  undef if unknown


\item[{ref\_key}] \mbox{}

Referential key for the file to attach to.


\item[{reference}] \mbox{}

Reference control code (text string) for attached financial database object.


\item[{file\_class}] \mbox{}

ID of the file class.


\item[{src\_class}] \mbox{}

ID of class of the original attachment point (for a link)


\item[{file\_path}] \mbox{}

Path, relative to \$LedgerSMB::tempdir, where file data is stored (for LaTeX use
of attached images).


\item[{sizex}] \mbox{}

X axis dimensions, if Image::Size is installed and file is image (only on files
retrieved for invoices).


\item[{sizey}] \mbox{}

Y axis dimensions, if Image::Size is installed and file is image (only on files
retrieved for invoices).

\end{description}
\subsection*{METHODS\label{LedgerSMB::File_METHODS}\index{LedgerSMB::File!METHODS}}
\begin{description}

\item[{get\_mime\_type}] \mbox{}

Sends the textual representation of the MIME type.  If not set, retrieves and
sets it.


\item[{set\_mime\_type}] \mbox{}

Sets the mipe\_type\_id from the mime\_type\_text


\item[{detect\_type}] \mbox{}

Auto-detects the type of the file.  Not yet implemented


\item[{get}] \mbox{}

Retrives a file.  ID and file\_class properties must be set.


\item[{get\_for\_template(\{ref\_key =$>$ int, file\_class =$>$ int\})}] \mbox{}

Returns file data for invoices for embedded images, except that content is set
to a directive relative to tempdir where these files are stored.


\item[{list(\{ref\_key =$>$ int, file\_class =$>$ int\})}] \mbox{}

Lists files directly attached to the object.


\item[{list\_links(\{ref\_key =$>$ int, file\_class =$>$ int\})}] \mbox{}

Lists the links directly attached to the object.


\item[{merge(hashref)}] \mbox{}

Merges in specific attributes from the ref.


\item[{commit()}] \mbox{}

Returns the value of DBI-$>$commit

\end{description}
\subsection*{COPYRIGHT\label{LedgerSMB::File_COPYRIGHT}\index{LedgerSMB::File!COPYRIGHT}}


Copyright (C) 2011 The LedgerSMB Core Team



This file is licensed under the Gnu General Public License version 2, or at your
option any later version.  A copy of the license should have been included with
your software.

\section{SYNOPSIS\label{SYNOPSIS}\index{SYNOPSIS}}


This module provides the APIs for database creation and management

\section{COPYRIGHT\label{COPYRIGHT}\index{COPYRIGHT}}


This module is copyright (C) 2007, the LedgerSMB Core Team and subject to 
the GNU General Public License (GPL) version 2, or at your option, any later
version.  See the COPYRIGHT and LICENSE files for more information.

\section{METHODS\label{METHODS}\index{METHODS}}
\begin{description}

\item[{LedgerSMB::Database-$>$new(\{dbname = \$dbname, countrycode = \$cc, chart\_name = \$name, company\_name = \$company, username = \$username, password = \$password\})}] \mbox{}

This function creates a new database management object with the specified
characteristics.  The \$dbname is the name of the database. the countrycode
is the two-letter ISO code.  The company name is the friendly name for 
dropdown boxes on the Login screen.



As some countries may have multiple available charts, you can also specify
a chart name as well.



Note that the arguments can be any hashref. If it is a LedgerSMB object,
however, it will attempt to copy all attributes beginning with \_ into the 
current object (\_user, \_locale, etc).


\item[{base\_backup}] \mbox{}

This routine connects to the database using pg\_dumpall and returns a plain text,
roles-only dump of the current database cluster.  This is left uncompressed for
readability and ease of troubleshooting.  Base backups are advised to be taken
frequently and in conjunction with single database backups.  The single database
backups will backup all data but no roles.  Restoring a new database onto a new
server post-crash with only the single-database backup thus means recreating all
users.



The file is named roles\_[date].sql by default where the date is in
yyyy-mm-dd format.


\item[{db\_backup()}] \mbox{}

This routine connects to the database using pg\_dump and creates a Pg-native 
database backup of the selected db only.  There is some redundancy with the base
backup but the overlap is minimal.  You can restore your database and data with
the db\_bakup, but not the users and roles.  You can restore the users and roles
with the base\_backup but not your database.



The resulting file is named backup\_[dbname]\_[date].bak with the date in
yyyy-mm-dd format.


\item[{get\_info()}] \mbox{}

This routine connects to the database using DBI and attempts to determine if a 
related application is running in that database and if so what version.  
It returns a hashref with the following keys set:

\begin{description}

\item[{username Set to the user of the current}] \textbf{connection}
\item[{appname Set to the current application name,}] \textbf{one of:}\begin{description}

\item[{ledgersmb}] \mbox{}
\item[{sql-ledger}] \mbox{}
\item[{undef}] \mbox{}\end{description}

\item[{version The current version of the application.}] \textbf{One of:}\begin{description}

\item[{legacy SQL-Ledger 2.6 and below, and LedgerSMB}] \textbf{1.1 and below}
\item[{1.2 (LedgerSMB only)}] \mbox{}
\item[{1.3 (LedgerSMB only)}] \mbox{}
\item[{1.3dev (LedgerSMB only)}] \mbox{}
\item[{2.7 (SQL-Ledger only)}] \mbox{}
\item[{2.8 (SQL-Ledger only)}] \mbox{}\end{description}
\begin{description}

\item[{full\_version The full version number of}] \textbf{the database version}
\item[{status Current status of the db. One of:}] \mbox{}
\item[{exists The database was confirmed to exist}] \mbox{}
\item[{does not exist The database was confirmed}] \textbf{to not exist}
\item[{undef The database could not be confirmed}] \textbf{to exist, or not}\end{description}
\end{description}


It is worth noting that this is designed to be informative and helpful in 
determining whether automatic upgrades can in fact occur or other 
administrative tasks can be run.  Sample output might be:



\{    appname =$>$ undef, 
     version =$>$ undef, 
full\_version =$>$ undef,
      status =$>$ 'does not exist'\}



or



\{    appname =$>$ 'sql-ledger',
     version =$>$ '2.8',
full\_version =$>$ '2.8.33',
      status =$>$ 'exists'\}



or



\{   appname =$>$ 'ledgersmb',
    version =$>$ '1.2'
fullversion =$>$ '1.2.0',
     status =$>$ 'exists' \}



It goes without saying that status will always equal 'exists' if appname is set.
However the converse is not true.  If the status is 'exists' and appname is not
set, this merely means that the database exists but is not used by a recognized
application.  So administrative functions are advised to check both the appname
and status values.



Finally, it is important to note that LedgerSMB 1.1 and prior, and SQL-Ledger 
2.6.x and prior are lumped under appname =$>$ 'ledgersmb' and version =$>$ 'legacy',
though the fullversion may give you an idea of what the actual version is run.


\item[{\$db-$>$server\_version();}] \mbox{}

Connects to the server and returns the version number in x.y.z format.


\item[{\$db-$>$create();}] \mbox{}

Creates a database and loads the contrib files.  This is done from template0, 
meaning nothing added to postgres will be found in this database.  This was 
necessary as a workaround for issues on some Debian systems.



Returns true if successful, false of not.  Creates a log called dblog in the 
temporary directory with all the output from the psql files.



In DEBUG mode, will show all lines to STDERR.  In ERROR logging mode, will 
display only those lines containing the word ERROR.


\item[{\$db-$>$load\_modules(\$loadorder)}] \mbox{}

Loads or reloads sql modules from \$loadorder


\item[{\$db-$>$exec\_script(\{script =$>$ 'path/to/file', logfile =$>$ 'path/to/log'\})}] \mbox{}

Executes the script.  Returns 0 if successful, 1 if there are errors suggesting
that types are already created, and 2 if there are other errors.


\item[{\$db-$>$create\_and\_load();}] \mbox{}

Creates a database and then loads it.


\item[{\$db-$>$process\_roles(\$rolefile);}] \mbox{}

Loads database Roles templates.


\item[{\$db-$>$log\_from\_logfile();}] \mbox{}

Process log file and log relevant pieces via the log classes.

\section{LedgerSMB::RESTXML::Handler\label{LedgerSMB::RESTXML::Handler}\index{LedgerSMB::RESTXML::Handler}}


RESTful LSMB API

\paragraph*{cgi\_handle\label{LedgerSMB::RESTXML::Handler_cgi_handle}\index{LedgerSMB::RESTXML::Handler!cgi\ handle}}


CGI\_handle is the gateway for the RESTful lsmb API.

\paragraph*{NOTES\label{LedgerSMB::RESTXML::Handler_NOTES}\index{LedgerSMB::RESTXML::Handler!NOTES}}
\paragraph*{try\_to\_load\label{LedgerSMB::RESTXML::Handler_try_to_load}\index{LedgerSMB::RESTXML::Handler!try\ to\ load}}


try\_to\_load will try to load a RESTXML document handler module.  returns undef
if it cannot load the given module for any reason.  passed the type of RESTXML
document to try to load.  returns a blessed anonymous hashref if the module
*can*, and is successfully loaded.

\paragraph*{connect\_db\label{LedgerSMB::RESTXML::Handler_connect_db}\index{LedgerSMB::RESTXML::Handler!connect\ db}}


Given  a user's config, returns a database connection handle.

\section{LedgerSMB::RESTXML::Document::Session\label{LedgerSMB::RESTXML::Document::Session}\index{LedgerSMB::RESTXML::Document::Session}}


Sets up an authentication session for iterativly accessing documents.

\subsection*{SYNOPSIS\label{LedgerSMB::RESTXML::Document::Session_SYNOPSIS}\index{LedgerSMB::RESTXML::Document::Session!SYNOPSIS}}


This sets up an authentication session for iteratively accessing documents in LedgerSMB.  A user should
post a login document to /Session/userid, and upon success, they will receive a cookie which they can use to further
access other resources.

\section{LedgerSMB::RESTXML::Document::Base\label{LedgerSMB::RESTXML::Document::Base}\index{LedgerSMB::RESTXML::Document::Base}}


Base XML:Twig structure function

\paragraph*{hash\_to\_twig\label{LedgerSMB::RESTXML::Document::Base_hash_to_twig}\index{LedgerSMB::RESTXML::Document::Base!hash\ to\ twig}}


Convinenve function to convert a hashref to a XML::Twig structure.



passed a hashref, required arguments:



hash - the hash to convert



name - the name of the root element.



optional arguments:



sort - by default, on set to 0 to disable.  toggles whether or not hash keys are sorted
in the resulting xml node created.  Disabling this may save some performance if converting a lot of
nodes at once.

\section{LedgerSMB::Batch\label{LedgerSMB::Batch}\index{LedgerSMB::Batch}}


Batch/voucher management model for LedgerSMB 1.3

\subsection*{SYNOPSIS\label{LedgerSMB::Batch_SYNOPSIS}\index{LedgerSMB::Batch!SYNOPSIS}}


Batch/voucher management model for LedgerSMB 1.3

\subsection*{METHODS\label{LedgerSMB::Batch_METHODS}\index{LedgerSMB::Batch!METHODS}}
\begin{description}

\item[{get\_new\_info}] \mbox{}

This gets the information required for the new batch screen.  Currently this
just populates the batch\_number hashref value.


\item[{create}] \mbox{}

Saves the batch info and populates the id hashref value with the id inserted.


\item[{delete\_voucher(\$id)}] \mbox{}

Deletes the voucher specified by \$id.


\item[{get\_search\_criteria Sets all hash values}] \textbf{needed for the search interface:}\begin{description}

\item[{batch\_classes List of all batch classes}] \mbox{}
\item[{batch\_users
List of all users}] \mbox{}\end{description}

\item[{get\_search\_method (private)}] \mbox{}

Determines the appropriate search method, either for empty, mini, or full 
searches



Returns the appropriate stored proc name.


\item[{get\_search\_results}] \mbox{}

Returns the appropriate search as detected by get\_search\_method.


\item[{get\_class\_id(\$type)}] \mbox{}

Returns the class\_id of batch class specified by its label.


\item[{post}] \mbox{}

Posts a batch to the books and makes the vouchers show up in transaction 
reports, financial statements, and more.


\item[{delete}] \mbox{}

Deletes the unapproved batch and all vouchers under it.


\item[{list\_vouchers Returns a list of all vouchers}] \textbf{in the batch and attaches that list to \$self-$>$\{vouchers\}}
\item[{get}] \mbox{}

Gets the batch and merges information with the current batch object.

\end{description}
\subsection*{Copyright (C) 2009, The LedgerSMB core team.\label{LedgerSMB::Batch_Copyright_C_2009_The_LedgerSMB_core_team_}\index{LedgerSMB::Batch!Copyright (C) 2009, The LedgerSMB core team.}}


This file is licensed under the Gnu General Public License version 2, or at your
option any later version.  A copy of the license should have been included with
your software.

\section{LedgerSMB::IC\label{LedgerSMB::IC}\index{LedgerSMB::IC}}


Inventory Control backend

\begin{description}

\item[{get\_files}] \mbox{}

Returns a list of files associated with the existing transaction.  This is 
provisional, and wil change for 1.4 as the GL transaction functionality is 
                  \{ref\_key =$>$ \$self-$>$\{id\}, file\_class =$>$ 1\}
rewritten

\end{description}
\section{SYNOPSIS\label{SYNOPSIS}\index{SYNOPSIS}}


This provides better database integration than LedgerSMB::DBObject, which has
been left in place for backwards compatibility.  LedgerSMB::SODA provides
services for loosely tying the application to the database through interface
discovery and other services.



In LedgerSMB 1.4 new code, all database access should go through here.

\section{PROPERTIES\label{PROPERTIES}\index{PROPERTIES}}
\begin{description}

\item[{dbh This is the database handle through}] \textbf{which all access to the database goes.}
\item[{dbroles List of database roles for the current}] \textbf{logged in user. This can be specified in the constructor or discovered later with LedgerSMB::SODA-$>$get\_roles}
\item[{db
Name of the current database}] \mbox{}
\item[{username Name of the current logged in user.}] \mbox{}\end{description}
\section{CONSTRUCTOR SYNTAX\label{CONSTRUCTOR_SYNTAX}\index{CONSTRUCTOR SYNTAX}}
\begin{description}

\item[{Full syntax}] \mbox{}

LedgerSMB::SODA-$>$new(\{ db =$>$ \$string, username =$>$ \$string, cred =$>$ \$string \});



Here username is the database user to connect as and cred is the credential
string to be used for the connection.  This syntax would be preferred for thick
clients interacting with a LedgerSMB database because it allows one to grab
user-specified credentials and pass them through to this syntax.


\item[{Minimal syntax LedgerSMB::New(\{ db =$>$ \$string \})}] \mbox{}

Here, with no args other than db, we grab the appropriate credentials via 
LedgerSMB::Auth



Out of the box, LedgerSMB only supports HTTP basic credentials. Kerberos could
be supported with minimal effort.

\end{description}
\section{METHODS\label{METHODS}\index{METHODS}}
\begin{description}

\item[{is\_allowed\_role(string \$rolename) Returns}] \textbf{true if the role (minus the role prefix, which defaults to "lsmb\_\$\{db\}\_\_" where \$db is the return value of \$self-$>$db) is granted to the user, false otherwise.}
\item[{register\_type(\{sql\_type =$>$ \$string, perl\_class =$>$ \$string, parse\_func =$>$bool\})}] \mbox{}

This function registers a Perl class in association with a SQL type.



When a method is dispatched the return values are sorted through to determine
what types they are.  Registered types are then used to handle input and output
to application types.



Registered types corresponding to simple PostgreSQL types are expected to have a
constructor syntax supporting a simple \{string =$>$ \$string\} argument list with no
further arguments.  Additionally they are expected to have either a
to\_db\_string() method which represents the object as a string suitable for
insertion into the database, or (as a fallback) a to\_string method which
represents the the object as a simple string for general purposes.



Registered types corresponding to complex PostgreSQL types will use the standard
Moose-type constructor, passing in the hashref of the returned data (after
members have been checked for registered types).  They are also expected to
either be a hashref or have a to\_hashref method that can be used to convert to a
hashref for db entry purposes.  Note that Moose classes are compliant with this
by default, but that a to\_hashref method could be useful in setting some custom
properties.



If parse\_func is true, then parse\_input will parse the input by using a select
statement to cast the input as its sql type.  This is mostly helpful where the
parsing capabilities of the database engine are very well developed and the
number of inputs to be parsed is very low.  At present only dates are expected
to be parsed this way.


\item[{parse\_input(class =$>$ \$string, value}] \textbf{=$>$ \$string) This is a hook for parsing data via the database for registered types.}

If the parse\_input flag is set of for the registered type, we cast via the
database.  If not, we just return the value.


\item[{soda\_method}] \mbox{}

Minimal invocation:

\begin{verbatim}
 $soda->soda_method({ caller => $object, #supplies properties
                      method => $string, #name of stored procedure
 });
\end{verbatim}


Maximal invocation:

\begin{verbatim}
 $soda->soda_method({ caller => $object,   # required
                      method => $string,   # required
                        args => $hashref,  # may be required on some stored 
                                           # procedures
                       order => $arrayref, # optional, procedures usually have
                                           # defaults
                     windows => $arrayref, # optional see below
                        aggs => $arrayref, # optional, see below
 });
\end{verbatim}


The syntax of this method is a bit complicated because the needed feature set
has become quite a bit larger than that which was needed and available when
LedgerSMB::DBObject-$>$exec\_method was written.



Supported arguments are:
=over
=item caller
Caller object, whose properties are used where an argument is named prop\_*.  It
is required.


\item[{schema Optional. Gives the schema name to}] \textbf{find the function in.}
\item[{method Name of stored procedure called.}] \textbf{It is required.}
\item[{args Hashref for non-property argument names.}] \textbf{An argument which is prefixed with in\_ or arg\_ draws its argument from this hashref. The in\_ prefix is supported to allow stored procedures to be shared with LedgerSMB::DBObjects (from the 1.3 codebase and addons).}
\item[{order List of hashrefs for order by clause.}] \textbf{Each hashref contains:}\begin{description}

\item[{column (required)}] \mbox{}
\item[{order (optional enum(asc, desc))}] \mbox{}
\item[{null\_order (optional enum(first, last))}] \mbox{}\end{description}


Expressions for ordering are not supported due to SQL injection concerns, but
column numbers are.


\item[{windows List of window specifications. Each}] \textbf{window is a hashref in the form of:}

\{name =$>$\$string, partion =$>$ \$string, order =$>$ \$arrayref\}



order follows same semantics as the argument to the main



To these are added the following pre-defined windows:

\begin{description}

\item[{rows\_unbounded\_pre}] \mbox{}

ROWS UNBOUNDED PRECEDING


\item[{rows\_bw\_unbounded\_pre\_and\_current ROWS}] \textbf{BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW}
\item[{rows\_bw\_unbounded\_pre\_and\_following}] \textbf{ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING}\end{description}

\item[{aggs An array of hashrefs, each of which}] \textbf{contains four elements:}\begin{description}

\item[{agg \$string}] \mbox{}

Name of aggregate


\item[{alias \$string}] \mbox{}

Column name to assign aggregate


\item[{window \$string}] \mbox{}

Name of window


\item[{cols \$arrayref}] \mbox{}

array ref of column names for the aggregate.

\end{description}


Examples:



A basic list of journal entries might be done with:



\$soda-$>$soda\_method(\{ caller =$>$ \$gl\_report, method =$>$ 'gl\_report\_\_run' \});



However if we want to run this with a running total, we can:

\begin{verbatim}
        $soda->soda_method({ caller => $gl_report
                             method => 'gl_report__run',
                               aggs => [{ agg => 'sum',
                                        alias => 'running_total',
                                         cols => ['amount'],
                                       window => 'rows_unbounded_pre',
                                       }],
                          });
\end{verbatim}

\item[{query\_custom\_fields}] \mbox{}
\item[{commit Commits to the database unless LSMB\_TEST}] \textbf{is set, in which case it tests whether the database transaction is commitable, returns true if it is. Otheriwse it returns false and rolls back.}\end{description}
\section{ERRORS\label{ERRORS}\index{ERRORS}}


The module runs errors through a private method \_dberror which sets appropriate
messages, logs messages, and then throws an exception.  Error messages handled
here are:

\begin{description}

\item[{Internal Database Error SQL State 42883.}] \textbf{Undefined function. This is always a bug or an issue with the database being out of sync with the application.}
\item[{Access Denied Insufficient permissions to}] \textbf{perform the operation. Corresponds to SQL States 42501 and 42401.}
\item[{Invalid date/time entered SQL State 22008.}] \textbf{The date or time entered was not in a valid format.}
\item[{Division by 0 error}] \mbox{}
\item[{Required input not provide This occurs when}] \textbf{a NOT NULL constraint is violated. SQL states 22004 and 23502}
\item[{Conflict with Existing Data SQL State 23505,}] \textbf{indivates that a unique constraint has been violated.}
\item[{Error from Function: \$errstr P0001: There}] \textbf{was an unhandled exception in a function.}
\item[{stringify(string \$typename, @hashrefs)}] \mbox{}

Stringify returns an arrayref of strings representing the hashes in the SQL
complex type identified.

\end{description}
\section{ENVIRONMENT VARIABLES\label{ENVIRONMENT_VARIABLES}\index{ENVIRONMENT VARIABLES}}
\begin{description}

\item[{LSMB\_TEST}] \mbox{}

When this environment variable is set, LedgerSMB::SODA will not write to the
database.  Instead it will test to see if a transaction is committable, and if 
so, simply return true.  If not, it will rollback the current transaction and
return false.  This allows us to run all sorts of tests without permanently
writing data to the database.  Note that in some cases, however, tests may block
other uses of the application due to longer-than-normal transaction blocks.



To work around this issue, it is recommended that test cases roll back between
test cases unless they must continue.  If deadlocks result, tests may have to be
run during off-hours.

\end{description}
\section{SEE ALSO\label{SEE_ALSO}\index{SEE ALSO}}
\section{COPYRIGHT\label{COPYRIGHT}\index{COPYRIGHT}}


This file is licensed under the Gnu General Public License (GPL) version 2, or 
at your option any later version.  A copy of the license should have been 
included with your software.

\section{LedgerSMB::AA\label{LedgerSMB::AA}\index{LedgerSMB::AA}}


Contains the routines for managing AR and AP transactions.

\subsection*{SYNOPSIS\label{LedgerSMB::AA_SYNOPSIS}\index{LedgerSMB::AA!SYNOPSIS}}


This module contains the routines for managing AR and AP transactions and 
many of the reorts (a few others are found in LedgerSMB::RP.pm).



All routines require \$form-$>$\{dbh\} to be set so that database actions can
be performed.



This module is due to be deprecated for active development as soon as a 
replacement is available.

\begin{description}

\item[{post\_transaction() Post transaction uses}] \textbf{the following variables in the \$form variable: * dbh - the database connection handle * currency - The current users' currency * defaultcurrency - The "normal" currency * department - Unknown * department\_id - ID for the department * exchangerate - Conversion between currency and defaultcurrency * invnumber - invoice number * reverse - ? * rowcount - Number of rows in the invoice * taxaccounts - Apply taxes? * taxincluded - ? * transdate - Date of the transaction * vc - Vendor or customer - determines transaction type}
\item[{get\_files}] \mbox{}

Returns a list of files associated with the existing transaction.  This is 
provisional, and will change for 1.4 as the GL transaction functionality is 
                  \{ref\_key =$>$ \$self-$>$\{id\}, file\_class =$>$ 1\}
rewritten


\item[{transactions($\backslash$\%myconfig, \$form)}] \mbox{}

Generates the transaction and outstanding reports.  Form variables used in this
function are:



approved: whether or not transactions must be approved to show up



transdatefrom: Earliest day of transactions



transdateto:  Latest day of transactions



month, year, interval:  Used in palce of transdatefrom and transdate to



vc:  'customer' for ar, 'vendor' for ap.



meta\_number:  customer/vendor number



entity\_id:  A specific entity id



parts\_id:  Show transactions including a specific part



department\_id:  Transactions for a department



entity\_credit\_account: As an alternate for meta\_number to identify a customer
of vendor credit account



invoice\_type:  3 for on-hold, 2 for active



The transaction list is stored at:
@\{\$form-$>$\{transactions\}\}


\item[{taxform\_exist(\$form, \$cv\_id)}] \mbox{}

Determines if a taxform attached to the entity\_credit\_account record (where
the id field is the same as \$cv\_id) exists. Returns true if it exists, false
if not.


\item[{update\_ac\_tax\_form(\$form,\$dbh,\$entry\_id,\$report)}] \mbox{}

Updates the ac\_tax\_form checkbox for the acc\_trans.entry\_id (where it is the 
same as \$entry\_id).  If \$report is true, sets it to true, if false, sets it to
false.  \$report must be a valid *postgresql* bool value (0/1, t/f, 
'true'/'false').


\item[{get\_taxchech(\$entry\_id,\$dbh)}] \mbox{}

Returns true if the acc\_trans record has been set to reportable in the past
false otherwise.


\item[{save\_intnotes(\$form)}] \mbox{}

Saves the \$form-$>$\{intnotes\} into the ar/ap.intnotes field.

\end{description}
\subsection*{COPTYRIGHT\label{LedgerSMB::AA_COPTYRIGHT}\index{LedgerSMB::AA!COPTYRIGHT}}


\# LedgerSMB
\# Small Medium Business Accounting software
\# http://www.ledgersmb.org/
\# Copyright (C) 2006-2010
\# This work contains copyrighted information from a number of sources all used
\# with permission.
\#
\# This file contains source code included with or based on SQL-Ledger which
\# is Copyright Dieter Simader and DWS Systems Inc. 2000-2005 and licensed
\# under the GNU General Public License version 2 or, at your option, any later
\# version.  For a full list including contact information of contributors,
\# maintainers, and copyright holders, see the CONTRIBUTORS file.
\#
\# Original Copyright Notice from SQL-Ledger 2.6.17 (before the fork):
\# Copyright (C) 2006
\#
\#  Author: DWS Systems Inc.
\#     Web: http://www.sql-ledger.org
\#
\#  Contributors:
\#
\#
\# See COPYRIGHT file for copyright information

\section{LedgerSMB::Request\label{LedgerSMB::Request}\index{LedgerSMB::Request}}




\subsection*{SYNPOSIS\label{LedgerSMB::Request_SYNPOSIS}\index{LedgerSMB::Request!SYNPOSIS}}


This class provides the basic HTTP request handling for LedgerSMB.  It is 
designed to be modular and easily changed.

\section{LedgerSMB::IR\label{LedgerSMB::IR}\index{LedgerSMB::IR}}


Inventory received module

\begin{description}

\item[{get\_files}] \mbox{}

Returns a list of files associated with the existing transaction.  This is 
provisional, and will change for 1.4 as the GL transaction functionality is 
                  \{ref\_key =$>$ \$self-$>$\{id\}, file\_class =$>$ 1\}
rewritten

\section{LedgerSMB::DBObject::Budget\_Report\label{LedgerSMB::DBObject::Budget_Report}\index{LedgerSMB::DBObject::Budget\ Report}}




\subsection*{SYNOPSIS\label{LedgerSMB::DBObject::Budget_Report_SYNOPSIS}\index{LedgerSMB::DBObject::Budget Report!SYNOPSIS}}


Reporting routines for budgets.  Currently only displays a variance report.

\subsection*{INHERITANCE\label{LedgerSMB::DBObject::Budget_Report_INHERITANCE}\index{LedgerSMB::DBObject::Budget Report!INHERITANCE}}
\begin{description}

\item[{LedgerSMB}] \mbox{}
\item[{LedgerSMB::DBObject}] \mbox{}\end{description}
\subsection*{PROPERTIES\label{LedgerSMB::DBObject::Budget_Report_PROPERTIES}\index{LedgerSMB::DBObject::Budget Report!PROPERTIES}}
\begin{description}

\item[{id
The id of the budget}] \mbox{}
\item[{start\_date The start date of the budget,}] \textbf{inclusive}
\item[{end\_date The end date of the budget, inclusive}] \mbox{}
\item[{reference The reference or control code}] \textbf{of the budget}
\item[{description
Description of the budget}] \mbox{}
\item[{entered\_by entity id of the one who entered}] \textbf{the budget}
\item[{approved\_by entity id of the one who approved}] \textbf{the budget}
\item[{obsolete\_by entity id of the one who marked}] \textbf{the budget obsolete}
\item[{entered\_at Timestamp when the budget was}] \textbf{saved}
\item[{approved\_at Timestamp when the budget was}] \textbf{approved}
\item[{obsolete\_at Timestamp when the budget was}] \textbf{marked obsolete}
\item[{entered\_by\_name Name of the entity who}] \textbf{entered the budget}
\item[{approved\_by\_name Name of the entity who}] \textbf{approved the budget}
\item[{obsolete\_by\_name Name of the entity who}] \textbf{marked the budget obsolete}
\item[{department\_id The ID of the department}] \textbf{for which this budget was written}
\item[{department\_name Name of the department}] \textbf{for which this budget was written}
\item[{project\_id ID of project for which this}] \textbf{budget was written}
\item[{projectnumber Project number for which this}] \textbf{budget was written}
\item[{lines Lines of the report. Each line is}] \textbf{a hashref containing:}\begin{description}

\item[{accno Account number for the account in}] \textbf{question}
\item[{account\_label Description for the account}] \textbf{in question}
\item[{account\_id ID for the account in question}] \mbox{}
\item[{budget\_description Description for the}] \textbf{line item of the budget}
\item[{budget\_amount
The amount budgetted}] \mbox{}
\item[{used\_amount
The amount actually used}] \mbox{}
\item[{variance
budgetted - used}] \mbox{}\end{description}
\end{description}
\subsection*{METHODS\label{LedgerSMB::DBObject::Budget_Report_METHODS}\index{LedgerSMB::DBObject::Budget Report!METHODS}}
\begin{description}

\item[{run\_report(\$id);}] \mbox{}

Takes a blank (base) object and populates with the variance report data provided
by the id argument.

\end{description}
\subsection*{COPYRIGHT AND LICENSE\label{LedgerSMB::DBObject::Budget_Report_COPYRIGHT_AND_LICENSE}\index{LedgerSMB::DBObject::Budget Report!COPYRIGHT AND LICENSE}}


Copyright (C) 2011 LedgerSMB Core Team.  This file is licensed under the GNU 
General Public License version 2, or at your option any later version.  Please
see the included License.txt for details.

\section{LedgerSMB::DBObject::Asset\_Report\label{LedgerSMB::DBObject::Asset_Report}\index{LedgerSMB::DBObject::Asset\ Report}}


LedgerSMB Base Class for Asset Reports

\subsection*{SYNOPSIS\label{LedgerSMB::DBObject::Asset_Report_SYNOPSIS}\index{LedgerSMB::DBObject::Asset Report!SYNOPSIS}}


This library contains the base utility functions for creating, saving, and
retrieving depreciation categories of asset depreciation and disposal reports.

\subsection*{STANDARD PROPERTIES\label{LedgerSMB::DBObject::Asset_Report_STANDARD_PROPERTIES}\index{LedgerSMB::DBObject::Asset Report!STANDARD PROPERTIES}}
\begin{description}

\item[{id int}] \mbox{}

Integer id of asset report


\item[{report\_date date}] \mbox{}

Effective date of report


\item[{gl\_id bigint}] \mbox{}

ID of GL transaction if applicable and approved.


\item[{asset\_class bigint}] \mbox{}

ID of asset class for the report the assets are


\item[{report\_class int}] \mbox{}

Integer of the report class desired.


\item[{entered\_by bigint}] \mbox{}

Integer id of the individual who entered the report


\item[{approved\_by bigint}] \mbox{}

Integer id of the individual who approved the report


\item[{entered\_at timestamp}] \mbox{}

Timestamp the report was created


\item[{approved\_at timestamp}] \mbox{}

Timestamp the report was approved


\item[{depreciated\_qty}] \mbox{}

Number of units (production or time) depreciated


\item[{dont\_approve bool}] \mbox{}

If true, do not approve, ever.


\item[{submitted bool}] \mbox{}

If true, submitted for approval

\end{description}
\subsection*{METHODS\label{LedgerSMB::DBObject::Asset_Report_METHODS}\index{LedgerSMB::DBObject::Asset Report!METHODS}}
\begin{description}

\item[{save}] \mbox{}

Uses standard properties



Saves report to the database.  Sets ID.



For each asset to be added to the report, we see:



for each row, id\_\$row contains the asset id for that row.  Let this be \$id



if asset\_\$id, the asset is added.  Each asset also has:
amount\_\$id
dm\_\$id
percent\_\$id


\item[{get}] \mbox{}

Gets report from the database.


\item[{get\_nbv}] \mbox{}

Returns line items for the Net Book Value report.


\item[{generate}] \mbox{}

Properties used:



* report\_id int:  Report to enter the transactions into, 
* accum\_account\_id int:  ID for accumulated depreciation.


\item[{approve}] \mbox{}

Properties used:



id



For depreciation accounts, expense\_acct must be set.



For disposal accounts, gain\_acct and loss\_acct must be set.



Approves the referenced transaction and creates a GL draft (which must then be 
approved.


\item[{search}] \mbox{}

Searches for matching asset reports for review and approval.



Search criteria in properties:



* start\_date date
* end\_date date
* asset\_class int
* approved bool
* entered\_by int



Start and end dates specify the date range (inclusive) and all other matches
are exact. Undefs match all records.


\item[{get\_metadata}] \mbox{}

Sets the following properties:



* asset\_classes:  List of asset classes
* exp\_accounts:  List of expense accounts
* gain\_accounts:  List of gain accounts
* loss\_accounts:  list of loss accounts
* disp\_methods:  List of disposal methods

\end{description}
\subsection*{Copyright (C) 2010, The LedgerSMB core team.\label{LedgerSMB::DBObject::Asset_Report_Copyright_C_2010_The_LedgerSMB_core_team_}\index{LedgerSMB::DBObject::Asset Report!Copyright (C) 2010, The LedgerSMB core team.}}


This file is licensed under the Gnu General Public License version 2, or at your
option any later version.  A copy of the license should have been included with
your software.

\section{LedgerSMB::DBObject::Entity::Company -{}- Company (business) handling for LedgerSMB\label{LedgerSMB::DBObject::Entity::Company_-_-_Company_business_handling_for_LedgerSMB}\index{LedgerSMB::DBObject::Entity::Company -{}- Company (business) handling for LedgerSMB}}




\subsection*{SYNOPSIS\label{LedgerSMB::DBObject::Entity::Company_-_-_Company_business_handling_for_LedgerSMB_SYNOPSIS}\index{LedgerSMB::DBObject::Entity::Company - - Company business handling for LedgerSMB!SYNOPSIS}}


This handles the overall data management for companies as customers, vendors, sales 
leads etc.

\subsection*{INHERITS\label{LedgerSMB::DBObject::Entity::Company_-_-_Company_business_handling_for_LedgerSMB_INHERITS}\index{LedgerSMB::DBObject::Entity::Company - - Company business handling for LedgerSMB!INHERITS}}
\begin{description}

\item[{LedgerSMB::DBObject::Entity}] \mbox{}\end{description}
\subsection*{PROPERTIES\label{LedgerSMB::DBObject::Entity::Company_-_-_Company_business_handling_for_LedgerSMB_PROPERTIES}\index{LedgerSMB::DBObject::Entity::Company - - Company business handling for LedgerSMB!PROPERTIES}}
\begin{description}

\item[{entity\_id}] \mbox{}

ID of entity attached.  This is also an interal reference to this company.


\item[{legal\_name}] \mbox{}

Legal name of the company.  Will also map back to the entity's name field.


\item[{tax\_id}] \mbox{}

Tax identifier for the company.


\item[{sales\_tax\_id}] \mbox{}

Sales tax identifier for the company (like a GST or VAT number)


\item[{license\_number}] \mbox{}

Buisness license number for the company


\item[{sic\_code}] \mbox{}

Business categorization code.  SIC, NAICS, or other systems can be used.


\item[{created}] \mbox{}

Date when the company was entered into LedgerSMB

\end{description}
\subsection*{METHODS\label{LedgerSMB::DBObject::Entity::Company_-_-_Company_business_handling_for_LedgerSMB_METHODS}\index{LedgerSMB::DBObject::Entity::Company - - Company business handling for LedgerSMB!METHODS}}
\begin{description}

\item[{get(\$id)}] \mbox{}

This retrieves and returns the item as a blessed reference


\item[{get\_by\_cc(\$cc)}] \mbox{}

This retrieves a company associated with a control code.  Dies with error if 
company does not exist.


\item[{save()}] \mbox{}

Saves the item and populates db defaults in id and created.

\end{description}
\subsection*{COPYRIGHT\label{LedgerSMB::DBObject::Entity::Company_-_-_Company_business_handling_for_LedgerSMB_COPYRIGHT}\index{LedgerSMB::DBObject::Entity::Company - - Company business handling for LedgerSMB!COPYRIGHT}}


Copyright (C) 2012, the LedgerSMB Core Team.  This file may be re-used under the GNU GPL
version 2 or at your option any future version.  Please see the accompanying LICENSE 
file for details.

\section{LedgerSMB::DBObject::Entity::Bank\label{LedgerSMB::DBObject::Entity::Bank}\index{LedgerSMB::DBObject::Entity::Bank}}


Bank account info for customers, vendors, 
employees, and more.

\subsection*{SYNPOSIS\label{LedgerSMB::DBObject::Entity::Bank_SYNPOSIS}\index{LedgerSMB::DBObject::Entity::Bank!SYNPOSIS}}
\begin{verbatim}
  @bank_list = LedgerSMB::DBObject::Entity::Bank->list($entity_id);
  $bank->save;
\end{verbatim}
\subsection*{DESCRIPTION\label{LedgerSMB::DBObject::Entity::Bank_DESCRIPTION}\index{LedgerSMB::DBObject::Entity::Bank!DESCRIPTION}}


This module manages bank accounts, for wire transfers, etc. for customers,
vendors, employees etc.   Bank accounts are attached to the entity with the
credit account being able to attach itself to a single bank account.

\subsection*{INHERITS\label{LedgerSMB::DBObject::Entity::Bank_INHERITS}\index{LedgerSMB::DBObject::Entity::Bank!INHERITS}}
\begin{description}

\item[{LedgerSMB::DBObject\_Moose;}] \mbox{}\end{description}


head1 PROPERTIES

\begin{description}

\item[{entity\_id Int}] \mbox{}

If set this is attached to an entity.  This can optionally be set to a contact
record attached to a credit account but is ignored in that case.


\item[{credit\_id Int}] \mbox{}

If this is set, this is attached to an entity credit account.  If this and
entity\_id are set, entity\_id is ignored.



This is never set on retrieval, but is used to attach this as the default bank
account for a given entity credit account.


\item[{id}] \mbox{}

If set this indicates this has been saved to the db.


\item[{bic}] \mbox{}

Banking Institution Code, such as a SWIFT code or ABA routing number.  This can
be set to undef because there are cases where the BIC is not needed for wire
transfers.


\item[{iban}] \mbox{}

This is the bank account number.  It is required on all records.

\end{description}
\subsection*{METHODS\label{LedgerSMB::DBObject::Entity::Bank_METHODS}\index{LedgerSMB::DBObject::Entity::Bank!METHODS}}
\begin{description}

\item[{list(\$entity\_id)}] \mbox{}

Lists all bank accounts for entity\_id.  This does not need to be performed on a
blessed reference.  All return results are objects.


\item[{save()}] \mbox{}

Saves the bank account object to the database and reinstantiates it, thus
setting things like the id field.


\item[{delete}] \mbox{}

Deletes the bank account object from the database.

\end{description}
\subsection*{COPYRIGHT\label{LedgerSMB::DBObject::Entity::Bank_COPYRIGHT}\index{LedgerSMB::DBObject::Entity::Bank!COPYRIGHT}}


OPYRIGHT (C) 2012 The LedgerSMB Core Team.  This file may be re-used under the
terms of the GNU General Public License version 2 or at your option any later
version.  Please see the enclosed LICENSE file for details.

\section{LedgerSMB::DBObject::Entity::Credit\_Account\label{LedgerSMB::DBObject::Entity::Credit_Account}\index{LedgerSMB::DBObject::Entity::Credit\ Account}}


Customer/Vendor Acct Management for LSMB

\subsection*{SYNOPSYS\label{LedgerSMB::DBObject::Entity::Credit_Account_SYNOPSYS}\index{LedgerSMB::DBObject::Entity::Credit Account!SYNOPSYS}}


This module provides customer/vendor credit account management features for
LedgerSMB.  These include credit limit, credit limit remaining, terms, discounts
and the like.

\subsection*{DESCRIPTION\label{LedgerSMB::DBObject::Entity::Credit_Account_DESCRIPTION}\index{LedgerSMB::DBObject::Entity::Credit Account!DESCRIPTION}}


TODO

\subsection*{INHERITS\label{LedgerSMB::DBObject::Entity::Credit_Account_INHERITS}\index{LedgerSMB::DBObject::Entity::Credit Account!INHERITS}}
\begin{description}

\item[{LedgerSMB::DBObject\_Moose}] \mbox{}\end{description}
\subsection*{PROPERTIES\label{LedgerSMB::DBObject::Entity::Credit_Account_PROPERTIES}\index{LedgerSMB::DBObject::Entity::Credit Account!PROPERTIES}}
\begin{description}

\item[{id}] \mbox{}

This is the internal, machine readable id.


\item[{entity\_id}] \mbox{}

The internal id for the entity to which this is attached.


\item[{entity\_class}] \mbox{}

This is the entity class.  These are hard-coded values.  The main ones used here
are 1 for vendor and 2 for customer.


\item[{pay\_to\_name}] \mbox{}

This is the name that checks are written to or from.


\item[{discount}] \mbox{}

Early payment discount percent.


\item[{description}] \mbox{}

This is the general description for the account.


\item[{discount\_terms}] \mbox{}

The number of days before the payment discount expires.


\item[{discount\_account\_id}] \mbox{}

The id of the account that the discounts are tracked against.


\item[{taxincluded}] \mbox{}

Whether taxes are included by default.


\item[{creditlimit}] \mbox{}

The total debt that is acceptable for the account


\item[{current\_debt}] \mbox{}

This is a number that represents the amount of debt currently carried.  This is
not populated by a simple retrieve since it is a somewhat performance sensitive
operation.  Use get\_current\_debt() to set it.


\item[{terms}] \mbox{}

This is the number of days before an invoice is considered overdue.


\item[{meta\_number}] \mbox{}

This is the human readable account number.


\item[{business\_id}] \mbox{}

This is the id of the business type.


\item[{business\_type}] \mbox{}

This is the name of the business type associated.


\item[{language\_code}] \mbox{}

This is the standard language code to set for communications to the customer or
vendor.  This allows us to print localized invoices.  Values are ones such as
'en\_US'.


\item[{pricegroup\_id}] \mbox{}

This is the numeric id of the pricegroup in which the customer is placed.  It
has no effect for vendors.


\item[{curr}] \mbox{}

The currency to use for billing this customer or for bills received from this
vendor.


\item[{startdate}] \mbox{}

The first allowed date for invoices.


\item[{enddate}] \mbox{}

The last allowable date for invoices


\item[{threshold}] \mbox{}

Do not show invoices as available for payment/receipt until over this threshold


\item[{employee\_id}] \mbox{}

This is the ID for the salesman who is attached to the credit account.  Used by
some for commissions calculations and the like


\item[{ar\_ap\_account\_id}] \mbox{}

The id for the AR or AP account, use for payment reversals.  Required on save.


\item[{cash\_account\_id}] \mbox{}

The id that is the default for the cash account.


\item[{bank\_account}] \mbox{}

This is a link to the bank account record.  Note that multiple bank accounts can
be linked to an entity, but only one can be primary, for things like payments by
wire or ACH.


\item[{tax\_ids}] \mbox{}

This is an arrayref of ints for the tax accounts linked to the customer.


\item[{bank\_account}] \mbox{}

Bank account for the credit account


\item[{taxform\_id}] \mbox{}

This is the tax reporting form associated with the account.

\end{description}
\subsection*{METHODS\label{LedgerSMB::DBObject::Entity::Credit_Account_METHODS}\index{LedgerSMB::DBObject::Entity::Credit Account!METHODS}}
\begin{description}

\item[{prepare\_input(\$hashref)}] \mbox{}

Takes all PGNumber and PGDate inputs and constructs appropriate classes.


\item[{get\_by\_id(\$id int);}] \mbox{}

Retrieves and returns the entity credit account corresponding with the id 
mentioned.


\item[{get\_by\_meta\_number(\$meta\_number string,}] \textbf{\$entity\_class int)}

Retrieves and returns the entity credit account, of entity class \$entity\_class, 
identified by \$meta\_number


\item[{list\_for\_entity(\$entity\_id int, [\$entity\_class}] \textbf{int]);}

Returns a list of entity credit accounts for the entity (company or person)
identified by \$entity\_id


\item[{get\_current\_debt()}] \mbox{}

Sets \$self-$>$current\_debt and returns the same value.


\item[{save()}] \mbox{}

Saves the entity credit account.  This also sets db defaults if not set.


\item[{get\_pricematrix}] \mbox{}

This routine gets the price matrix for the customer or vendor.  This returns a 
hashref with up to two keys:  pricematrix for all vendors and customers, and
pricematrix\_pricegroup for customers.


\item[{delete\_pricematrix(\$entry\_id)}] \mbox{}

This deletes a pricematrix line identified by \$entry\_id


\item[{save\_pricematrix}] \mbox{}

Updates or inserts the price matrix.

\end{description}
\subsection*{COPYRIGHT\label{LedgerSMB::DBObject::Entity::Credit_Account_COPYRIGHT}\index{LedgerSMB::DBObject::Entity::Credit Account!COPYRIGHT}}


Copyright (C) 2012 The LedgerSMB Core Team. This file may be reused under the 
terms of the GNU General Public License version 2 or at your option any later 
version.  Please see the attached LICENSE file for details.

\section{LedgerSMB::DBObject::Entity::User\label{LedgerSMB::DBObject::Entity::User}\index{LedgerSMB::DBObject::Entity::User}}


User management Logic for LedgerSMB

\subsection*{SYNOPSYS\label{LedgerSMB::DBObject::Entity::User_SYNOPSYS}\index{LedgerSMB::DBObject::Entity::User!SYNOPSYS}}


Resetting a password (expires in 24 hrs):
  my \$user = LedgerSMB::DBObject::Entity::User-$>$get(\$entity\_id);
  my \$user-$>$reset\_password('temporary\_password');



Creating a new user:
  my \$user = LedgerSMB::DBObject::Entity::User-$>$new(\%\$request); 
  \$user-$>$save;



Saving permissions:
  my \$user = LedgerSMB::DBObject::Entity::User-$>$new(\%\$request);
  \$user-$>$set\_roles(\$request);

\subsection*{PROPERTIES\label{LedgerSMB::DBObject::Entity::User_PROPERTIES}\index{LedgerSMB::DBObject::Entity::User!PROPERTIES}}
\begin{description}

\item[{entity\_id}] \mbox{}

This is the integer id of the entity of the user


\item[{username}] \mbox{}

Username of the individual.  Would be the name of a valid Pg role.


\item[{pls\_import}] \mbox{}

If this flag is set, we don't try to set a password on creating a new user. Also
we don't create the user account.  This assumes that we are making a
pre-existing PostgreSQL user into a LedgerSMB user.


\item[{password}] \mbox{}

This is only used for new users. It sets a temporary password (good for 24 hrs)


\item[{role\_list}] \mbox{}

A list of role names granted to the user.

\end{description}
\subsection*{METHODS\label{LedgerSMB::DBObject::Entity::User_METHODS}\index{LedgerSMB::DBObject::Entity::User!METHODS}}
\begin{description}

\item[{get(\$entity\_id)}] \mbox{}

Returns the user object for that entity id.


\item[{reset\_password(\$password)}] \mbox{}

Resets a user's password to a temporary password good for 24 hours.


\item[{create}] \mbox{}

Creates the new user.


\item[{save\_roles(\$role\_list)}] \mbox{}

Saves (grants) roles requested.


\item[{list\_roles}] \mbox{}

Lists roles for database.

\end{description}
\subsection*{COPYRIGHT\label{LedgerSMB::DBObject::Entity::User_COPYRIGHT}\index{LedgerSMB::DBObject::Entity::User!COPYRIGHT}}


Copyright (C) 2012 The LedgerSMB Core Team.  This file may be reused under the
conditions of the GNU GPL v2 or at your option any later version.  Please see
the accompanying LICENSE.TXT for more information.

\section{LedgerSMB::DBObject::Entity::Note\label{LedgerSMB::DBObject::Entity::Note}\index{LedgerSMB::DBObject::Entity::Note}}


Notes handling for customers, vendors, 
employees, etc.

\subsection*{SYNPOSIS\label{LedgerSMB::DBObject::Entity::Note_SYNPOSIS}\index{LedgerSMB::DBObject::Entity::Note!SYNPOSIS}}
\begin{verbatim}
  @notes = LedgerSMB::DBObject::Entity::Bank->list($entity_id, [$credit_id]);
  $note->add;
\end{verbatim}
\subsection*{DESCRIPTION\label{LedgerSMB::DBObject::Entity::Note_DESCRIPTION}\index{LedgerSMB::DBObject::Entity::Note!DESCRIPTION}}


This module handles tracking of notes for customers, vendors, employees, sales
leads, and more.  Notes are expected to be read-only, and essentially
append-only.



This module handles attaching notes either at the entity level or the credit id
level.

\subsection*{INHERITS\label{LedgerSMB::DBObject::Entity::Note_INHERITS}\index{LedgerSMB::DBObject::Entity::Note!INHERITS}}
\begin{description}

\item[{LedgerSMB::DBObject\_Moose;}] \mbox{}\end{description}


head1 PROPERTIES

\begin{description}

\item[{entity\_id Int}] \mbox{}

If set this is attached to an entity.  This can optionally be set to a contact
record attached to a credit account but is ignored in that case.


\item[{credit\_id Int}] \mbox{}

If this is set, this is attached to an entity credit account.  If this and
entity\_id are set, entity\_id is ignored.


\item[{id}] \mbox{}

If set this indicates this has been saved to the db.


\item[{subject}] \mbox{}

This is the subject of the note.


\item[{note}] \mbox{}

The contents of the note.  Required


\item[{'note\_class'}] \mbox{}

ID for note class (1 for entity, 3 for eca, etc)

\end{description}
\subsection*{METHODS\label{LedgerSMB::DBObject::Entity::Note_METHODS}\index{LedgerSMB::DBObject::Entity::Note!METHODS}}
\begin{description}

\item[{list(\$entity\_id, [\$credit\_id])}] \mbox{}

Lists all bank accounts for entity\_id.  This does not need to be performed on a
blessed reference.  All return results are objects.


\item[{save()}] \mbox{}

Saves the bank account object to the database and reinstantiates it, thus
setting things like the id field.

\end{description}
\subsection*{COPYRIGHT\label{LedgerSMB::DBObject::Entity::Note_COPYRIGHT}\index{LedgerSMB::DBObject::Entity::Note!COPYRIGHT}}


OPYRIGHT (C) 2012 The LedgerSMB Core Team.  This file may be re-used under the
terms of the GNU General Public License version 2 or at your option any later
version.  Please see the enclosed LICENSE file for details.

\section{LedgerSMB::DBObject::Entity::Contact\label{LedgerSMB::DBObject::Entity::Contact}\index{LedgerSMB::DBObject::Entity::Contact}}


Contact info handling for LSMB

\subsection*{SYNPOSIS\label{LedgerSMB::DBObject::Entity::Contact_SYNPOSIS}\index{LedgerSMB::DBObject::Entity::Contact!SYNPOSIS}}
\begin{verbatim}
  @contact_list = LedgerSMB::DBObject::Entity::Contact->list(
         {entity_id = $entity_id, credit_id = $credit_id }
  );
\end{verbatim}
\subsection*{DESCRIPTION\label{LedgerSMB::DBObject::Entity::Contact_DESCRIPTION}\index{LedgerSMB::DBObject::Entity::Contact!DESCRIPTION}}


This module provides contact info handling for LedgerSMB.  Each contact info
record consists of optionally an entity\_id or a credit\_id, a class, a class
name, a description, and the actual contact information.  This is used to track
everything from phone numbers to email addresses both of natural persons and
companies in LedgerSMB.

\subsection*{INHERITS\label{LedgerSMB::DBObject::Entity::Contact_INHERITS}\index{LedgerSMB::DBObject::Entity::Contact!INHERITS}}
\begin{description}

\item[{LedgerSMB::DBObject\_Moose;}] \mbox{}\end{description}


head1 PROPERTIES

\begin{description}

\item[{entity\_id Int}] \mbox{}

If set this is attached to an entity.  This can optionally be set to a contact
record attached to a credit account but is ignored in that case.


\item[{credit\_id Int}] \mbox{}

If this is set, this is attached to an entity credit account.  If this and
entity\_id are set, entity\_id is ignored.


\item[{class\_id Int}] \mbox{}

This must be set, and references the class id of the contact.  These can be
presumed to be static values, and are contained in the contact\_class table.
Currently that table contains:

\begin{verbatim}
  id |      class      
 ----+-----------------
   1 | Primary Phone
   2 | Secondary Phone
   3 | Cell Phone
   4 | AIM
   5 | Yahoo
   6 | Gtalk
   7 | MSN
   8 | IRC
   9 | Fax
  10 | Generic Jabber
  11 | Home Phone
  12 | Email
  13 | CC
  14 | BCC
  15 | Billing Email
  16 | Billing CC
  17 | Billing BCC
\end{verbatim}

\item[{class Str}] \mbox{}

This is set when retrieving a contact record to the name of the contact class,
such as IRC, Fax, or Email.


\item[{description Str}] \mbox{}

This is set to the description of the contact record.


\item[{contact Str}] \mbox{}

This is the string with the actual contact information, such as an email address
or phone number.


\item[{old\_class\_id}] \mbox{}

If this is set, along with old\_contact (below), then saving will try to overwrite
if possible.


\item[{old\_contact}] \mbox{}\end{description}
\subsection*{METHODS\label{LedgerSMB::DBObject::Entity::Contact_METHODS}\index{LedgerSMB::DBObject::Entity::Contact!METHODS}}
\begin{description}

\item[{list(\$args, \$request);}] \mbox{}

Returns a list of blessed contact references


\item[{save()}] \mbox{}

Saves the record


\item[{delete()}] \mbox{}

deletes the record


\item[{list\_classes()}] \mbox{}

Lists classes as unblessed hashrefs

\end{description}
\subsection*{COPYRIGHT\label{LedgerSMB::DBObject::Entity::Contact_COPYRIGHT}\index{LedgerSMB::DBObject::Entity::Contact!COPYRIGHT}}


OPYRIGHT (C) 2012 The LedgerSMB Core Team.  This file may be re-used under the
terms of the GNU General Public License version 2 or at your option any later
version.  Please see the enclosed LICENSE file for details.

\section{LedgerSMB::DBObject::Entity::Payroll::Wage\label{LedgerSMB::DBObject::Entity::Payroll::Wage}\index{LedgerSMB::DBObject::Entity::Payroll::Wage}}


Wages and Salary Handling 
for LedgerSMB

\subsection*{SYNPOSIS\label{LedgerSMB::DBObject::Entity::Payroll::Wage_SYNPOSIS}\index{LedgerSMB::DBObject::Entity::Payroll::Wage!SYNPOSIS}}


To retrieve a list of wages for an entity:

\begin{verbatim}
  my @wages = LedgerSMB::DBObject::Entity::Person::Wage->list($entity_id);
\end{verbatim}


To retrieve a list of wage categories for selection:
  my @classes = LedgerSMB::DBObject::Entity::Person::Wage-$>$classes(\$entity\_id);



To save a new wage:

\begin{verbatim}
  my $wage = LedgerSMB::DBObject::Entity::Person::Wage->new(%$request);
  $wage->save;
\end{verbatim}
\subsection*{PROPERTIES\label{LedgerSMB::DBObject::Entity::Payroll::Wage_PROPERTIES}\index{LedgerSMB::DBObject::Entity::Payroll::Wage!PROPERTIES}}
\begin{description}

\item[{entry\_id}] \mbox{}

This is the entry id (when set) of the wage.


\item[{type\_id}] \mbox{}

This is the class id of the wage (when set)


\item[{rate}] \mbox{}

This is the rate that one is paid.  Depending on class could be hourly, per 
month, or per unit produced.

\end{description}
\subsection*{METHODS\label{LedgerSMB::DBObject::Entity::Payroll::Wage_METHODS}\index{LedgerSMB::DBObject::Entity::Payroll::Wage!METHODS}}
\begin{description}

\item[{list(\$entity\_id)}] \mbox{}

Retrns a list of wage objects for entity


\item[{classes(\$country\_id)}] \mbox{}

Returns a list of wage classes


\item[{save}] \mbox{}

Saves the wage and attaches to the entity record

\end{description}
\subsection*{COPYRIGHT\label{LedgerSMB::DBObject::Entity::Payroll::Wage_COPYRIGHT}\index{LedgerSMB::DBObject::Entity::Payroll::Wage!COPYRIGHT}}
\section{LedgerSMB::DBObject::Entity::Payroll::Deduction\label{LedgerSMB::DBObject::Entity::Payroll::Deduction}\index{LedgerSMB::DBObject::Entity::Payroll::Deduction}}


Payroll Deduction handling for
LedgerSMB

\subsection*{SYNPOSIS\label{LedgerSMB::DBObject::Entity::Payroll::Deduction_SYNPOSIS}\index{LedgerSMB::DBObject::Entity::Payroll::Deduction!SYNPOSIS}}


To retrieve a list of deductions for an entity:

\begin{verbatim}
  my @deducts = LedgerSMB::DBObject::Entity::Person::Deductions->list(
             $entity_id
  );
\end{verbatim}


To retrieve a list of deduction categories for selection:
  my @types = LedgerSMB::DBObject::Entity::Person::Deduction-$>$types(
              \$country\_id
  );



To save a new deduction:

\begin{verbatim}
  my $deduct= LedgerSMB::DBObject::Entity::Person::Deduction->new(%$request);
  $deduct->save;
\end{verbatim}
\subsection*{PROPERTIES\label{LedgerSMB::DBObject::Entity::Payroll::Deduction_PROPERTIES}\index{LedgerSMB::DBObject::Entity::Payroll::Deduction!PROPERTIES}}
\begin{description}

\item[{entry\_id}] \mbox{}

This is the entry id (when set) of the deduction.


\item[{type\_id}] \mbox{}

This is the class id of the deduction


\item[{rate}] \mbox{}

The rate handling here is deduction class specific.  Some deductions may be 
percentages of income, they may be fixed amounts, or they may be calculated on 
some other basis.  Therefore.....

\end{description}
\subsection*{METHODS\label{LedgerSMB::DBObject::Entity::Payroll::Deduction_METHODS}\index{LedgerSMB::DBObject::Entity::Payroll::Deduction!METHODS}}
\begin{description}

\item[{list(\$entity\_id)}] \mbox{}

Retrns a list of  deduction objects for entity


\item[{classes(\$country\_id)}] \mbox{}

Returns a list of deduction classes


\item[{save}] \mbox{}

Saves the deduction and attaches to the entity record

\end{description}
\subsection*{COPYRIGHT\label{LedgerSMB::DBObject::Entity::Payroll::Deduction_COPYRIGHT}\index{LedgerSMB::DBObject::Entity::Payroll::Deduction!COPYRIGHT}}
\section{LedgerSMB::DBObject::Entity::Person -{}- Natural Person handling for LedgerSMB\label{LedgerSMB::DBObject::Entity::Person_-_-_Natural_Person_handling_for_LedgerSMB}\index{LedgerSMB::DBObject::Entity::Person -{}- Natural Person handling for LedgerSMB}}




\subsection*{SYNOPSIS\label{LedgerSMB::DBObject::Entity::Person_-_-_Natural_Person_handling_for_LedgerSMB_SYNOPSIS}\index{LedgerSMB::DBObject::Entity::Person - - Natural Person handling for LedgerSMB!SYNOPSIS}}


To save:

\begin{verbatim}
 my $person = LedgerSMB::DBObject::Entity::Person->new(\%$request);
 $person->save;
\end{verbatim}


To get by entity id:

\begin{verbatim}
 my $person = LedgerSMB::DBObject::Entity::Person->get($entity_id);
\end{verbatim}


To get by control code:

\begin{verbatim}
 my $person = LedgerSMB::DBObject::Entity::Person->get_by_cc($control_code);
\end{verbatim}
\subsection*{INHERITS\label{LedgerSMB::DBObject::Entity::Person_-_-_Natural_Person_handling_for_LedgerSMB_INHERITS}\index{LedgerSMB::DBObject::Entity::Person - - Natural Person handling for LedgerSMB!INHERITS}}
\begin{description}

\item[{LedgerSMB::DBObject::Entity}] \mbox{}\end{description}
\subsection*{PROPERTIES\label{LedgerSMB::DBObject::Entity::Person_-_-_Natural_Person_handling_for_LedgerSMB_PROPERTIES}\index{LedgerSMB::DBObject::Entity::Person - - Natural Person handling for LedgerSMB!PROPERTIES}}
\begin{description}

\item[{entity\_id}] \mbox{}

ID of entity attached.  This is also an interal reference to this person.


\item[{first\_name}] \mbox{}

Given name of the individual.


\item[{middle\_name}] \mbox{}

Middle name of individual


\item[{last\_name}] \mbox{}

Surname of individual


\item[{salutation\_id}] \mbox{}

Salutation id.  These are fixed as:

\begin{verbatim}
  id | salutation 
 ----+------------
   1 | Dr.
   2 | Miss.
   3 | Mr.
   4 | Mrs.
   5 | Ms.
   6 | Sir.
 (6 rows)
\end{verbatim}

\item[{salutations}] \mbox{}

Constant hashref of above salutations, key is id.


\item[{created}] \mbox{}

Date when the  person was entered into LedgerSMB

\end{description}
\subsection*{METHODS\label{LedgerSMB::DBObject::Entity::Person_-_-_Natural_Person_handling_for_LedgerSMB_METHODS}\index{LedgerSMB::DBObject::Entity::Person - - Natural Person handling for LedgerSMB!METHODS}}
\begin{description}

\item[{get(\$id)}] \mbox{}

This retrieves and returns the item as a blessed reference


\item[{get\_by\_cc(\$cc)}] \mbox{}

This retrieves a person associated with a control code.  Dies with error if 
person does not exist.


\item[{save()}] \mbox{}

Saves the item and populates db defaults in id and created.

\end{description}
\subsection*{COPYRIGHT\label{LedgerSMB::DBObject::Entity::Person_-_-_Natural_Person_handling_for_LedgerSMB_COPYRIGHT}\index{LedgerSMB::DBObject::Entity::Person - - Natural Person handling for LedgerSMB!COPYRIGHT}}


Copyright (C) 2012, the LedgerSMB Core Team.  This file may be re-used under the GNU GPL
version 2 or at your option any future version.  Please see the accompanying LICENSE 
file for details.

\section{LedgerSMB::DBObject::Entity::Person::Employee -{}- Employee handling for LedgerSMB\label{LedgerSMB::DBObject::Entity::Person::Employee_-_-_Employee_handling_for_LedgerSMB}\index{LedgerSMB::DBObject::Entity::Person::Employee -{}- Employee handling for LedgerSMB}}




\subsection*{SYNOPSIS\label{LedgerSMB::DBObject::Entity::Person::Employee_-_-_Employee_handling_for_LedgerSMB_SYNOPSIS}\index{LedgerSMB::DBObject::Entity::Person::Employee - - Employee handling for LedgerSMB!SYNOPSIS}}


To save:

\begin{verbatim}
 my $emp = LedgerSMB::DBObject::Entity::Person::Employee(\%$request);
 $emp->save;
\end{verbatim}


To get by entity id:

\begin{verbatim}
 my $emp = LedgerSMB::DBObject::Entity::Person::Employee->get($entity_id);
\end{verbatim}


To get by control code:

\begin{verbatim}
 my $emp 
     = LedgerSMB::DBObject::Entity::Person::Employee->get_by_cc($control_code);
\end{verbatim}
\subsection*{INHERITS\label{LedgerSMB::DBObject::Entity::Person::Employee_-_-_Employee_handling_for_LedgerSMB_INHERITS}\index{LedgerSMB::DBObject::Entity::Person::Employee - - Employee handling for LedgerSMB!INHERITS}}
\begin{description}

\item[{LedgerSMB::DBObject::Entity::Person}] \mbox{}\end{description}
\subsection*{PROPERTIES\label{LedgerSMB::DBObject::Entity::Person::Employee_-_-_Employee_handling_for_LedgerSMB_PROPERTIES}\index{LedgerSMB::DBObject::Entity::Person::Employee - - Employee handling for LedgerSMB!PROPERTIES}}
\begin{description}

\item[{start\_date}] \mbox{}

Start date for employee.


\item[{end\_date}] \mbox{}

End date for employee


\item[{dob}] \mbox{}

Date of Birth.  Required.


\item[{role}] \mbox{}

Organizational role.  Is manager, user, or administrator


\item[{ssn}] \mbox{}

Social security number, tax number, or the like for the employee.  Required


\item[{sales}] \mbox{}

Bool, whether the individual is a salesperson or not


\item[{manager\_id}] \mbox{}

Entity id of manager


\item[{employeenumber}] \mbox{}

Employee number, required, for employee.

\end{description}
\subsection*{METHODS\label{LedgerSMB::DBObject::Entity::Person::Employee_-_-_Employee_handling_for_LedgerSMB_METHODS}\index{LedgerSMB::DBObject::Entity::Person::Employee - - Employee handling for LedgerSMB!METHODS}}
\begin{description}

\item[{get(\$entity\_id)}] \mbox{}

This does not need to be a blessed reference.  It does return a reference 
blessed if the employee is found or undef otherwise.


\item[{get\_by\_cc(\$control\_code);}] \mbox{}

Similar to get above but accepts as input the control code rather than the
entity\_id.


\item[{save()}] \mbox{}

Saves the employee.  Must be a blessed reference.

\end{description}
\subsection*{COPYRIGHT\label{LedgerSMB::DBObject::Entity::Person::Employee_-_-_Employee_handling_for_LedgerSMB_COPYRIGHT}\index{LedgerSMB::DBObject::Entity::Person::Employee - - Employee handling for LedgerSMB!COPYRIGHT}}


Copyright (C) 2012, the LedgerSMB Core Team.  This file may be re-used under 
the GNU GPL version 2 or at your option any future version.  Please see the 
accompanying LICENSE file for details.

\section{LedgerSMB::DBObject::Entity::Location\label{LedgerSMB::DBObject::Entity::Location}\index{LedgerSMB::DBObject::Entity::Location}}


Address Handling for LedgerSMB Contacts

\subsection*{SYNPOSIS\label{LedgerSMB::DBObject::Entity::Location_SYNPOSIS}\index{LedgerSMB::DBObject::Entity::Location!SYNPOSIS}}


This contains a the basic handling of addresses for LedgerSMB contacts.



Addresses may be tacked for billing, marketing, and shipping, and may be
attached either to the entity (person or company) or credit account
(customer/vendor account).

\subsection*{INHERITS\label{LedgerSMB::DBObject::Entity::Location_INHERITS}\index{LedgerSMB::DBObject::Entity::Location!INHERITS}}
\begin{description}

\item[{LedgerSMB::DBObject\_Moose}] \mbox{}\end{description}
\subsection*{PROPERTIES\label{LedgerSMB::DBObject::Entity::Location_PROPERTIES}\index{LedgerSMB::DBObject::Entity::Location!PROPERTIES}}
\begin{description}

\item[{active}] \mbox{}

Bool, whether the address is active.


\item[{inactive\_date}] \mbox{}

Date when the location became inactive.


\item[{id}] \mbox{}

Internal id of the actual location entry.


\item[{entity\_id}] \mbox{}

Internal id of linked entity.  Is undef if linked to an entity credit account 
instead


\item[{credit\_id}] \mbox{}

Internal id of lined entity credit account.  Is undef if linked to entity
instead.


\item[{location\_class}] \mbox{}

Internal id of location class.

\begin{enumerate}

\item for Billing
\item for Sales
\item for Shipping\end{enumerate}

\item[{old\_location\_class}] \mbox{}

Old location class for updating


\item[{class\_name}] \mbox{}

The name of the class that goes with the id.  This is not set until
\$self-$>$set\_class\_name is called.


\item[{line\_one}] \mbox{}

The first line of the street address.


\item[{line\_two}] \mbox{}

The second line of the street address


\item[{line\_three}] \mbox{}

The third line of the street address


\item[{city}] \mbox{}

Name of the city.


\item[{state}] \mbox{}

Name of the state or province


\item[{mail\_code}] \mbox{}

Zip or postal code


\item[{country\_id}] \mbox{}

This is the internal id of the country for the address.


\item[{counry\_name}] \mbox{}

The name of the country

\end{description}
\subsection*{METHODS\label{LedgerSMB::DBObject::Entity::Location_METHODS}\index{LedgerSMB::DBObject::Entity::Location!METHODS}}
\begin{description}

\item[{get(\$args hashref)}] \mbox{}

Retrieves locations and returns them.  Args include:

\begin{description}

\item[{entity\_id (required)}] \mbox{}
\item[{credit\_id (optional)}] \mbox{}
\item[{only\_class int (optional)}] \mbox{}\end{description}


This function returns all locations attached to the entity\_id and, if the credit\_id is provided, all locations attached to the credit\_id as well.  The two 
are appended together with the ones at the entity level coming first.



If only\_class is set, all results will be discarded that are not a specific 
class (useful for retrieving billing info only).


\item[{save()}] \mbox{}

Saves the current location to the database


\item[{delete()}] \mbox{}

Deletes the current location

\end{description}
\subsection*{COPYRIGHT\label{LedgerSMB::DBObject::Entity::Location_COPYRIGHT}\index{LedgerSMB::DBObject::Entity::Location!COPYRIGHT}}


COPYRIGHT (C) 2012 The LedgerSMB Core Team.  This file may be re-used under the
terms of the GNU General Public License version 2 or at your option any later
version.  Please see the enclosed LICENSE file for details.

\section{SYNOPSYS\label{SYNOPSYS}\index{SYNOPSYS}}


This module contains the routines for managing and recording journal entries.
Such journal entries are the base of the accounting software and include all
invoices issued to customers and vendors, all payments and receipts, all 
transfers between bank accounts, etc.

\section{INHERITANCE\label{INHERITANCE}\index{INHERITANCE}}


the following modules are in the inheritance tree of this module

\begin{description}

\item[{Moose}] \mbox{}
\item[{LedgerSMB}] \mbox{}
\item[{LedgerSMB::DBObject}] \mbox{}\end{description}
\section{PROPERTIES\label{PROPERTIES}\index{PROPERTIES}}
\begin{description}

\item[{id (rw, int, not required) This is the id}] \textbf{of the journal entry, auto-generated when saved. Should be undef when the journal entry has not yet been saved. Will be set on all entries retrieved from the database.}
\item[{reference (rw, string, required) This is}] \textbf{the source document number for the journal entry. For an invoice this will be the invoice number. For a check it will be the check number. In other cases, it could be other specified identifiers. All GL and all sales references must be unique.}
\item[{description (rw, string, not required)}] \mbox{}

This is an optional description for the transaction, such as the memo field
of a check.


\item[{journal (rw, int, required)}] \mbox{}

This tells us which journal the transaction is being entered in and hence what 
the transaction type is.  The following values are hard-coded in the database:

\begin{enumerate}

\item General

Used for general journal entries, for example transfers between bank accounts,
adjustments, and the like.


\item Sales

Used for sales invoices with or without inventory.


\item Purchases

Used to record vendor invoices with or without inventory.


\item Receipts

Used to record moneys received from customers.


\item Dispursements

Used to record moneys paid to vendors

\end{enumerate}

\item[{post\_date (rw, date, required) This records}] \textbf{the date the transaction officially hits the books (with or without adjustments).}
\item[{effective\_start(rw, date, optional) Records}] \textbf{the date the transaction begins to take effect (for example the beginning of a lease). Used for manually calculating adjustments and could be used for an add-on to do the same. If not provided, defaults to post\_date.}
\item[{effective\_end (rw, date, optional) Records}] \textbf{the date the transaction ceases to take effect (for example the ending date of a year-long pre-paid lease). Used for manually calculating adjustments and could be used for an add-on to do the same. if not provided, defaults to post\_date.}
\item[{currency(rw, string, required) Three characters}] \textbf{identifying the currency in use (for example USD, CAD, or EUR).}
\item[{approved (ro, bool, required, defaults to}] \textbf{0) Reports whether the transaction has been approved. Is not saved when the journal entry is saved.}
\item[{is\_template (rw, bool, required, defaults}] \textbf{to 0)}

This is set as true when saving as a template.  Templates can be copied to new
transactions or deleted but cannot be approved themselves.


\item[{entered\_by (ro, int, not required) This}] \textbf{is the entity id of the one entering the transaction. It is set automatically by the database.}\section{LedgerSMB::DBObject::Reconciliation\label{LedgerSMB::DBObject::Reconciliation}\index{LedgerSMB::DBObject::Reconciliation}}


LedgerSMB class defining the core 
database interaction logic for Reconciliation.

\subsection*{SYOPSIS\label{LedgerSMB::DBObject::Reconciliation_SYOPSIS}\index{LedgerSMB::DBObject::Reconciliation!SYOPSIS}}


This module creates object instances based on LedgerSMB's in-database ORM.

\subsection*{METHODS\label{LedgerSMB::DBObject::Reconciliation_METHODS}\index{LedgerSMB::DBObject::Reconciliation!METHODS}}


Please note, this module needs a lot of cleanup.

\begin{description}

\item[{new (\$class, base =$>$ \$LedgerSMB::hash)}] \mbox{}

This is the base constructor for all child classes.  It must be used with base
argument because this is necessary for database connectivity and the like.



Of course the base object can be any object that inherits LedgerSMB, so you can
use any subclass of that.  The per-session dbh is passed between the objects 
this way as is any information that is needed.


\item[{get\_report(\$self, \$report\_id)}] \mbox{}

Collects all the rows from the database in the given report. Returns an 
arrayref of entries in the table for the given report\_id.



Returns undef in the event of no records found.


\item[{get\_corrections(\$self, \$report\_id, \$entry\_id)}] \mbox{}

Returns the corrections made for the selected report and entry.
Returns undef in the event of no corrections found.


\item[{entry (\$self,\$report\_id,\$entry\_id)}] \mbox{}

Returns a single entry from the pending reports table, either cleared or
uncleared.


\item[{update}] \mbox{}

Updates the report, pulling in any new transactions in the date range into the 
transaction list.


\item[{submit}] \mbox{}

Submits the reconciliation set for approval.


\item[{save}] \mbox{}

Saves the reconciliation set for later work


\item[{import\_file}] \mbox{}

Calls the file import function.  This is generally assumed to be a csv file
although the plugin is very modular and plugins could be written for other 
formats.  The format structure is per account id.


\item[{approve(\$self,\$reportid)}] \mbox{}

Approves the pending report \$reportid.
Checks for error codes in the pending report, and approves the report if none
are found.



Limitations: The creating user may not approve the report.



Returns 1 on success.


\item[{new\_report}] \mbox{}

Creates a new report with data entered.


\item[{delete (\$self, \$report\_id)}] \mbox{}

Requires report\_id



This will allow the deletion of a report if the report is not approved and 
the user either owns the unsubmitted report, or the user has the right to 
approve reports.



Returns 0 if successful, or a true result if not.


\item[{add\_entries}] \mbox{}

Adds entries from the import file routine.



This function is extremely order dependent.  Meaningful scn's must be submitted 
first it is also recommended that amounts be ordered where scn's are not found.


\item[{search}] \mbox{}

Searches for reconciliation reports.  No inputs mandatory.



date\_from and date\_to specify ranges.
balance\_from and balance\_to specify ranges
chart\_id specifies an account
submitted and approved are exact matches to status.


\item[{get}] \mbox{}

Gets all information relating to a reconciliation report.



id must be set.



Populates main hash with values from cr\_report



Also populates

\begin{description}

\item[{report\_lines}] \mbox{}

a list of report lines


\item[{account\_info}] \mbox{}

a hashrefo of information from the account table.


\item[{beginning\_balance}] \mbox{}
\item[{cleared\_total}] \mbox{}
\item[{outstanding\_total}] \mbox{}
\item[{mismatch\_our\_total}] \mbox{}
\item[{mismatch\_our\_credits}] \mbox{}
\item[{mismatch\_our\_debits}] \mbox{}
\item[{mismatch\_their\_total}] \mbox{}
\item[{mismatch\_their\_credits}] \mbox{}
\item[{mismatch\_their\_debits}] \mbox{}\end{description}

\item[{get\_accounts}] \mbox{}

This is a simple wrapper around reconciliation\_\_account\_list

\end{description}
\subsection*{Copyright (C) 2007, The LedgerSMB core team.\label{LedgerSMB::DBObject::Reconciliation_Copyright_C_2007_The_LedgerSMB_core_team_}\index{LedgerSMB::DBObject::Reconciliation!Copyright (C) 2007, The LedgerSMB core team.}}


This file is licensed under the Gnu General Public License version 2, or at your
option any later version.  A copy of the license should have been included with
your software.

\section{LedgerSMB::DBObject::Asset\label{LedgerSMB::DBObject::Asset}\index{LedgerSMB::DBObject::Asset}}


LedgerSMB Base Class for Fixed Assets

\subsection*{SYNOPSIS\label{LedgerSMB::DBObject::Asset_SYNOPSIS}\index{LedgerSMB::DBObject::Asset!SYNOPSIS}}


This library contains the base utility functions for creating, saving, and
retrieving fixed assets for depreciation

\subsection*{STANDARD PROPERTIES\label{LedgerSMB::DBObject::Asset_STANDARD_PROPERTIES}\index{LedgerSMB::DBObject::Asset!STANDARD PROPERTIES}}
\begin{description}

\item[{id (integer)}] \mbox{}

Unique id number of asset.


\item[{description (text)}] \mbox{}

Text description of asset.


\item[{tag (text)}] \mbox{}

Arbitrary tag identifier, unique for current, non-disposed assets.


\item[{purchase\_value (numeric)}] \mbox{}

Numeric representation of purchase value.


\item[{salvage\_value (numeric)}] \mbox{}

Numeric representation of estimated salvage value.


\item[{usable\_life (numeric)}] \mbox{}

Numeric representation of estimated usable life.


\item[{purchase\_date (date)}] \mbox{}

Date item was purchase


\item[{start\_depreciation (date)}] \mbox{}

Date item is put into service, when depreciation should start.  If unknown
we use the purchase\_date instead.


\item[{location\_id (int)}] \mbox{}

ID of business location where asset is stored.


\item[{department\_id (int)}] \mbox{}

ID of department where asset is stored


\item[{invoice\_id (int)}] \mbox{}

ID of purchasing invoice


\item[{asset\_account\_id (int)}] \mbox{}

ID of account to store asset value


\item[{dep\_account\_id (int)}] \mbox{}

ID of account to store cumulative depreciation


\item[{exp\_account\_id (int)}] \mbox{}

ID of account to store expense when disposed of.


\item[{obsolete\_by (int)}] \mbox{}

Obsolete by other asset id.  Undef if active, otherwise the id of the active 
asset that replaces this. Used for partial depreciation.


\item[{asset\_class\_id (int)}] \mbox{}

ID of asset class.

\end{description}
\subsection*{METHODS\label{LedgerSMB::DBObject::Asset_METHODS}\index{LedgerSMB::DBObject::Asset!METHODS}}
\begin{description}

\item[{save}] \mbox{}

Uses standard properties



Saves the asset item to the database



Sets any properties set by the database that were not in the original object,
usually ID (if no match to current ID or if ID was undef).


\item[{import\_file}] \mbox{}

Parses a csv file.  Sets \$self-$>$\{import\_entries\} to an arrayref where each
member is an arrayref of fields.  It is up to the workflow script to handle 
these entries.



Header information is set to \$self-$>$\{import\_header\}.


\item[{get}] \mbox{}

Gets a fixed asset, sets all standard properties.  The id property must be set.


\item[{search}] \mbox{}

Searches for asset\_items matching criteria.  Sets \$self-$>$\{search\_results\} to 
the result.



Search criteria set by the following properties:
* id
* asset\_class
* description
* tag
* purchase\_date
* purchase\_value
* usable\_life
* salvage\_value 
* start\_depreciation
* warehouse\_id
* department\_id
* invoice\_id 
* asset\_account\_id
* dep\_account\_id



Tag and description are partial matches.  All other matches are exact.  Undef
matches all values.


\item[{save\_note}] \mbox{}

Saves a note.  Uses the following properties:



* id
* subject
* note


\item[{get\_metadata}] \mbox{}

Sets the following:



* asset\_classes:  List of all asset classes
* locations:  List of all warehouses/locations
* deprtments:  List of all departments
* asset\_accounts:  List of all asset accounts
* dep\_accounts:  List of all depreciation accounts
* exp\_accounts:  List of all expense accounts


\item[{get\_next\_tag}] \mbox{}

Returns next tag number



Sets \$self-$>$\{tag\} to that value.


\item[{import\_asset}] \mbox{}

Uses standard properties.  Saves record in import report for batch review and 
creation.

\end{description}
\subsection*{Copyright (C) 2010, The LedgerSMB core team.\label{LedgerSMB::DBObject::Asset_Copyright_C_2010_The_LedgerSMB_core_team_}\index{LedgerSMB::DBObject::Asset!Copyright (C) 2010, The LedgerSMB core team.}}


This file is licensed under the Gnu General Public License version 2, or at your
option any later version.  A copy of the license should have been included with
your software.

\section{LedgerSMB::DBObject::Business\_Unit\_Class\label{LedgerSMB::DBObject::Business_Unit_Class}\index{LedgerSMB::DBObject::Business\ Unit\ Class}}




\subsection*{SYNOPSYS\label{LedgerSMB::DBObject::Business_Unit_Class_SYNOPSYS}\index{LedgerSMB::DBObject::Business Unit Class!SYNOPSYS}}


This holds the information as to the handling of classes of buisness units.  
Business units are reporting units which can be used to classify various line 
items of transactions in different ways and include handling for departments, 
funds, and projects.

\subsection*{PROPERTIES\label{LedgerSMB::DBObject::Business_Unit_Class_PROPERTIES}\index{LedgerSMB::DBObject::Business Unit Class!PROPERTIES}}
\begin{description}

\item[{id}] \mbox{}

This is the internal id of the unit class.  It is undef when the class has not
yet been saved in the database


\item[{label}] \mbox{}

This is the human-readible label for the class.  It must be unique among
classes.


\item[{active bool}] \mbox{}

If true, indicates that this will show up on screens.  If not, it will be
hidden.


\item[{modules bool}] \mbox{}

If true, indicates that this will not show up on accounting transaction screens.
this is indivated for CRM and other applications.


\item[{ordering}] \mbox{}

The entry boxes (drop down or text entry) are set arranged from low to high
by this field on the data entry screens.

\end{description}
\subsection*{METHODS\label{LedgerSMB::DBObject::Business_Unit_Class_METHODS}\index{LedgerSMB::DBObject::Business Unit Class!METHODS}}
\begin{description}

\item[{get(\$id)}] \mbox{}

returns the business unit class that corresponds to the id requested.


\item[{save}] \mbox{}

Saves the existing buisness unit class to the database, and updates any fields 
changed in the process.


\item[{save\_modules}] \mbox{}

This saves only the module permissions.  This takes the list of modules and prepares an array for the saving and then saves the modules.  This is broken off as a public 
interface because it makes it possible to activate/deactive regarding modules after the 
fact without changing anything else.


\item[{list(bool \$active, string \$mod\_name)}] \mbox{}

Returns a list of all business unit classes.


\item[{delete}] \mbox{}

Deletes a business unit class.  Such classes may not have business units attached.

\end{description}
\subsection*{PREDEFINED CLASSES\label{LedgerSMB::DBObject::Business_Unit_Class_PREDEFINED_CLASSES}\index{LedgerSMB::DBObject::Business Unit Class!PREDEFINED CLASSES}}
\begin{description}

\item[{Department, ID: 1}] \mbox{}
\item[{Project, ID: 2}] \mbox{}
\item[{Job, ID: 3}] \mbox{}

Used for manufacturing lots


\item[{Fund, ID: 4}] \mbox{}

Used by non-profits for funds accounting


\item[{Customer, ID 5}] \mbox{}

Used in some countries/industries for multi-customer receipts


\item[{Vendor, ID 6}] \mbox{}

Used in some countries/industries for multi-vendor payments

\end{description}
\subsection*{COPYRIGHT\label{LedgerSMB::DBObject::Business_Unit_Class_COPYRIGHT}\index{LedgerSMB::DBObject::Business Unit Class!COPYRIGHT}}


Copyright (C) 2012 The LedgerSMB Core Team.  This module may be used under the
GNU GPL in accordance with the LICENSE file listed.

\section{LedgerSMB::DBobject::Date\label{LedgerSMB::DBobject::Date}\index{LedgerSMB::DBobject::Date}}


Date Handling Back-end Routines for LedgerSMB

\subsection*{SYNOPSIS\label{LedgerSMB::DBobject::Date_SYNOPSIS}\index{LedgerSMB::DBobject::Date!SYNOPSIS}}


Provides the functions for generating the data structures for dates used in 
LedgerSMB.

\subsection*{METHODS\label{LedgerSMB::DBobject::Date_METHODS}\index{LedgerSMB::DBobject::Date!METHODS}}
\begin{description}

\item[{LedgerSMB::DBObject::Payment-$>$new()}] \mbox{}

Inherited from LedgerSMB::DBObject.  Please see that documnetation for details.


\item[{\$self-$>$build\_filter\_by\_period()}] \mbox{}

This function takes \$locale as an argument to build the list boxes, of the
period filter.



It sets \$self-$>$\{yearsOptions\}, \$self-$>$\{\$monthsOptions\}, \$self-$>$\{radioOptions\} 
so you just pass the hash to the template system. :)

\end{description}
\subsection*{COPYRIGHT\label{LedgerSMB::DBobject::Date_COPYRIGHT}\index{LedgerSMB::DBobject::Date!COPYRIGHT}}


Copyright (c) 2009, the LedgerSMB Core Team.  This is licensed under the GNU 
General Public License, version 2, or at your option any later version.  Please 
see the accompanying License.txt for more information.

\section{LedgerSMB::DBObject::Account\label{LedgerSMB::DBObject::Account}\index{LedgerSMB::DBObject::Account}}


Base class for chart of accounts entries

\subsection*{SYNOPSYS\label{LedgerSMB::DBObject::Account_SYNOPSYS}\index{LedgerSMB::DBObject::Account!SYNOPSYS}}


This class contains methods for managing chart of accounts entries (headings 
and accounts).

\subsection*{INERITS\label{LedgerSMB::DBObject::Account_INERITS}\index{LedgerSMB::DBObject::Account!INERITS}}
\begin{description}

\item[{LedgerSMB::DBObject}] \mbox{}\end{description}
\subsection*{METHODS\label{LedgerSMB::DBObject::Account_METHODS}\index{LedgerSMB::DBObject::Account!METHODS}}
\begin{description}

\item[{save()}] \mbox{}

This method saves the chart of accounts entry.



The hash component of the object may contain an id attribute, used to overwrite
an account if that one exists.



Hash entries Used:



id: (optional):  If set, overwrite existing account.
accno: the text used to specify the account number
description:  Text to describe the account
category: A = asset, L = liability, Q = Equity, I = Income, E = expense
gifi\_accno:  The GIFI account entry control code
heading: (Optional) The integer representing the heading.id desired 
contra:  If true, the account balances on the opposite side.
tax:  If true, is a tax account
link:  a list of strings representing text box identifier.


\item[{get()}] \mbox{}

This method gets a chart of accounts entry.  It requires that the \$account-$>$\{id\}
value must be properly set.


\item[{check\_transactions()}] \mbox{}

Returns true if the account has transactions, false if not.  Also sets the
\$account-$>$\{has\_transactions\} value to the return value.



\$account-$>$\{id\} must be set.


\item[{is\_recon}] \mbox{}

Returns true if is set up for reconciliation.  False otherwise.


\item[{delete()}] \mbox{}

Attempts to delete the account.  This will NOT succeed if the account is
referenced in any way by any transactions, credit accounts, etc.



\$account-$>$\{id\} must be set.


\item[{list()}] \mbox{}

Returns a list of all accounts.


\item[{generate\_links()}] \mbox{}

A mostly-private method for generating and checking whether link data is valid.



This is usually done (automatically) in preparation for saving the information 
to the database.


\item[{list\_headings}] \mbox{}

Returns a list of account\_heading's.  No inputs required.

\end{description}
\subsection*{SEE ALSO\label{LedgerSMB::DBObject::Account_SEE_ALSO}\index{LedgerSMB::DBObject::Account!SEE ALSO}}


LedgerSMB::DBObject, LedgerSMB

\subsection*{COPYRIGHT\label{LedgerSMB::DBObject::Account_COPYRIGHT}\index{LedgerSMB::DBObject::Account!COPYRIGHT}}


Copyright (c) 2009, the LedgerSMB Core Team.  This is licensed under the GNU 
General Public License, version 2, or at your option any later version.  Please 
see the accompanying License.txt for more information.

\section{LedgerSMB::DBObject::Draft\label{LedgerSMB::DBObject::Draft}\index{LedgerSMB::DBObject::Draft}}


LedgerSMB base class for managing "drafts."

\subsection*{SYNOPSIS\label{LedgerSMB::DBObject::Draft_SYNOPSIS}\index{LedgerSMB::DBObject::Draft!SYNOPSIS}}


This module contains the methods for managing unapproved, unbatched financial 
transactions.  This does not contain facities for creating such transactions, 
only searching for them, and posting them to the books.

\subsection*{METHODS\label{LedgerSMB::DBObject::Draft_METHODS}\index{LedgerSMB::DBObject::Draft!METHODS}}
\begin{description}

\item[{search()}] \mbox{}

returns a list of results for the search criteria.  This list is also stored 
in \$draft-$>$\{search\_resuts\}



Requres \$self-$>$\{type\} to be one of 'ar', 'ap', or 'gl'



Optional hash entries for search criteria are:



with\_accno: Draft transaction against a specific account.
from\_date:  Earliest date for match
to\_date: Latest date for match
amount\_le: total less than or equal to
amount\_ge: total greater than or equal to


\item[{approve()}] \mbox{}

Approves the draft identified by the transaction id in \$draft-$>$\{id\}.  Once
approved, the draft shows up in financial reports.


\item[{delete()}] \mbox{}

Deletes the draft associated with transaction id in \$draft-$>$\{id\}.



Naturally, only unapproved transactions can be deleted.  Once posted to the
books, a draft may not be deleted.

\end{description}
\subsection*{COPYRIGHT\label{LedgerSMB::DBObject::Draft_COPYRIGHT}\index{LedgerSMB::DBObject::Draft!COPYRIGHT}}


Copyright (C) 2009 LedgerSMB Core Team.  This file is licensed under the GNU 
General Public License version 2, or at your option any later version.  Please
see the included License.txt for details.

\section{LedgerSMB::DBObject::Admin\label{LedgerSMB::DBObject::Admin}\index{LedgerSMB::DBObject::Admin}}


User/group management for LedgerSMB

\subsection*{SYNOPSIS\label{LedgerSMB::DBObject::Admin_SYNOPSIS}\index{LedgerSMB::DBObject::Admin!SYNOPSIS}}


User/group management for LedgerSMB

\subsection*{INHERITS\label{LedgerSMB::DBObject::Admin_INHERITS}\index{LedgerSMB::DBObject::Admin!INHERITS}}
\begin{description}

\item[{Universal}] \mbox{}
\item[{LedgerSMB}] \mbox{}
\item[{LedgerSMB::DBObject}] \mbox{}\end{description}
\subsection*{METHODS\label{LedgerSMB::DBObject::Admin_METHODS}\index{LedgerSMB::DBObject::Admin!METHODS}}
\begin{description}

\item[{delete\_user(\$delete\_role)}] \mbox{}

Deletes a user specified by \$self-$>$\{user\_id\}.



if \$delete\_role is true, deletes the role too.


\item[{search\_users}] \mbox{}

Returns a list of users matching search criteria, and attaches that list to the 
user\_results hash value.



Search criteria:

\begin{description}

\item[{username}] \mbox{}
\item[{first\_name}] \mbox{}
\item[{last\_name}] \mbox{}
\item[{ssn}] \mbox{}
\item[{dob}] \mbox{}\end{description}


Undef matches all values.  All matches exact except username which allows for
partial matches.


\item[{list\_sessions}] \mbox{}

returns a list of active sessions, when they were last used, and how many 
discretionary locks they hold.  The list is also attached to the
active\_sessions hash value.  No inputs required or used.


\item[{delete\_session}] \mbox{}

Deletes a session identified by the session\_id hashref.


\item[{save\_roles}] \mbox{}

Saves the roles assigned to a user.
Each role is specified as a hashref true value, where the key is the full name
of the role (i.e. starting with lsmb\_[dbname]\_\_).


\item[{get\_salutations}] \mbox{}

Returns a list of salutation records from the db for the dropdowns.


\item[{get\_roles}] \mbox{}

Returns a list of role names with the following format:



\{role =$>$ \$full\_role\_name, description =$>$ \$short\_role\_name\}



The short role name is the full role name with the prefix removed (i.e. without
the lsmb\_[dbname]\_\_ prefix).


\item[{get\_countries}] \mbox{}

Returns a reference to an array of hashrefs including the country data in the db.



Sets the same reference to the countries hash value.


\item[{get\_contact\_classes}] \mbox{}

Returns a list of hashrefs (\{id =$>$, class =$>$\}) relating to the contact classes.

\end{description}
\subsection*{COPYRIGHT\label{LedgerSMB::DBObject::Admin_COPYRIGHT}\index{LedgerSMB::DBObject::Admin!COPYRIGHT}}


Copyright (c) 2009, the LedgerSMB Core Team.  This is licensed under the GNU 
General Public License, version 2, or at your option any later version.  Please 
see the accompanying License.txt for more information.

\section{LedgerSMB::DBObject::Menu\label{LedgerSMB::DBObject::Menu}\index{LedgerSMB::DBObject::Menu}}


Menu Handling Back-end Routines for LedgerSMB

\subsection*{SYNOPSIS\label{LedgerSMB::DBObject::Menu_SYNOPSIS}\index{LedgerSMB::DBObject::Menu!SYNOPSIS}}


Provides the functions for generating the data structures for the LedgerSMB
menu.

\subsection*{COPYRIGHT\label{LedgerSMB::DBObject::Menu_COPYRIGHT}\index{LedgerSMB::DBObject::Menu!COPYRIGHT}}


Copyright (c) 2007 The LedgerSMB Core Team.  Licensed under the GNU General 
Public License version 2 or at your option any later version.  Please see the
included COPYRIGHT and LICENSE files for more information.

\subsection*{METHODS\label{LedgerSMB::DBObject::Menu_METHODS}\index{LedgerSMB::DBObject::Menu!METHODS}}
\begin{description}

\item[{new()}] \mbox{}

Inherited from LedgerSMB::DBObject.  Please see that documnetation for details.


\item[{generate()}] \mbox{}

This function returns a list of menu items.  Each list item is a hashref:
keys \%menu\_item would return the equivalent of qw(position id level label path 
args).  Returns the complete list and sets \$menu-$>$\{menu\_items\} to a referene to 
th result set, This function does not return an entry for the top-level menu.


\item[{generate\_section()}] \mbox{}

This class acts like Menu::Generate except it returns only a cross-section of 
the menu.  Basically it returns all nodes which are direct children below
\$object-$>$\{parent\_id\}.


\item[{will\_expire\_soon()}] \mbox{}

This method returns true if the user's password will expire soon 
(within the next week).

\end{description}
\subsection*{Copyright (C) 2007 The LedgerSMB Core Team\label{LedgerSMB::DBObject::Menu_Copyright_C_2007_The_LedgerSMB_Core_Team}\index{LedgerSMB::DBObject::Menu!Copyright (C) 2007 The LedgerSMB Core Team}}


Licensed under the GNU General Public License version 2 or later (at your 
option).  For more information please see the included LICENSE and COPYRIGHT 
files.

\section{LedgerSMB::DBOject::Payment\label{LedgerSMB::DBOject::Payment}\index{LedgerSMB::DBOject::Payment}}


Payment Handling Back-end Routines for LedgerSMB

\subsection*{SYNOPSIS\label{LedgerSMB::DBOject::Payment_SYNOPSIS}\index{LedgerSMB::DBOject::Payment!SYNOPSIS}}


Provides the functions for generating the data structures payments made in 
LedgerSMB.   This module currently handles only basic payment logic, and does
handle overpayment logic, though these features will be moved into this module
in the near future.

\subsection*{COPYRIGHT\label{LedgerSMB::DBOject::Payment_COPYRIGHT}\index{LedgerSMB::DBOject::Payment!COPYRIGHT}}


Copyright (c) 2007 The LedgerSMB Core Team.  Licensed under the GNU General 
Public License version 2 or at your option any later version.  Please see the
included COPYRIGHT and LICENSE files for more information.

\subsection*{METHODS\label{LedgerSMB::DBOject::Payment_METHODS}\index{LedgerSMB::DBOject::Payment!METHODS}}
\begin{description}

\item[{LedgerSMB::DBObject::Payment-$>$new()}] \mbox{}

Inherited from LedgerSMB::DBObject.  Please see that documnetation for details.


\item[{\$payment-$>$get\_open\_accounts()}] \mbox{}

This function returns a list of open accounts depending on the 
\$payment-$>$\{account\_class\} property.  If this property is 1, it returns a list 
of vendor accounts, for 2, a list of customer accounts are returned.



The returned list of hashrefs is stored in the \$payment-$>$\{accounts\} property.
Each hashref has the following keys:  id (entity id), name, and entity\_class.



An account is considered open if there are outstanding, unpaid invoices 
attached to it.  Customer/vendor payment threshold is not considered for this 
calculation.

\end{description}
\begin{description}

\item[{text\_amount(\$value)}] \mbox{}

Returns the textual representation, as defined in localization rules, for the
numeric value passed.

\end{description}
\begin{description}

\item[{get\_metadata()}] \mbox{}

Semi-private method for preparing the object for other tasks, such as displaying
payment options.

\end{description}
\begin{description}

\item[{search()}] \mbox{}

Seturns a series of payments matching the search criteria.



Search results are also stored at \$payment-$>$\{search\_results\}.

\end{description}
\begin{description}

\item[{get\_open\_accounts()}] \mbox{}

Returns a list of open accounts for the payment operation.



These are also stored on \$payment-$>$\{accounts\}

\end{description}
\begin{description}

\item[{\$payment-$>$get\_entity\_credit\_account()}] \mbox{}

Returns billing information for the current account, and saves it to an arrayref
at \$payment-$>$\{entity\_accounts\}/

\end{description}
\begin{description}

\item[{\$payment-$>$get\_all\_accounts()}] \mbox{}

This function returns a list of open or closed accounts depending on the 
\$payment-$>$\{account\_class\} property.  If this property is 1, it returns a list 
of vendor accounts, for 2, a list of customer accounts are returned.



The returned list of hashrefs is stored in the \$payment-$>$\{accounts\} property.
Each hashref has the following keys:  id (entity id), name, and entity\_class.

\end{description}
\$payment-$>$reverse()



This function reverses a payment.  A payment is defined as one source 
(\$payment-$>$\{source\}) to one cash account (\$payment-$>$\{cash\_accno\}) to one date 
(\$payment-$>$\{date\_paid\}) to one vendor/customer (\$payment-$>$\{credit\_id\}, 
\$payment-$>$\{account\_class\}).  This reverses the entries with that source.

\begin{description}

\item[{\$payment-$>$get\_open\_invoices()}] \mbox{}

This function returns a list of open invoices depending on the 
\$payment-$>$\{account\_class\}, \$payment-$>$\{entity\_id\}, and \$payment-$>$\{curr\} 
properties.  Account classes follow the conventions above.  This list is hence
specific to a customer or vendor and currency as well.



The returned list of hashrefs is stored in the \$payment-$>$\{open\_invoices\} 
property. Each hashref has the following keys:  id (entity id), name, and 
entity\_class.

\end{description}
\begin{description}

\item[{\$payment-$>$get\_open\_invoice()}] \mbox{}

This function is an especific case of get\_open\_invoices(), because get\_open\_invoice() 
can search for a specific invoice, which can be searched by the \$payment-$>$\{invnumber\} 
variable

\end{description}
\begin{description}

\item[{\$payment-$>$get\_all\_contact\_invoices()}] \mbox{}

This function returns a list of open accounts depending on the 
\$payment-$>$\{account\_class\} property.  If this property is 1, it returns a list 
of vendor accounts, for 2, a list of customer accounts are returned.  Attached
to each account is a list of open invoices.  The data structure is somewhat 
complex.



Each item in the list has the following keys: contact\_id, contact\_name, $\backslash$
account\_number, total\_due, and invoices.



The invoices entry is a reference to an array of hashrefs.  Each of these 
hashrefs has the following keys: invoice\_id, invnumber, invoice\_date, amount, 
discount, and due.



These are filtered based on the (required) properties:
\$payment-$>$\{account\_class\}, \$payment-$>$\{business\_type\}, \$payment-$>$\{date\_from\},
\$payment-$>$\{date\_to\}, and \$payment-$>$\{ar\_ap\_accno\}.



The \$payment-$>$\{ar\_ap\_accno\} property is used to filter out by AR or AP account.



The following can also be optionally passed: \$payment-$>$\{batch\_id\}.  If this is 
patched, vouchers in the current batch will be picked up as well.



The returned list of hashrefs is stored in the \$payment-$>$\{contact\} property.
Each hashref has the following keys:  id (entity id), name, and entity\_class.

\end{description}
\begin{description}

\item[{list\_open\_projects}] \mbox{}

This method gets the current date attribute, and provides a list of open
projects.  The list is attached to \$self-$>$\{projects\} and returned.

\end{description}
\begin{description}

\item[{list\_departments}] \mbox{}

This method gets the type of document as a parameter, and provides a list of departments
of the required type.
The list is attached to \$self-$>$\{departments\} and returned.

\end{description}
\begin{description}

\item[{list\_open\_vc}] \mbox{}

This method gets the type of vc (vendor or customer) as a parameter, and provides a list of departments
of the required type.
The list is attached to \$self-$>$\{departments\} and returned.

\end{description}
\begin{description}

\item[{get\_open\_currencies}] \mbox{}

This method gets a list of the open currencies inside the database, it requires that  
\$self-$>$\{account\_class\} (must be 1 or 2)  exist to work.



WARNING THIS IS NOT BEING USED BY THE SINGLE PAYMENT SYSTEM....

\end{description}
\begin{description}

\item[{list\_accounting}] \mbox{}

This method lists all accounts that match the role specified in account\_class property and
are available to store the payment or receipts. 
=back
=cut



sub list\_accounting \{
 my (\$self) = @\_;
 @\{\$self-$>$\{pay\_accounts\}\} = \$self-$>$exec\_method( funcname =$>$ 'chart\_list\_cash');
 return @\{\$self-$>$\{pay\_accounts\}\}; 
\}


\item[{list\_overpayment\_accounting}] \mbox{}

This method lists all accounts that match the role specified in account\_class property and
are available to store an overpayment / advanced payment / pre-payment. 
=back
=cut



sub list\_overpayment\_accounting \{
 my (\$self) = @\_;
 @\{\$self-$>$\{overpayment\_accounts\}\} = \$self-$>$exec\_method( funcname =$>$ 'chart\_list\_overpayment');
 return @\{\$self-$>$\{overpayment\_accounts\}\}; 
\}


\item[{get\_sources}] \mbox{}

This method builds all the possible sources of money,
in the future it will look inside the DB. 
=back


\item[{get\_exchange\_rate(currency, date)}] \mbox{}

This method gets the exchange rate for the specified currency and date


\item[{get\_default\_currency}] \mbox{}

This method gets the default currency 
=back


\item[{get\_current\_date}] \mbox{}

This method returns the system's current date


\item[{get\_vc\_info}] \mbox{}

This method returns the contact informatino for a customer or vendor according to
\$self-$>$\{account\_class\}


\item[{get\_payment\_detail\_data}] \mbox{}

This method sets appropriate project, department, etc. fields.


\item[{post\_bulk}] \mbox{}

This function posts the payments in bulk.  Note that queue\_payments is not a 
common setting and rather this provides a hook for an add-on.



This API was developed early in 1.3 and is likely to change for better 
encapsulation.  Currenty it uses the following structure:



Within the main hashref:

\begin{description}

\item[{contact\_count}] \mbox{}

The number of payments.  One per contact.


\item[{contact\_\$row}] \mbox{}

for (1 .. contact\_count), contact\_\$\_ is the entity credit account's id 
associated with the current contact.  We will call this \$contact\_id below.



For each contact id, we have the following, suffixed with \_\$contact\_id:

\begin{description}

\item[{source}] \mbox{}
\item[{invoice\_count}] \mbox{}

Number of invoices to loop through


\item[{invoice\_\$\{contact\_id\}\_\$row}] \mbox{}

for \$row in (1 .. invoice\_count), each this provides the transaction id of the
invoice.

\end{description}


Each invoice has the following attributes, suffxed with 
\$\{invoice\_id\}

\begin{description}

\item[{amount}] \mbox{}
\item[{paid}] \mbox{}
\item[{net}] \mbox{}\end{description}
\end{description}


In the future the payment posting API will become more standardized and the 
conversion between flat and hierarchical representation will be moved to the
workflow scripts.


\item[{check\_job}] \mbox{}

To be moved into payment\_queue addon.


\item[{post\_payment}] \mbox{}

This method uses payment\_post to store a payment (not a bulk payment) on the database.


\item[{gather\_printable\_info}] \mbox{}

This method retrieves all the payment related info needed to build a
document and print it. IT IS NECESSARY TO ALREADY HAVE payment\_id on \$self


\item[{get\_open\_overpayment\_entities}] \mbox{}

This method retrieves all the entities with the specified
account\_class which have unused overpayments


\item[{get\_unused\_overpayments}] \mbox{}

This is a simple wrapper around payment\_get\_unused\_overpayments sql function.


\item[{get\_available\_overpayment\_amount}] \mbox{}

Simple wrapper around payment\_get\_available\_overpayment\_amount sql function.


\item[{init}] \mbox{}

Initializes the num2text system


\item[{num2text}] \mbox{}

Translates numbers into words.

\section{LedgerSMB::DBObject::User\label{LedgerSMB::DBObject::User}\index{LedgerSMB::DBObject::User}}


LedgerSMB User DB Objects

\begin{description}

\item[{LedgerSMB::User-$>$country\_codes();}] \mbox{}

Returns a hash where the keys are registered locales and the values are the
textual representation of the locale name.

\end{description}
\section{LedgerSMB::DBObject::Report::Unapproved::Batch\_Detail\label{LedgerSMB::DBObject::Report::Unapproved::Batch_Detail}\index{LedgerSMB::DBObject::Report::Unapproved::Batch\ Detail}}


List Vouchers by Batch 
in LedgerSMB

\subsection*{SYNPOSIS\label{LedgerSMB::DBObject::Report::Unapproved::Batch_Detail_SYNPOSIS}\index{LedgerSMB::DBObject::Report::Unapproved::Batch Detail!SYNPOSIS}}
\begin{verbatim}
  my $report = LedgerSMB::DBObject::Report::Unapproved::Batch_Detail->new(
      %$request
  );
  $report->run;
  $report->render($request, $format);
\end{verbatim}
\subsection*{DESCRIPTION\label{LedgerSMB::DBObject::Report::Unapproved::Batch_Detail_DESCRIPTION}\index{LedgerSMB::DBObject::Report::Unapproved::Batch Detail!DESCRIPTION}}


This provides an ability to search for (and approve or delete) pending
transactions grouped in batches.  This report only handles the vouchers in the 
bach themselves. For searching for batches, use
LedgerSMB::DBObject::Report::Unapproved::Batch\_Overview instead.

\subsection*{INHERITS\label{LedgerSMB::DBObject::Report::Unapproved::Batch_Detail_INHERITS}\index{LedgerSMB::DBObject::Report::Unapproved::Batch Detail!INHERITS}}
\begin{description}

\item[{LedgerSMB::DBObject::Report;}] \mbox{}\end{description}
\subsection*{PROPERTIES\label{LedgerSMB::DBObject::Report::Unapproved::Batch_Detail_PROPERTIES}\index{LedgerSMB::DBObject::Report::Unapproved::Batch Detail!PROPERTIES}}
\begin{description}

\item[{columns}] \mbox{}

Read-only accessor, returns a list of columns.

\begin{description}

\item[{select}] \mbox{}

Select boxes for selecting the returned items.


\item[{id}] \mbox{}

ID of transaction


\item[{batch\_class}] \mbox{}

Text description of batch class


\item[{transdate}] \mbox{}

Post date of transaction
use LedgerSMB::DBObject::Report::Unapproved::Batch\_Overview;


\item[{reference text}] \mbox{}

Invoice number or GL reference


\item[{description}] \mbox{}

Description of transaction


\item[{amount}] \mbox{}

Total on voucher.  For AR/AP amount, this is the total of the AR/AP account 
before payments.  For payments, receipts, and GL, it is the sum of the credits.

\end{description}

\item[{name}] \mbox{}

Returns the localized template name


\item[{header\_lines}] \mbox{}

Returns the inputs to display on header.


\item[{subtotal\_cols}] \mbox{}

Returns list of columns for subtotals

\end{description}
\subsubsection*{Criteria Properties\label{LedgerSMB::DBObject::Report::Unapproved::Batch_Detail_Criteria_Properties}\index{LedgerSMB::DBObject::Report::Unapproved::Batch Detail!Criteria Properties}}


Note that in all cases, undef matches everything.

\begin{description}

\item[{batch\_id (Int)}] \mbox{}

ID of batch to list vouchers of.

\end{description}
\subsection*{METHODS\label{LedgerSMB::DBObject::Report::Unapproved::Batch_Detail_METHODS}\index{LedgerSMB::DBObject::Report::Unapproved::Batch Detail!METHODS}}
\begin{description}

\item[{run\_report()}] \mbox{}

Runs the report, and assigns rows to \$self-$>$rows.

\end{description}
\subsection*{COPYRIGHT\label{LedgerSMB::DBObject::Report::Unapproved::Batch_Detail_COPYRIGHT}\index{LedgerSMB::DBObject::Report::Unapproved::Batch Detail!COPYRIGHT}}


COPYRIGHT (C) 2012 The LedgerSMB Core Team.  This file may be re-used following
the terms of the GNU General Public License version 2 or at your option any
later version.  Please see included LICENSE.TXT for details.

\section{LedgerSMB::DBObject::Report::Unapproved::Batch\_Overview\label{LedgerSMB::DBObject::Report::Unapproved::Batch_Overview}\index{LedgerSMB::DBObject::Report::Unapproved::Batch\ Overview}}


Search Batches in 
LedgerSMB

\subsection*{SYNPOSIS\label{LedgerSMB::DBObject::Report::Unapproved::Batch_Overview_SYNPOSIS}\index{LedgerSMB::DBObject::Report::Unapproved::Batch Overview!SYNPOSIS}}
\begin{verbatim}
  my $report = LedgerSMB::DBObject::Report::Unapproved::Batch_Overview->new(%$request);
  $report->run;
  $report->render($request, $format);
\end{verbatim}
\subsection*{DESCRIPTION\label{LedgerSMB::DBObject::Report::Unapproved::Batch_Overview_DESCRIPTION}\index{LedgerSMB::DBObject::Report::Unapproved::Batch Overview!DESCRIPTION}}


This provides an ability to search for (and approve or delete) pending
transactions grouped in batches.  This report only handles the batches 
themselves.  You cannot delete individual vouchers in this report.  For that,
use LedgerSMB::DBObject::Report::Unapproved::Batch\_Detail instead.

\subsection*{INHERITS\label{LedgerSMB::DBObject::Report::Unapproved::Batch_Overview_INHERITS}\index{LedgerSMB::DBObject::Report::Unapproved::Batch Overview!INHERITS}}
\begin{description}

\item[{LedgerSMB::DBObject::Report;}] \mbox{}\end{description}
\subsection*{PROPERTIES\label{LedgerSMB::DBObject::Report::Unapproved::Batch_Overview_PROPERTIES}\index{LedgerSMB::DBObject::Report::Unapproved::Batch Overview!PROPERTIES}}
\begin{description}

\item[{columns}] \mbox{}

Read-only accessor, returns a list of columns.

\begin{description}

\item[{select}] \mbox{}

Select boxes for selecting the returned items.


\item[{id}] \mbox{}

ID of transaction


\item[{post\_date}] \mbox{}

Post date of transaction


\item[{reference text}] \mbox{}

Invoice number or GL reference


\item[{description}] \mbox{}

Description of transaction


\item[{transaction\_total}] \mbox{}

Total of AR/AP/GL vouchers (GL vouchers credit side only is counted)


\item[{payment\_total}] \mbox{}

Total of payment lines (credit side)



Amount

\end{description}

\item[{name}] \mbox{}

Returns the localized template name


\item[{header\_lines}] \mbox{}

Returns the inputs to display on header.


\item[{subtotal\_cols}] \mbox{}

Returns list of columns for subtotals

\end{description}
\subsubsection*{Criteria Properties\label{LedgerSMB::DBObject::Report::Unapproved::Batch_Overview_Criteria_Properties}\index{LedgerSMB::DBObject::Report::Unapproved::Batch Overview!Criteria Properties}}


Note that in all cases, undef matches everything.

\begin{description}

\item[{reference (text)}] \mbox{}

Exact match on reference or invoice number.


\item[{type}] \mbox{}

ar for AR drafts, ap for AP drafts, gl for GL ones.


\item[{amount\_gt}] \mbox{}

The amount of the draft must be greater than this for it to show up.


\item[{amount\_lt}] \mbox{}

The amount of the draft must be less than this for it to show up.

\end{description}
\subsection*{METHODS\label{LedgerSMB::DBObject::Report::Unapproved::Batch_Overview_METHODS}\index{LedgerSMB::DBObject::Report::Unapproved::Batch Overview!METHODS}}
\begin{description}

\item[{prepare\_criteria(\$request)}] \mbox{}

Instantiates the PGDate and PGNumber inputs.


\item[{run\_report()}] \mbox{}

Runs the report, and assigns rows to \$self-$>$rows.

\end{description}
\subsection*{COPYRIGHT\label{LedgerSMB::DBObject::Report::Unapproved::Batch_Overview_COPYRIGHT}\index{LedgerSMB::DBObject::Report::Unapproved::Batch Overview!COPYRIGHT}}


COPYRIGHT (C) 2012 The LedgerSMB Core Team.  This file may be re-used following
the terms of the GNU General Public License version 2 or at your option any
later version.  Please see included LICENSE.TXT for details.

\section{LedgerSMB::DBObject::Report::Unapproved::Drafts\label{LedgerSMB::DBObject::Report::Unapproved::Drafts}\index{LedgerSMB::DBObject::Report::Unapproved::Drafts}}


Unapproved Drafts (single 
transactions) in LedgerSMB

\subsection*{SYNPOSIS\label{LedgerSMB::DBObject::Report::Unapproved::Drafts_SYNPOSIS}\index{LedgerSMB::DBObject::Report::Unapproved::Drafts!SYNPOSIS}}
\begin{verbatim}
  my $report = LedgerSMB::DBObject::Report::Unapproved::Drafts->new(%$request);
  $report->run;
  $report->render($request, $format);
\end{verbatim}
\subsection*{DESCRIPTION\label{LedgerSMB::DBObject::Report::Unapproved::Drafts_DESCRIPTION}\index{LedgerSMB::DBObject::Report::Unapproved::Drafts!DESCRIPTION}}


This provides an ability to search for (and approve or delete) pending
transactions.

\subsection*{INHERITS\label{LedgerSMB::DBObject::Report::Unapproved::Drafts_INHERITS}\index{LedgerSMB::DBObject::Report::Unapproved::Drafts!INHERITS}}
\begin{description}

\item[{LedgerSMB::DBObject::Report;}] \mbox{}\end{description}
\subsection*{PROPERTIES\label{LedgerSMB::DBObject::Report::Unapproved::Drafts_PROPERTIES}\index{LedgerSMB::DBObject::Report::Unapproved::Drafts!PROPERTIES}}
\begin{description}

\item[{columns}] \mbox{}

Read-only accessor, returns a list of columns.

\begin{description}

\item[{select}] \mbox{}

Select boxes for selecting the returned items.


\item[{id}] \mbox{}

ID of transaction


\item[{transdate}] \mbox{}

Post date of transaction


\item[{reference text}] \mbox{}

Invoice number or GL reference


\item[{description}] \mbox{}

Description of transaction


\item[{amount}] \mbox{}

Amount

\end{description}

\item[{name}] \mbox{}

Returns the localized template name


\item[{header\_lines}] \mbox{}

Returns the inputs to display on header.


\item[{subtotal\_cols}] \mbox{}

Returns list of columns for subtotals

\end{description}
\subsubsection*{Criteria Properties\label{LedgerSMB::DBObject::Report::Unapproved::Drafts_Criteria_Properties}\index{LedgerSMB::DBObject::Report::Unapproved::Drafts!Criteria Properties}}


Note that in all cases, undef matches everything.

\begin{description}

\item[{reference (text)}] \mbox{}

Exact match on reference or invoice number.


\item[{type}] \mbox{}

ar for AR drafts, ap for AP drafts, gl for GL ones.


\item[{amount\_gt}] \mbox{}

The amount of the draft must be greater than this for it to show up.


\item[{amount\_lt}] \mbox{}

The amount of the draft must be less than this for it to show up.

\end{description}
\subsection*{METHODS\label{LedgerSMB::DBObject::Report::Unapproved::Drafts_METHODS}\index{LedgerSMB::DBObject::Report::Unapproved::Drafts!METHODS}}
\begin{description}

\item[{prepare\_criteria(\$request)}] \mbox{}

Instantiates the PGDate and PGNumber inputs.


\item[{run\_report()}] \mbox{}

Runs the report, and assigns rows to \$self-$>$rows.

\end{description}
\subsection*{COPYRIGHT\label{LedgerSMB::DBObject::Report::Unapproved::Drafts_COPYRIGHT}\index{LedgerSMB::DBObject::Report::Unapproved::Drafts!COPYRIGHT}}


COPYRIGHT (C) 2012 The LedgerSMB Core Team.  This file may be re-used following
the terms of the GNU General Public License version 2 or at your option any
later version.  Please see included LICENSE.TXT for details.

\section{LedgerSMB::DBObject::Report::Aging\label{LedgerSMB::DBObject::Report::Aging}\index{LedgerSMB::DBObject::Report::Aging}}


AR/AP Aging reports for LedgerSMB

\subsection*{SYNPOSIS\label{LedgerSMB::DBObject::Report::Aging_SYNPOSIS}\index{LedgerSMB::DBObject::Report::Aging!SYNPOSIS}}
\begin{verbatim}
  my $agereport = LedgerSMB::DBObject::Report::Aging->new(%$request);
  $agereport->run;
  $agereport->render($request, $format);
\end{verbatim}
\subsection*{DESCRIPTION\label{LedgerSMB::DBObject::Report::Aging_DESCRIPTION}\index{LedgerSMB::DBObject::Report::Aging!DESCRIPTION}}


This module provides reports that show how far overdue payments for invoices
are.  This can be useful to help better manage collection of moneys owed, etc.



This module is also capable of printing statements, which are basically aging
reportins aimed at the customer in question.

\subsection*{INHERITS\label{LedgerSMB::DBObject::Report::Aging_INHERITS}\index{LedgerSMB::DBObject::Report::Aging!INHERITS}}
\begin{description}

\item[{LedgerSMB::DBObject::Report;}] \mbox{}\end{description}
\subsection*{PROPERTIES\label{LedgerSMB::DBObject::Report::Aging_PROPERTIES}\index{LedgerSMB::DBObject::Report::Aging!PROPERTIES}}
\begin{description}

\item[{columns}] \mbox{}

Read-only accessor, returns a list of columns.

\begin{description}

\item[{select}] \mbox{}
\item[{credit\_account}] \mbox{}
\item[{language}] \mbox{}
\item[{invnumber}] \mbox{}
\item[{order}] \mbox{}
\item[{transdate}] \mbox{}
\item[{duedate}] \mbox{}
\item[{c0}] \mbox{}
\item[{c30}] \mbox{}
\item[{c60}] \mbox{}
\item[{c90}] \mbox{}
\item[{total}] \mbox{}
\item[{one for each business unit class returned}] \mbox{}\end{description}

\item[{filter\_template}] \mbox{}

Returns the template name for the filter.


\item[{name}] \mbox{}

Returns the localized template name


\item[{template}] \mbox{}

Returns the name of the template to use


\item[{header\_lines}] \mbox{}

Returns the inputs to display on header.

\end{description}
\subsubsection*{Criteria Properties\label{LedgerSMB::DBObject::Report::Aging_Criteria_Properties}\index{LedgerSMB::DBObject::Report::Aging!Criteria Properties}}


Note that in all cases, undef matches everything.

\begin{description}

\item[{report\_type}] \mbox{}

Is 'summary' or 'detail'


\item[{accno}] \mbox{}

Exact match for the account number for the AR/AP account


\item[{to\_date}] \mbox{}

Calculate report as on a specific date


\item[{entity\_class}] \mbox{}

1 for vendor, 2 for customer

\end{description}
\subsection*{METHODS\label{LedgerSMB::DBObject::Report::Aging_METHODS}\index{LedgerSMB::DBObject::Report::Aging!METHODS}}
\begin{description}

\item[{prepare\_criteria(\$request)}] \mbox{}

Instantiates the PGDate and PGNumber inputs.


\item[{run\_report()}] \mbox{}

Runs the report, and assigns rows to \$self-$>$rows.

\end{description}
\subsection*{COPYRIGHT\label{LedgerSMB::DBObject::Report::Aging_COPYRIGHT}\index{LedgerSMB::DBObject::Report::Aging!COPYRIGHT}}


COPYRIGHT (C) 2012 The LedgerSMB Core Team.  This file may be re-used following
the terms of the GNU General Public License version 2 or at your option any
later version.  Please see included LICENSE.TXT for details.

\section{LedgerSMB::DBObject::Report::co::Balance\_y\_Mayor\label{LedgerSMB::DBObject::Report::co::Balance_y_Mayor}\index{LedgerSMB::DBObject::Report::co::Balance\ y\ Mayor}}


Colombian Balance/Ledger Rpt

\subsection*{SYNPOSIS\label{LedgerSMB::DBObject::Report::co::Balance_y_Mayor_SYNPOSIS}\index{LedgerSMB::DBObject::Report::co::Balance y Mayor!SYNPOSIS}}
\begin{verbatim}
  my $bmreport = LedgerSMB::DBObject::Report::co::Balance_y_Mayor->new(%$request);
  $bmreport->run;
  $bmreport->render($request, $format);
\end{verbatim}
\subsection*{DESCRIPTION\label{LedgerSMB::DBObject::Report::co::Balance_y_Mayor_DESCRIPTION}\index{LedgerSMB::DBObject::Report::co::Balance y Mayor!DESCRIPTION}}


This module provides Balance y Mayor reports for LedgerSMB to Colombian 
standards. This report shows total activity over a time period.

\subsection*{INHERITS\label{LedgerSMB::DBObject::Report::co::Balance_y_Mayor_INHERITS}\index{LedgerSMB::DBObject::Report::co::Balance y Mayor!INHERITS}}
\begin{description}

\item[{LedgerSMB::DBObject::Report;}] \mbox{}\end{description}
\subsection*{PROPERTIES\label{LedgerSMB::DBObject::Report::co::Balance_y_Mayor_PROPERTIES}\index{LedgerSMB::DBObject::Report::co::Balance y Mayor!PROPERTIES}}
\begin{description}

\item[{columns}] \mbox{}

Read-only accessor, returns a list of columns.

\begin{description}

\item[{accno}] \mbox{}

Account Number


\item[{description}] \mbox{}

Account name


\item[{document\_type}] \mbox{}
\item[{debits}] \mbox{}
\item[{credits}] \mbox{}\end{description}

\item[{filter\_template}] \mbox{}

Returns the template name for the filter.


\item[{name}] \mbox{}

Returns the localized template name


\item[{header\_lines}] \mbox{}

Returns the inputs to display on header.

\end{description}
\subsubsection*{Criteria Properties\label{LedgerSMB::DBObject::Report::co::Balance_y_Mayor_Criteria_Properties}\index{LedgerSMB::DBObject::Report::co::Balance y Mayor!Criteria Properties}}


Note that in all cases, undef matches everything.

\begin{description}

\item[{date\_from (text)}] \mbox{}

start date for the report


\item[{date\_to}] \mbox{}

End date for the report

\end{description}
\subsection*{METHODS\label{LedgerSMB::DBObject::Report::co::Balance_y_Mayor_METHODS}\index{LedgerSMB::DBObject::Report::co::Balance y Mayor!METHODS}}
\begin{description}

\item[{prepare\_criteria(\$request)}] \mbox{}

Instantiates the PGDate and PGNumber inputs.


\item[{run\_report()}] \mbox{}

Runs the report, and assigns rows to \$self-$>$rows.

\end{description}
\subsection*{COPYRIGHT\label{LedgerSMB::DBObject::Report::co::Balance_y_Mayor_COPYRIGHT}\index{LedgerSMB::DBObject::Report::co::Balance y Mayor!COPYRIGHT}}


COPYRIGHT (C) 2012 The LedgerSMB Core Team.  This file may be re-used following
the terms of the GNU General Public License version 2 or at your option any
later version.  Please see included LICENSE.TXT for details.

\section{LedgerSMB::DBObject::Report::co::Caja\_Diaria\label{LedgerSMB::DBObject::Report::co::Caja_Diaria}\index{LedgerSMB::DBObject::Report::co::Caja\ Diaria}}


Caja Diaria Reports (Colombia)

\subsection*{SYNPOSIS\label{LedgerSMB::DBObject::Report::co::Caja_Diaria_SYNPOSIS}\index{LedgerSMB::DBObject::Report::co::Caja Diaria!SYNPOSIS}}
\begin{verbatim}
  my $cdreport = LedgerSMB::DBObject::Report::co::Caja_Diaria->new(%$request);
  $cdreport->run;
  $cdreport->render($request, $format);
\end{verbatim}
\subsection*{DESCRIPTION\label{LedgerSMB::DBObject::Report::co::Caja_Diaria_DESCRIPTION}\index{LedgerSMB::DBObject::Report::co::Caja Diaria!DESCRIPTION}}


This module provides Caja Diaria eports for LedgerSMB to Colombian standards.
These reports provide an overview of cash activity to a set of accounts for a
specific period.

\subsection*{INHERITS\label{LedgerSMB::DBObject::Report::co::Caja_Diaria_INHERITS}\index{LedgerSMB::DBObject::Report::co::Caja Diaria!INHERITS}}
\begin{description}

\item[{LedgerSMB::DBObject::Report;}] \mbox{}\end{description}
\subsection*{PROPERTIES\label{LedgerSMB::DBObject::Report::co::Caja_Diaria_PROPERTIES}\index{LedgerSMB::DBObject::Report::co::Caja Diaria!PROPERTIES}}
\begin{description}

\item[{columns}] \mbox{}

Read-only accessor, returns a list of columns.

\begin{description}

\item[{accno}] \mbox{}

Account Number


\item[{description}] \mbox{}

Account name


\item[{document\_type}] \mbox{}
\item[{debits}] \mbox{}
\item[{credits}] \mbox{}\end{description}

\item[{filter\_template}] \mbox{}

Returns the template name for the filter.


\item[{name}] \mbox{}

Returns the localized template name


\item[{header\_lines}] \mbox{}

Returns the inputs to display on header.

\end{description}
\subsubsection*{Criteria Properties\label{LedgerSMB::DBObject::Report::co::Caja_Diaria_Criteria_Properties}\index{LedgerSMB::DBObject::Report::co::Caja Diaria!Criteria Properties}}


Note that in all cases, undef matches everything.

\begin{description}

\item[{date\_from (text)}] \mbox{}

start date for the report


\item[{date\_to}] \mbox{}

End date for the report


\item[{from\_accno}] \mbox{}
\item[{to\_accno}] \mbox{}\end{description}
\subsection*{METHODS\label{LedgerSMB::DBObject::Report::co::Caja_Diaria_METHODS}\index{LedgerSMB::DBObject::Report::co::Caja Diaria!METHODS}}
\begin{description}

\item[{prepare\_criteria(\$request)}] \mbox{}

Instantiates the PGDate and PGNumber inputs.


\item[{run\_report()}] \mbox{}

Runs the report, and assigns rows to \$self-$>$rows.

\end{description}
\subsection*{COPYRIGHT\label{LedgerSMB::DBObject::Report::co::Caja_Diaria_COPYRIGHT}\index{LedgerSMB::DBObject::Report::co::Caja Diaria!COPYRIGHT}}


COPYRIGHT (C) 2012 The LedgerSMB Core Team.  This file may be re-used following
the terms of the GNU General Public License version 2 or at your option any
later version.  Please see included LICENSE.TXT for details.

\section{LedgerSMB::DBObject::Reports::Budget::Search\label{LedgerSMB::DBObject::Reports::Budget::Search}\index{LedgerSMB::DBObject::Reports::Budget::Search}}


Search for Budgets

\subsection*{SYNPOSIS\label{LedgerSMB::DBObject::Reports::Budget::Search_SYNPOSIS}\index{LedgerSMB::DBObject::Reports::Budget::Search!SYNPOSIS}}
\begin{verbatim}
  my $report = LedgerSMB::DBObject::Report::Budget::Search->new(%$request);
  $report->run;
  $report->render($request, $format);
\end{verbatim}
\subsection*{DESCRIPTION\label{LedgerSMB::DBObject::Reports::Budget::Search_DESCRIPTION}\index{LedgerSMB::DBObject::Reports::Budget::Search!DESCRIPTION}}


This is a basic search report for budgets.

\subsection*{PROPERTIES\label{LedgerSMB::DBObject::Reports::Budget::Search_PROPERTIES}\index{LedgerSMB::DBObject::Reports::Budget::Search!PROPERTIES}}
\begin{description}

\item[{columns}] \mbox{}

Read only accessor.  This provides the columns for the report

\begin{description}

\item[{start\_date}] \mbox{}

Start date of the budget


\item[{end\_date}] \mbox{}

End date of the budget


\item[{reference}] \mbox{}

Reference/control code of the budget


\item[{description}] \mbox{}

Budget description


\item[{entered\_by\_name}] \mbox{}

Who entered the budget


\item[{approved\_by\_name}] \mbox{}

Who approved the budget


\item[{obsolete\_by\_name}] \mbox{}

Who marked the budget obsolete

\end{description}

\item[{name}] \mbox{}

Returns the localized name of the template


\item[{header\_lines}] \mbox{}

Returns the inputs to display on header.

\end{description}
\subsection*{CRITERIA PROPERTIES\label{LedgerSMB::DBObject::Reports::Budget::Search_CRITERIA_PROPERTIES}\index{LedgerSMB::DBObject::Reports::Budget::Search!CRITERIA PROPERTIES}}
\begin{description}

\item[{reference}] \mbox{}

Matches the beginning of the reference of the budget


\item[{description}] \mbox{}

Matched using full text rules against the description


\item[{start\_date}] \mbox{}

Exact match for the start date


\item[{end\_date}] \mbox{}

Exact match for end date.


\item[{buisness\_units}] \mbox{}

This returns all budgets matching all business units listed here.

\end{description}
\subsection*{METHODS\label{LedgerSMB::DBObject::Reports::Budget::Search_METHODS}\index{LedgerSMB::DBObject::Reports::Budget::Search!METHODS}}
\begin{description}

\item[{prepare\_criteria}] \mbox{}

Creates criteria from web input to types expected


\item[{run\_report}] \mbox{}

Runs the report

\end{description}
\subsection*{COPYRIGHT AND LICENSE\label{LedgerSMB::DBObject::Reports::Budget::Search_COPYRIGHT_AND_LICENSE}\index{LedgerSMB::DBObject::Reports::Budget::Search!COPYRIGHT AND LICENSE}}


Copyright (C) 2011 LedgerSMB Core Team.  This file is licensed under the GNU 
General Public License version 2, or at your option any later version.  Please
see the included License.txt for details.

\section{LedgerSMB::DBObject::Report::Budget::Variance\label{LedgerSMB::DBObject::Report::Budget::Variance}\index{LedgerSMB::DBObject::Report::Budget::Variance}}


Variance Report per Budget

\subsection*{SYNPOSIS\label{LedgerSMB::DBObject::Report::Budget::Variance_SYNPOSIS}\index{LedgerSMB::DBObject::Report::Budget::Variance!SYNPOSIS}}
\begin{verbatim}
  my $report = LedgerSMB::DBObject::Report::Budget::Variance->new(%$request);
  $report->run;
  $report->render($request, $format);
\end{verbatim}
\subsection*{DESCRIPTION\label{LedgerSMB::DBObject::Report::Budget::Variance_DESCRIPTION}\index{LedgerSMB::DBObject::Report::Budget::Variance!DESCRIPTION}}


This is a basic variance report for budgets.  A variance report shows budgetted
debits and credits along with those actually accrued during the stated period.
It thus provides a way of measuring both current and historical expenditures
against what was budgetted.

\subsection*{PROPERTIES\label{LedgerSMB::DBObject::Report::Budget::Variance_PROPERTIES}\index{LedgerSMB::DBObject::Report::Budget::Variance!PROPERTIES}}
\begin{description}

\item[{columns}] \mbox{}

Read only accessor.  This provides the columns for the report

\begin{description}

\item[{budget\_description}] \mbox{}

Description of he budget line item


\item[{accno}] \mbox{}

Account number budgetted


\item[{account\_label}] \mbox{}

Account name


\item[{budget\_amount}] \mbox{}

Amount (normalized left or right) budgetted


\item[{used\_amount}] \mbox{}

Amount (normalized left or right) used


\item[{variance}] \mbox{}

Difference between budgetted and used.

\end{description}

\item[{name}] \mbox{}

Returns name of report


\item[{header\_lines}] \mbox{}

Returns the inputs to display on header.

\end{description}
\subsection*{CRITERIA PROPERTIES\label{LedgerSMB::DBObject::Report::Budget::Variance_CRITERIA_PROPERTIES}\index{LedgerSMB::DBObject::Report::Budget::Variance!CRITERIA PROPERTIES}}
\begin{description}

\item[{id}] \mbox{}

Budget id for variance report.  This is the only search criteria currently 
supported.

\end{description}
\subsection*{HEADER PROPERTIES\label{LedgerSMB::DBObject::Report::Budget::Variance_HEADER_PROPERTIES}\index{LedgerSMB::DBObject::Report::Budget::Variance!HEADER PROPERTIES}}


These are used to generate the header as displayed and are typically pulled in 
from a budget object.

\begin{description}

\item[{reference}] \mbox{}
\item[{description}] \mbox{}
\item[{start\_date}] \mbox{}
\item[{end\_date}] \mbox{}\end{description}
\subsection*{METHODS\label{LedgerSMB::DBObject::Report::Budget::Variance_METHODS}\index{LedgerSMB::DBObject::Report::Budget::Variance!METHODS}}
\begin{description}

\item[{for\_budget\_id}] \mbox{}

Retrieves budget info and creates variance report object for it.


\item[{run\_report}] \mbox{}

Runs the report, setting rows for rendering.

\end{description}
\subsection*{COPYRIGHT AND LICENSE\label{LedgerSMB::DBObject::Report::Budget::Variance_COPYRIGHT_AND_LICENSE}\index{LedgerSMB::DBObject::Report::Budget::Variance!COPYRIGHT AND LICENSE}}


Copyright (C) 2012 LedgerSMB Core Team.  This file is licensed under the GNU 
General Public License version 2, or at your option any later version.  Please
see the included License.txt for details.

\section{LedgerSMB::DBObject::Report::GL\label{LedgerSMB::DBObject::Report::GL}\index{LedgerSMB::DBObject::Report::GL}}


GL Reports for LedgerSMB

\subsection*{SYNPOSIS\label{LedgerSMB::DBObject::Report::GL_SYNPOSIS}\index{LedgerSMB::DBObject::Report::GL!SYNPOSIS}}
\begin{verbatim}
  my $glreport = LedgerSMB::DBObject::Report::GL->new(%$request);
  $glreport->run;
  $glreport->render($request, $format);
\end{verbatim}
\subsection*{DESCRIPTION\label{LedgerSMB::DBObject::Report::GL_DESCRIPTION}\index{LedgerSMB::DBObject::Report::GL!DESCRIPTION}}


This module provides GL reports for LedgerSMB.  GL reports are useful for 
searching for and reporting financial transactions.

\subsection*{INHERITS\label{LedgerSMB::DBObject::Report::GL_INHERITS}\index{LedgerSMB::DBObject::Report::GL!INHERITS}}
\begin{description}

\item[{LedgerSMB::DBObject::Report;}] \mbox{}\end{description}
\subsection*{PROPERTIES\label{LedgerSMB::DBObject::Report::GL_PROPERTIES}\index{LedgerSMB::DBObject::Report::GL!PROPERTIES}}
\begin{description}

\item[{columns}] \mbox{}

Read-only accessor, returns a list of columns.

\begin{description}

\item[{id}] \mbox{}
\item[{reference}] \mbox{}
\item[{description}] \mbox{}
\item[{transdate}] \mbox{}
\item[{source}] \mbox{}
\item[{memo}] \mbox{}
\item[{debits}] \mbox{}
\item[{credits}] \mbox{}
\item[{entry\_id}] \mbox{}
\item[{cleared}] \mbox{}
\item[{chart\_id}] \mbox{}
\item[{accno}] \mbox{}
\item[{gifi\_accno}] \mbox{}
\item[{running\_balance}] \mbox{}
\item[{one for each business unit class returned}] \mbox{}\end{description}

\item[{filter\_template}] \mbox{}

Returns the template name for the filter.


\item[{name}] \mbox{}

Returns the localized template name


\item[{header\_lines}] \mbox{}

Returns the inputs to display on header.


\item[{subtotal\_cols}] \mbox{}

Returns list of columns for subtotals

\end{description}
\subsubsection*{Criteria Properties\label{LedgerSMB::DBObject::Report::GL_Criteria_Properties}\index{LedgerSMB::DBObject::Report::GL!Criteria Properties}}


Note that in all cases, undef matches everything.

\begin{description}

\item[{reference (text)}] \mbox{}

Exact match on reference or invoice number.


\item[{accno}] \mbox{}

Exact match for the account number


\item[{category}] \mbox{}

Is one of A (Asset), L (Liability), Q (Equity), I (Income), or E (Expense).



When set only matches lines attached to transactions of specfied type.


\item[{source}] \mbox{}

Exact match of source field


\item[{memo}] \mbox{}

Full text search of memo field


\item[{description}] \mbox{}

Full text search of description field of GL transaction


\item[{from\_date}] \mbox{}

Earliest date which matches the search


\item[{to\_date}] \mbox{}

Last date that matches the search


\item[{approved}] \mbox{}

Unless false, only matches approved transactions.  When false, matches all 
transactions.  This is the one exception to the general rule that undef matches
all.


\item[{amount\_from}] \mbox{}

The lowest value that can match, amount-wise.


\item[{amount\_to}] \mbox{}

The highest value that can match, amount-wise.


\item[{business\_units}] \mbox{}

Array of business unit id's

\end{description}
\subsection*{METHODS\label{LedgerSMB::DBObject::Report::GL_METHODS}\index{LedgerSMB::DBObject::Report::GL!METHODS}}
\begin{description}

\item[{prepare\_criteria(\$request)}] \mbox{}

Instantiates the PGDate and PGNumber inputs.


\item[{run\_report()}] \mbox{}

Runs the report, and assigns rows to \$self-$>$rows.

\end{description}
\subsection*{COPYRIGHT\label{LedgerSMB::DBObject::Report::GL_COPYRIGHT}\index{LedgerSMB::DBObject::Report::GL!COPYRIGHT}}


COPYRIGHT (C) 2012 The LedgerSMB Core Team.  This file may be re-used following
the terms of the GNU General Public License version 2 or at your option any
later version.  Please see included LICENSE.TXT for details.

\section{LedgerSMB::DBObject::Report::COA\label{LedgerSMB::DBObject::Report::COA}\index{LedgerSMB::DBObject::Report::COA}}


Chart of Accounts List for LedgerSMB

\subsection*{SYNPOSIS\label{LedgerSMB::DBObject::Report::COA_SYNPOSIS}\index{LedgerSMB::DBObject::Report::COA!SYNPOSIS}}
\begin{verbatim}
  my $report = LedgerSMB::DBObject::Report::COA->new(%$request);
  $report->run;
  $report->render($request, $format);
\end{verbatim}
\subsection*{DESCRIPTION\label{LedgerSMB::DBObject::Report::COA_DESCRIPTION}\index{LedgerSMB::DBObject::Report::COA!DESCRIPTION}}


This module provides a Chart of Account report for LedgerSMB.  This account is
useful regarding checking on current balances and managing the accounts.
Typically columns are displayed based on the permissions of the user.

\subsection*{INHERITS\label{LedgerSMB::DBObject::Report::COA_INHERITS}\index{LedgerSMB::DBObject::Report::COA!INHERITS}}
\begin{description}

\item[{LedgerSMB::DBObject::Report;}] \mbox{}\end{description}
\subsection*{PROPERTIES\label{LedgerSMB::DBObject::Report::COA_PROPERTIES}\index{LedgerSMB::DBObject::Report::COA!PROPERTIES}}
\begin{description}

\item[{columns}] \mbox{}

Read-only accessor, returns a list of columns.  Unless otherwise noted, each
column is intended to be visible to all who have permissions to run the report.

\begin{description}

\item[{accno}] \mbox{}

Displays the account number.


\item[{description}] \mbox{}

Account description.


\item[{gifi\_accno}] \mbox{}

This is the GIFI account number.


\item[{debit\_balance}] \mbox{}

This is the debit balance (or blank if none or balance is credit).


\item[{credit\_balance}] \mbox{}

This is the credit balance (or blank if none or balance is debit)


\item[{link}] \mbox{}

This lists the link descriptions.  Each represents a group of drop-downs the
user has access to.  This should be visible only to admin users.


\item[{edit}] \mbox{}

Link to edit the account.  Should be visible only to admin users.


\item[{delete}] \mbox{}

Link to delete the account if it has no transactions.  Should be visible only to
admin users.

\end{description}

\item[{name}] \mbox{}

Returns the localized template name


\item[{header\_lines}] \mbox{}

Returns the inputs to display on header.


\item[{subtotal\_cols}] \mbox{}

Returns list of columns for subtotals

\end{description}
\subsubsection*{Criteria Properties\label{LedgerSMB::DBObject::Report::COA_Criteria_Properties}\index{LedgerSMB::DBObject::Report::COA!Criteria Properties}}


No criteria required.

\subsection*{METHODS\label{LedgerSMB::DBObject::Report::COA_METHODS}\index{LedgerSMB::DBObject::Report::COA!METHODS}}
\begin{description}

\item[{run\_report()}] \mbox{}

Runs the report, and assigns rows to \$self-$>$rows.

\end{description}
\subsection*{COPYRIGHT\label{LedgerSMB::DBObject::Report::COA_COPYRIGHT}\index{LedgerSMB::DBObject::Report::COA!COPYRIGHT}}


COPYRIGHT (C) 2012 The LedgerSMB Core Team.  This file may be re-used following
the terms of the GNU General Public License version 2 or at your option any
later version.  Please see included LICENSE.TXT for details.

\section{LedgerSMB::DBObject::Report::Contact::Search\label{LedgerSMB::DBObject::Report::Contact::Search}\index{LedgerSMB::DBObject::Report::Contact::Search}}


Search for Customers, Vendors,
and more.

\subsection*{SYNPOSIS\label{LedgerSMB::DBObject::Report::Contact::Search_SYNPOSIS}\index{LedgerSMB::DBObject::Report::Contact::Search!SYNPOSIS}}
\begin{verbatim}
  my $report = LedgerSMB::DBObject::Report::GL->new(%$request);
  $report->run;
  $report->render($request, $format);
\end{verbatim}
\subsection*{DESCRIPTION\label{LedgerSMB::DBObject::Report::Contact::Search_DESCRIPTION}\index{LedgerSMB::DBObject::Report::Contact::Search!DESCRIPTION}}


This report provides contact search facilities.  It can be used to search for
any sort of company or person, whether sales lead, vendor, customer, or
referral.

\subsection*{INHERITS\label{LedgerSMB::DBObject::Report::Contact::Search_INHERITS}\index{LedgerSMB::DBObject::Report::Contact::Search!INHERITS}}
\begin{description}

\item[{LedgerSMB::DBObject::Report;}] \mbox{}\end{description}
\subsection*{PROPERTIES\label{LedgerSMB::DBObject::Report::Contact::Search_PROPERTIES}\index{LedgerSMB::DBObject::Report::Contact::Search!PROPERTIES}}
\begin{description}

\item[{columns}] \mbox{}

Read-only accessor, returns a list of columns.


\item[{name}] \mbox{}
\item[{header\_lines}] \mbox{}\end{description}
\subsection*{CRITERIA PROPERTIES\label{LedgerSMB::DBObject::Report::Contact::Search_CRITERIA_PROPERTIES}\index{LedgerSMB::DBObject::Report::Contact::Search!CRITERIA PROPERTIES}}
\begin{description}

\item[{entity\_class}] \mbox{}

The account/entity class of the contact.  Required and an exact match.


\item[{name\_part}] \mbox{}

Full text search on contact name.


\item[{control\_code}] \mbox{}

Matches the beginning of the control code string


\item[{contact\_info}] \mbox{}

Aggregated from email, phone, fax, etc.  Aggregated by this report (internal).


\item[{email}] \mbox{}

Email address, exact match on any email address.


\item[{phone}] \mbox{}

Exact match on phone any phone number, fax, etc.


\item[{meta\_number}] \mbox{}

Matches beginning of customer/vendor/etc. number.


\item[{notes}] \mbox{}

Full text search of all entity/eca notes


\item[{address}] \mbox{}

Full text search (fully matching) on any address line.


\item[{city}] \mbox{}

Exact match on city


\item[{state}] \mbox{}

Exact match on state/province


\item[{mail\_code}] \mbox{}

Match on beginning of mail or post code


\item[{country}] \mbox{}

Full or short name of country (i.e. US or United States, or CA or Canada).


\item[{active\_date\_from}] \mbox{}

Active items only from this date.


\item[{active\_date\_to}] \mbox{}

Active items only to this date.

\end{description}
\subsection*{METHODS\label{LedgerSMB::DBObject::Report::Contact::Search_METHODS}\index{LedgerSMB::DBObject::Report::Contact::Search!METHODS}}
\begin{description}

\item[{prepare\_criteria}] \mbox{}

Converts inputs to PgDate where needed


\item[{run\_report}] \mbox{}

Runs the report, populates rows.

\end{description}
\subsection*{COPYRIGHT\label{LedgerSMB::DBObject::Report::Contact::Search_COPYRIGHT}\index{LedgerSMB::DBObject::Report::Contact::Search!COPYRIGHT}}


COPYRIGHT (C) 2012 The LedgerSMB Core Team.  This file may be re-used following
the terms of the GNU General Public License version 2 or at your option any
later version.  Please see included LICENSE.TXT for details.

\section{LedgerSMB::DBObject::Report::Contact::History\label{LedgerSMB::DBObject::Report::Contact::History}\index{LedgerSMB::DBObject::Report::Contact::History}}


Purchase history reports
and more.

\subsection*{SYNPOSIS\label{LedgerSMB::DBObject::Report::Contact::History_SYNPOSIS}\index{LedgerSMB::DBObject::Report::Contact::History!SYNPOSIS}}
\begin{verbatim}
  my $report = LedgerSMB::DBObject::Report::Contact::History->new(%$request);
  $report->run;
  $report->render($request, $format);
\end{verbatim}
\subsection*{DESCRIPTION\label{LedgerSMB::DBObject::Report::Contact::History_DESCRIPTION}\index{LedgerSMB::DBObject::Report::Contact::History!DESCRIPTION}}


This report provides purchase history reports.  It can be used to search for 
both customers and vendors.

\subsection*{INHERITS\label{LedgerSMB::DBObject::Report::Contact::History_INHERITS}\index{LedgerSMB::DBObject::Report::Contact::History!INHERITS}}
\begin{description}

\item[{LedgerSMB::DBObject::Report;}] \mbox{}\end{description}
\subsection*{PROPERTIES\label{LedgerSMB::DBObject::Report::Contact::History_PROPERTIES}\index{LedgerSMB::DBObject::Report::Contact::History!PROPERTIES}}
\begin{description}

\item[{columns}] \mbox{}

Read-only accessor, returns a list of columns.


\item[{name}] \mbox{}
\item[{header\_lines}] \mbox{}\end{description}
\subsection*{CRITERIA PROPERTIES\label{LedgerSMB::DBObject::Report::Contact::History_CRITERIA_PROPERTIES}\index{LedgerSMB::DBObject::Report::Contact::History!CRITERIA PROPERTIES}}
\begin{description}

\item[{account\_class}] \mbox{}

The account/entity class of the contact.  Required and an exact match.


\item[{name}] \mbox{}

This is the name of the customer or vendor.  It is an exact match.


\item[{meta\_number}] \mbox{}

Partial match on account number


\item[{contact\_info}] \mbox{}

Phone, email, etc to select on.  Partial match


\item[{address\_line}] \mbox{}

Partial match on any address line


\item[{city}] \mbox{}

Partial match on city name


\item[{state}] \mbox{}

Partial match on name of state or probince


\item[{zip}] \mbox{}

Partial match on zip/mail\_code


\item[{salesperson}] \mbox{}

Partial match on salesperson name


\item[{notes}] \mbox{}

Full text search on notes


\item[{country\_id}] \mbox{}

country id of customer


\item[{from\_date}] \mbox{}

Include only invoices starting on this date


\item[{to\_date}] \mbox{}

Include only invoices before this date


\item[{type}] \mbox{}

This is the type of document to be returned:

\begin{description}

\item[{i}] \mbox{}

Invoices


\item[{o}] \mbox{}

Orders


\item[{q}] \mbox{}

Quotations

\end{description}

\item[{start\_from}] \mbox{}

Include only customers active starting this date.


\item[{start\_to}] \mbox{}

Include only customers becoming active no later than this date


\item[{inc\_open}] \mbox{}

Include open invoices/orders/etc.


\item[{inc\_closed}] \mbox{}

Include closed invoices/orders/etc.


\item[{is\_summary}] \mbox{}

If this is true it is a summary report.  Otherwise full details shown.

\end{description}
\subsection*{METHODS\label{LedgerSMB::DBObject::Report::Contact::History_METHODS}\index{LedgerSMB::DBObject::Report::Contact::History!METHODS}}
\begin{description}

\item[{prepare\_criteria}] \mbox{}

Converts inputs to PgDate where needed


\item[{run\_report}] \mbox{}

Runs the report, populates rows.

\end{description}
\subsection*{COPYRIGHT\label{LedgerSMB::DBObject::Report::Contact::History_COPYRIGHT}\index{LedgerSMB::DBObject::Report::Contact::History!COPYRIGHT}}


COPYRIGHT (C) 2012 The LedgerSMB Core Team.  This file may be re-used following
the terms of the GNU General Public License version 2 or at your option any
later version.  Please see included LICENSE.TXT for details.

\section{LedgerSMB::DBObject::Report::Contact::Purchase\label{LedgerSMB::DBObject::Report::Contact::Purchase}\index{LedgerSMB::DBObject::Report::Contact::Purchase}}


Search AR/AP Transactions and
generate Reports

\subsection*{SYNPOSIS\label{LedgerSMB::DBObject::Report::Contact::Purchase_SYNPOSIS}\index{LedgerSMB::DBObject::Report::Contact::Purchase!SYNPOSIS}}
\begin{verbatim}
  my $report = LedgerSMB::DBObject::Report::Contact::Purchase->new(%$request);
  $report->run;
  $report->render($request, $format);
\end{verbatim}
\subsection*{DESCRIPTION\label{LedgerSMB::DBObject::Report::Contact::Purchase_DESCRIPTION}\index{LedgerSMB::DBObject::Report::Contact::Purchase!DESCRIPTION}}


This report provides the capacity to generate reports equivalent to the AR and
AP transaction and outstanding reports in 1.3 and earlier.  General uses include
reviewing outstanding transactions, transactions that were outstanding at a
certain point, and locating specific transactions.

\subsection*{INHERITS\label{LedgerSMB::DBObject::Report::Contact::Purchase_INHERITS}\index{LedgerSMB::DBObject::Report::Contact::Purchase!INHERITS}}
\begin{description}

\item[{LedgerSMB::DBObject::Report;}] \mbox{}\end{description}
\subsection*{PROPERTIES\label{LedgerSMB::DBObject::Report::Contact::Purchase_PROPERTIES}\index{LedgerSMB::DBObject::Report::Contact::Purchase!PROPERTIES}}
\begin{description}

\item[{columns}] \mbox{}

Read-only accessor, returns a list of columns.


\item[{name}] \mbox{}
\item[{header\_lines}] \mbox{}\end{description}
\subsection*{CRITERIA PROPERTIES\label{LedgerSMB::DBObject::Report::Contact::Purchase_CRITERIA_PROPERTIES}\index{LedgerSMB::DBObject::Report::Contact::Purchase!CRITERIA PROPERTIES}}
\begin{description}

\item[{entity\_class}] \mbox{}

Must be 1 for vendor or 2 for customer.  No other values will return any values.


\item[{accno}] \mbox{}

Account Number for search.  If set can be either in the form of the actual 
account number itself or in the form of accno-{}-description (returned by the
current ajaxselect implementation).


\item[{name\_part}] \mbox{}

Full text search on contact name.


\item[{meta\_number}] \mbox{}

Matches the beginning of the meta\_number for the entity credit account.


\item[{invnumber}] \mbox{}

Invoice number.  Matches the beginning of the string.


\item[{ordnumber}] \mbox{}

Order number.  Matches the beginning of the string.


\item[{ponumber}] \mbox{}

Purchas order number.  Matches the beginning of the string.


\item[{source}] \mbox{}

Matches any source field in line item details.  This can be used to see which
invoices were paid by a specific payment.


\item[{description}] \mbox{}

Full text search on transaction description


\item[{notes}] \mbox{}

Full text search on notes of invoice


\item[{ship\_via}] \mbox{}

Full text search on ship\_via field.


\item[{from\_date}] \mbox{}

Invoices posted starting on this date


\item[{to\_date}] \mbox{}

Invoices posted no later than this date


\item[{as\_of}] \mbox{}

Shows invoice balances as of this date.


\item[{summarize}] \mbox{}

Tells whether to summarize the report (i.e. produce a summary report rather than
a detail report).

\end{description}
\subsection*{METHODS\label{LedgerSMB::DBObject::Report::Contact::Purchase_METHODS}\index{LedgerSMB::DBObject::Report::Contact::Purchase!METHODS}}
\begin{description}

\item[{prepare\_criteria}] \mbox{}

Converts inputs to PgDate where needed


\item[{run\_report}] \mbox{}

Runs the report, populates rows.

\end{description}
\subsection*{COPYRIGHT\label{LedgerSMB::DBObject::Report::Contact::Purchase_COPYRIGHT}\index{LedgerSMB::DBObject::Report::Contact::Purchase!COPYRIGHT}}


COPYRIGHT (C) 2012 The LedgerSMB Core Team.  This file may be re-used following
the terms of the GNU General Public License version 2 or at your option any
later version.  Please see included LICENSE.TXT for details.

\section{LedgerSMB::DBObject::EOY\label{LedgerSMB::DBObject::EOY}\index{LedgerSMB::DBObject::EOY}}


End of Year handling module

\subsection*{SYNOPSYS\label{LedgerSMB::DBObject::EOY_SYNOPSYS}\index{LedgerSMB::DBObject::EOY!SYNOPSYS}}


This class contains methods for end of year entry.

\subsection*{BASIC PROPERTIES\label{LedgerSMB::DBObject::EOY_BASIC_PROPERTIES}\index{LedgerSMB::DBObject::EOY!BASIC PROPERTIES}}
\begin{description}

\item[{end\_date specifies the end date for a closed}] \textbf{period.}
\item[{reference specifies the gl reference field}] \textbf{associated with the account closure}
\item[{description specifies the gl description}] \textbf{field associated with the account closure}
\item[{retention\_acc\_id specifies the account}] \textbf{id used as a retaining account.}\end{description}
\subsection*{METHODS\label{LedgerSMB::DBObject::EOY_METHODS}\index{LedgerSMB::DBObject::EOY!METHODS}}
\begin{description}

\item[{\$eoy-$>$checkpoint\_only();}] \mbox{}

This creates account checkpoints at \$eoy-$>$\{end\_date\}.  This has two uses:
1)  Can be used to "close" books without zeroing income/expense accounts.  This
prevents data from being inserted for earlier dates.



2)  This can be used to improve performance by creating a "lookback" point.


\item[{\$eoy-$>$reopen\_books()}] \mbox{}

This reverses any end of year transaction on \$eoy-$>$\{end\_date\}, and deletes 
checkpoints for that day.


\item[{\$eoy-$>$close\_books()}] \mbox{}

Requires all properies in BASIC PROPERTIES to be set.  This creates a gl 
yearend transaction, and moves income/expenses to the selected equity account
for retained earnings.


\item[{\$eoy-$>$list\_earnings\_accounts}] \mbox{}

Returns a list of equity accounts, and sets \$eoy-$>$\{earnings\_accounts\} to a 
list of hashrefs.  These are used to select retained earnings accounts in 
closing books.

\end{description}
\subsection*{COPYRYIGHT\label{LedgerSMB::DBObject::EOY_COPYRYIGHT}\index{LedgerSMB::DBObject::EOY!COPYRYIGHT}}


Copyright (C) 2009 The LedgerSMB Core Team.  This may be re-used as permitted by
the GNU General Public License v 2 or at your option any later version.  Please
see included License.txt for details.

\section{LedgerSMB::DBObject::Asset\_Class\label{LedgerSMB::DBObject::Asset_Class}\index{LedgerSMB::DBObject::Asset\ Class}}


LedgerSMB Base Class for Asset Classes

\subsection*{SYNOPSIS\label{LedgerSMB::DBObject::Asset_Class_SYNOPSIS}\index{LedgerSMB::DBObject::Asset Class!SYNOPSIS}}


This library contains the base utility functions for creating, saving, and
retrieving depreciation categories of assets.

\subsection*{STANDARD PROPERTIES\label{LedgerSMB::DBObject::Asset_Class_STANDARD_PROPERTIES}\index{LedgerSMB::DBObject::Asset Class!STANDARD PROPERTIES}}
\begin{description}

\item[{id}] \mbox{}

Integer ID of record.


\item[{lable}] \mbox{}

Text description of asset class


\item[{asset\_account\_id}] \mbox{}

Integer id of asset account.


\item[{dep\_account\_id}] \mbox{}

Integer id of depreciation account.


\item[{method}] \mbox{}

Integer id of depreciation method.

\end{description}
\subsection*{METHODS\label{LedgerSMB::DBObject::Asset_Class_METHODS}\index{LedgerSMB::DBObject::Asset Class!METHODS}}
\begin{description}

\item[{save}] \mbox{}

Properties used:
id:  (Optional) ID of existing class to overwrite. 
asset\_account\_id: Account id to store asset values
dep\_account\_id: Account id for depreciation information 
method:  ID of depreciation method
label:  Name of the asset class
unit\_label:  Label of the depreciation unit



Typically sets ID if no match found or if ID not provided.


\item[{get\_metadata}] \mbox{}

sets:



asset\_accounts to arrayref of asset accounts
dep\_accounts to arrayref of depreciation accounts
dep\_methods to arrayrefo of depreciation methods


\item[{get\_asset\_class()}] \mbox{}

Requires id to be set.



Sets all other standard properties if the record is found.


\item[{list\_asset\_classes}] \mbox{}

Sets classes to a list of all asset classes, ordered as per db.

\end{description}
\subsection*{Copyright (C) 2010, The LedgerSMB core team.\label{LedgerSMB::DBObject::Asset_Class_Copyright_C_2010_The_LedgerSMB_core_team_}\index{LedgerSMB::DBObject::Asset Class!Copyright (C) 2010, The LedgerSMB core team.}}


This file is licensed under the Gnu General Public License version 2, or at your
option any later version.  A copy of the license should have been included with
your software.

\section{LedgerSMB::DBObject::Business\_Unit\_Class\label{LedgerSMB::DBObject::Business_Unit_Class}\index{LedgerSMB::DBObject::Business\ Unit\ Class}}




\subsection*{SYNOPSYS\label{LedgerSMB::DBObject::Business_Unit_Class_SYNOPSYS}\index{LedgerSMB::DBObject::Business Unit Class!SYNOPSYS}}


This holds the information as to the handling of classes of buisness units.  
Business units are reporting units which can be used to classify various line 
items of transactions in different ways and include handling for departments, 
funds, and projects.

\subsection*{PROPERTIES\label{LedgerSMB::DBObject::Business_Unit_Class_PROPERTIES}\index{LedgerSMB::DBObject::Business Unit Class!PROPERTIES}}
\begin{description}

\item[{id}] \mbox{}

This is the internal id of the unit class.  It is undef when the class has not
yet been saved in the database


\item[{class\_id}] \mbox{}

Required. Internal id of class (1 for department, 2 for project, etc)


\item[{control\_code}] \mbox{}

This is a textual reference to the business reporting unit.  It must be unique
to the business units of its class.


\item[{description}] \mbox{}

Textual description of the reporting unit.


\item[{start\_date}] \mbox{}

The first date the business reporting unit is valid.  We use the PGDate class
here for conversion to/from input and to/from strings for the db.


\item[{end\_date}] \mbox{}

The last date the business reporting unit is valid.  We use the PGDate class
here for conversion to/from input and to/from strings for the db.


\item[{parent\_id}] \mbox{}

The internal id of the parent, if applicable.  undef means no parent.


\item[{parent}] \mbox{}

A reference to the parent business reporting unit


\item[{credit\_id}] \mbox{}

The internal id of the customer, vendor, employee, etc. attached to this 
unit.


\item[{children}] \mbox{}

The children of the current unit, if applicable, and desired.



This is not set unless get\_tree has already been called.

\end{description}
\subsection*{METHODS\label{LedgerSMB::DBObject::Business_Unit_Class_METHODS}\index{LedgerSMB::DBObject::Business Unit Class!METHODS}}
\begin{description}

\item[{get(\$id)}] \mbox{}

Returns the business reporting unit referenced by the id.


\item[{save}] \mbox{}

Saves the business reporting unit ot the database and updates changes to object.


\item[{list (\$date, \$class\_id, \$credit\_id,}] \textbf{\$strict, \$active\_on)}

Lists all business reporting units active on \$date, for \$credit\_id (or for all
credit\_ids), and of \$class.  Undef on date and credit\_id match all rows.


\item[{delete}] \mbox{}

Deletes the buisness reporting unit.  A unit can only be deleted if it has no 
children and no transactions attached.


\item[{search}] \mbox{}

Returns a list of buisness reporting units matching search criteria.


\item[{get\_tree}] \mbox{}

Retrieves children recursively from the database and populates children 
appropriately


\item[{tree\_to\_list}] \mbox{}

Returns tree as a list.

\end{description}
\subsection*{COPYRIGHT\label{LedgerSMB::DBObject::Business_Unit_Class_COPYRIGHT}\index{LedgerSMB::DBObject::Business Unit Class!COPYRIGHT}}


Copyright (C) 2012 The LedgerSMB Core Team.  This module may be used under the
GNU GPL in accordance with the LICENSE file listed.

\section{LedgerSMB::DBObject::App\_Module -{}- Application Module Lists for LedgerSMB\label{LedgerSMB::DBObject::App_Module_-_-_Application_Module_Lists_for_LedgerSMB}\index{LedgerSMB::DBObject::App\ Module -{}- Application Module Lists for LedgerSMB}}




\subsection*{SYNOPSYS\label{LedgerSMB::DBObject::App_Module_-_-_Application_Module_Lists_for_LedgerSMB_SYNOPSYS}\index{LedgerSMB::DBObject::App Module - - Application Module Lists for LedgerSMB!SYNOPSYS}}


Application modules, new to LedgerSMB 1.4, are ways to categorize functionality in 
LedgerSMB.  In future versions, these may be important to security management and the
like.  However at present they are mostly available to tie various reporting entries
to various parts of the software.



Note that modules are generally read-only and not expected to be saved in the system.



The id attribute is expected to be static and hardcoded, so these must be assigned.



A default module (id 0, label '') is available for doing lookups.

\subsection*{INHERITS\label{LedgerSMB::DBObject::App_Module_-_-_Application_Module_Lists_for_LedgerSMB_INHERITS}\index{LedgerSMB::DBObject::App Module - - Application Module Lists for LedgerSMB!INHERITS}}
\begin{description}

\item[{LedgerSMB::DBObject\_Moose}] \mbox{}\end{description}
\subsection*{PROPERTIES\label{LedgerSMB::DBObject::App_Module_-_-_Application_Module_Lists_for_LedgerSMB_PROPERTIES}\index{LedgerSMB::DBObject::App Module - - Application Module Lists for LedgerSMB!PROPERTIES}}
\begin{description}

\item[{int id}] \mbox{}

This is the internal system id of the module.


\item[{string label}] \mbox{}

This is the human readable label.

\end{description}
\subsection*{METHODS\label{LedgerSMB::DBObject::App_Module_-_-_Application_Module_Lists_for_LedgerSMB_METHODS}\index{LedgerSMB::DBObject::App Module - - Application Module Lists for LedgerSMB!METHODS}}
\begin{description}

\item[{get(\$id)}] \mbox{}

This retrieves a single module by id, and returns it.


\item[{list()}] \mbox{}

This returns a list of all modules, ordered by id.

\end{description}
\subsection*{COPYRIGHT\label{LedgerSMB::DBObject::App_Module_-_-_Application_Module_Lists_for_LedgerSMB_COPYRIGHT}\index{LedgerSMB::DBObject::App Module - - Application Module Lists for LedgerSMB!COPYRIGHT}}


Copyright (C) 2012, The LedgerSMB Core Team.  This file may be reused under the terms of
the GNU General Public License, version 2, or at your option any later version.  See
the included LICENSE.txt for details.

\section{LedgerSMB::DBObject::TaxFormm\label{LedgerSMB::DBObject::TaxFormm}\index{LedgerSMB::DBObject::TaxFormm}}


Includes methods for saving and retrieving tax forms.

\subsection*{SYNOPSIS\label{LedgerSMB::DBObject::TaxFormm_SYNOPSIS}\index{LedgerSMB::DBObject::TaxFormm!SYNOPSIS}}


This module includes methods for saving and retrieving tax forms, and running
reports.  The tax forms are for reporting purchases or sales to tax bodies, and
as of 1.3.0, the only tax forms officially included are those of the 1099-MISC 
and 1099-INT forms of the USA.



Currently there is no abstraction layer to allow replacing the various reports
on the fly, but this will have to be implemented in the future.

\subsection*{METHODS\label{LedgerSMB::DBObject::TaxFormm_METHODS}\index{LedgerSMB::DBObject::TaxFormm!METHODS}}
\begin{description}

\item[{save
Saves the tax form. Inputs are:}] \mbox{}\begin{description}

\item[{form\_name (required) The name of the form,}] \textbf{eg, 1099-MISC}
\item[{country\_id (required) The id of the country}] \mbox{}
\item[{id (optional) The id of the tax form to}] \textbf{overwrite}\end{description}


In the future it is likely that we will add a taxform\_sproc\_id too as part of
an abstraction layer.


\item[{get(\$id)}] \mbox{}

Retrieves information on the tax form specified and merges it with the current
object.  Properties set are:

\begin{description}

\item[{id
ID of tax form}] \mbox{}
\item[{form\_name Name of tax form (eg, 1099-MISC)}] \mbox{}
\item[{country\_id ID of country attached to tax}] \textbf{form}\end{description}

\item[{get\_full\_list}] \mbox{}

No inputs required.  Provides a list of hashrefs (and attaches them to the 
form property of the object hashref).



Each hashref has the same properties as are set by get(\$id) above, but also
includes country\_name which is the full name of the country (eg, 'United 
States').



Default ordering is by country name and then by tax form name.


\item[{get\_forms}] \mbox{}

No inputs needed



Returns a list of hashrefs representing tax forms.  Each hashref contains
the same properties as from get() above.  Default ordering is by country id
then tax form id.


\item[{get\_metadata}] \mbox{}

Gets metadata for the screen.



Sets the following hashref properties

\begin{description}

\item[{countries A list of all countries, for drop}] \textbf{down box purposes.}
\item[{default\_country The default country of}] \textbf{the organization, to set the dropdown box.}\end{description}
\end{description}
\subsection*{COPYRIGHT\label{LedgerSMB::DBObject::TaxFormm_COPYRIGHT}\index{LedgerSMB::DBObject::TaxFormm!COPYRIGHT}}


Copyright (C) 2009 LedgerSMB Core Team.  This file is licensed under the GNU 
General Public License version 2, or at your option any later version.  Please
see the included License.txt for details.

\section{LedgerSMB::DBObject::Report\label{LedgerSMB::DBObject::Report}\index{LedgerSMB::DBObject::Report}}


Base Reporting Functionality for LedgerSMB

\subsection*{SYNPOSIS\label{LedgerSMB::DBObject::Report_SYNPOSIS}\index{LedgerSMB::DBObject::Report!SYNPOSIS}}


This Perl module provides base utility functions for reporting in LedgerSMB.
This is intended to be an abstract class, never having direct instances, but
instead inherited out to other modules.

\subsection*{DESCRIPTION\label{LedgerSMB::DBObject::Report_DESCRIPTION}\index{LedgerSMB::DBObject::Report!DESCRIPTION}}


LedgerSMB::DBObject::Report provides basic utility functions for reporting in
LedgerSMB.  It is an abstract class.  Individual report types MUST inherit this
out.



Subclasses MUST define the following subroutines:

\begin{description}

\item[{get\_columns}] \mbox{}

This MUST return a list of hashrefs for the columns per the dynatable block.

\end{description}


Additionally, subclasses MAY define any of the following:

\begin{description}

\item[{template}] \mbox{}

Returns the name of the template to be used.  Otherwise a generic
UI/reports/display\_report template will be used.

\end{description}
\subsection*{INHERITS\label{LedgerSMB::DBObject::Report_INHERITS}\index{LedgerSMB::DBObject::Report!INHERITS}}
\begin{description}

\item[{LedgerSMB::DBObject\_Moose}] \mbox{}\end{description}
\subsection*{PROPERTIES\label{LedgerSMB::DBObject::Report_PROPERTIES}\index{LedgerSMB::DBObject::Report!PROPERTIES}}
\begin{description}

\item[{cols}] \mbox{}

This is an array of hashrefs.  Properties for each hashref:

\begin{description}

\item[{col\_id}] \mbox{}

ID of column, alphanumeric, used in names of elements, classes, etc.  Required
for smooth operation.


\item[{name}] \mbox{}

Localized name of column for labelling purposes


\item[{type}] \mbox{}

Display type of info.  May be text, href, input\_text, checkbox, or radio.  For a
report, it will typically be text or href.


\item[{href\_base}] \mbox{}

Base for href.  Only meaningful if type is href


\item[{class}] \mbox{}

CSS class (additional) for the column.

\end{description}

\item[{rows}] \mbox{}

This is an arrayref of rows.  Each row has fields with keys equal to the col\_id
fields of the columns above.


\item[{format}] \mbox{}

This is the format, and must be one used by LedgerSMB::Template.  Options
expected for 1.4 out of the box include csv, pdf, ps, xls, and ods.  Other
formats could be supported in the future.  If undefined, defaults html.


\item[{order\_by}] \mbox{}

The column to order on.  used in providing subtotals also.


\item[{old\_order\_by}] \mbox{}

Previous order by.  Used internally to determine order direction.


\item[{order\_dir}] \mbox{}

either asc, desc, or undef.  used to determine next ordering.


\item[{order\_url}] \mbox{}

Url for order redirection.  Interal only.


\item[{show\_subtotals}] \mbox{}

bool, determines whether to show subtotals.


\item[{buttons}] \mbox{}

Buttons to show at the bottom of the screen

\end{description}
\subsection*{METHODS\label{LedgerSMB::DBObject::Report_METHODS}\index{LedgerSMB::DBObject::Report!METHODS}}
\begin{description}

\item[{render}] \mbox{}

This takes no arguments and simply renders the report as is.


\item[{show\_cols}] \mbox{}

Returns a list of columns based on selected ones from the report


\item[{prepare\_input}] \mbox{}

Handles from\_date and to\_date fields, as well as from\_month, from\_year, and 
interval, setting from\_date and to\_date to LedgerSMB::PGDate types, and setting
from\_amount and to\_amount to LedgerSMB::PGNumber types.



Valid values for interval are:

\begin{description}

\item[{none}] \mbox{}

No start date, end date as first of the month


\item[{month}] \mbox{}

Valid for the month selected


\item[{quarter}] \mbox{}

Valid for the month selected and the two proceeding ones.


\item[{year}] \mbox{}

Valid for a year starting with the month selected.

\end{description}
\end{description}
\subsection*{COPYRIGHT\label{LedgerSMB::DBObject::Report_COPYRIGHT}\index{LedgerSMB::DBObject::Report!COPYRIGHT}}


COPYRIGHT (C) 2012 The LedgerSMB Core Team.  This file may be re-used under the
terms of the LedgerSMB General Public License version 2 or at your option any
later version.  Please see enclosed LICENSE file for details.

\section{LedgerSMB::DBObject::Pricelist\label{LedgerSMB::DBObject::Pricelist}\index{LedgerSMB::DBObject::Pricelist}}


Pricelists for customers and vendors

\subsection*{SYNOPSIS\label{LedgerSMB::DBObject::Pricelist_SYNOPSIS}\index{LedgerSMB::DBObject::Pricelist!SYNOPSIS}}
\begin{verbatim}
 my $pl = LedgerSMB::DBObject::Pricelist->new({base => $request});
 $pl->save(\@lines);
\end{verbatim}
\subsection*{DESCRIPTION\label{LedgerSMB::DBObject::Pricelist_DESCRIPTION}\index{LedgerSMB::DBObject::Pricelist!DESCRIPTION}}


This module contains the pricelist saving routines for 1.3.  In 1.4 more
pricelist routines will be added.

\subsection*{PROPERTIES\label{LedgerSMB::DBObject::Pricelist_PROPERTIES}\index{LedgerSMB::DBObject::Pricelist!PROPERTIES}}
\begin{description}

\item[{entity\_class}] \mbox{}

This tells us whether this is a customer or vendor's pricelist.


\item[{credit\_id}] \mbox{}

tells us who this is for.

\end{description}
\subsection*{METHODS\label{LedgerSMB::DBObject::Pricelist_METHODS}\index{LedgerSMB::DBObject::Pricelist!METHODS}}
\begin{description}

\item[{save($\backslash$@array);}] \mbox{}

Saves the pricelist.

\end{description}
\subsection*{COPYRIGHT\label{LedgerSMB::DBObject::Pricelist_COPYRIGHT}\index{LedgerSMB::DBObject::Pricelist!COPYRIGHT}}


Copyright (C) 2012 The LedgerSMB Core Team.  This file may be re-used under the
terms of the GNU General Public License version 2 or at your option any later
version.  Please see the included LICENSE.txt for more information.

\section{LedgerSMB::DBObject::Customer\label{LedgerSMB::DBObject::Customer}\index{LedgerSMB::DBObject::Customer}}


LedgerSMB Class for Customers

\subsection*{SYNOPSIS\label{LedgerSMB::DBObject::Customer_SYNOPSIS}\index{LedgerSMB::DBObject::Customer!SYNOPSIS}}


This library contains the base utility functions for creating, saving, and
retrieving customers.

\subsection*{INHERITS\label{LedgerSMB::DBObject::Customer_INHERITS}\index{LedgerSMB::DBObject::Customer!INHERITS}}


LedgerSMB::DBObject::Company

\subsection*{METHODS\label{LedgerSMB::DBObject::Customer_METHODS}\index{LedgerSMB::DBObject::Customer!METHODS}}
\begin{description}

\item[{set\_entity\_class}] \mbox{}

Sets entity\_class to 2.

\end{description}
\subsection*{COPYRIGHT\label{LedgerSMB::DBObject::Customer_COPYRIGHT}\index{LedgerSMB::DBObject::Customer!COPYRIGHT}}


Copyright (c) 2009, the LedgerSMB Core Team.  This is licensed under the GNU 
General Public License, version 2, or at your option any later version.  Please 
see the accompanying License.txt for more information.

\section{LedgerSMB::DBObject::Entity -{}- Entity Management base classes for LedgerSMB\label{LedgerSMB::DBObject::Entity_-_-_Entity_Management_base_classes_for_LedgerSMB}\index{LedgerSMB::DBObject::Entity -{}- Entity Management base classes for LedgerSMB}}




\subsection*{SYNOPSYS\label{LedgerSMB::DBObject::Entity_-_-_Entity_Management_base_classes_for_LedgerSMB_SYNOPSYS}\index{LedgerSMB::DBObject::Entity - - Entity Management base classes for LedgerSMB!SYNOPSYS}}


This module anages basic entity management for persons and companies, both of which will
likely inherit this class.

\subsection*{INHERITS\label{LedgerSMB::DBObject::Entity_-_-_Entity_Management_base_classes_for_LedgerSMB_INHERITS}\index{LedgerSMB::DBObject::Entity - - Entity Management base classes for LedgerSMB!INHERITS}}
\begin{description}

\item[{LedgerSMB::DBObject\_Moose}] \mbox{}\end{description}
\subsection*{PROPERTIES\label{LedgerSMB::DBObject::Entity_-_-_Entity_Management_base_classes_for_LedgerSMB_PROPERTIES}\index{LedgerSMB::DBObject::Entity - - Entity Management base classes for LedgerSMB!PROPERTIES}}
\begin{description}

\item[{id}] \mbox{}

This is the internal, system id, which is a surrogate key.  This will be undefined when
the entity has not yet been saved to the database and set once it has been saved or 
retrieved.


\item[{control\_code}] \mbox{}

The control code is the internal handling number for the operator to use to pull up 
an entity,


\item[{name}] \mbox{}

The unofficial name of the entity.  This is usually copied in from company.legal\_name
or prepared (using some sort of locale-specific logic) from person.first\_name and
person.last\_name.


\item[{country\_id}] \mbox{}

ID of country of entiy.


\item[{country\_name}] \mbox{}

Name of country (optional)


\item[{entity\_class}] \mbox{}

Primary class of entity.  This is mostly for reporting purposes.  See entity\_class
table in database for list of valid values, but 1 is for vendors, 2 for customers, 
3 for employees, etc.

\end{description}
\subsection*{COPYRIGHT\label{LedgerSMB::DBObject::Entity_-_-_Entity_Management_base_classes_for_LedgerSMB_COPYRIGHT}\index{LedgerSMB::DBObject::Entity - - Entity Management base classes for LedgerSMB!COPYRIGHT}}


Copyright (C) 2012 The LedgerSMB Core Team.  This file may be reused under the
conditions of the GNU GPL v2 or at your option any later version.  Please see the
accompanying LICENSE.TXT for more information.

\section{LedgerSMB::DBObject::Budget\label{LedgerSMB::DBObject::Budget}\index{LedgerSMB::DBObject::Budget}}




\subsection*{SYNOPSIS\label{LedgerSMB::DBObject::Budget_SYNOPSIS}\index{LedgerSMB::DBObject::Budget!SYNOPSIS}}


This module provides budget management routines, such as entering budgets,
approving or rejecting them, and marking them obsolete.  It does not include
more free-form areas like reporting.  For those, see
LedgerSMB::DBObject::Budget\_Report.

\subsection*{INHERITANCE\label{LedgerSMB::DBObject::Budget_INHERITANCE}\index{LedgerSMB::DBObject::Budget!INHERITANCE}}
\begin{description}

\item[{LedgerSMB}] \mbox{}
\item[{LedgerSMB::DBObject}] \mbox{}\end{description}
\subsection*{PROPERTIES\label{LedgerSMB::DBObject::Budget_PROPERTIES}\index{LedgerSMB::DBObject::Budget!PROPERTIES}}
\begin{description}

\item[{\$id INT
   The id of the budget}] \mbox{}
\item[{\$start\_date date The start date of the}] \textbf{budget, inclusive}
\item[{\$end\_date date The end date of the budget,}] \textbf{inclusive}
\item[{\$reference text This is a text reference}] \textbf{identifier for the budget}
\item[{\$description text This is a text field}] \textbf{for the budget description. It is searchable.}
\item[{\$entered\_by int Entity id of the employee}] \textbf{or contractor who entered the budget}
\item[{\$approved\_by int Entity id of the employee}] \textbf{or contractor who approved the budget}
\item[{\$obsolete\_by int Entity id for the employee}] \textbf{or contractor who marked the budget obsolete}
\item[{\$entered\_at timestamp Time the budget}] \textbf{was entered}
\item[{\$approved\_at timestamp Time the budget}] \textbf{was approved}
\item[{\$obsolete\_at timestamp Time the budget}] \textbf{was deleted}
\item[{\$entered\_by\_name text Name of entity}] \textbf{who entered the budget.}
\item[{\$approved\_by\_name text Name of entity}] \textbf{who approved the budget}
\item[{\$obsolete\_by\_name text Name of entity}] \textbf{who obsoleted the budget}
\item[{@business\_unit\_ids}] \mbox{}

List of id's of business units which the budget covers


\item[{@lines These are the actual lines of the}] \textbf{budget. Each one is a hashref containing}
\item[{\$budget\_id int Optional. Don't use. Use}] \textbf{the \$id field of the parent instead.}
\item[{\$account\_id int The id of the chart of}] \textbf{accounts entry}
\item[{\$accno text The account number for the}] \textbf{coa entry}
\item[{\$amount numeric The amount budgetted}] \mbox{}
\item[{\$description text Description of line item}] \mbox{}\end{description}
@notes
Where each note is a hashref containing

\begin{description}

\item[{\$subject string
   Subject of note}] \mbox{}
\item[{\$note string
   The body of the note.}] \mbox{}
\item[{\$created timestamp This is when the note}] \textbf{was created}
\item[{\$created\_by string Username of the individual}] \textbf{who created the note at the time of its creation.}\end{description}
\subsection*{METHODS\label{LedgerSMB::DBObject::Budget_METHODS}\index{LedgerSMB::DBObject::Budget!METHODS}}
\begin{description}

\item[{save}] \mbox{}

Saves the current budget.


\item[{from\_input}] \mbox{}

Prepares dates as PGDate formats


\item[{search This method uses the object as the}] \textbf{search criteria. Nulls/undefs match all values. The properties used are:}\begin{description}

\item[{start\_date Matches the start date of the}] \textbf{budget. Full match only.}
\item[{end\_date Matches the end date of the budget.}] \textbf{Full match only}
\item[{includes\_date This date is between start}] \textbf{date and end date of budget, inclusive.}
\item[{reference Partial match on budget reference}] \mbox{}
\item[{description Full text search against description}] \mbox{}
\item[{entered\_by
Exact match of entered by.}] \mbox{}
\item[{approved\_by
Exact match of approved by}] \mbox{}
\item[{department\_id Exact match of department\_id}] \mbox{}
\item[{project\_id
Exact match of project\_id}] \mbox{}
\item[{is\_approved true lists approved budgets,}] \textbf{false lists unapproved budgets. null/undef lists all.}
\item[{is\_obsolete true lists obsolete budgets.}] \textbf{False lists non-obsolete budgets. null/undef lists all.}\end{description}

\item[{get(id) takes a new (base) object and populates}] \textbf{with info for the budget.}
\item[{approve
Marks the budget as approved.}] \mbox{}
\item[{reject
Reject and deletes the budget.}] \mbox{}
\item[{obsolete Marks the budget as obsolete/superceded.}] \mbox{}
\item[{save\_note(subject string, note string)}] \textbf{Attaches a note with this subject and content to the budget.}\end{description}
\subsection*{SEE ALSO\label{LedgerSMB::DBObject::Budget_SEE_ALSO}\index{LedgerSMB::DBObject::Budget!SEE ALSO}}
\begin{description}

\item[{LedgerSMB}] \mbox{}
\item[{LedgerSMB::DBObject}] \mbox{}
\item[{LedgerSMB::DBObject::Budget\_Report}] \mbox{}\end{description}
\subsection*{COPYRIGHT AND LICENSE\label{LedgerSMB::DBObject::Budget_COPYRIGHT_AND_LICENSE}\index{LedgerSMB::DBObject::Budget!COPYRIGHT AND LICENSE}}


Copyright (C) 2011 LedgerSMB Core Team.  This file is licensed under the GNU 
General Public License version 2, or at your option any later version.  Please
see the included License.txt for details.

\section{LedgerSMB::DBObject::Vendor\label{LedgerSMB::DBObject::Vendor}\index{LedgerSMB::DBObject::Vendor}}


LedgerSMB Class for Vendors

\subsection*{SYNOPSIS\label{LedgerSMB::DBObject::Vendor_SYNOPSIS}\index{LedgerSMB::DBObject::Vendor!SYNOPSIS}}


This library contains the base utility functions for creating, saving, and
retrieving vendors.

\subsection*{INHERITS\label{LedgerSMB::DBObject::Vendor_INHERITS}\index{LedgerSMB::DBObject::Vendor!INHERITS}}


LedgerSMB::DBObject::Company

\subsection*{METHODS\label{LedgerSMB::DBObject::Vendor_METHODS}\index{LedgerSMB::DBObject::Vendor!METHODS}}
\begin{description}

\item[{set\_entity\_class}] \mbox{}

Sets entity\_class to 1.

\end{description}
\subsection*{COPYRIGHT\label{LedgerSMB::DBObject::Vendor_COPYRIGHT}\index{LedgerSMB::DBObject::Vendor!COPYRIGHT}}


Copyright (c) 2009, the LedgerSMB Core Team.  This is licensed under the GNU 
General Public License, version 2, or at your option any later version.  Please 
see the accompanying License.txt for more information.

\section{LedgerSMB::Mailer\label{LedgerSMB::Mailer}\index{LedgerSMB::Mailer}}


Mail output for LedgerSMB

\subsection*{SYNOPSIS\label{LedgerSMB::Mailer_SYNOPSIS}\index{LedgerSMB::Mailer!SYNOPSIS}}
\subsection*{COPYRIGHT\label{LedgerSMB::Mailer_COPYRIGHT}\index{LedgerSMB::Mailer!COPYRIGHT}}
\begin{verbatim}
 #====================================================================
 # LedgerSMB
 # Small Medium Business Accounting software
 # http://www.ledgersmb.org/
 #
 # Copyright (C) 2006
 # This work contains copyrighted information from a number of sources
 # all used with permission.
 #
 # This file contains source code included with or based on SQL-Ledger
 # which # is Copyright Dieter Simader and DWS Systems Inc. 2000-2005
 # and licensed under the GNU General Public License version 2 or, at
 # your option, any later version.  For a full list including contact
 # information of contributors, maintainers, and copyright holders,
 # see the CONTRIBUTORS file.
 #
 # Original Copyright Notice from SQL-Ledger 2.6.17 (before the fork):
 # Copyright (C) 2002
 #
 #  Author: DWS Systems Inc.
 #       Web: http://www.sql-ledger.org
 #
 #  Contributors:
 #
 # Original Author and copyright holder:
 # Dieter Simader dsmimader@sql-ledger.com
 #====================================================================
\end{verbatim}
\subsection*{METHODS\label{LedgerSMB::Mailer_METHODS}\index{LedgerSMB::Mailer!METHODS}}
\subsubsection*{LedgerSMB::Mailer-$>$new(...)\label{LedgerSMB::Mailer_LedgerSMB::Mailer-_new_}\index{LedgerSMB::Mailer!LedgerSMB::Mailer-$>$new(...)}}


Create a new Mailer object.  If any arguments are passed in, a message
that uses them will be automatically prepared but not sent.

\subsubsection*{\$mail-$>$prepare\_message(to =$>$ \$to, from =$>$ \$from, ...)\label{LedgerSMB::Mailer__mail-_prepare_message_to_to_from_from_}\index{LedgerSMB::Mailer!\$mail-$>$prepare\ message(to =$>$ \$to, from =$>$ \$from, ...)}}


Prepares and encodes base message for sending or adding attachments.

\paragraph*{Arguments\label{LedgerSMB::Mailer_Arguments}\index{LedgerSMB::Mailer!Arguments}}
\begin{description}

\item[{to, from, cc, bcc}] \mbox{}

Address fields for the email.


\item[{subject}] \mbox{}

The subject for the email.


\item[{message}] \mbox{}

The message body for the email.


\item[{contenttype}] \mbox{}

The conttent type for the body of the message, not for any attachments.


\item[{notify}] \mbox{}

Sets the Disposition-Notification-To header (read receipt request) for the
message.  This header will only be added if a from address is set.

\end{description}
\subsubsection*{\$mail-$>$attach(data =$>$ \$data, file =$>$ \$file,
                     filename =$>$ \$name, strip =$>$ \$strip)\label{LedgerSMB::Mailer__mail-_attach_data_data_file_file_filename_name_strip_strip_}\index{LedgerSMB::Mailer!\$mail-$>$attach(data =$>$ \$data, file =$>$ \$file,
                     filename =$>$ \$name, strip =$>$ \$strip)}}


Add an attachment to the prepared message.  If \$data is specified, use the
value of that variable as the attachment value, otherwise attach the file
given by \$file.  If both a file and data are given, the data is attached.
filename must be given and is used to name the attachment.



\$strip is an optional string to remove from the filename send with the
attachment.

\subsubsection*{\$mail-$>$send\label{LedgerSMB::Mailer__mail-_send}\index{LedgerSMB::Mailer!\$mail-$>$send}}


Sends a prepared message using the method configured in ledgersmb.conf.

\section{LedgerSMB::Location\label{LedgerSMB::Location}\index{LedgerSMB::Location}}


LedgerSMB class for managing Business Locations

\subsection*{SYOPSIS\label{LedgerSMB::Location_SYOPSIS}\index{LedgerSMB::Location!SYOPSIS}}


This module contains location management routines.  This subclasses 
LedgerSMB::DBObject to provide access to automatice mapping of function 
arguments and the like.

\subsection*{METHODS\label{LedgerSMB::Location_METHODS}\index{LedgerSMB::Location!METHODS}}
\begin{description}

\item[{delete}] \mbox{}
\item[{save}] \mbox{}

Saves the location.  Properties to be set to be saved are:



* location\_id: Optional:  Overwrite location with this id.
* address1: First line of the address.
* address2: Second line of the address
* address3: Third line of the address
* city
* state: state or province
* zipcode: zipcode or mail code, 
* country:  The id of the country as per the country table


\item[{get}] \mbox{}

Retrieves a location record based on the id field of the object.  Merges the 
properties into the object.


\item[{search Returns anarrayref (and stores it}] \textbf{on \$self-$>$\{search\_results\} based on the search of addresses. Not currently used.}

Attributes used as search criteria:
address1: Partial match for address line 1
address2: Partial match for address line 2,
city:  Partial match for city name
state: Partial match for state or province name, 
zipcode:  Partial match for zip or postal code,
country: Partial name for country name)


\item[{list\_all}] \mbox{}

Provides a list of all locations, ordered by country, then city, then state.


\item[{delete}] \mbox{}

Deletes the location identified by id

\end{description}
\subsection*{Copyright (C) 2007, The LedgerSMB core team.\label{LedgerSMB::Location_Copyright_C_2007_The_LedgerSMB_core_team_}\index{LedgerSMB::Location!Copyright (C) 2007, The LedgerSMB core team.}}


This file is licensed under the Gnu General Public License version 2, or at your
option any later version.  A copy of the license should have been included with
your software.

\section{LedgerSMB::DBObject\_Moose\label{LedgerSMB::DBObject_Moose}\index{LedgerSMB::DBObject\ Moose}}


LedgerSMB class for building objects from db 
relations, now with Moose!

\subsection*{SYOPSIS\label{LedgerSMB::DBObject_Moose_SYOPSIS}\index{LedgerSMB::DBObject Moose!SYOPSIS}}


This module creates object instances based on LedgerSMB's in-database ORM, using Moose.

\subsection*{METHODS\label{LedgerSMB::DBObject_Moose_METHODS}\index{LedgerSMB::DBObject Moose!METHODS}}
\begin{description}

\item[{new (\$class, base =$>$ \$LedgerSMB::hash)}] \mbox{}

This is the base constructor for all child classes.  It must be used with base
argument because this is necessary for database connectivity and the like.



Of course the base object can be any object that inherits LedgerSMB, so you can
use any subclass of that.  The per-session dbh is passed between the objects 
this way as is any information that is needed.


\item[{exec\_method}] \mbox{}

(\$self, procname =$>$ \$function\_name, [args =$>$ $\backslash$@args, schema =$>$ \$schema,
continue\_on\_error=$>$\$continue\_on\_error])



Provides the basic mapping of parameters to the SQL stored procedure function 
arguments.



If $\backslash$@args is not defined, args are mapped from the object's properties, 
stripping them of their in\_ prefix.  If schema is provided, that is used 
instead of PostgreSQL's search path.  If continue\_on\_error is provided and true,
the operation will not raise an exception in the event of a database error, and 
it will be up to the application to handle any exceptions.


\item[{\_db\_array\_scalars(@elements) creates}] \textbf{a db array from scalars.}
\item[{\_db\_array\_literal(@elements) creates}] \textbf{a multiple dimension db array from 	preparsed db arrays or other data which does not need to be escaped.}
\item[{set\_ordering}] \mbox{}

Sets the ordering used by default for specific functions called by exec\_method


\item[{run\_custom\_queries}] \mbox{}

Backward-compatible with 1.2 custom query system for moving forward.

\end{description}
\subsection*{Copyright (C) 2007, The LedgerSMB core team.\label{LedgerSMB::DBObject_Moose_Copyright_C_2007_The_LedgerSMB_core_team_}\index{LedgerSMB::DBObject Moose!Copyright (C) 2007, The LedgerSMB core team.}}


This file is licensed under the Gnu General Public License version 2, or at your
option any later version.  A copy of the license should have been included with
your software.

\section{LedgerSMB::PGNumeric\label{LedgerSMB::PGNumeric}\index{LedgerSMB::PGNumeric}}




\subsection*{SYNPOSIS\label{LedgerSMB::PGNumeric_SYNPOSIS}\index{LedgerSMB::PGNumeric!SYNPOSIS}}


This is a wrapper class for handling a database interface for numeric (int, 
float, numeric) data types to/from the database and to/from user input.



This extends Math::BigFloat and can be used in this way.

\subsection*{INHERITS\label{LedgerSMB::PGNumeric_INHERITS}\index{LedgerSMB::PGNumeric!INHERITS}}
\begin{description}

\item[{Math::BigFloat}] \mbox{}\end{description}
\subsection*{SUPPORTED I/O FORMATS\label{LedgerSMB::PGNumeric_SUPPORTED_I_O_FORMATS}\index{LedgerSMB::PGNumeric!SUPPORTED I/O FORMATS}}
\begin{enumerate}

\item 00 (default)
\item ,00
\item 000.00
\item 000,00
\item ,000.00
\item 000,00
\item '000,00
\item '000.00\end{enumerate}
\subsection*{SUPPORTED NEGATIVE FORMATS\label{LedgerSMB::PGNumeric_SUPPORTED_NEGATIVE_FORMATS}\index{LedgerSMB::PGNumeric!SUPPORTED NEGATIVE FORMATS}}


All use 123.45 as an example.

\begin{description}

\item[{def (DEFAULT)}] \mbox{}

positive:  123.45
negative: -123.45


\item[{DRCR}] \mbox{}

positive:  123.45 CR
negative:  123.45 DR


\item[{paren}] \mbox{}

positive:  123.45
negative: (123.45)

\end{description}
\subsection*{IO METHODS\label{LedgerSMB::PGNumeric_IO_METHODS}\index{LedgerSMB::PGNumeric!IO METHODS}}
\begin{description}

\item[{from\_input(string \$input, hashref \%args);}] \mbox{}

The input is formatted.


\item[{to\_output(\$hashref or \%hash);}] \mbox{}

All arguments are optional.  Hash or hashref arguments include

\begin{description}

\item[{format}] \mbox{}

Override user's default output format with specified format for this number.


\item[{places}] \mbox{}

Specifies the number of places to round


\item[{money}] \mbox{}

Specifies to round to configured number format for money


\item[{neg\_format}] \mbox{}

Specifies the negative format


\item[{locale}] \mbox{}\end{description}

\item[{from\_db}] \mbox{}
\item[{to\_db}] \mbox{}\end{description}
\subsection*{Copyright (C) 2011, The LedgerSMB core team.\label{LedgerSMB::PGNumeric_Copyright_C_2011_The_LedgerSMB_core_team_}\index{LedgerSMB::PGNumeric!Copyright (C) 2011, The LedgerSMB core team.}}


This file is licensed under the Gnu General Public License version 2, or at your
option any later version.  A copy of the license should have been included with
your software.

\section{LedgerSMB::REST\_Format::json\label{LedgerSMB::REST_Format::json}\index{LedgerSMB::REST\ Format::json}}


JSON support for LedgerSMB RESTful web services.

\subsection*{SYNOPSYS\label{LedgerSMB::REST_Format::json_SYNOPSYS}\index{LedgerSMB::REST Format::json!SYNOPSYS}}


my \$hash = LedgerSMB::REST\_Format::json::from\_input(\$request);
my \$json = LedgerSMB::REST\_Format::json::to\_output(\$request);

\subsection*{COPYRIGHT\label{LedgerSMB::REST_Format::json_COPYRIGHT}\index{LedgerSMB::REST Format::json!COPYRIGHT}}


Copyright (C) 2012 The LedgerSMB Core Team.



This file may be used under the terms of the GNU General Public License 
version 2 or at your option any later version.  Please see the included
LICENSE.TXT file.

\section{LedgerSMB::REST\_Format::xml\label{LedgerSMB::REST_Format::xml}\index{LedgerSMB::REST\ Format::xml}}


XML file support for LedgerSMB RESTful web 
services.

\subsection*{SYNOPSYS\label{LedgerSMB::REST_Format::xml_SYNOPSYS}\index{LedgerSMB::REST Format::xml!SYNOPSYS}}


my \$hash = LedgerSMB::REST\_Format::xml::from\_input(\$request);
my \$xml = LedgerSMB::REST\_Format::xml::to\_output(\$request);

\subsection*{COPYRIGHT\label{LedgerSMB::REST_Format::xml_COPYRIGHT}\index{LedgerSMB::REST Format::xml!COPYRIGHT}}


Copyright (C) 2012 The LedgerSMB Core Team.



This file may be used under the terms of the GNU General Public License 
version 2 or at your option any later version.  Please see the included
LICENSE.TXT file.

\section{LedgerSMB::Template::ODS\label{LedgerSMB::Template::ODS}\index{LedgerSMB::Template::ODS}}


Template support module for LedgerSMB

\subsection*{SYNOPSIS\label{LedgerSMB::Template::ODS_SYNOPSIS}\index{LedgerSMB::Template::ODS!SYNOPSIS}}


OpenDocument Spreadsheet output.

\subsection*{METHODS\label{LedgerSMB::Template::ODS_METHODS}\index{LedgerSMB::Template::ODS!METHODS}}
\begin{description}

\item[{get\_template (\$name)}] \mbox{}

Returns the appropriate template filename for this format.  '.xlst' is the
extension that was chosen for the templates.


\item[{preprocess (\$vars)}] \mbox{}

Returns \$vars.


\item[{process (\$parent, \$cleanvars)}] \mbox{}

Processes the template for text.


\item[{postprocess (\$parent)}] \mbox{}

Returns the output filename.

\end{description}
\subsection*{Copyright (C) 2007, The LedgerSMB core team.\label{LedgerSMB::Template::ODS_Copyright_C_2007_The_LedgerSMB_core_team_}\index{LedgerSMB::Template::ODS!Copyright (C) 2007, The LedgerSMB core team.}}


This work contains copyrighted information from a number of sources all used
with permission.



It is released under the GNU General Public License Version 2 or, at your 
option, any later version.  See COPYRIGHT file for details.  For a full list 
including contact information of contributors, maintainers, and copyright 
holders, see the CONTRIBUTORS file.

\section{LedgerSMB::Template::CSV\label{LedgerSMB::Template::CSV}\index{LedgerSMB::Template::CSV}}


Template support module for LedgerSMB

\subsection*{METHODS\label{LedgerSMB::Template::CSV_METHODS}\index{LedgerSMB::Template::CSV!METHODS}}
\begin{description}

\item[{get\_template (\$name)}] \mbox{}

Returns the appropriate template filename for this format.


\item[{preprocess (\$vars)}] \mbox{}

Returns \$vars.


\item[{process (\$parent, \$cleanvars)}] \mbox{}

Processes the template for text.


\item[{postprocess (\$parent)}] \mbox{}

Returns the output filename.

\end{description}
\subsection*{Copyright (C) 2007, The LedgerSMB core team.\label{LedgerSMB::Template::CSV_Copyright_C_2007_The_LedgerSMB_core_team_}\index{LedgerSMB::Template::CSV!Copyright (C) 2007, The LedgerSMB core team.}}


This work contains copyrighted information from a number of sources all used
with permission.



It is released under the GNU General Public License Version 2 or, at your 
option, any later version.  See COPYRIGHT file for details.  For a full list 
including contact information of contributors, maintainers, and copyright 
holders, see the CONTRIBUTORS file.
=cut



package LedgerSMB::Template::CSV;



use warnings;
use strict;



use Error qw(:try);
use Template;
use LedgerSMB::Template::TTI18N;



my \$binmode = ':utf8';
binmode STDOUT, \$binmode;
binmode STDERR, \$binmode;



sub get\_template \{
	my \$name = shift;
	return "\$\{name\}.csv";
\}



sub preprocess \{
	my \$rawvars = shift;
	my \$vars;
        if (eval \{\$rawvars-$>$can('to\_output')\})\{
           \$rawvars = \$rawvars-$>$to\_output;
        \}
	my \$type = ref \$rawvars;

\begin{verbatim}
        #XXX fix escaping function
        return $rawvars if $type =~ /^LedgerSMB::Locale/;
        return unless defined $rawvars;
        if ( $type eq 'ARRAY' ) {
                for (@{$rawvars}) {
                        push @{$vars}, preprocess( $_ );
                }
        } elsif ( !$type or $type eq 'SCALAR' or $type eq 'Math::BigInt::GMP') { 
                        # Scalars or GMP objects (which are SCALAR refs) --CT
                if ($type eq 'SCALAR' or $type eq 'Math::BigInt::GMP') {
                        $vars = $$rawvars;
                } else {
                        $vars = $rawvars;
                }
                $vars =~ s/(^ +| +$)//g;
                $vars =~ s/"/""/g;
                $vars = qq|"$vars"| if $vars =~ /[^0-9.+-]/;
        } else { # hashes and objects
                for ( keys %{$rawvars} ) {
                        $vars->{$_} = preprocess( $rawvars->{$_} );
                }
        }
        return $vars;
}
\end{verbatim}


sub process \{
	my \$parent = shift;
	my \$cleanvars = shift;
	my \$template;
	my \$source;
	my \$output;
        \$parent-$>$\{binmode\} = \$binmode;

\begin{verbatim}
        if ($parent->{outputfile}) {
                $output = "$parent->{outputfile}.csv";
        } else {
                $output = \$parent->{output};
        }
        if (ref $parent->{template} eq 'SCALAR') {
                $source = $parent->{template};
        } elsif (ref $parent->{template} eq 'ARRAY') {
                $source = join "\n", @{$parent->{template}};
        } else {
                $source = get_template($parent->{template});
        }
        $template = Template->new({
                INCLUDE_PATH => [$parent->{include_path_lang}, $parent->{include_path}, 'UI/lib'],
                START_TAG => quotemeta('<?lsmb'),
                END_TAG => quotemeta('?>'),
                DELIMITER => ';',
                DEBUG => ($parent->{debug})? 'dirs': undef,
                DEBUG_FORMAT => '',
                }) || throw Error::Simple Template->error();
\end{verbatim}
\begin{verbatim}
        if (not $template->process(
                $source, 
                {%$cleanvars, %$LedgerSMB::Template::TTI18N::ttfuncs,
                        'escape' => \&preprocess},
                $output, binmode => ':utf8')) {
                throw Error::Simple $template->error();
        }
        $parent->{mimetype} = 'text/csv';
}
\end{verbatim}


sub postprocess \{
	my \$parent = shift;
	\$parent-$>$\{rendered\} = "\$parent-$>$\{outputfile\}.csv" if \$parent-$>$\{outputfile\};
        if (!\$parent-$>$\{rendered\})\{
            return "\$parent-$>$\{template\}.csv";
        \}
	return \$parent-$>$\{rendered\};
\}



sub escape \{
\}



1;

\section{LedgerSMB::Template::TTI18N\label{LedgerSMB::Template::TTI18N}\index{LedgerSMB::Template::TTI18N}}


Template Toolkit i18n support functions

\subsection*{SYNOPSIS\label{LedgerSMB::Template::TTI18N_SYNOPSIS}\index{LedgerSMB::Template::TTI18N!SYNOPSIS}}


Various functions for Template Toolkit templates for internationalisation
support.

\subsection*{METHODS\label{LedgerSMB::Template::TTI18N_METHODS}\index{LedgerSMB::Template::TTI18N!METHODS}}
\begin{description}

\item[{$<$?lsmb gettext(locale, 'string [\_1]',}] \textbf{param) ?$>$}

Output the gettext translation for the string in the given locale.  If
locale is a LedgerSMB::Locale object, it uses it.  If it is a string, the
locale is loaded, cached, and used.

\end{description}
\subsection*{Copyright (C) 2007, The LedgerSMB core team.\label{LedgerSMB::Template::TTI18N_Copyright_C_2007_The_LedgerSMB_core_team_}\index{LedgerSMB::Template::TTI18N!Copyright (C) 2007, The LedgerSMB core team.}}


This work contains copyrighted information from a number of sources all used
with permission.



It is released under the GNU General Public License Version 2 or, at your 
option, any later version.  See COPYRIGHT file for details.  For a full list 
including contact information of contributors, maintainers, and copyright 
holders, see the CONTRIBUTORS file.
=cut



package LedgerSMB::Template::TTI18N;



use LedgerSMB::Locale;



my \%locales; \# Cache string-loaded locales
our \$ttfuncs = \{\};



\$ttfuncs-$>$\{gettext\} = sub \{
	my \$locale = shift;
	if (ref \$locale) \{
		return \$locale-$>$text(@\_);
	\} elsif (\$locales\{\$locale\}) \{
		return \$locales\{\$locale\}-$>$text(@\_);
	\} else \{
		\$locales\{\$locale\} = LedgerSMB::Locale-$>$get\_handle(\$locale);
		return \$locales\{\$locale\}-$>$text(@\_);
	\}
\};

\section{LedgerSMB::Template::TXT\label{LedgerSMB::Template::TXT}\index{LedgerSMB::Template::TXT}}


Template support module for LedgerSMB

\subsection*{METHODS\label{LedgerSMB::Template::TXT_METHODS}\index{LedgerSMB::Template::TXT!METHODS}}
\begin{description}

\item[{get\_extension Private method to get extension.}] \textbf{Do not call directly.}
\item[{get\_template (\$name)}] \mbox{}

Returns the appropriate template filename for this format.


\item[{preprocess (\$vars)}] \mbox{}

Returns \$vars.


\item[{process (\$parent, \$cleanvars)}] \mbox{}

Processes the template for text.


\item[{postprocess (\$parent)}] \mbox{}

Returns the output filename.

\end{description}
\subsection*{Copyright (C) 2007, The LedgerSMB core team.\label{LedgerSMB::Template::TXT_Copyright_C_2007_The_LedgerSMB_core_team_}\index{LedgerSMB::Template::TXT!Copyright (C) 2007, The LedgerSMB core team.}}


This work contains copyrighted information from a number of sources all used
with permission.



It is released under the GNU General Public License Version 2 or, at your 
option, any later version.  See COPYRIGHT file for details.  For a full list 
including contact information of contributors, maintainers, and copyright 
holders, see the CONTRIBUTORS file.
=cut



package LedgerSMB::Template::TXT;



use warnings;
use strict;



use Error qw(:try);
use Template;
use LedgerSMB::Template::TTI18N;



my \$binmode = ':utf8';
binmode STDOUT, \$binmode;
binmode STDERR, \$binmode;



sub get\_extension \{
    my (\$parent) = shift;
    if (\$parent-$>$\{format\_args\}-$>$\{extension\})\{
        return \$parent-$>$\{format\_args\}-$>$\{extension\};
    \} else \{
        return 'txt';
    \}
\}



sub get\_template \{
    my (\$name, \$parent) = @\_;
    my \$extension;
    return "\$\{name\}.". get\_extension(\$parent);
\}



sub preprocess \{ \# TODO handling of objects with to\_output methods
    my \$rawvars = shift;
    return \$rawvars;
\}



sub process \{
	my \$parent = shift;
	my \$cleanvars = shift;
	my \$template;
	my \$source;
	my \$output;
        \$parent-$>$\{binmode\} = \$binmode;
	if (\$parent-$>$\{outputfile\}) \{
		\$output = "\$parent-$>$\{outputfile\}.". get\_extension(\$parent);
	\} else \{
		\$output = $\backslash$\$parent-$>$\{output\};
	\}
	if (ref \$parent-$>$\{template\} eq 'SCALAR') \{
		\$source = \$parent-$>$\{template\};
	\} elsif (ref \$parent-$>$\{template\} eq 'ARRAY') \{
		\$source = join "$\backslash$n", @\{\$parent-$>$\{template\}\};
	\} else \{
		\$source = get\_template(\$parent-$>$\{template\}, \$parent);
	\}
	\$template = Template-$>$new(\{
		INCLUDE\_PATH =$>$ [\$parent-$>$\{include\_path\_lang\}, \$parent-$>$\{include\_path\}, 'UI/lib'],
		START\_TAG =$>$ quotemeta('$<$?lsmb'),
		END\_TAG =$>$ quotemeta('?$>$'),
		DELIMITER =$>$ ';',
		DEBUG =$>$ (\$parent-$>$\{debug\})? 'dirs': undef,
		DEBUG\_FORMAT =$>$ '',
		\}) $|$$|$ throw Error::Simple Template-$>$error();

\begin{verbatim}
        if (not $template->process(
                $source, 
                {%$cleanvars, %$LedgerSMB::Template::TTI18N::ttfuncs,
                        'escape' => \&preprocess},
                $output, binmode => ':utf8')) {
                throw Error::Simple $template->error();
        }
        $parent->{mimetype} = 'text/plain';
}
\end{verbatim}


sub postprocess \{
    my (\$parent) = shift;
    if (!\$parent-$>$\{rendered\})\{
        return \$parent-$>$\{template\} . '.' . get\_extension(\$parent); 
    \}
    \$parent-$>$\{rendered\} = "\$parent-$>$\{outputfile\}.". get\_extension(\$parent) if \$parent-$>$\{outputfile\};
    return \$parent-$>$\{rendered\};
\}



1;

\section{LedgerSMB::Template::HTML\label{LedgerSMB::Template::HTML}\index{LedgerSMB::Template::HTML}}


Template support module for LedgerSMB

\subsection*{METHODS\label{LedgerSMB::Template::HTML_METHODS}\index{LedgerSMB::Template::HTML!METHODS}}
\begin{description}

\item[{get\_template (\$name)}] \mbox{}

Returns the appropriate template filename for this format.


\item[{preprocess (\$vars)}] \mbox{}

This method returns a reference to a hash that contains a copy of the passed
hashref's data with HTML entities converted to escapes.


\item[{process (\$parent, \$cleanvars)}] \mbox{}

Processes the template for HTML.


\item[{postprocess (\$parent)}] \mbox{}

Currently does nothing.


\item[{escape(\$string)}] \mbox{}

Escapes a scalar string and returns the sanitized version.

\end{description}
\subsection*{Copyright (C) 2007, The LedgerSMB core team.\label{LedgerSMB::Template::HTML_Copyright_C_2007_The_LedgerSMB_core_team_}\index{LedgerSMB::Template::HTML!Copyright (C) 2007, The LedgerSMB core team.}}


This work contains copyrighted information from a number of sources all used
with permission.



It is released under the GNU General Public License Version 2 or, at your 
option, any later version.  See COPYRIGHT file for details.  For a full list 
including contact information of contributors, maintainers, and copyright 
holders, see the CONTRIBUTORS file.
=cut



package LedgerSMB::Template::HTML;



use warnings;
use strict;



use Error qw(:try);
use CGI::Simple::Standard qw(:html);
use Template;
use LedgerSMB::Template::TTI18N;



my \$binmode = ':utf8';
binmode STDOUT, \$binmode;
binmode STDERR, \$binmode;



sub get\_template \{
    my \$name = shift;
    return "\$\{name\}.html";
\}



sub preprocess \{
    my \$rawvars = shift;
    my \$vars;
    if (eval \{\$rawvars-$>$can('to\_output')\})\{
        \$rawvars = \$rawvars-$>$to\_output;
    \}
    my \$type = ref \$rawvars;

\begin{verbatim}
    return $rawvars if $type =~ /^LedgerSMB::Locale/;
    return unless defined $rawvars;
    if ( $type eq 'ARRAY' ) {
        for (@{$rawvars}) {
            push @{$vars}, preprocess( $_ );
        }
    } elsif (!$type) {
        return escape($rawvars);
    } elsif ($type eq 'SCALAR' or $type eq 'Math::BigInt::GMP') {
        return escape($$rawvars);
    } elsif ($type eq 'CODE'){
        return $rawvars;
    } elsif ($type eq 'IO::File'){
        return undef;
    } else { # Hashes and objects
        for ( keys %{$rawvars} ) {
            $vars->{preprocess($_)} = preprocess( $rawvars->{$_} );
        }
    }
\end{verbatim}
\begin{verbatim}
    return $vars;
}
\end{verbatim}


sub escape \{
    my \$vars = shift @\_;
    if (defined \$vars)\{
        \$vars = escapeHTML(\$vars);
        \$vars =\texttt{\~{}} s$|$$\backslash$n$|$$<$br $\backslash$/$>$$|$gm;\#better syntax-look under gvim with escaped slash
        return \$vars;
    \}
    return undef;
\}



sub process \{
	my \$parent = shift;
	my \$cleanvars = shift;
	my \$template;
	my \$output;
	my \$source;
        \$parent-$>$\{binmode\} = \$binmode;

\begin{verbatim}
        if ($parent->{outputfile}) {
                $output = "$parent->{outputfile}.html";
        } else {
                $output = \$parent->{output};
        }
        if (ref $parent->{template} eq 'SCALAR') {
                $source = $parent->{template};
        } elsif (ref $parent->{template} eq 'ARRAY') {
                $source = join "\n", @{$parent->{template}};
        } else {
                $source = get_template($parent->{template});
        }
        my $tempdir;
        if ($LedgerSMB::Sysconfig::cache_templates){
            $tempdir = $LedgerSMB::Sysconfig::cache_template_dir;
        } else {
            $tempdir = undef;
        }
        $template = Template->new({
                INCLUDE_PATH => [$parent->{include_path_lang}, $parent->{include_path},'templates/demo','UI/lib'],
                ENCODING => 'utf8',
                START_TAG => quotemeta('<?lsmb'),
                END_TAG => quotemeta('?>'),
                DELIMITER => ';',
                TRIM => 1,
                COMPILE_DIR=> $tempdir,
                DEBUG => ($parent->{debug})? 'dirs': undef,
                DEBUG_FORMAT => '',
                }) || throw Error::Simple Template->error(); 
        if (not $template->process(
                $source, 
                {%$cleanvars, %$LedgerSMB::Template::TTI18N::ttfuncs,
                        'escape' => \&preprocess},
                $output, {binmode => ':utf8'})) {
                throw Error::Simple $template->error();
        }
        $parent->{mimetype} = 'text/html';
}
\end{verbatim}


sub postprocess \{
    my \$parent = shift;
    \$parent-$>$\{rendered\} = "\$parent-$>$\{outputfile\}.html" if \$parent-$>$\{outputfile\};
    return \$parent-$>$\{rendered\};
\}



1;

\section{LedgerSMB::Template::Elements\label{LedgerSMB::Template::Elements}\index{LedgerSMB::Template::Elements}}


Template Utility Functions

\subsection*{SYNOPSIS\label{LedgerSMB::Template::Elements_SYNOPSIS}\index{LedgerSMB::Template::Elements!SYNOPSIS}}


Provides utility functions for generating elements for the user interface
templates

\subsection*{METHODS\label{LedgerSMB::Template::Elements_METHODS}\index{LedgerSMB::Template::Elements!METHODS}}
\begin{description}

\item[{LedgerSMB::Template::Elements-$>$new()}] \mbox{}

Returns a blessed hashref from this namespace.

\end{description}
\begin{description}

\item[{\$object-$>$generate\_hidden\_elements([...]);}] \mbox{}

Builds data structure for hidden form fields.  Values from the
\$form object are run through \$form-$>$quote.



Sample data structure added to \$form-$>$hidden\_elements():

\begin{verbatim}
 $self->{form_elements}{hidden_elements} = [{ type => 'hidden', name => 'foo', value => 'bar'... } ...]
\end{verbatim}


A reference to this structure is returned as well.

\end{description}
\begin{description}

\item[{\$form-$>$generate\_radio\_elements(\$radios);}] \mbox{}

Roll out a single radios hash to an array of radio elements,
using the values array as index.



Sample data structure added to \$form-$>$generate\_radio\_elements(\$radios):



my \$radios = \{
    name =$>$ 'radio\_name',
    class =$>$ 'radio',
    attributes =$>$ \{ foo =$>$ 'bar' \},
    values =$>$ [ '1', '2', '3'],
    labels =$>$ [ 'Label one', '', 'Label three'],
    default\_value =$>$ '2',
\};

\end{description}
\begin{description}

\item[{\$form-$>$generate\_checkbox\_elements(\$checkboxes);}] \mbox{}

Roll out a single checkboxes hash to an array of checkbox elements,
using the names array as index.  Note that if no 'values' array
is passed, value for all checkboxes default to 1.



Sample data structure added to \$form-$>$generate\_checkbox\_elements(\$checkboxes):



my \$checkboxes = \{
    names =$>$ [
        'checkbox\_name1',
        'checkbox\_name2',
        'checkbox\_name3',
    ],
    class =$>$ 'checkbox',
    attributes =$>$ \{ foo =$>$ 'bar' \},
    values =$>$ [ '4', '', '3'],
    labels =$>$ [ 'Label one', '', 'Label three'],
    default\_values =$>$ [ 'checkbox\_name1'],



\};

\end{description}
\section{LedgerSMB::Template::LaTeX\label{LedgerSMB::Template::LaTeX}\index{LedgerSMB::Template::LaTeX}}


Template support module for LedgerSMB

\subsection*{SYNOPSIS\label{LedgerSMB::Template::LaTeX_SYNOPSIS}\index{LedgerSMB::Template::LaTeX!SYNOPSIS}}


Muxed LaTeX rendering support.  Handles PDF, Postscript, and DVI output.

\subsection*{DETAILS\label{LedgerSMB::Template::LaTeX_DETAILS}\index{LedgerSMB::Template::LaTeX!DETAILS}}


The final output format is determined by the format\_option of filetype.  The
valid filetype specifiers are 'pdf', 'ps', and 'dvi'.

\subsection*{METHODS\label{LedgerSMB::Template::LaTeX_METHODS}\index{LedgerSMB::Template::LaTeX!METHODS}}
\begin{description}

\item[{get\_template (\$name)}] \mbox{}

Returns the appropriate template filename for this format.


\item[{preprocess (\$vars)}] \mbox{}

Currently does nothing.


\item[{process (\$parent, \$cleanvars)}] \mbox{}

Processes the template for the appropriate output format.


\item[{postprocess (\$parent)}] \mbox{}

Currently does nothing.


\item[{escape(\$string)}] \mbox{}

Escapes a scalar string and returns the sanitized version.

\end{description}
\subsection*{Copyright (C) 2007, The LedgerSMB core team.\label{LedgerSMB::Template::LaTeX_Copyright_C_2007_The_LedgerSMB_core_team_}\index{LedgerSMB::Template::LaTeX!Copyright (C) 2007, The LedgerSMB core team.}}


This work contains copyrighted information from a number of sources all used
with permission.



It is released under the GNU General Public License Version 2 or, at your 
option, any later version.  See COPYRIGHT file for details.  For a full list 
including contact information of contributors, maintainers, and copyright 
holders, see the CONTRIBUTORS file.
=cut



package LedgerSMB::Template::LaTeX;



use warnings;
use strict;



use Error qw(:try);
use Template::Latex;
use LedgerSMB::Template::TTI18N;
use Log::Log4perl;



\#my \$binmode = ':utf8';
my \$binmode = ':raw';
binmode STDOUT, \$binmode;
binmode STDERR, \$binmode;



my \$logger = Log::Log4perl-$>$get\_logger('LedgerSMB::Template::LaTeX');



sub get\_template \{
	my \$name = shift;
	return "\$\{name\}.tex";
\}



sub preprocess \{
	my \$rawvars = shift;
	my \$vars;
        if (eval \{\$rawvars-$>$can('to\_output')\})\{
           \$rawvars = \$rawvars-$>$to\_output;
        \}
	my \$type = ref \$rawvars;

\begin{verbatim}
        return $rawvars if $type =~ /^LedgerSMB::Locale/;
        return unless defined $type;
        if ($type eq 'ARRAY') {
                for (@{$rawvars}) {
                        push @{$vars}, preprocess($_);
                }
        } elsif (!$type or $type eq 'SCALAR' or $type eq 'Math::BigInt::GMP'
                or $type eq 'CODE'
        ) {
                if ($type eq 'SCALAR' or $type eq 'Math::BigInt::GMP') {
                        $vars = $$rawvars;
                } else {
                        $vars = $rawvars;
                }
                #XXX Fix escaping
                $vars = escape($vars);
        } else {
                for ( keys %{$rawvars} ) {
                        $vars->{$_} = preprocess($rawvars->{$_});
                }
        }
        return $vars;
}
\end{verbatim}


my \%escapes = (
   '\&' =$>$ '$\backslash$$\backslash$\&',
   '\$' =$>$ '$\backslash$$\backslash$\$',
   '$\backslash$$\backslash$' =$>$ '\{$\backslash$$\backslash$textbackslash\}',
   '\_' =$>$ '$\backslash$$\backslash$\_',
   '$<$' =$>$ '$\backslash$$\backslash$$<$',
   '$>$' =$>$ '$\backslash$$\backslash$$>$',
   '\texttt{\~{}}' =$>$ '$\backslash$$\backslash$\texttt{\~{}}',
   '\^{}' =$>$ '$\backslash$$\backslash$\^{}',
   '\#' =$>$ '$\backslash$$\backslash$\#',
   '\%' =$>$ '$\backslash$$\backslash$\%',
   '\{' =$>$ '$\backslash$$\backslash$\{',
   '\}' =$>$ '$\backslash$$\backslash$\}',
  );



\# Breaking this off to be used separately.
sub escape \{
    my (\$vars) = shift @\_;

\begin{verbatim}
    if (defined $vars){
            $vars =~ s/([&\$\\_<>~^#\%\{\}])/$escapes{$1}/g;
            $vars =~ s/–/--/g;
            $vars =~ s/[—―]/---/g;
            $vars =~ s/"(.*)"/``$1''/gs;
            $vars =~ s/\n/\\\\/gm;
            $vars =~ s/\\\\\\\\/\n\n/g;
    }
    return $vars;
}
\end{verbatim}


sub process \{
	my \$parent = shift;
	my \$cleanvars = shift;
	my \$template;
	my \$source;
	\$parent-$>$\{outputfile\} $|$$|$=
		"\$\{LedgerSMB::Sysconfig::tempdir\}/\$parent-$>$\{template\}-output-\$\$";

\begin{verbatim}
        $parent->{binmode} = $binmode;
        if (ref $parent->{template} eq 'SCALAR') {
                $source = $parent->{template};
        } elsif (ref $parent->{template} eq 'ARRAY') {
                $source = join "\n", @{$parent->{template}};
        } else {
                $source = get_template($parent->{template});
        }
        $Template::Latex::DEBUG = 1 if $parent->{debug};
        my $format = 'ps';
        if ($parent->{format_args}{filetype} eq 'dvi') {
                $format = 'dvi';
        } elsif ($parent->{format_args}{filetype} eq 'pdf') {
                $format = 'pdf';
        }
        $template = Template::Latex->new({
                LATEX_FORMAT => $format,
                INCLUDE_PATH => [$parent->{include_path_lang}, $parent->{include_path},'templates/demo','UI/lib'],
                START_TAG => quotemeta('<?lsmb'),
                END_TAG => quotemeta('?>'),
                DELIMITER => ';',
                ENCODING => 'utf8',
                DEBUG => ($parent->{debug})? 'dirs': undef,
                DEBUG_FORMAT => '',
                }) || throw Error::Simple Template::Latex->error(); 
        if (not $template->process(
                $source, 
                {%$cleanvars, %$LedgerSMB::Template::TTI18N::ttfuncs,
                        'escape' => \&preprocess},
                "$parent->{outputfile}.$format", {binmode => 1})) {
                throw Error::Simple $template->error();
        }
        if (lc $format eq 'dvi') {
                $parent->{mimetype} = 'application/x-dvi';
        } elsif (lc $format eq 'pdf') {
                $parent->{mimetype} = 'application/pdf';
        } else {
                $parent->{mimetype} = 'application/postscript';
        }
        $parent->{rendered} = "$parent->{outputfile}.$format";
}
\end{verbatim}


sub postprocess \{
	my \$parent = shift;
	return \$parent-$>$\{rendered\};
\}



1;

\section{LedgerSMB::Template\label{LedgerSMB::Template}\index{LedgerSMB::Template}}


Template support module for LedgerSMB

\subsection*{SYNOPSIS\label{LedgerSMB::Template_SYNOPSIS}\index{LedgerSMB::Template!SYNOPSIS}}


This module renders templates.

\subsection*{METHODS\label{LedgerSMB::Template_METHODS}\index{LedgerSMB::Template!METHODS}}
\begin{description}

\item[{new(user =$>$ $\backslash$\%myconfig, template}] \textbf{=$>$ \$string, format =$>$ \$string, [locale =$>$ \$locale] [language =$>$ \$string], [include\_path =$>$ \$path], [no\_auto\_output =$>$ \$bool], [method =$>$ \$string], [no\_escape =$>$ \$bool], [debug =$>$ \$bool], [output\_file =$>$ \$string] );}

This command instantiates a new template:

\begin{description}

\item[{template}] \mbox{}

The template to be processed.  This can either be a reference to the template
in string form or the name of the file that is the template to be processed.


\item[{format}] \mbox{}

The format to be used.  Currently HTML, PS, PDF, TXT and CSV are supported.


\item[{format\_options (optional)}] \mbox{}

A hash of format-specific options.  See the appropriate LSMB::T::foo for
details.


\item[{output\_options (optional)}] \mbox{}

A hash of output-specific options.  See the appropriate output method for
details.


\item[{locale (optional)}] \mbox{}

The locale object to use for regular gettext lookups.  Having this option adds
the text function to the usable list for the templates.  Has no effect on the
gettext function.


\item[{language (optional)}] \mbox{}

The language for template selection.


\item[{include\_path (optional)}] \mbox{}

Overrides the template directory.  Used with user interface templates.


\item[{no\_auto\_output (optional)}] \mbox{}

Disables the automatic output of rendered templates.


\item[{no\_escape (optional)}] \mbox{}

Disables escaping on the template variables.


\item[{debug (optional)}] \mbox{}

Enables template debugging.



With the TT-based renderers, HTML, PS, PDF, TXT, and CSV, the portion of the
template to get debugging messages is to be surrounded by
$<$?lsmb DEBUG format 'foo' ?$>$ statements.  Example:

\begin{verbatim}
    <tr><td colspan="<?lsmb columns.size ?>"></td></tr>
    <tr class="listheading">
  <?lsmb FOREACH column IN columns ?>
  <?lsmb DEBUG format '$file line $line : [% $text %]' ?>
      <th class="listtop"><?lsmb heading.$column ?></th>
  <?lsmb DEBUG format '' ?>
  <?lsmb END ?>
    </tr>
\end{verbatim}

\item[{method/media (optional)}] \mbox{}

The output method to use, defaults to HTTP.  Media is a synonym for method


\item[{output\_file (optional)}] \mbox{}

The base name of the file for output.

\end{description}

\item[{available\_formats()}] \mbox{}

Returns a list of format names, any of the following (in order) as applicable:

\begin{description}

\item[{HTML (always available)}] \mbox{}
\item[{TXT (includes CSV, always available))}] \mbox{}
\item[{PDF}] \mbox{}
\item[{PS}] \mbox{}
\item[{XLS}] \mbox{}
\item[{ODS}] \mbox{}\end{description}

\item[{new\_UI(user =$>$ $\backslash$\%myconfig,}] \textbf{locale =$>$ \$locale, template =$>$ \$file, ...)}

Wrapper around the constructor that sets the path to 'UI', format to 'HTML',
and leaves auto-output enabled.


\item[{render(\$hashref)}] \mbox{}

This command renders the template.  If no\_auto\_output was not specified during
instantiation, this also writes the result to standard output and exits.
Otherwise it returns the name of the output file if a file was created.  When
no output file is created, the output is held in \$self-$>$\{output\}.



Currently email and server-side printing are not supported.


\item[{output}] \mbox{}

This function outputs the rendered file in an appropriate manner.


\item[{my \$bool = \_valid\_language()}] \mbox{}

This command checks for valid langages.  Returns 1 if the language is valid, 
0 if it is not.


\item[{column\_heading()}] \mbox{}

Apply locale settings to column headings and add sort urls if necessary.


\item[{escape(\$string)}] \mbox{}

Escapes a scalar string if the format supports such escaping and returns the
sanitized version.

\end{description}
\subsection*{Copyright 2007, The LedgerSMB Core Team\label{LedgerSMB::Template_Copyright_2007_The_LedgerSMB_Core_Team}\index{LedgerSMB::Template!Copyright 2007, The LedgerSMB Core Team}}


This file is licensed under the GNU General Public License version 2, or at your
option any later version.  A copy of the license should have been included with
your software.

\section{SYNPOSIS
This class handles formatting and mapping between the DateTime module and
PostgreSQL. It provides a handler for date and timestamp datatypes.\label{SYNPOSIS_This_class_handles_formatting_and_mapping_between_the_DateTime_module_and_PostgreSQL_It_provides_a_handler_for_date_and_timestamp_datatypes_}\index{SYNPOSIS
This class handles formatting and mapping between the DateTime module and
PostgreSQL. It provides a handler for date and timestamp datatypes.}}
\section{PROPERTIES\label{PROPERTIES}\index{PROPERTIES}}
\begin{description}

\item[{date A DateTime object for internal storage}] \textbf{and processing.}\end{description}
\section{SUPPORTED FORMATS\label{SUPPORTED_FORMATS}\index{SUPPORTED FORMATS}}


Formats are written with hyphens as separators.  You can actually use any other
character other than D, M, or Y as the separator, so instead of YYYY-MM-DD, you
could have YYYY/MM/DD, YYYY!MM!DD, etc.



On the database side, these are all converted to YYYY-MM-DD format.

\begin{description}

\item[{'YYYY-MM-DD'}] \mbox{}
\item[{DD-MM-YYYY}] \mbox{}
\item[{DD/MM/YYYY}] \mbox{}
\item[{MM-DD-YYYY}] \mbox{}
\item[{MM/DD/YYYY}] \mbox{}
\item[{YYYYMMDD}] \mbox{}
\item[{YYMMDD}] \mbox{}
\item[{DDMMYYYY}] \mbox{}
\item[{DDMMYY}] \mbox{}
\item[{MMDDYYYY}] \mbox{}
\item[{MMDDYY}] \mbox{}
\item[{DDmonYYYY}] \mbox{}\end{description}
\section{CONSTRUCTOR SYNTAX\label{CONSTRUCTOR_SYNTAX}\index{CONSTRUCTOR SYNTAX}}


LedgerSMB::PgDate-$>$new(\{ date =$>$ DateTime-$>$new(year =$>$ 2012, day =$>$ 31, month =$>$
12)\});



Note the constructor here is private, and not intended to be called directly.



Use from\_db and from\_input methods instead since these handle appropriately 
different formats and handle construction differently.

\section{METHODS\label{METHODS}\index{METHODS}}
\begin{description}

\item[{from\_input(\$string date, optional \$has\_time)}] \mbox{}

Parses this from an input string according to the user's dateformat



Input parsing iterates through formats specified for the format string.  If
\$has\_time is set and true, or if it is not defined then ' \%T' is added to the
end of the format string.  Similarly, if \$has\_time is undef or set and false,
the format is used as is.  This allows the calling scripts to specify either
that the string includes a time portion or that it does not, and allows this
module to handle the parsing.


\item[{to\_output(optional string \$format)}] \mbox{}

This returns the human readable formatted date.  If \$format is supplied, it is 
used.  If \$format is not supplied, the dateformat of the user is used.


\item[{from\_db (string \$date, string \$type)}] \mbox{}

The \$date is the date or datetime value from the db. The type is either 'date',
'timestamp', or 'datetime'.


\item[{to\_db This returns the preferred form for}] \textbf{database queries.}\end{description}
\section{Copyright (C) 2011, The LedgerSMB core team.\label{Copyright_C_2011_The_LedgerSMB_core_team_}\index{Copyright (C) 2011, The LedgerSMB core team.}}


This file is licensed under the Gnu General Public License version 2, or at your
option any later version.  A copy of the license should have been included with
your software.

