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

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



Revision: 4793
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=4793&view=rev
Author:   einhverfr
Date:     2012-05-28 05:38:34 +0000 (Mon, 28 May 2012)
Log Message:
-----------
Moving COA report to new 1.4 framework

Modified Paths:
--------------
    trunk/LedgerSMB/AA.pm
    trunk/LedgerSMB/Form.pm
    trunk/UI/accounts/edit.html
    trunk/bin/am.pl
    trunk/sql/modules/chart.sql

Removed Paths:
-------------
    trunk/LedgerSMB/CA.pm
    trunk/bin/ca.pl

Modified: trunk/LedgerSMB/AA.pm
===================================================================
--- trunk/LedgerSMB/AA.pm	2012-05-28 05:19:33 UTC (rev 4792)
+++ trunk/LedgerSMB/AA.pm	2012-05-28 05:38:34 UTC (rev 4793)
@@ -1433,7 +1433,7 @@
 		SELECT c.accno
 		  FROM account c
 		  JOIN eca_tax ct ON (ct.chart_id = c.id)
-		 WHERE ct.eca_id = ?|;
+		 WHERE ct.eca_id = ? AND NOT obsolete |;
 
     $sth = $dbh->prepare($query);
     $sth->execute( $form->{"$form->{vc}_id"} ) || $form->dberror($query);

Deleted: trunk/LedgerSMB/CA.pm
===================================================================
--- trunk/LedgerSMB/CA.pm	2012-05-28 05:19:33 UTC (rev 4792)
+++ trunk/LedgerSMB/CA.pm	2012-05-28 05:38:34 UTC (rev 4793)
@@ -1,117 +0,0 @@
-#=====================================================================
-# LedgerSMB
-# Small Medium Business Accounting software
-# http://www.ledgersmb.org/
-#
-
-# Copyright (C) 2006
-# This work contains copyrighted information from a number of sources all used
-# with permission.
-#
-# This file contains source code included with or based on SQL-Ledger which
-# is Copyright Dieter Simader and DWS Systems Inc. 2000-2005 and licensed
-# under the GNU General Public License version 2 or, at your option, any later
-# version.  For a full list including contact information of contributors,
-# maintainers, and copyright holders, see the CONTRIBUTORS file.
-#
-# Original Copyright Notice from SQL-Ledger 2.6.17 (before the fork):
-# Copyright (C) 2001
-#
-#  Author: DWS Systems Inc.
-#     Web: http://www.sql-ledger.org
-#
-#  Contributors:
-#
-#======================================================================
-#
-# This file has undergone whitespace cleanup.
-#
-#======================================================================
-#
-# chart of accounts
-#
-#======================================================================
-
-package CA;
-
-sub all_accounts {
-
-    my ( $self, $myconfig, $form ) = @_;
-
-    my $amount = ();
-
-    # connect to database
-    my $dbh = $form->{dbh};
-
-    my $approved = ($form->{approved})? 'TRUE' : 'FALSE';
-
-    my $query = qq|
-		   SELECT accno, SUM(acc_trans.amount) AS amount
-		     FROM chart
-		     JOIN acc_trans ON (chart.id = acc_trans.chart_id)
-		     JOIN transactions ON (acc_trans.trans_id = transactions.id)
-                     JOIN (SELECT id, approved, 'ap' AS tablename FROM ap 
-		          UNION
-                         SELECT id, approved, 'ar' as tablename FROM ar
-			 UNION 
-                         SELECT id, approved, 'gl' as tablename FROM gl
-		    ) g ON (g.id = acc_trans.trans_id 
-				AND transactions.table_name = g.tablename)
-		    WHERE ($approved OR acc_trans.approved)
-			  AND (g.approved OR $approved)
-		 GROUP BY accno|;
-
-    my $sth = $dbh->prepare($query);
-    $sth->execute || $form->dberror($query);
-
-    while ( my $ref = $sth->fetchrow_hashref(NAME_lc) ) {
-        $form->db_parse_numeric(sth=>$sth, hashref=>$ref);
-        $amount{ $ref->{accno} } = $ref->{amount};
-    }
-
-    $sth->finish;
-
-    $query = qq|
-		SELECT accno, description
-		  FROM gifi|;
-
-    $sth = $dbh->prepare($query);
-    $sth->execute || $form->dberror($query);
-
-    my $gifi = ();
-
-    while ( my ( $accno, $description ) = $sth->fetchrow_array ) {
-        $gifi{$accno} = $description;
-    }
-
-    $sth->finish;
-
-    $query = qq|
-		    SELECT c.id, c.accno, c.description, c.charttype, 
-		           c.gifi_accno, c.category, c.link
-		      FROM chart c
-		  ORDER BY accno, c.charttype DESC|;
-
-    $sth = $dbh->prepare($query);
-    $sth->execute || $form->dberror($query);
-
-    while ( my $ca = $sth->fetchrow_hashref(NAME_lc) ) {
-        $ca->{amount}           = $amount{ $ca->{accno} };
-        $ca->{gifi_description} = $gifi{ $ca->{gifi_accno} };
-
-        if ( $ca->{amount} < 0 ) {
-            $ca->{debit} = $ca->{amount} * -1;
-        }
-        else {
-            $ca->{credit} = $ca->{amount};
-        }
-
-        push @{ $form->{CA} }, $ca;
-    }
-
-    $sth->finish;
-    $dbh->commit;
-
-}
-
-1;

Modified: trunk/LedgerSMB/Form.pm
===================================================================
--- trunk/LedgerSMB/Form.pm	2012-05-28 05:19:33 UTC (rev 4792)
+++ trunk/LedgerSMB/Form.pm	2012-05-28 05:38:34 UTC (rev 4793)
@@ -1,4 +1,3 @@
-
 =head1 NAME
 
 LedgerSMB::Form - Provides general legacy support functions and the central object.
@@ -2286,6 +2285,7 @@
     # now get the account numbers
     $query = qq|SELECT accno, description, link
 				  FROM chart
+                  JOIN account USING id AND NOT obsolete
 				 WHERE link LIKE ?
 			  ORDER BY accno|;
 

Modified: trunk/UI/accounts/edit.html
===================================================================
--- trunk/UI/accounts/edit.html	2012-05-28 05:19:33 UTC (rev 4792)
+++ trunk/UI/accounts/edit.html	2012-05-28 05:38:34 UTC (rev 4793)
@@ -35,6 +35,24 @@
     } ?>
   </div>
 </div>
+<?lsmb IF form.id ?>
+<div  class="inputline" id="obsolete-line">
+<label class="line" for='obsolete'><?lsmb text('Obsolete') ?></label>
+<?lsmb
+        IF form.obsolete; 
+           obsolete = 'CHECKED';
+        END; 
+        INCLUDE input element_data={
+               name = 'obsolete'
+               type = 'checkbox',
+            checked = obsolete
+              value = '1'
+        } ?>
+   </div>
+   
+</div>
+<?lsmb END #  IF ID ?>
+<div class="inputline" id="obsolete_line">
 <div class="inputline" id="desc-line">
    <label class="line"><?lsmb text('Description') ?></label>
    <div class="inputgroup">

Modified: trunk/bin/am.pl
===================================================================
--- trunk/bin/am.pl	2012-05-28 05:19:33 UTC (rev 4792)
+++ trunk/bin/am.pl	2012-05-28 05:38:34 UTC (rev 4793)
@@ -33,7 +33,6 @@
 #======================================================================
 
 use LedgerSMB::AM;
-use LedgerSMB::CA;
 use LedgerSMB::Form;
 use LedgerSMB::User;
 use LedgerSMB::RP;
@@ -178,164 +177,6 @@
 
 }
 
-sub list_account {
-
-    CA->all_accounts( \%myconfig, \%$form );
-
-    $form->{title} = $locale->text('Chart of Accounts');
-
-    # construct callback
-    $callback =
-"$form->{script}?action=list_account&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}";
-
-    $form->{callback} = $callback;
-    @column_index = qw(accno gifi_accno description debit credit link delete);
-
-    my $column_names = {
-        accno => $locale->text('Account'),
-        gifi_accno => $locale->text('GIFI'),
-        description => $locale->text('Description'),
-        debit => $locale->text('Debit'),
-        credit => $locale->text('Credit'),
-        link => $locale->text('Link'),
-        delete => $locale->text('Delete')
-    };
-
-    # escape callback
-    $callback = $form->escape($callback);
-
-    my @rows;
-    foreach my $ca ( @{ $form->{CA} } ) {
-
-        my %column_data;
-        $ca->{debit}  = " ";
-        $ca->{credit} = " ";
-
-        if ( $ca->{amount} > 0 ) {
-            $ca->{credit} =
-              $form->format_amount( \%myconfig, $ca->{amount}, 2, " " );
-        }
-        if ( $ca->{amount} < 0 ) {
-            $ca->{debit} =
-              $form->format_amount( \%myconfig, -$ca->{amount}, 2, " " );
-        }
-
-        #$ca->{link} =~ s/:/<br>/og;
-
-        $gifi_accno = $form->escape( $ca->{gifi_accno} );
-
-        if ( $ca->{charttype} eq "H" ) {
-            $column_data{class} = 'heading';
-            $column_data{accno} = {
-              text => $ca->{accno},
-              href => "account.pl?action=edit&id=$ca->{id}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&charttype=H&callback=$callback"};
-            $column_data{gifi_accno} = {
-              text => $ca->{gifi_accno},
-              href => "$form->{script}?action=edit_gifi&accno=$gifi_accno&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback"};
-            $column_data{description} = $ca->{description};
-            $column_data{debit}  = " ";
-            $column_data{credit} = " ";
-            $column_data{link}   = " ";
-
-        }
-        else {
-            $i++;
-            $i %= 2;
-            $column_data{i} = $i;
-            $column_data{accno} = {
-              text => $ca->{accno},
-              href => "account.pl?action=edit&charttype=A&id=$ca->{id}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback"};
-            $column_data{gifi_accno} = {
-              text => $ca->{gifi_accno},
-              href => "$form->{script}?action=edit_gifi&accno=$gifi_accno&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback"};
-            $column_data{description} = $ca->{description};
-            $column_data{debit}       = $ca->{debit};
-            $column_data{credit} = $ca->{credit};
-	    if (($ca->{debit} =~ /\d/ )or ($ca->{credit} =~ /\d/)){
-               # Note, this is just a stub in case we want to put a 
-               # message here --CT
-            } else {
-                $column_data{delete} ={text => '['.$locale->text('Delete').']',
-                                      href => 'am.pl?action=delete_account&'.
-                                              'id='.$ca->{id} };
-            }
-	    $column_data{link}   = {text => $ca->{link}, delimiter => ':'};
-
-        }
-        push @rows, \%column_data;
-    }
-
-    my %can_load;
-    $can_load{CSV} = 1;
-    $can_load{ODS} = eval { require OpenOffice::OODoc };
-
-    my @buttons;
-    for my $type (qw(CSV ODS)) {
-        push @buttons, {
-            name => 'action',
-            value => lc "${type}_list_account",
-            text => $locale->text("[_1] Report", $type),
-            type => 'submit',
-            class => 'submit',
-            disabled => $can_load{$type} ? "" : "disabled",
-        };
-    }
-    my %hiddens = (
-        callback => $callback,
-        action => 'list_account',
-        path => $form->{path},
-        login => $form->{login},
-        sessionid => $form->{sessionid},
-        );
-
-    my %row_alignment = ('credit' => 'right', 'debit' => 'right');
-    my $format = uc substr($form->{action}, 0, 3);
-    my $template = LedgerSMB::Template->new(
-        user => \%myconfig, 
-        locale => $locale,
-        path => 'UI',
-        template => 'form-dynatable',
-        format => ($format ne 'LIS')? $format: 'HTML');
-    
-    my $column_heading = $template->column_heading($column_names);
-    
-    $template->render({
-        form => $form,
-        buttons => ..hidden..,
-	hiddens => \%hiddens,
-        columns => ..hidden..,
-        heading => $column_heading,
-        rows => ..hidden..,
-	row_alignment => \%row_alignment,
-    });
-}
-
-sub csv_list_account { &list_account }
-sub xls_list_account { &list_account }
-sub ods_list_account { &list_account }
-
-sub delete_account {
-
-    $form->{title} = $locale->text('Delete Account');
-
-    foreach $id (
-        qw(inventory_accno_id income_accno_id expense_accno_id fxgain_accno_id fxloss_accno_id)
-      )
-    {
-        if ( $form->{id} == $form->{$id} ) {
-            $form->error( $locale->text('Cannot delete default account!') );
-        }
-    }
-
-    if ( AM->delete_account( \%myconfig, \%$form ) ) {
-        $form->redirect( $locale->text('Account deleted!') );
-    }
-    else {
-        $form->error( $locale->text('Cannot delete account!') );
-    }
-
-}
-
 sub list_gifi {
 
     @{ $form->{fields} } = qw(accno description);

Deleted: trunk/bin/ca.pl
===================================================================
--- trunk/bin/ca.pl	2012-05-28 05:19:33 UTC (rev 4792)
+++ trunk/bin/ca.pl	2012-05-28 05:38:34 UTC (rev 4793)
@@ -1,290 +0,0 @@
-#=====================================================================
-# LedgerSMB Small Medium Business Accounting
-# http://www.ledgersmb.org/
-#
-
-# Copyright (C) 2006
-# This work contains copyrighted information from a number of sources all used
-# with permission.
-#
-# This file contains source code included with or based on SQL-Ledger which
-# is Copyright Dieter Simader and DWS Systems Inc. 2000-2005 and licensed
-# under the GNU General Public License version 2 or, at your option, any later
-# version.  For a full list including contact information of contributors,
-# maintainers, and copyright holders, see the CONTRIBUTORS file.
-#
-# Original Copyright Notice from SQL-Ledger 2.6.17 (before the fork):
-# Copyright (C) 2001
-#
-#  Author: DWS Systems Inc.
-#     Web: http://www.sql-ledger.org
-#
-#  Contributors:
-#
-#
-#  Author: DWS Systems Inc.
-#     Web: http://www.ledgersmb.org/
-#
-#  Contributors:
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-#======================================================================
-#
-# module for Chart of Accounts, Income Statement and Balance Sheet
-# search and edit transactions posted by the GL, AR and AP
-#
-#======================================================================
-
-use LedgerSMB::CA;
-use LedgerSMB::Template;
-
-1;
-
-# end of main
-
-# this is for our long dates
-# $locale->text('January')
-# $locale->text('February')
-# $locale->text('March')
-# $locale->text('April')
-# $locale->text('May ')
-# $locale->text('June')
-# $locale->text('July')
-# $locale->text('August')
-# $locale->text('September')
-# $locale->text('October')
-# $locale->text('November')
-# $locale->text('December')
-
-# this is for our short month
-# $locale->text('Jan')
-# $locale->text('Feb')
-# $locale->text('Mar')
-# $locale->text('Apr')
-# $locale->text('May')
-# $locale->text('Jun')
-# $locale->text('Jul')
-# $locale->text('Aug')
-# $locale->text('Sep')
-# $locale->text('Oct')
-# $locale->text('Nov')
-# $locale->text('Dec')
-
-sub chart_of_accounts {
-
-    CA->all_accounts( \%myconfig, \%$form );
-    my %hiddens;
-
-    @column_index = qw(accno gifi_accno description debit credit);
-
-    my $column_names = {
-        accno => 'Account',
-        gifi_accno => 'GIFI',
-        description => 'Description',
-        debit => 'Debit',
-        credit => 'Credit'
-    };
-
-    $form->{title} = $locale->text('Chart of Accounts');
-    $form->{callback} = 
-      qq|$form->{script}?path=$form->{path}&action=chart_of_accounts&login=$form->{login}&sessionid=$form->{sessionid}|;
-    $hiddens{callback} = $form->{callback};
-    $hiddens{path} = $form->{path};
-    $hiddens{action} = 'chart_of_accounts';
-    $hiddens{login} = $form->{login};
-    $hiddens{sessionid} = $form->{sessionid};
-
-    my @rows;
-    my $totaldebit = 0;
-    my $totalcredit = 0;
-    foreach my $ca ( @{ $form->{CA} } ) {
-        my %column_data;
-
-        my $description      = $form->escape( $ca->{description} );
-        my $gifi_description = $form->escape( $ca->{gifi_description} );
-
-        my $href =
-qq|$form->{script}?path=$form->{path}&action=list&accno=$ca->{accno}&login=$form->{login}&sessionid=$form->{sessionid}&description=$description&gifi_accno=$ca->{gifi_accno}&gifi_description=$gifi_description|;
-
-        if ( $ca->{charttype} eq "H" ) {
-            $column_data{class} = 'heading';
-            for (qw(accno description)) {
-                $column_data{$_} = $ca->{$_};
-            }
-            $column_data{gifi_accno} = $ca->{gifi_accno};
-        }
-        else {
-            $i++;
-            $i %= 2;
-            $column_data{i} = $i;
-            $column_data{accno} = {
-                text => $ca->{accno},
-                href => $href};
-            $column_data{gifi_accno} = {
-                text => $ca->{gifi_accno},
-                href => "$href&accounttype=gifi"};
-            $column_data{description} = $ca->{description};
-        }
-
-        $column_data{debit} =
-          $form->format_amount( \%myconfig, $ca->{debit}, 2, " " );
-        $column_data{credit} =
-          $form->format_amount( \%myconfig, $ca->{credit}, 2, " " );
-
-        $totaldebit  += $ca->{debit};
-        $totalcredit += $ca->{credit};
-
-	push @rows, \%column_data;
-    }
-
-    for (qw(accno gifi_accno description)) {
-        $column_data{$_} = " ";
-    }
-
-    $column_data{debit} = $form->format_amount( \%myconfig, $totaldebit, 2, 0 );
-    $column_data{credit} = $form->format_amount(\%myconfig, $totalcredit, 2, 0);
-
-    my @buttons;
-    push @buttons, {
-        name => 'action',
-        value => 'csv_chart_of_accounts',
-        text => $locale->text('CSV Report'),
-        type => 'submit',
-        class => 'submit',
-    };
-
-    my $template = LedgerSMB::Template->new(
-        user => \%myconfig, 
-        locale => $locale,
-        path => 'UI',
-        template => 'form-dynatable',
-        format => ($form->{action} =~ /^csv/)? 'CSV': 'HTML');
-        
-    my $column_heading = $template->column_heading($column_names);
-    
-    $template->render({
-        form => \%$form,
-        buttons => ..hidden..,
-        hiddens => \%hiddens,
-        columns => ..hidden..,
-        heading => $column_heading,
-        totals => \%column_data,
-        rows => ..hidden..,
-        row_alignment => {'credit' => 'right', 'debit' => 'right'},
-    });
-}
-
-sub csv_chart_of_accounts { &chart_of_accounts }
-
-sub list {
-
-    $form->{title} = $locale->text('List Transactions');
-    if ( $form->{accounttype} eq 'gifi' ) {
-        $form->{title} .= " - "
-          . $locale->text('GIFI')
-          . " $form->{gifi_accno} - $form->{gifi_description}";
-    }
-    else {
-        $form->{title} .= " - "
-          . $locale->text('Account')
-          . " $form->{accno} - $form->{description}";
-    }
-
-    # get departments
-    $form->all_departments( \%myconfig );
-    my $selectdepartment;
-    if ( @{ $form->{all_department} } ) {
-        $selectdepartment = {name => 'department', options => []};
-        push @{$selectdepartment->{options}}, {
-	    value => '',
-	    text => ''
-	};
-	for ( @{ $form->{all_department} } ) {
-            push @{$selectdepartment->{options}}, {
-                value => "$_->{description}--$_->{id}",
-                text => $_->{description}};
-        }
-    }
-
-    my $selectmonth;
-    my $selectyear;
-    my $interval;
-    if ( @{ $form->{all_years} } ) {
-
-        # accounting years
-        $selectyear = {name => 'year', options => []};
-        for ( @{ $form->{all_years} } ) {
-            push @{$selectyear->{options}}, {value => $_, text => $_};
-        }
-        
-        $selectmonth = {name => 'month', options => []};
-        for ( sort keys %{ $form->{all_month} } ) {
-            push @{$selectmonth->{options}}, {value => $_,
-                text => $locale->text($form->{all_month}{$_})};
-        }
-        $intervals = [
-            {type => 'radio', name => 'interval', value => '0',
-              checked => 'checked', text => $locale->text('Current')},
-            {type => 'radio', name => 'interval', value => '1',
-              text => $locale->text('Month')},
-            {type => 'radio', name => 'interval', value => '3', 
-              text => $locale->text('Quarter')},
-            {type => 'radio', name => 'interval', value => '12', 
-              text => $locale->text('Year')}];
-    }
-
-    my @includes = ({
-        type => 'checkbox',
-        name => 'l_accno',
-        value => 'Y',
-        text => $locale->text('AR/AP'),
-    },{
-        type => 'checkbox',
-        name => 'l_subtotal',
-        value => 'Y',
-        text => $locale->text('Subtotal'),
-    });
-    my $template = LedgerSMB::Template->new_UI(
-        user => \%myconfig,
-        locale => $locale,
-        template => 'ca-list-selector');
-    $template->render({
-        form => $form,
-	includes => ..hidden..,
-	selectmonth => $selectmonth,
-	selectyear => $selectyear,
-	selectdepartment => $selectdepartment,
-	intervals => $intervals,
-    });
-}
-
-sub ca_subtotal {
-
-    my %column_data;
-    for (@column_index) { $column_data{$_} = " " }
-
-    $column_data{debit} =
-      $form->format_amount( \%myconfig, $subtotaldebit, 2, " " );
-    $column_data{credit} =
-      $form->format_amount( \%myconfig, $subtotalcredit, 2, " " );
-
-    $subtotaldebit  = 0;
-    $subtotalcredit = 0;
-
-    $sameitem = $ca->{ $form->{sort} };
-    $column_data{is_subtotal} = 1;
-
-    return \%column_data;
-}
-

Modified: trunk/sql/modules/chart.sql
===================================================================
--- trunk/sql/modules/chart.sql	2012-05-28 05:19:33 UTC (rev 4792)
+++ trunk/sql/modules/chart.sql	2012-05-28 05:38:34 UTC (rev 4793)
@@ -131,6 +131,7 @@
                            or id in 
                           (select account_id from account_link 
                             where description = in_link_desc))
+                       AND not obsolete
               ORDER BY accno
 	LOOP
 		RETURN next out_row;

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