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

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



Revision: 2713
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=2713&view=rev
Author:   einhverfr
Date:     2009-07-07 19:18:20 +0000 (Tue, 07 Jul 2009)

Log Message:
-----------
Fixed asset modules beginning, more POD, and minor asset schema changes

Modified Paths:
--------------
    trunk/LedgerSMB/DBObject/Draft.pm
    trunk/LedgerSMB/DBObject/Payment.pm
    trunk/sql/modules/Assets-tables.sql
    trunk/sql/modules/Assets.sql

Added Paths:
-----------
    trunk/LedgerSMB/DBObject/Asset.pm
    trunk/LedgerSMB/DBObject/Asset_Class.pm
    trunk/LedgerSMB/DBObject/Asset_Report.pm

Added: trunk/LedgerSMB/DBObject/Asset.pm
===================================================================
--- trunk/LedgerSMB/DBObject/Asset.pm	                        (rev 0)
+++ trunk/LedgerSMB/DBObject/Asset.pm	2009-07-07 19:18:20 UTC (rev 2713)
@@ -0,0 +1,45 @@
+package LedgerSMB::DBObject::Asset;
+
+=head1 NAME
+
+LedgerSMB::DBObject::Asset.pm, LedgerSMB Base Class for Fixed Assets
+
+=head1 SYNOPSIS
+
+This library contains the base utility functions for creating, saving, and
+retrieving fixed assets for depreciation
+
+=cut
+
+use base qw(LedgerSMB::DBObject);
+use strict;
+
+sub save_asset {
+    my ($self) = @_;
+    my ($ref) = $self->exec_method(funcname => 'asset__save');
+    $self->merge($ref);
+    $self->{dbh}->commit || $self->error(
+                  $locale->text("Unable to save [_1] object", 
+                          $locale->text('Asset'))
+    );
+    return $ref if $self->{dbh}->commit;
+}
+
+sub get_asset {
+    my ($self) = @_;
+    my ($ref) = $self->exec_method(funcname => 'asset__get');
+    $self->merge($ref);
+    return $ref;
+}
+
+sub search_assets {
+    # TODO
+}
+
+
+sub get_metadata {
+    # TODO
+}
+
+
+1;

Added: trunk/LedgerSMB/DBObject/Asset_Class.pm
===================================================================
--- trunk/LedgerSMB/DBObject/Asset_Class.pm	                        (rev 0)
+++ trunk/LedgerSMB/DBObject/Asset_Class.pm	2009-07-07 19:18:20 UTC (rev 2713)
@@ -0,0 +1,42 @@
+package LedgerSMB::DBObject::Asset_Class;
+
+=head1 NAME
+
+LedgerSMB::DBObject::Asset_Class.pm, LedgerSMB Base Class for Asset Classes
+
+=head1 SYNOPSIS
+
+This library contains the base utility functions for creating, saving, and
+retrieving depreciation categories of assets.
+
+=cut
+
+use base qw(LedgerSMB::DBObject);
+use strict;
+
+sub save_asset_class {
+    my ($self) = @_;
+    my ($ref) = $self->exec_method(funcname => 'asset_class__save');
+    $self->merge($ref);
+    $self->{dbh}->commit || $self->error(
+                  $locale->text("Unable to save [_1] object", 
+                          $locale->text('Asset Class'))
+    );
+    return $ref if $self->{dbh}->commit;
+}
+
+sub get_asset_class {
+    my ($self) = @_;
+    my ($ref) = $self->exec_method(funcname => 'asset_class__get');
+    $self->merge($ref);
+    return $ref;
+}
+
+sub list_asset_classes {
+    my ($self) = @_;
+    my @refs = $self->exec_method(funcname => 'asset_class__list');
+    $self->{classes} = ..hidden..;
+    return @refs;
+}
+
+1;

Added: trunk/LedgerSMB/DBObject/Asset_Report.pm
===================================================================
--- trunk/LedgerSMB/DBObject/Asset_Report.pm	                        (rev 0)
+++ trunk/LedgerSMB/DBObject/Asset_Report.pm	2009-07-07 19:18:20 UTC (rev 2713)
@@ -0,0 +1,22 @@
+
+package LedgerSMB::DBObject::Asset_Report;
+
+=head1 NAME
+
+LedgerSMB::DBObject::Asset_Report.pm, LedgerSMB Base Class for Asset Reports
+
+=head1 SYNOPSIS
+
+This library contains the base utility functions for creating, saving, and
+retrieving depreciation categories of asset depreciation and disposal reports.
+
+=cut
+
+use base qw(LedgerSMB::DBObject);
+use strict;
+
+sub create_report {
+}
+
+sub get_report {
+}

Modified: trunk/LedgerSMB/DBObject/Draft.pm
===================================================================
--- trunk/LedgerSMB/DBObject/Draft.pm	2009-07-06 16:31:45 UTC (rev 2712)
+++ trunk/LedgerSMB/DBObject/Draft.pm	2009-07-07 19:18:20 UTC (rev 2713)
@@ -1,3 +1,19 @@
+=head1 NAME
+
+LedgerSMB:DBObject::Draft, LedgerSMB base class for managing "drafts."
+
+=head1 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.
+
+=head1 METHODS
+
+=over
+
+=cut
+
 package LedgerSMB::DBObject::Draft;
 
 use base qw/LedgerSMB::DBObject/;
@@ -2,2 +18,9 @@
 
+=item search()
+
+returns a list of results for the search criteria.  This list is also stored 
+in $draft->{search_resuts}
+
+=cut
+
 sub search {
@@ -8,6 +31,13 @@
     return @{$self->{draft_results}};
 }
 
+=item approve()
+
+Approves the draft identified by the transaction id in $draft->{id}.  Once
+approved, the draft shows up in financial reports.
+
+=cut
+
 sub approve {
    my ($self) = @_;
    if (!$self->{id}){
@@ -18,6 +48,15 @@
    return $self->{approved};
 }
 
+=item delete()
+
+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.
+
+=cut
+
 sub delete {
    my ($self) = @_;
    if (!$self->{id}){
@@ -28,4 +67,14 @@
    return $self->{deleted};
 }
 
+=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/LedgerSMB/DBObject/Payment.pm
===================================================================
--- trunk/LedgerSMB/DBObject/Payment.pm	2009-07-06 16:31:45 UTC (rev 2712)
+++ trunk/LedgerSMB/DBObject/Payment.pm	2009-07-07 19:18:20 UTC (rev 2713)
@@ -63,6 +63,17 @@
   ($self->{current_date}) = $self->{dbh}->selectrow_array('select current_date');
 }
 
+=over
+
+=item text_amount($value)
+
+Returns the textual representation, as defined in localization rules, for the
+numeric value passed.
+
+=back
+
+=cut
+
 sub text_amount {
     use LedgerSMB::Num2text;
     my ($self, $value) = @_;
@@ -71,6 +82,17 @@
     return $self->num2text($value);
 }
 
+=over
+
+=item get_metadata()
+
+Semi-private method for preparing the object for other tasks, such as displaying
+payment options.
+
+=back
+
+=cut
+
 sub get_metadata {
     my ($self) = @_;
     $self->list_open_projects();
@@ -98,10 +120,6 @@
      
        $self->{payment_type_return_label}=$self->{payment_type_label_id}->[0]->{label};
 
-       #print STDERR qq|______payment type id= $self->{payment_type_label_id}->[0]->{id} and label= $self->{payment_type_label_id}->[0]->{label}|;
- 
-       #print STDERR qq|______actual payment type id= $self->{payment_type_return_id} and label= $self->{payment_type_return_label}|;
-
     }
 
 
@@ -118,6 +136,18 @@
     }
 }
 
+=over
+
+=item search()
+
+Seturns a series of payments matching the search criteria.
+
+Search results are also stored at $payment->{search_results}.
+
+=back
+
+=cut
+
 sub search {
     my ($self) = @_;
     if ($self->{meta_number} && !$self->{credit_id}){
@@ -134,6 +164,18 @@
     return @{$self->{search_results}};
 }
 
+=over
+
+=item get_open_accounts()
+
+Returns a list of open accounts for the payment operation.
+
+These are also stored on $payment->{accounts}
+
+=back
+
+=cut
+
 sub get_open_accounts {
     my ($self) = @_;
     @{$self->{accounts}} = 
@@ -142,6 +184,17 @@
 }
 
 
+=over
+
+=item $payment->get_entity_credit_account()
+
+Returns billing information for the current account, and saves it to an arrayref
+at $payment->{entity_accounts}/
+
+=back
+
+=cut
+
 sub get_entity_credit_account{
   my ($self) = @_;
   @{$self->{entity_accounts}} =

Modified: trunk/sql/modules/Assets-tables.sql
===================================================================
--- trunk/sql/modules/Assets-tables.sql	2009-07-06 16:31:45 UTC (rev 2712)
+++ trunk/sql/modules/Assets-tables.sql	2009-07-07 19:18:20 UTC (rev 2713)
@@ -30,7 +30,8 @@
 -- year is only supported unit at present
 
 CREATE TABLE asset_class (
-	id serial primary key,
+	id serial not null unique,
+	label text primary key,
 	asset_account_id int references account(id),
 	dep_account_id int references account(id),
 	method int references asset_dep_method(id),

Modified: trunk/sql/modules/Assets.sql
===================================================================
--- trunk/sql/modules/Assets.sql	2009-07-06 16:31:45 UTC (rev 2712)
+++ trunk/sql/modules/Assets.sql	2009-07-07 19:18:20 UTC (rev 2713)
@@ -42,9 +42,23 @@
 	
 $$ language plpgsql;
 
+CREATE OR REPLACE FUNCTION asset_class__get (in_id int) RETURNS asset_class AS
+$$
+DECLARE ret_val asset_class;
+BEGIN 
+	SELECT * INTO ret_val FROM asset_class WHERE id = in_id;
+	RETURN ret_val;
+END;
+$$ language plpgsql;
+
+CREATE OR REPLACE FUNCTION asset_class__list() RETURNS SETOF asset_class AS
+$$
+SELECT * FROM asset_class ORDER BY label;
+$$ LANGUAGE SQL;
+
 CREATE OR REPLACE FUNCTION asset_class__save
 (in_id int, in_asset_account_id int, in_dep_account_id int, 
-in_method int, in_life_unit int)
+in_method int, in_life_unit int, in_label text)
 RETURNS asset_class AS
 $$
 DECLARE ret_val asset_class;
@@ -53,6 +67,7 @@
 	SET asset_account_id = in_asset_account_id,
 		dep_account_id = in_dep_account_id,
 		method = in_method,
+		label = in_label,
 		life_unit = in_life_unit
 	WHERE id = in_id;
 
@@ -62,9 +77,9 @@
 	END IF;
 
 	INSERT INTO asset_class (asset_account_id, dep_account_id, method,
-		life_unit)
+		life_unit, label)
 	VALUES (in_asset_account_id, in_dep_account_id, in_method, 
-		in_life_unit);
+		in_life_unit, label);
 
 	SELECT * INTO ret_val FROM asset_class 
 	WHERE id = currval('asset_class_id_seq');
@@ -73,6 +88,16 @@
 END;
 $$ language plpgsql;
 
+CREATE OR REPLACE FUNCTION asset__get (in_id int, in_tag text)
+RETURNS asset_item AS
+$$
+DECLARE ret_val asset_item;
+BEGIN
+	SELECT * into ret_val from asset_item WHERE id = in_id and in_tag = tag;
+	return ret_val;
+END;
+$$ language plpgsql;
+
 CREATE OR REPLACE FUNCTION asset__save
 (in_id int, in_asset_class int, in_description text, in_tag text, 
 in_purchase_date date, in_purchase_value numeric,
@@ -151,7 +176,7 @@
 			quote_literal(item.id) ||$E$)
 		$E$; 
 	END LOOP;
-	-- TODO:  ADD GL ENTRIES
+	-- TODO:  ADD GL lines at this point
 	RETURN ret_val;
 END;
 $$ language plpgsql;


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