summaryrefslogtreecommitdiff
path: root/LedgerSMB
diff options
context:
space:
mode:
authoraurynn_cmd <aurynn_cmd@4979c152-3d1c-0410-bac9-87ea11338e46>2008-07-11 20:10:36 +0000
committeraurynn_cmd <aurynn_cmd@4979c152-3d1c-0410-bac9-87ea11338e46>2008-07-11 20:10:36 +0000
commitca5f7b9b2eb6e42d92ca08272aae315b578046ad (patch)
tree23bf1250ddb068cb9fdc8028544adca8e81ef8a4 /LedgerSMB
parent26a243484e218eac4b5ddef5ac190af72a411af5 (diff)
Additions and fixes to the Reconciliation code.
git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@2212 4979c152-3d1c-0410-bac9-87ea11338e46
Diffstat (limited to 'LedgerSMB')
-rw-r--r--LedgerSMB/Admin.pm179
-rw-r--r--LedgerSMB/DBObject/User.pm80
-rw-r--r--LedgerSMB/Employee.pm91
-rw-r--r--LedgerSMB/Reconciliation/CSV.pm14
4 files changed, 7 insertions, 357 deletions
diff --git a/LedgerSMB/Admin.pm b/LedgerSMB/Admin.pm
deleted file mode 100644
index 8e6c5dfd..00000000
--- a/LedgerSMB/Admin.pm
+++ /dev/null
@@ -1,179 +0,0 @@
-package LedgerSMB::DBObject::Admin;
-
-use base LedgerSMB::DBObject;
-
-use LedgerSMB::DBObject::Location;
-use LedgerSMB::DBObject::Employee;
-use LedgerSMB::DBObject::Contact;
-
-sub save_user {
-
- my $self = shift @_;
-
- my $entity_id = shift @{ $self->exec_method( procname => "save_user" ) };
- $self->merge($entity_id);
-
- my $employee = LedgerSMB::DBObject::Employee->new(base=>$self, copy=>'list',
- merge=>[
- 'salutation',
- 'first_name',
- 'last_name',
- 'employeenumber',
- ]
- );
-
- $employee->{entity_id} = $entity_id->{id};
- $employee->save_employee();
-
- my $loc = LedgerSMB::DBObject::Location->new(base=>$self, copy=>'list',
- merge=>[
- 'address1',
- 'address2',
- 'city',
- 'state',
- 'zipcode',
- 'country',
- 'companyname',
- ]
- );
- $loc->save_location();
- $loc->join_to_person(person=>$employee);
-
-
- my $contact = LedgerSMB::DBObject::Contact->new(base=>$self, copy=>'list',
- merge=>[
- 'workphone',
- 'homephone',
- 'email',
- ]
- );
-
- $contact->save_homephone(person=>$employee);
- $contact->save_workphone(person=>$employee);
- $contact->save_email(person=>$employee);
-
- my $roles = $self->exec_method( procname => "all_roles" );
- my $user_roles = $self->exec_method(procname => "get_user_roles", args=>[ $self->{ modifying_user } ] );
-
- my %active_roles;
- for my $role (@{$user_roles}) {
-
- # These are our user's roles.
-
- $active_roles{$role} = 1;
- }
-
- my $status;
-
- for my $role ( @{ $roles } ) {
-
- # These roles are were ALL checked on the page, so they're the active ones.
-
- if ($active_roles{$role} && $self->{incoming_roles}->{$role}) {
-
- # do nothing.
- }
- elsif ($active_roles{$role} && !($self->{incoming_roles}->{$role} )) {
-
- # do remove function
- $status = $self->exec_method(procname => "remove_user_from_role",
- args=>[ $self->{ modifying_user }, $role ]
- }
- elsif ($self->{incoming_roles}->{$role} and !($active_roles{$role} )) {
-
- # do add function
- $status = $self->exec_method(procname => "add_user_to_role",
- args=>[ $self->{ modifying_user }, $role ]
- );
- }
- }
-}
-
-sub save_group {
-
- my $self = shift @_;
-
- my $existant = shift @{ $self->exec_method (procname=> "is_group", args=>[$self->{modifying_group}]) };
-
- my $group = shift @{ $self->exec_method (procname=> "save_group") };
-
- # first we grab all roles
-
- my $roles = $self->exec_method( procname => "all_roles" );
- my $user_roles = $self->exec_method(procname => "get_user_roles",
- args=>[ $self->{ group_name } ]
- );
-
- my %active_roles;
- for my $role (@{$user_roles}) {
-
- # These are our user's roles.
-
- $active_roles{$role} = 1;
- }
-
- my $status;
-
- for my $role ( @{ $roles } ) {
-
- # These roles are were ALL checked on the page, so they're the active ones.
-
- if ($active_roles{$role} && $self->{incoming_roles}->{$role}) {
-
- # we don't need to do anything.
- }
- elsif ($active_roles{$role} && !($self->{incoming_roles}->{$role} )) {
-
- # do remove function
- $status = $self->exec_method(
- procname => "remove_group_from_role",
- args=>[ $self->{ modifying_user }, $role ]
- );
- }
- elsif ($self->{incoming_roles}->{$role} and !($active_roles{$role} )) {
-
- # do add function
- $status = $self->exec_method(
- procname => "add_group_to_role",
- args=>[ $self->{ modifying_user }, $role ]
- );
- }
- }
-}
-
-
-sub delete_user {
-
- my $self = shift @_;
-
- my $status = shift @{ $self->exec_method(procname=>'delete_user', args=>[$self->{modifying_user}]) };
-
- if ($status) {
-
- return 1;
- } else {
-
- my $error = LedgerSMB::Error->new("Delete user failed.");
- $error->set_status($status);
- return $error;
- }
-}
-
-sub delete_group {
-
- my $self = shift @_;
-
- my $status = shift @{ $self->exec_method(procname=>'delete_group', args=>[$self->{groupname}])};
-
- if ($status) {
-
- return 1;
- } else {
-
- my $error = LedgerSMB::Error->new("Delete group failed.");
- $error->set_status($status);
- return $error;
- }
-}
-
-1; \ No newline at end of file
diff --git a/LedgerSMB/DBObject/User.pm b/LedgerSMB/DBObject/User.pm
deleted file mode 100644
index c84c6336..00000000
--- a/LedgerSMB/DBObject/User.pm
+++ /dev/null
@@ -1,80 +0,0 @@
-package LedgerSMB::DBObject::User;
-
-use base qw/LedgerSMB::DBObject/;
-
-sub save {
-
- my $self = shift @_;
-
- my $user = $self->get();
-
- if ( $user->{id} && $self->{is_a_user} ) {
-
- # doesn't check for the password - that's done in the sproc.
- $self->{id} = shift @{ $self->exec_method(procname=>'admin__save_user',
- args=>[$user->{id}, $self->{username}, $self->{password}] ) };
- if (!$self->{id}) {
-
- return 0;
- }
- }
- elsif ($user && !$self->{is_a_user}) {
-
- # there WAS a user, and we've decided we want that user to go away now.
-
- $self->{id} = $user->{id};
- return $self->remove();
-
- }
- elsif ($self->{is_a_user}) {
-
- # No user ID, meaning, creating a new one.
- $self->{id} = shift @{ $self->exec_method(procname=>'admin__save_user',
- args=>[undef, $self->{username}, $self->{password}] ) };
- }
- return 1;
-}
-
-sub get {
-
- my $self = shift @_;
-
- my ($user_id, $username) = @{ $self->exec_method(procname=>'admin__get_user',
- args=>[$self->{id}])};
-
- return {id=>$user_id, username=>$username};
-}
-
-sub remove {
-
- my $self = shift;
-
- my $code = $self->exec_method(procname=>"admin__delete_user", args=>[$self->{id}, $self->{username}]);
- $self->{id} = undef; # never existed..
-
- return $code->[0];
-}
-
-sub save_prefs {
-
- my $self = shift @_;
-
- my $pref_id = $self->exec_method(procname=>"admin__save_preferences",
- args=>[
- 'language',
- 'stylesheet',
- 'printer',
- 'dateformat',
- 'numberformat'
- ]
- );
-}
-
-sub get_all_users {
-
- my $self = shift @_;
-
- $self->{users} = $self->exec_method( procname=>"user__get_all_users" );
-}
-
-1;
diff --git a/LedgerSMB/Employee.pm b/LedgerSMB/Employee.pm
deleted file mode 100644
index e792aa84..00000000
--- a/LedgerSMB/Employee.pm
+++ /dev/null
@@ -1,91 +0,0 @@
-
-=head1 NAME
-
-LedgerSMB::Employee - LedgerSMB class for managing Employees
-
-=head1 SYOPSIS
-
-This module creates object instances based on LedgerSMB's in-database ORM.
-
-=head1 METHODS
-
-The following method is static:
-
-=over
-
-=item new ($LedgerSMB object);
-
-=back
-
-The following methods are passed through to stored procedures via Autoload.
-
-=over
-
-=item save
-
-=item get
-
-=item search
-
-=item list_managers
-
-The above list may grow over time, and may depend on other installed modules.
-
-=back
-
-=head1 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.
-
-=cut
-
-package LedgerSMB::Employee;
-use base qw(LedgerSMB::DBObject);
-use strict;
-our $VERSION = '1.0.0';
-
-sub save {
- my $self = shift;
-
- my $hashref = shift @{ $self->exec_method( procname => "employee_save" ) };
- $self->merge( $hashref, 'id' );
-}
-
-sub get {
- my $self = shift;
- my $hashref = shift @{ $self->exec_method( procname => "employee_get" ) };
- $self->merge( $hashref, keys %{$hashref} );
-}
-
-sub list_managers {
- my $self = shift;
- $self->{manager_list} =
- $self->exec_method( procname => "employee_list_managers" );
-}
-
-sub search {
- my $self = shift;
- $self->{search_results} =
- $self->exec_method( procname => "employee_search" );
-}
-
-sub set_location {
-
- my $self = shift @_;
- my $location = shift @_;
-
- my $code = $self->exec_method ( procname => 'employee_set_location',
- args=>[ $self->{id}, $location->{id} ] );
-
- if ($code) {
-
- # good, it worked.
-
- return 1;
- }
- return 0;
-}
-
-1;
diff --git a/LedgerSMB/Reconciliation/CSV.pm b/LedgerSMB/Reconciliation/CSV.pm
index f95bf194..c63ce327 100644
--- a/LedgerSMB/Reconciliation/CSV.pm
+++ b/LedgerSMB/Reconciliation/CSV.pm
@@ -4,7 +4,7 @@
package LedgerSMB::Reconciliation::CSV;
use base qw/LedgerSMB/;
-use Datetime;
+use DateTime;
sub load_file {
@@ -16,7 +16,7 @@ sub load_file {
local $/; # I think this is the right way to outrageously cheat
open(FH,$filename);
$contents = <FH>;
- }
+ };
return $contents;
}
@@ -30,8 +30,8 @@ sub process {
# Unpack for the format it is inexplicably in
($accno,
$checkno,
- $issuedate
- $amount
+ $issuedate,
+ $amount,
$cleared,
$last_three) = unpack("A10A10A6A10A6A3",$line);
@@ -50,9 +50,9 @@ sub process {
# First check the account number.
# According to the docs I have, it's all numbers.
-
+ ;
}
-
+
return;
}
@@ -66,4 +66,4 @@ sub error {
}
-1; \ No newline at end of file
+1;