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

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



Revision: 3459
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=3459&view=rev
Author:   einhverfr
Date:     2011-07-07 12:01:14 +0000 (Thu, 07 Jul 2011)

Log Message:
-----------
Fixed unloadable database, more fixed asset docstrings

Modified Paths:
--------------
    trunk/LedgerSMB/DBObject/Asset.pm
    trunk/LedgerSMB/DBObject/Asset_Class.pm
    trunk/LedgerSMB/DBObject/Asset_Report.pm
    trunk/sql/Pg-database.sql
    trunk/sql/modules/Assets.sql
    trunk/sql/modules/Location.sql
    trunk/sql/modules/Roles.sql
    trunk/sql/modules/admin.sql

Modified: trunk/LedgerSMB/DBObject/Asset.pm
===================================================================
--- trunk/LedgerSMB/DBObject/Asset.pm	2011-07-07 10:33:08 UTC (rev 3458)
+++ trunk/LedgerSMB/DBObject/Asset.pm	2011-07-07 12:01:14 UTC (rev 3459)
@@ -9,11 +9,98 @@
 This library contains the base utility functions for creating, saving, and
 retrieving fixed assets for depreciation
 
+=head1 STANDARD PROPERTIES
+
+=over
+
+=item id (integer)
+
+Unique id number of asset.
+
+=item description (text)
+
+Text description of asset.
+
+=item tag (text)
+
+Arbitrary tag identifier, unique for current, non-disposed assets.
+
+=item purchase_value (numeric)
+
+Numeric representation of purchase value.
+ 
+=item salvage_value (numeric)
+
+Numeric representation of estimated salvage value.
+
+=item usable_life (numeric)
+
+Numeric representation of estimated usable life.
+
+=item purchase_date (date)
+
+Date item was purchase
+
+=item start_depreciation (date)
+
+Date item is put into service, when depreciation should start.  If unknown
+we use the purchase_date instead.
+
+=item location_id (int)
+
+ID of business location where asset is stored.
+
+=item department_id (int)
+
+ID of department where asset is stored
+
+=item invoice_id (int)
+
+ID of purchasing invoice
+
+=item asset_account_id (int)
+
+ID of account to store asset value
+
+=item dep_account_id (int)
+
+ID of account to store cumulative depreciation
+
+=item exp_account_id (int)
+
+ID of account to store expense when disposed of.
+
+=item obsolete_by (int)
+
+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)
+
+ID of asset class.
+
+=back
+
+=head1 METHODS
+
+=over
+
 =cut
 
 use base qw(LedgerSMB::DBObject);
 use strict;
 
+=item save
+
+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).
+
+=cut
+
 sub save {
     my ($self) = @_;
     my ($ref) = $self->exec_method(funcname => 'asset__save');
@@ -25,6 +112,16 @@
     return $ref if $self->{dbh}->commit;
 }
 
+=item import_file
+
+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}.
+
+=cut
+
 sub import_file {
 
     my $self = shift @_;
@@ -52,11 +149,17 @@
         }
         push @{$self->{import_entries}}, ..hidden..;
     }     
-    unshift @{$self->{import_entries}}; # get rid of header line
+                   # get rid of header line
+    @{$self->{import_header}} = unshift @{$self->{import_entries}}; 
     return @{$self->{import_entries}};
 }
 
+=item get
 
+Gets a fixed asset, sets all standard properties.
+
+=cut
+
 sub get {
     my ($self) = @_;
     my ($ref) = $self->exec_method(funcname => 'asset__get');
@@ -64,6 +167,32 @@
     return $ref;
 }
 
+=item search
+
+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.
+
+=cut
+
 sub search {
     my ($self) = @_;
     my @results = $self->exec_method(funcname => 'asset_item__search');
@@ -71,12 +200,35 @@
     return @results;
 }
 
+=item save_note
+
+Saves a note.  Uses the following properties:
+
+* id
+* subject
+* note
+
+=cut
+
 sub save_note {
     my ($self) = @_;
     my ($ref) = $self->exec_method(funcname => 'asset_item__add_note');
     $self->{dbh}->commit;
 }
 
+=item get_metadata
+
+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
+
+=cut
+
 sub get_metadata {
     my ($self) = @_;
     @{$self->{asset_classes}} = $self->exec_method(funcname => 'asset_class__list');
@@ -104,6 +256,14 @@
     }
 }
 
+=item get_next_tag
+
+Returns next tag number
+
+Sets $self->{tag} to that value.
+
+=cut
+
 sub get_next_tag {
     my ($self) =  @_;
     my ($ref) = $self->call_procedure(
@@ -114,6 +274,13 @@
     $self->{dbh}->commit;
 }
 
+=item import_asset
+
+Uses standard properties.  Saves record in import report for batch review and 
+creation.
+
+=cut
+
 sub import_asset {
     my ($self) =  @_;
     my ($ref) = $self->exec_method(funcname => 'asset_report__import');
@@ -130,4 +297,15 @@
     }
 }
 
+
+=back
+
+=head1 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.
+
+=cut
+
 1;

Modified: trunk/LedgerSMB/DBObject/Asset_Class.pm
===================================================================
--- trunk/LedgerSMB/DBObject/Asset_Class.pm	2011-07-07 10:33:08 UTC (rev 3458)
+++ trunk/LedgerSMB/DBObject/Asset_Class.pm	2011-07-07 12:01:14 UTC (rev 3459)
@@ -120,4 +120,15 @@
     return @refs;
 }
 
+=back
+
+=head1 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.
+
+=cut
+
+
 1;

Modified: trunk/LedgerSMB/DBObject/Asset_Report.pm
===================================================================
--- trunk/LedgerSMB/DBObject/Asset_Report.pm	2011-07-07 10:33:08 UTC (rev 3458)
+++ trunk/LedgerSMB/DBObject/Asset_Report.pm	2011-07-07 12:01:14 UTC (rev 3459)
@@ -10,11 +10,78 @@
 This library contains the base utility functions for creating, saving, and
 retrieving depreciation categories of asset depreciation and disposal reports.
 
+=head1 STANDARD PROPERTIES
+
+=over
+
+=item id int
+
+Integer id of asset report
+
+=item report_date date
+
+Effective date of report
+
+=item gl_id bigint
+
+ID of GL transaction if applicable and approved.
+
+=item asset_class bigint 
+
+ID of asset class for the report the assets are 
+
+=item report_class int
+
+Integer of the report class desired.
+
+=item entered_by bigint
+
+Integer id of the individual who entered the report
+
+=item approved_by bigint
+
+Integer id of the individual who approved the report
+
+=item entered_at timestamp
+
+Timestamp the report was created
+
+=item approved_at timestamp
+
+Timestamp the report was approved
+
+=item depreciated_qty 
+
+Number of units (production or time) depreciated
+
+=item dont_approve bool
+
+If true, do not approve, ever.
+
+=item submitted bool
+
+If true, submitted for approval
+
+
+=back
+
+=head1 METHODS
+
+=over
+
 =cut
 
 use base qw(LedgerSMB::DBObject);
 use strict;
 
+=item save
+
+Uses standard properties
+
+Saves report to the database.  Sets ID.
+
+=cut
+
 sub save {
     my ($self) = @_;
     if ($self->{depreciation}){
@@ -40,6 +107,12 @@
     $self->{dbh}->commit;
 }
 
+=item get
+
+Gets report from the database.
+
+=cut
+
 sub get {
     my ($self) = @_;
     my ($ref) = $self->exec_method(funcname => 'asset_report__get');
@@ -114,4 +187,15 @@
     }
 }
 
+=back
+
+=head1 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.
+
+=cut
+
+
 1;

Modified: trunk/sql/Pg-database.sql
===================================================================
--- trunk/sql/Pg-database.sql	2011-07-07 10:33:08 UTC (rev 3458)
+++ trunk/sql/Pg-database.sql	2011-07-07 12:01:14 UTC (rev 3459)
@@ -3477,7 +3477,7 @@
 'in months', 'SLMM');
 
 INSERT INTO asset_dep_method(method, unit_class, sproc, unit_label, short_name) 
-values ('Annual Straight Line Daily', 1, 'asset_dep_straight_line_yr_m', 'in years', 'SLYM');
+values ('Annual Straight Line Monthly', 1, 'asset_dep_straight_line_yr_m', 'in years', 'SLYM');
 
 CREATE TABLE asset_class (
 	id serial not null unique,
@@ -3487,7 +3487,7 @@
 	method int references asset_dep_method(id)
 );
 
-COMMENT ON asset_class IS $$
+COMMENT ON TABLE asset_class IS $$
 The account fields here set the defaults for the individual asset items.  They
 are non-authoritative.
 $$;
@@ -3504,14 +3504,6 @@
 INSERT INTO asset_disposal_method (label, multiple, short_label)
 values ('Sale', '1', 'S');
 
-CREATE TABLE asset_rl_to_disposal_method (
-       report_id int references asset_report(id),
-       asset_id int references asset_item(id),
-       disposal_method_id int references asset_disposal_method(id),
-       percent_disposed numeric,
-       primary key (report_id, asset_id, disposal_method_id)
-);
-
 CREATE TABLE asset_item (
 	id serial primary key, -- needed due to possible null in natural key
 	description text,
@@ -3545,6 +3537,7 @@
 INSERT INTO note_class (id, class) values (4, 'Asset');
 ALTER TABLE asset_note alter column note_class set default 4;
 
+
 CREATE TABLE asset_report_class (
 	id int not null unique,
 	class text primary key
@@ -3579,6 +3572,17 @@
 	PRIMARY KEY(asset_id, report_id)
 );
 
-COMMENT ON asset_report_line.department_id IS
+COMMENT ON column asset_report_line.department_id IS
 $$ In case assets are moved between departments, we have to store this here.$$;
+
+CREATE TABLE asset_rl_to_disposal_method (
+       report_id int references asset_report(id),
+       asset_id int references asset_item(id),
+       disposal_method_id int references asset_disposal_method(id),
+       percent_disposed numeric,
+       primary key (report_id, asset_id, disposal_method_id)
+);
+
+COMMENT ON TABLE asset_rl_to_disposal_method IS
+$$ Maps disposal method to line items in the asset disposal report.$$;
 commit;

Modified: trunk/sql/modules/Assets.sql
===================================================================
--- trunk/sql/modules/Assets.sql	2011-07-07 10:33:08 UTC (rev 3458)
+++ trunk/sql/modules/Assets.sql	2011-07-07 12:01:14 UTC (rev 3459)
@@ -1217,7 +1217,6 @@
 
 COMMENT ON FUNCTION asset_disposal__approve
 (in_id int, in_gain_acct int, in_loss_acct int, in_asset_acct int)
-returns asset_report)
 IS $$ This approves the asset_report for disposals, creating relevant GL drafts.
 
 If the report is a partial disposal report, imports remaining percentages as new

Modified: trunk/sql/modules/Location.sql
===================================================================
--- trunk/sql/modules/Location.sql	2011-07-07 10:33:08 UTC (rev 3458)
+++ trunk/sql/modules/Location.sql	2011-07-07 12:01:14 UTC (rev 3459)
@@ -13,7 +13,7 @@
 END;
 $$ language plpgsql;
 
-COMMENT ON location_list_class() IS
+COMMENT ON FUNCTION location_list_class() IS
 $$ Lists location classes, by default in order entered.$$;
 
 CREATE OR REPLACE FUNCTION location_list_country()
@@ -119,7 +119,7 @@
 END;
 $$ language plpgsql;
 
-COMMENT ON location__get (in_id integer) IS
+COMMENT ON FUNCTION location__get (in_id integer) IS
 $$ Returns the location specified by in_id.$$;
 
 CREATE OR REPLACE FUNCTION location_search 
@@ -147,7 +147,7 @@
 $$ LANGUAGE PLPGSQL;
 
 COMMENT ON FUNCTION location_search
-(in_companyname varchar, in_address1 varchar, in_address2 varchar,
+(in_address1 varchar, in_address2 varchar,
         in_city varchar, in_state varchar, in_zipcode varchar,
         in_country varchar) IS
 $$ Returns matching locations.  All matches may be partial.$$;

Modified: trunk/sql/modules/Roles.sql
===================================================================
--- trunk/sql/modules/Roles.sql	2011-07-07 10:33:08 UTC (rev 3458)
+++ trunk/sql/modules/Roles.sql	2011-07-07 12:01:14 UTC (rev 3459)
@@ -1455,7 +1455,7 @@
 TO "lsmb_<?lsmb dbname ?>__users_manage";
 GRANT EXECUTE ON FUNCTION  admin__create_group(TEXT)
 TO "lsmb_<?lsmb dbname ?>__users_manage";
-GRANT EXECUTE ON FUNCTION  admin__delete_user(text)
+GRANT EXECUTE ON FUNCTION  admin__delete_user(text, bool)
 TO "lsmb_<?lsmb dbname ?>__users_manage";
 GRANT EXECUTE ON FUNCTION  admin__list_roles(text)
 TO "lsmb_<?lsmb dbname ?>__users_manage";
@@ -1626,6 +1626,8 @@
 GRANT select ON account_link_description TO PUBLIC;
 GRANT select ON sic TO public;
 GRANT SELECT ON parts_translation,  project_translation TO public;
+GRANT SELECT ON asset_report_class, asset_rl_to_disposal_method,
+                asset_disposal_method TO PUBLIC;
 
 GRANT EXECUTE ON FUNCTION user__get_all_users() TO public;
 

Modified: trunk/sql/modules/admin.sql
===================================================================
--- trunk/sql/modules/admin.sql	2011-07-07 10:33:08 UTC (rev 3458)
+++ trunk/sql/modules/admin.sql	2011-07-07 12:01:14 UTC (rev 3459)
@@ -467,7 +467,8 @@
     
 $$ language 'plpgsql' SECURITY DEFINER;
 
-REVOKE EXECUTE ON FUNCTION admin__delete_user(in_username TEXT) from public;
+REVOKE EXECUTE ON FUNCTION admin__delete_user(in_username TEXT, 
+in_drop_role bool) from public;
 
 comment on function admin__delete_user(text, bool) is $$ 
     Drops the provided user, as well as deletes the user configuration data.


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