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

SF.net SVN: ledger-smb:[4314] trunk/LedgerSMB/AM.pm



Revision: 4314
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=4314&view=rev
Author:   einhverfr
Date:     2012-02-14 14:38:32 +0000 (Tue, 14 Feb 2012)
Log Message:
-----------
Removing project/department logic that will be in new interface

Modified Paths:
--------------
    trunk/LedgerSMB/AM.pm

Modified: trunk/LedgerSMB/AM.pm
===================================================================
--- trunk/LedgerSMB/AM.pm	2012-02-14 14:36:54 UTC (rev 4313)
+++ trunk/LedgerSMB/AM.pm	2012-02-14 14:38:32 UTC (rev 4314)
@@ -58,158 +58,6 @@
 
 my $logger = Log::Log4perl->get_logger('AM');
 
-=item AM->get_account($myconfig, $form);
-
-Populates the $form attributes accno, description, charttype, gifi_accno,
-category, link, and contra with details about the account that has the id
-$form->{id}.  If there are no acc_trans entries that refer to that account,
-$form->{orphaned} is made true, otherwise $form->{orphaned} is set to false.
-
-Also populates 'inventory_accno_id', 'income_accno_id', 'expense_accno_id',
-'fxgain_accno_id', and 'fxloss_accno_id' with the values from defaults.
-
-$myconfig is unused.
-
-=cut
-
-sub get_account {
-
-    my ( $self, $myconfig, $form ) = @_;
-
-    my $dbh = $form->{dbh};
-
-    my $query = qq|
-		SELECT accno, description, charttype, gifi_accno,
-		       category, link, contra
-		  FROM chart
-		 WHERE id = ?|;
-
-    my $sth = $dbh->prepare($query);
-    $sth->execute( $form->{id} ) || $form->dberror($query);
-
-    my $ref = $sth->fetchrow_hashref(NAME_lc);
-    for ( keys %$ref ) { $form->{$_} = $ref->{$_} }
-    $sth->finish;
-
-    # get default accounts
-    $query = qq|
-		SELECT (SELECT value FROM defaults
-		         WHERE setting_key = 'inventory_accno_id')
-		       AS inventory_accno_id,
-		       (SELECT value FROM defaults
-		         WHERE setting_key = 'income_accno_id')
-		       AS income_accno_id, 
-		       (SELECT value FROM defaults
-		         WHERE setting_key = 'expense_accno_id')
-		       AS expense_accno_id,
-		       (SELECT value FROM defaults
-		         WHERE setting_key = 'fxgain_accno_id')
-		       AS fxgain_accno_id, 
-		       (SELECT value FROM defaults
-		         WHERE setting_key = 'fxloss_accno_id')
-		       AS fxloss_accno_id|;
-
-    $sth = $dbh->prepare($query);
-    $sth->execute || $form->dberror($query);
-
-    $ref = $sth->fetchrow_hashref(NAME_lc);
-    for ( keys %$ref ) { $form->{$_} = $ref->{$_} }
-    $sth->finish;
-
-    # check if we have any transactions
-    $query = qq|
-		SELECT trans_id 
-		  FROM acc_trans
-		 WHERE chart_id = ? 
-		 LIMIT 1|;
-    $sth = $dbh->prepare($query);
-    $sth->execute( $form->{id} );
-    ( $form->{orphaned} ) = $sth->fetchrow_array();
-    $form->{orphaned} = !$form->{orphaned};
-
-    $dbh->commit;
-}
-
-=item AM->delete_account($myconfig, $form);
-
-Deletes the account with the id $form->{id}.  Calls $form->error if there are
-any acc_trans entries that reference it.  If any parts have that account for
-an inventory, income, or COGS (expense) account, switch the part to using the
-default account for that type.  Also deletes all tax, partstax, customertax, and
-vendortax table entries for the account.
-
-$myconfig is unused.
-
-=cut
-
-sub delete_account {
-
-    my ( $self, $myconfig, $form ) = @_;
-
-    # connect to database, turn off AutoCommit
-    my $dbh = $form->{dbh};
-    my $sth;
-    my $query = qq|
-		SELECT count(*)
-		  FROM acc_trans
-		 WHERE chart_id = ?|;
-    $sth = $dbh->prepare($query);
-    $sth->execute( $form->{id} );
-    my ($rowcount) = $sth->fetchrow_array();
-
-    if ($rowcount) {
-        $form->error( "Cannot delete accounts with associated transactions!" );
-    }
-
-    # delete chart of account record
-    $query = qq|
-		DELETE FROM chart
-		      WHERE id = ?|;
-
-    $sth = $dbh->prepare($query);
-    $sth->execute( $form->{id} ) || $form->dberror($query);
-
-    # set inventory_accno_id, income_accno_id, expense_accno_id to defaults
-    $query = qq|
-		UPDATE parts
-		   SET inventory_accno_id = (SELECT value::int
-		                               FROM defaults
-					      WHERE setting_key = 
-							'inventory_accno_id')
-		 WHERE inventory_accno_id = ?|;
-
-    $sth = $dbh->prepare($query);
-    $sth->execute( $form->{id} ) || $form->dberror($query);
-
-    for (qw(income_accno_id expense_accno_id)) {
-        $query = qq|
-			UPDATE parts
-			   SET $_ = (SELECT value::int
-			               FROM defaults
-			              WHERE setting_key = '$_')
-			 WHERE $_ = ?|;
-
-        $sth = $dbh->prepare($query);
-        $sth->execute( $form->{id} ) || $form->dberror($query);
-        $sth->finish;
-    }
-
-    foreach my $table (qw(partstax customertax vendortax tax)) {
-        $query = qq|
-			DELETE FROM $table
-			      WHERE chart_id = ?|;
-
-        $sth = $dbh->prepare($query);
-        $sth->execute( $form->{id} ) || $form->dberror($query);
-        $sth->finish;
-    }
-
-    # commit and redirect
-    my $rc = $dbh->commit;
-
-    $rc;
-}
-
 =item AM->gifi_accounts($myconfig, $form);
 
 Populates the list referred to as $form->{ALL} with hashes of gifi numbers and
@@ -520,157 +368,6 @@
 
 }
 
-=item AM->departments($myconfig, $form);
-
-Populate the list referred to as $form->{ALL} with hashes of details about
-departments.  The hashes all contain the id, description, and role of the
-department and are ordered by the description.
-
-$myconfig is unused.
-
-=cut
-
-sub departments {
-
-    my ( $self, $myconfig, $form ) = @_;
-
-    # connect to database
-    my $dbh = $form->{dbh};
-
-    $form->sort_order();
-    my $query = qq|SELECT id, description, role
-					 FROM department
-				 ORDER BY description $form->{direction}|;
-
-    $sth = $dbh->prepare($query);
-    $sth->execute || $form->dberror($query);
-
-    while ( my $ref = $sth->fetchrow_hashref(NAME_lc) ) {
-        push @{ $form->{ALL} }, $ref;
-    }
-
-    $sth->finish;
-    $dbh->commit;
-
-}
-
-=item AM->get_department($myconfig, $form);
-
-Fills $form->{description} and $form->{role} with details about the department
-with the id value of $form->{id}.  If the department has not been used as part
-of a transaction referred to in dpt_trans, set $form->{orphaned} to true, 
-otherwise it is set to false.
-
-$myconfig is unused.
-
-=cut
-
-sub get_department {
-
-    my ( $self, $myconfig, $form ) = @_;
-
-    # connect to database
-    my $dbh = $form->{dbh};
-    my $sth;
-
-    my $query = qq|
-		SELECT description, role
-		  FROM department
-		 WHERE id = ?|;
-
-    $sth = $dbh->prepare($query);
-    $sth->execute( $form->{id} );
-    ( $form->{description}, $form->{role} ) = $sth->fetchrow_array;
-    $sth->finish;
-
-    for ( keys %$ref ) { $form->{$_} = $ref->{$_} }
-
-    # see if it is in use
-    $query = qq|
-		SELECT count(*) 
-		  FROM dpt_trans
-		 WHERE department_id = ? |;
-
-    $sth = $dbh->prepare($query);
-    $sth->execute( $form->{id} );
-    ( $form->{orphaned} ) = $sth->fetchrow_array;
-    if ( ( $form->{orphaned} * 1 ) == 0 ) {
-        $form->{orphaned} = 1;
-    }
-    else {
-        $form->{orphaned} = 0;
-    }
-
-    $dbh->commit;
-}
-
-=item AM->save_department($myconfig, $form);
-
-Add or update a department record.  If $form->{id} is set, the department with
-that id is updated, otherwise a new department is added.  The department role
-(either 'C' for cost centres or 'P' for profit centres) and description is
-taken from the $form attributes 'role' and 'description'.
-
-$myconfig is unused.
-
-=cut
-
-sub save_department {
-
-    my ( $self, $myconfig, $form ) = @_;
-
-    # connect to database
-    my $dbh = $form->{dbh};
-
-    $form->{description} =~ s/-(-)+/-/g;
-    $form->{description} =~ s/ ( )+/ /g;
-    my $sth;
-    my @queryargs = ( $form->{description}, $form->{role} );
-    if ( $form->{id} ) {
-        $query = qq|
-			UPDATE department 
-			   SET description = ?,
-			       role = ?
-			 WHERE id = ?|;
-        push @queryargs, $form->{id};
-
-    }
-    else {
-        $query = qq|
-			INSERT INTO department (description, role)
-			     VALUES (?, ?)|;
-    }
-
-    $sth = $dbh->prepare($query);
-    $sth->execute(@queryargs) || $form->dberror($query);
-    $dbh->commit;
-
-}
-
-=item AM->delete_department($myconfig, $form)
-
-Deletes the department with an id of $form->{id}.
-
-$myconfig is unused.
-
-=cut
-
-sub delete_department {
-
-    my ( $self, $myconfig, $form ) = @_;
-
-    # connect to database
-    my $dbh = $form->{dbh};
-
-    $query = qq|
-		DELETE FROM department
-		      WHERE id = ?|;
-
-    $dbh->prepare($query)->execute( $form->{id} );
-    $dbh->commit;
-
-}
-
 =item AM->business($myconfig, $form);
 
 Populates the list referred to as $form->{ALL} with hashes containing details

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