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

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



Revision: 5327
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=5327&view=rev
Author:   einhverfr
Date:     2012-12-09 03:59:41 +0000 (Sun, 09 Dec 2012)
Log Message:
-----------
Timecard types

Modified Paths:
--------------
    trunk/LedgerSMB/Timecard.pm
    trunk/sql/Pg-database.sql
    trunk/sql/modules/Timecards.sql

Added Paths:
-----------
    trunk/LedgerSMB/Timecard/
    trunk/LedgerSMB/Timecard/Type.pm

Added: trunk/LedgerSMB/Timecard/Type.pm
===================================================================
--- trunk/LedgerSMB/Timecard/Type.pm	                        (rev 0)
+++ trunk/LedgerSMB/Timecard/Type.pm	2012-12-09 03:59:41 UTC (rev 5327)
@@ -0,0 +1,140 @@
+=head1 NAME
+
+LedgerSMB::Timecard::Type - Timecard Types for LedgerSMB
+
+=head1 SYNOPSIS
+
+To retrieve a specific timecard type:
+
+ my $type = LedgerSMB::Timecard::Type->get($id);
+
+To list all types, orderd by label:
+
+ my @types = LedgerSMB::Timecard::Type->list();
+
+=cut
+
+package LedgerSMB::Timecard::Type;
+use Moose;
+with 'LedgerSMB::DBObject_Moose';
+
+=head1 DESCRIPTION
+
+The timecard type system is used to categorize time, material, and overhead 
+cards for projects, payroll, manufacturing, and the like.  These are not 
+created through the front-end but rather integral to modules which may be
+developed in the future.  The three preloaded types are:
+
+=over
+
+=item time
+
+Tracks time used for professional services for projects.
+
+=item materials
+
+Tracks materials used for projects
+
+=item overhead
+
+Tracks time used for payroll and the like.  
+
+=back
+
+Other types may be created over time.
+
+=head1 PROPERTIES
+
+=over
+
+=item id int
+
+This is the internal id of the timecard type.
+
+=cut 
+
+has id => (is => 'ro', isa => 'Str', required => 1);
+
+=item label string
+
+This is the human readable ID of the timecard type
+
+=cut
+
+has label => (is => 'ro', isa => 'Str', required => 1);
+
+=item description string
+
+General description for the timecard type
+
+=cut
+
+has description => (is => 'ro', isa => 'Str', required => 1);
+
+=item is_service bool
+
+If this is set to true, then the timecards associated will only pull services.
+
+=cut
+
+has is_service => (is => 'ro', isa => 'Bool', required => 1);
+
+=item is_timecard bool
+
+If true, then the timecard will pull only labor and overhead
+
+=cut
+
+has is_timecard => (is => 'ro', isa => 'Bool', required => 1);
+
+
+=back
+
+=head1 METHODS
+
+=over
+
+=item get($id int)
+
+Retrieves information for a specific timecard type
+
+=cut
+
+sub get {
+    my ($self, $id) = @_;
+    my ($ref) = __PACKAGE__->call_procedure(
+         funcname => 'timecard_type__get', args => [$id]
+    );
+    return __PACKAGE__->new($ref);
+}
+
+=item list()
+
+Retrieves a list of all timecard types.
+
+=cut
+
+sub list {
+    my @results = __PACKAGE__->call_procedure(
+            funcname => 'timecard_type__list'
+    );
+    my @types;
+    for my $r (@results){
+        push @types, __PACKAGE__->new(%$r);
+    }
+    return @types;
+}
+
+=back
+
+=head1 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.
+
+=cut
+
+__PACKAGE__->meta->make_immutable;
+1;
+

Modified: trunk/LedgerSMB/Timecard.pm
===================================================================
--- trunk/LedgerSMB/Timecard.pm	2012-12-08 16:38:13 UTC (rev 5326)
+++ trunk/LedgerSMB/Timecard.pm	2012-12-09 03:59:41 UTC (rev 5327)
@@ -240,6 +240,10 @@
 
 =head1 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.
+
 =cut
 
 __PACKAGE__->meta->make_immutable;

Modified: trunk/sql/Pg-database.sql
===================================================================
--- trunk/sql/Pg-database.sql	2012-12-08 16:38:13 UTC (rev 5326)
+++ trunk/sql/Pg-database.sql	2012-12-09 03:59:41 UTC (rev 5327)
@@ -2270,6 +2270,15 @@
   is_timecard bool default true
 );
 
+INSERT INTO jctype (id, label, description, is_service, is_timecard)
+VALUES (1, 'time', 'Timecards for project services', true, true);
+
+INSERT INTO jctype (id, label, description, is_service, is_timecard)
+VALUES (2, 'materials', 'Materials for projects', false, false);
+
+INSERT INTO jctype (id, label, description, is_service, is_timecard)
+VALUES (3, 'overhead', 'Time/Overhead for payroll, manufacturing, etc', false, true);
+
 CREATE TABLE jcitems (
   id serial PRIMARY KEY,
   business_unit_id int references business_unit(id),

Modified: trunk/sql/modules/Timecards.sql
===================================================================
--- trunk/sql/modules/Timecards.sql	2012-12-08 16:38:13 UTC (rev 5326)
+++ trunk/sql/modules/Timecards.sql	2012-12-09 03:59:41 UTC (rev 5327)
@@ -157,4 +157,20 @@
 END;
 $$;
 
+-- Timecard Types
+
+CREATE OR REPLACE FUNCTION timecard_type__get(in_id int) returns jctype 
+LANGUAGE sql AS $$
+
+SELECT * FROM jctype where id = $1;
+
+$$;
+
+CREATE OR REPLACE FUNCTION timecard_type__list() RETURNS SETOF jctype
+LANGUAGE SQL AS $$
+
+SELECT * FROM jctype ORDER BY label;
+
+$$;
+
 COMMIT;

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