[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SF.net SVN: ledger-smb:[3365] trunk



Revision: 3365
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=3365&view=rev
Author:   einhverfr
Date:     2011-06-28 09:36:18 +0000 (Tue, 28 Jun 2011)

Log Message:
-----------

* Changed getting tax accounts to use account.tax instead of account_link_description
* Added and revised doc strings for Account.sql, chart.sql, scripts/account.pl and LedgerSMB/DBObject/Account.pm

Modified Paths:
--------------
    trunk/LedgerSMB/DBObject/Account.pm
    trunk/scripts/account.pl
    trunk/sql/modules/Account.sql
    trunk/sql/modules/chart.sql

Modified: trunk/LedgerSMB/DBObject/Account.pm
===================================================================
--- trunk/LedgerSMB/DBObject/Account.pm	2011-06-28 06:17:28 UTC (rev 3364)
+++ trunk/LedgerSMB/DBObject/Account.pm	2011-06-28 09:36:18 UTC (rev 3365)
@@ -7,6 +7,14 @@
 This class contains methods for managing chart of accounts entries (headings 
 and accounts).
 
+=head1 INERITS
+
+=over
+
+=item LedgerSMB::DBObject
+
+=back
+
 =head1 METHODS
 
 =cut
@@ -21,6 +29,21 @@
 
 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.
+
 =cut
 
 sub save {

Modified: trunk/scripts/account.pl
===================================================================
--- trunk/scripts/account.pl	2011-06-28 06:17:28 UTC (rev 3364)
+++ trunk/scripts/account.pl	2011-06-28 09:36:18 UTC (rev 3365)
@@ -5,8 +5,35 @@
 use Data::Dumper;
 use strict;
 
+=pod
+
+=head1 NAME
+
+LedgerSMB:Scripts::account, LedgerSMB workflow scripts for managing accounts
+
+=head1 SYNOPSIS
+
+This module contains the workflows for managing chart of accounts entries.
+
+In prior versions of LedgerSMB, these were found in the AM.pm.  In the current 
+version, these have been broken out and given their own API which is more 
+maintainable.
+    
+=head1 METHODS
+        
+=over   
+        
+=cut
+
+
 my $logger = Log::Log4perl::get_logger("LedgerSMB::DBObject::Account");
 
+=item new
+
+Displays a screen to create a new account.
+
+=cut
+
 sub new {
     my ($request) = @_;
     $request->{title} = $request->{_locale}->text('Add Account');
@@ -14,6 +41,14 @@
     _display_account_screen($request);     
 }
 
+=edit
+
+Retrieves account information and then displays the screen.  
+
+Requires the id variable in the request to be set.
+
+=cut
+
 sub edit {
     my ($request) = @_;
     $request->{chart_id} = $request->{id};
@@ -25,6 +60,23 @@
     _display_account_screen($a);
 }
 
+=item save
+
+Saves the account.
+
+Request variables
+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.
+
+=cut
+
 sub save {
     my ($request) = @_;
     my $account = LedgerSMB::DBObject::Account->new(base => $request);
@@ -32,6 +84,12 @@
     edit($request); 
 }
 
+=item save_as_new
+
+Saves as a new account.  Deletes the id field and then calls save()
+
+=cut
+
 sub save_as_new {
     my ($request) = @_;
     delete $request->{id};
@@ -103,6 +161,12 @@
 
 }
 
+=item yearend_info
+
+Shows the yearend screen.  No expected inputs.
+
+=cut
+
 sub yearend_info {
     use LedgerSMB::DBObject::EOY;
     my ($request) = @_;
@@ -117,6 +181,18 @@
     $template->render($eoy);
 }
 
+=item post_yearend
+
+Posts a year-end closing transaction.
+
+Request variables expected:
+end_date: Date for the yearend transaction.  
+reference: GL Source identifier.
+description: Description of transaction
+in_retention_acc_id: Account id to post retained earnings into
+
+=cut
+
 sub post_yearend {
     use LedgerSMB::DBObject::EOY;
     my ($request) = @_;
@@ -131,6 +207,15 @@
     
 }
 
-# From AM.pm, modified for better API.
+=back
 
+=head1 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.
+
+=cut
+
+
 1;

Modified: trunk/sql/modules/Account.sql
===================================================================
--- trunk/sql/modules/Account.sql	2011-06-28 06:17:28 UTC (rev 3364)
+++ trunk/sql/modules/Account.sql	2011-06-28 09:36:18 UTC (rev 3365)
@@ -6,22 +6,29 @@
      select * from account where accno = $1;
 $$ language sql;
 
+COMMENT ON FUNCTION account__get_from_accno(in_accno text) IS
+$$ Returns the account where the accno field matches (excatly) the 
+in_accno provided.$$;
 
 CREATE OR REPLACE FUNCTION account__get_taxes()
 RETURNS setof account AS
 $$
 SELECT * FROM account 
- WHERE id IN (select account_id from account_link 
-               where description ilike '%tax%')
+ WHERE tax is true
 ORDER BY accno;
 $$ language sql;
 
+COMMENT ON FUNCTION account__get_taxes() IS
+$$ Returns set of accounts where the tax attribute is true.$$;
 
 CREATE OR REPLACE FUNCTION account_get (in_id int) RETURNS setof chart AS
 $$
 SELECT * from chart where id = $1 and charttype = 'A';
 $$ LANGUAGE sql;
 
+COMMENT ON FUNCTION account_get(in_id int) IS
+$$Returns an entry from the chart view which matches the id requested, and which
+is an account, not a heading.$$;
 
 CREATE OR REPLACE FUNCTION account_heading_get (in_id int) RETURNS chart AS
 $$
@@ -33,6 +40,9 @@
 END;
 $$ LANGUAGE plpgsql;
 
+COMMENT ON FUNCTION account_heading_get(in_id int) IS
+$$Returns an entry from the chart view which matches the id requested, and which
+is a heading, not an account.$$;
 
 CREATE OR REPLACE FUNCTION account_has_transactions (in_id int) RETURNS bool AS
 $$
@@ -46,6 +56,9 @@
 END;
 $$ LANGUAGE plpgsql;
 
+COMMENT ON FUNCTION account_has_transactions (in_id int) IS
+$$ Checks to see if any transactions use this account.  If so, returns true.
+If not, returns false.$$;
 
 CREATE OR REPLACE FUNCTION account_save 
 (in_id int, in_accno text, in_description text, in_category char(1), 
@@ -116,13 +129,29 @@
 END;
 $$ language plpgsql;
 
+COMMENT ON FUNCTION account_save
+(in_id int, in_accno text, in_description text, in_category char(1),
+in_gifi_accno text, in_heading int, in_contra bool, in_tax bool,
+in_link text[]) IS
+$$ This deletes existing account_link entries, where the 
+account_link.description is not designated as a custom one in the 
+account_link_description table.
 
+If no account heading is provided, the account heading which has an accno field
+closest to but prior (by collation order) is used.
+
+Then it saves the account information, and rebuilds the account_link records 
+based on the in_link array.
+$$;
+
 CREATE OR REPLACE FUNCTION account_heading_list()
 RETURNS SETOF account_heading AS
 $$
 SELECT * FROM account_heading order by accno;
 $$ language sql;
 
+COMMENT ON FUNCTION account_heading_list() IS
+$$ Lists all existing account headings.$$;
 
 CREATE OR REPLACE FUNCTION account_heading_save 
 (in_id int, in_accno text, in_description text, in_parent int)
@@ -145,6 +174,9 @@
 END;
 $$ LANGUAGE PLPGSQL;
 
+COMMENT ON FUNCTION account_heading_save
+(in_id int, in_accno text, in_description text, in_parent int) IS
+$$ Saves an account heading. $$;
 
 CREATE OR REPLACE RULE chart_i AS ON INSERT TO chart
 DO INSTEAD
@@ -175,17 +207,29 @@
     END;
 $BODY$ LANGUAGE PLPGSQL;
 
+COMMENT ON FUNCTION cr_coa_to_account_save(in_accno text, in_description text)
+IS $$ Provides default rules for setting reconciliation labels.  Currently 
+saves a label of accno ||'--' || description.$$;
+
 CREATE OR REPLACE FUNCTION account__get_by_link_desc(in_description text)
 RETURNS SETOF account AS $$
 SELECT * FROM account
 WHERE id IN (SELECT account_id FROM account_link WHERE description = $1);
 $$ language sql;
 
-CREATE OR REPLACE FUNCTION get_link_descriptions() RETURNS SETOF account_link_description AS
+COMMENT ON FUNCTION account__get_by_link_desc(in_description text) IS
+$$ Gets a list of accounts with a specific link description set.  For example,
+for a dropdown list.$$;
+
+CREATE OR REPLACE FUNCTION get_link_descriptions() 
+RETURNS SETOF account_link_description AS
 $$
     SELECT * FROM account_link_description;
 $$ LANGUAGE SQL;
 
+COMMENT ON FUNCTION get_link_descriptions() IS
+$$ Gets a set of all valid account_link descriptions.$$;
+
 CREATE OR REPLACE FUNCTION account__save_tax
 (in_chart_id int, in_validto date, in_rate numeric, in_taxnumber text, 
 in_pass int, in_taxmodule_id int, in_old_validto date)
@@ -211,4 +255,8 @@
 
 END;
 $$ language plpgsql;
-     
+
+COMMENT ON FUNCTION account__save_tax
+(in_chart_id int, in_validto date, in_rate numeric, in_taxnumber text,
+in_pass int, in_taxmodule_id int, in_old_validto date) IS
+$$ This saves tax rates.$$; 

Modified: trunk/sql/modules/chart.sql
===================================================================
--- trunk/sql/modules/chart.sql	2011-06-28 06:17:28 UTC (rev 3364)
+++ trunk/sql/modules/chart.sql	2011-06-28 09:36:18 UTC (rev 3365)
@@ -69,6 +69,12 @@
 END;
 $$ language plpgsql;
 
+COMMENT ON FUNCTION report_trial_balance 
+(in_datefrom date, in_dateto date, in_department_id int, in_project_id int,
+in_gifi bool) IS
+$$ This is a simple routine to generate trial balances for the full
+company, for a project, or for a department.$$;
+
 CREATE OR REPLACE FUNCTION chart_list_all()
 RETURNS SETOF chart AS
 $$
@@ -82,6 +88,9 @@
 END;
 $$ LANGUAGE PLPGSQL;
 
+COMMENT ON FUNCTION chart_list_all() IS
+$$ Generates a list of chart view entries.$$;
+
 CREATE OR REPLACE FUNCTION chart_get_ar_ap(in_account_class int)
 RETURNS SETOF chart AS
 $$
@@ -101,30 +110,41 @@
        END LOOP;
 END;
 $$ LANGUAGE PLPGSQL;
+
 COMMENT ON FUNCTION chart_get_ar_ap(in_account_class int) IS
-$$ This function returns the cash account acording with in_account_class which must be 1 or 2 $$;
+$$ This function returns the cash account acording with in_account_class which 
+must be 1 or 2.
 
-CREATE OR REPLACE FUNCTION chart_list_search(search text, link_desc text)
+If in_account_class is 1 then it returns a list of AP accounts, and if 
+in_account_class is 2, then a list of AR accounts.$$;
+
+CREATE OR REPLACE FUNCTION chart_list_search(in_search text, in_link_desc text)
 RETURNS SETOF account AS
 $$
 DECLARE out_row account%ROWTYPE;
 BEGIN
 	FOR out_row IN 
 		SELECT * FROM account 
-                 WHERE (accno ~* ('^'||search) 
-                       OR description ~* ('^'||search))
+                 WHERE (accno ~* ('^'||in_search) 
+                       OR description ~* ('^'||in_search))
                        AND (link_desc IS NULL 
                            or id in 
                           (select account_id from account_link 
-                            where description = link_desc))
+                            where description = in_link_desc))
               ORDER BY accno
 	LOOP
 		RETURN next out_row;
 	END LOOP;
 END;$$
 LANGUAGE 'plpgsql';
-							
 
+COMMENT ON FUNCTION chart_list_search(in_search text, in_link_desc text) IS
+$$ This returns a list of account entries where the description or account 
+number begins with in_search.
+
+If in_link_desc is provided, the list is further filtered by which accounts are 
+set to an account_link.description equal to that provided.$$;
+
 CREATE OR REPLACE FUNCTION chart_list_overpayment(in_account_class int)
 RETURNS SETOF chart AS
 $$
@@ -147,6 +167,10 @@
 END;
 $$ language plpgsql;
 
+COMMENT ON FUNCTION chart_list_overpayment(in_account_class int) is
+$$ Returns a list of AP_overpayment accounts if in_account_class is 1
+Otherwise it returns a list of AR_overpayment accounts.$$;
+
 CREATE OR REPLACE FUNCTION chart_list_cash(in_account_class int)
 returns setof chart
 as $$
@@ -169,8 +193,12 @@
  END;
 $$ language plpgsql;
 COMMENT ON FUNCTION chart_list_cash(in_account_class int) IS
-$$ This function returns the overpayment accounts acording with in_account_class which must be 1 or 2 $$;
+$$ This function returns the overpayment accounts acording with 
+in_account_class which must be 1 or 2.
 
+If in_account_class is 1 it returns a list of AP cash accounts and 
+if 2, AR cash accounts.$$;
+
 CREATE OR REPLACE FUNCTION chart_list_discount(in_account_class int)
 RETURNS SETOF chart AS
 $$
@@ -194,4 +222,8 @@
 $$ language plpgsql;
 
 COMMENT ON FUNCTION chart_list_discount(in_account_class int) IS
-$$ This function returns the discount accounts acording with in_account_class which must be 1 or 2 $$;
+$$ This function returns the discount accounts acording with in_account_class 
+which must be 1 or 2.
+
+If in_account_class is 1, returns AP discount accounts, if 2, AR discount 
+accounts.$$;


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.