From df073d6e09c0f87fb2e88cc215ace843a5851d4a Mon Sep 17 00:00:00 2001 From: einhverfr Date: Thu, 12 Apr 2007 20:46:20 +0000 Subject: Formatting with Perltidy git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/branches/1.2@1068 4979c152-3d1c-0410-bac9-87ea11338e46 --- bin/ca.pl | 638 ++++++++++++++++++++++++++++++++++++-------------------------- 1 file changed, 369 insertions(+), 269 deletions(-) (limited to 'bin/ca.pl') diff --git a/bin/ca.pl b/bin/ca.pl index 9554914d..ae2768e8 100755 --- a/bin/ca.pl +++ b/bin/ca.pl @@ -8,9 +8,9 @@ # 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, +# 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): @@ -43,12 +43,13 @@ # # module for Chart of Accounts, Income Statement and Balance Sheet # search and edit transactions posted by the GL, AR and AP -# +# #====================================================================== use LedgerSMB::CA; 1; + # end of main # this is for our long dates @@ -79,27 +80,30 @@ use LedgerSMB::CA; # $locale->text('Nov') # $locale->text('Dec') - sub chart_of_accounts { - CA->all_accounts(\%myconfig, \%$form); + CA->all_accounts( \%myconfig, \%$form ); - @column_index = qw(accno gifi_accno description debit credit); + @column_index = qw(accno gifi_accno description debit credit); - $column_header{accno} = qq||.$locale->text('Account').qq|\n|; - $column_header{gifi_accno} = qq||.$locale->text('GIFI').qq|\n|; - $column_header{description} = qq||.$locale->text('Description').qq|\n|; - $column_header{debit} = qq||.$locale->text('Debit').qq|\n|; - $column_header{credit} = qq||.$locale->text('Credit').qq|\n|; - + $column_header{accno} = + qq|| . $locale->text('Account') . qq|\n|; + $column_header{gifi_accno} = + qq|| . $locale->text('GIFI') . qq|\n|; + $column_header{description} = + qq|| . $locale->text('Description') . qq|\n|; + $column_header{debit} = + qq|| . $locale->text('Debit') . qq|\n|; + $column_header{credit} = + qq|| . $locale->text('Credit') . qq|\n|; - $form->{title} = $locale->text('Chart of Accounts'); + $form->{title} = $locale->text('Chart of Accounts'); - $colspan = $#column_index + 1; - - $form->header; + $colspan = $#column_index + 1; + + $form->header; - print qq| + print qq| @@ -107,55 +111,73 @@ sub chart_of_accounts { |; - for (@column_index) { print $column_header{$_} } + for (@column_index) { print $column_header{$_} } - print qq| + print qq| |; - - foreach $ca (@{ $form->{CA} }) { - - $description = $form->escape($ca->{description}); - $gifi_description = $form->escape($ca->{gifi_description}); - - $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") { - print qq||; - for (qw(accno description)) { $column_data{$_} = "" } - $column_data{gifi_accno} = ""; - } else { - $i++; $i %= 2; - print qq||; - $column_data{accno} = ""; - $column_data{gifi_accno} = ""; - $column_data{description} = ""; - } - - $column_data{debit} = "\n"; - $column_data{credit} = "\n"; - - $totaldebit += $ca->{debit}; - $totalcredit += $ca->{credit}; - - for (@column_index) { print "$column_data{$_}\n" } - - print qq| + foreach $ca ( @{ $form->{CA} } ) { + + $description = $form->escape( $ca->{description} ); + $gifi_description = $form->escape( $ca->{gifi_description} ); + + $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" ) { + print qq||; + for (qw(accno description)) { + $column_data{$_} = ""; + } + $column_data{gifi_accno} = + ""; + } + else { + $i++; + $i %= 2; + print qq||; + $column_data{accno} = ""; + $column_data{gifi_accno} = +""; + $column_data{description} = ""; + } + + $column_data{debit} = + "\n"; + $column_data{credit} = + "\n"; + + $totaldebit += $ca->{debit}; + $totalcredit += $ca->{credit}; + + for (@column_index) { print "$column_data{$_}\n" } + + print qq| |; - } + } + + for (qw(accno gifi_accno description)) { + $column_data{$_} = ""; + } - for (qw(accno gifi_accno description)) { $column_data{$_} = "" } + $column_data{debit} = + ""; + $column_data{credit} = + ""; - $column_data{debit} = ""; - $column_data{credit} = ""; - - print ""; + print ""; - for (@column_index) { print "$column_data{$_}\n" } + for (@column_index) { print "$column_data{$_}\n" } - print qq| + print qq| @@ -168,57 +190,74 @@ sub 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}"; - } + $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); - if (@{ $form->{all_department} }) { - $form->{selectdepartment} = " - + | if $form->{selectdepartment}; - if (@{ $form->{all_years} }) { - # accounting years - $form->{selectaccountingyear} = " - + |; - } + } + $form->header; - $form->header; - - print qq| + print qq| {script}> @@ -241,17 +280,19 @@ sub list {
$ca->{$_}$ca->{gifi_accno} 
$ca->{accno}$ca->{gifi_accno} $ca->{description}".$form->format_amount(\%myconfig, $ca->{debit}, 2, " ")."".$form->format_amount(\%myconfig, $ca->{credit}, 2, " ")."
$ca->{$_}$ca->{gifi_accno} 
$ca->{accno}$ca->{gifi_accno} $ca->{description}" + . $form->format_amount( \%myconfig, $ca->{debit}, 2, " " ) + . "" + . $form->format_amount( \%myconfig, $ca->{credit}, 2, " " ) + . "
  " + . $form->format_amount( \%myconfig, $totaldebit, 2, 0 ) . "" + . $form->format_amount( \%myconfig, $totalcredit, 2, 0 ) . "".$form->format_amount(\%myconfig, $totaldebit, 2, 0)."".$form->format_amount(\%myconfig, $totalcredit, 2, 0)."

|.$locale->text('Department').qq|| . $locale->text('Department') . qq|
|.$locale->text('Period').qq|| . $locale->text('Period') . qq| -  |.$locale->text('Current').qq| -  |.$locale->text('Month').qq| -  |.$locale->text('Quarter').qq| -  |.$locale->text('Year').qq| +  | + . $locale->text('Current') . qq| +  | + . $locale->text('Month') . qq| +  | + . $locale->text('Quarter') . qq| +  | + . $locale->text('Year') . qq|
$department - + - + $selectfrom - +
|.$locale->text('From').qq|| . $locale->text('From') . qq| |.$locale->text('To').qq|| . $locale->text('To') . qq|
|.$locale->text('Include in Report').qq|| . $locale->text('Include in Report') . qq| -  |.$locale->text('AR/AP').qq| -  |.$locale->text('Subtotal').qq| +  | + . $locale->text('AR/AP') . qq| +  | + . $locale->text('Subtotal') . qq|
@@ -264,7 +305,9 @@ sub list { -
+
@@ -273,104 +316,133 @@ sub list { } - sub list_transactions { - CA->all_transactions(\%myconfig, \%$form); - - $department = $form->escape($form->{department}); - $projectnumber = $form->escape($form->{projectnumber}); - $title = $form->escape($form->{title}); + CA->all_transactions( \%myconfig, \%$form ); - # construct href - $href = "$form->{script}?action=list_transactions&department=$department&projectnumber=$projectnumber&title=$title"; - for (qw(path oldsort accno login sessionid fromdate todate accounttype gifi_accno l_heading l_subtotal l_accno)) { $href .= "&$_=$form->{$_}" } + $department = $form->escape( $form->{department} ); + $projectnumber = $form->escape( $form->{projectnumber} ); + $title = $form->escape( $form->{title} ); - $drilldown = $href; - $drilldown .= "&sort=$form->{sort}"; + # construct href + $href = +"$form->{script}?action=list_transactions&department=$department&projectnumber=$projectnumber&title=$title"; + for ( + qw(path oldsort accno login sessionid fromdate todate accounttype gifi_accno l_heading l_subtotal l_accno) + ) + { + $href .= "&$_=$form->{$_}"; + } - $href .= "&direction=$form->{direction}"; - - $form->sort_order(); - - $drilldown .= "&direction=$form->{direction}"; - - $form->{prevreport} = $href unless $form->{prevreport}; - $href .= "&prevreport=".$form->escape($form->{prevreport}); - $drilldown .= "&prevreport=".$form->escape($form->{prevreport}); - - # figure out which column comes first - $column_header{transdate} = qq||.$locale->text('Date').qq||; - $column_header{reference} = qq||.$locale->text('Reference').qq||; - $column_header{description} = qq||.$locale->text('Description').qq||; - $column_header{cleared} = qq||.$locale->text('R').qq||; - $column_header{source} = qq||.$locale->text('Source').qq||; - $column_header{debit} = qq||.$locale->text('Debit').qq||; - $column_header{credit} = qq||.$locale->text('Credit').qq||; - $column_header{balance} = qq||.$locale->text('Balance').qq||; - $column_header{accno} = qq||.$locale->text('AR/AP').qq||; - - @columns = qw(transdate reference description debit credit); - if ($form->{link} =~ /_paid/) { - @columns = qw(transdate reference description source cleared debit credit); - } - push @columns, "accno" if $form->{l_accno}; - @column_index = $form->sort_columns(@columns); - - - if ($form->{accounttype} eq 'gifi') { - for (qw(accno description)) { $form->{$_} = $form->{"gifi_$_"} } - } - if ($form->{accno}) { - push @column_index, "balance"; - } - - $form->{title} = ($form->{accounttype} eq 'gifi') ? $locale->text('GIFI') : $locale->text('Account'); - - $form->{title} .= " $form->{accno} - $form->{description}"; + $drilldown = $href; + $drilldown .= "&sort=$form->{sort}"; + + $href .= "&direction=$form->{direction}"; + + $form->sort_order(); + + $drilldown .= "&direction=$form->{direction}"; + + $form->{prevreport} = $href unless $form->{prevreport}; + $href .= "&prevreport=" . $form->escape( $form->{prevreport} ); + $drilldown .= "&prevreport=" . $form->escape( $form->{prevreport} ); + + # figure out which column comes first + $column_header{transdate} = + qq|| + . $locale->text('Date') + . qq||; + $column_header{reference} = + qq|| + . $locale->text('Reference') + . qq||; + $column_header{description} = + qq|| + . $locale->text('Description') + . qq||; + $column_header{cleared} = + qq|| . $locale->text('R') . qq||; + $column_header{source} = + qq|| . $locale->text('Source') . qq||; + $column_header{debit} = + qq|| . $locale->text('Debit') . qq||; + $column_header{credit} = + qq|| . $locale->text('Credit') . qq||; + $column_header{balance} = + qq|| . $locale->text('Balance') . qq||; + $column_header{accno} = + qq|| . $locale->text('AR/AP') . qq||; + + @columns = qw(transdate reference description debit credit); + if ( $form->{link} =~ /_paid/ ) { + @columns = + qw(transdate reference description source cleared debit credit); + } + push @columns, "accno" if $form->{l_accno}; + @column_index = $form->sort_columns(@columns); - if ($form->{department}) { - ($department) = split /--/, $form->{department}; - $options = $locale->text('Department')." : $department
"; - } - if ($form->{projectnumber}) { - ($projectnumber) = split /--/, $form->{projectnumber}; - $options .= $locale->text('Project Number')." : $projectnumber
"; - } + if ( $form->{accounttype} eq 'gifi' ) { + for (qw(accno description)) { $form->{$_} = $form->{"gifi_$_"} } + } + if ( $form->{accno} ) { + push @column_index, "balance"; + } + $form->{title} = + ( $form->{accounttype} eq 'gifi' ) + ? $locale->text('GIFI') + : $locale->text('Account'); - if ($form->{fromdate} || $form->{todate}) { + $form->{title} .= " $form->{accno} - $form->{description}"; - if ($form->{fromdate}) { - $fromdate = $locale->date(\%myconfig, $form->{fromdate}, 1); + if ( $form->{department} ) { + ($department) = split /--/, $form->{department}; + $options = $locale->text('Department') . " : $department
"; } - if ($form->{todate}) { - $todate = $locale->date(\%myconfig, $form->{todate}, 1); + if ( $form->{projectnumber} ) { + ($projectnumber) = split /--/, $form->{projectnumber}; + $options .= $locale->text('Project Number') . " : $projectnumber
"; } - - $form->{period} = "$fromdate - $todate"; - } else { - $form->{period} = $locale->date(\%myconfig, $form->current_date(\%myconfig), 1); - } - $form->{period} = "{prevreport}>$form->{period}" if $form->{prevreport}; - - $options .= $form->{period}; - - - # construct callback - $department = $form->escape($form->{department},1); - $projectnumber = $form->escape($form->{projectnumber},1); - $title = $form->escape($form->{title},1); - $form->{prevreport} = $form->escape($form->{prevreport},1); - - $form->{callback} = "$form->{script}?action=list_transactions&department=$department&projectnumber=$projectnumber&title=$title"; - for (qw(path direction oldsort accno login sessionid fromdate todate accounttype gifi_accno l_heading l_subtotal l_accno prevreport)) { $form->{callback} .= "&$_=$form->{$_}" } - - - $form->header; + if ( $form->{fromdate} || $form->{todate} ) { + + if ( $form->{fromdate} ) { + $fromdate = $locale->date( \%myconfig, $form->{fromdate}, 1 ); + } + if ( $form->{todate} ) { + $todate = $locale->date( \%myconfig, $form->{todate}, 1 ); + } + + $form->{period} = "$fromdate - $todate"; + } + else { + $form->{period} = + $locale->date( \%myconfig, $form->current_date( \%myconfig ), 1 ); + } - print qq| + $form->{period} = "{prevreport}>$form->{period}" + if $form->{prevreport}; + + $options .= $form->{period}; + + # construct callback + $department = $form->escape( $form->{department}, 1 ); + $projectnumber = $form->escape( $form->{projectnumber}, 1 ); + $title = $form->escape( $form->{title}, 1 ); + $form->{prevreport} = $form->escape( $form->{prevreport}, 1 ); + + $form->{callback} = +"$form->{script}?action=list_transactions&department=$department&projectnumber=$projectnumber&title=$title"; + for ( + qw(path direction oldsort accno login sessionid fromdate todate accounttype gifi_accno l_heading l_subtotal l_accno prevreport) + ) + { + $form->{callback} .= "&$_=$form->{$_}"; + } + + $form->header; + + print qq| @@ -387,111 +459,134 @@ sub list_transactions { |; - for (@column_index) { print "$column_header{$_}\n" } + for (@column_index) { print "$column_header{$_}\n" } - print qq| + print qq| |; - # add sort to callback - $form->{callback} = $form->escape($form->{callback} . "&sort=$form->{sort}"); + # add sort to callback + $form->{callback} = + $form->escape( $form->{callback} . "&sort=$form->{sort}" ); - if (@{ $form->{CA} }) { - $sameitem = $form->{CA}->[0]->{$form->{sort}}; - } + if ( @{ $form->{CA} } ) { + $sameitem = $form->{CA}->[0]->{ $form->{sort} }; + } - $ml = ($form->{category} =~ /(A|E)/) ? -1 : 1; - $ml *= -1 if $form->{contra}; + $ml = ( $form->{category} =~ /(A|E)/ ) ? -1 : 1; + $ml *= -1 if $form->{contra}; - if ($form->{accno} && $form->{balance}) { - - for (@column_index) { $column_data{$_} = "" } + if ( $form->{accno} && $form->{balance} ) { - $column_data{balance} = ""; + for (@column_index) { $column_data{$_} = "" } - $i++; $i %= 2; - - print qq| + $column_data{balance} = + ""; + + $i++; + $i %= 2; + + print qq| |; - for (@column_index) { print "$column_data{$_}\n" } - print qq| + for (@column_index) { print "$column_data{$_}\n" } + print qq| |; - } - - foreach $ca (@{ $form->{CA} }) { - - if ($form->{l_subtotal} eq 'Y') { - if ($sameitem ne $ca->{$form->{sort}}) { - &ca_subtotal; - } } - - # construct link to source - $href = "{module}.pl?path=$form->{path}&action=edit&id=$ca->{id}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$form->{callback}>$ca->{reference}"; - - - $column_data{debit} = ""; - $column_data{credit} = ""; - - $form->{balance} += $ca->{amount}; - $column_data{balance} = ""; - - $subtotaldebit += $ca->{debit}; - $subtotalcredit += $ca->{credit}; - - $totaldebit += $ca->{debit}; - $totalcredit += $ca->{credit}; - - $column_data{transdate} = qq||; - $column_data{reference} = qq||; - $column_data{description} = qq||; - - $column_data{cleared} = ($ca->{cleared}) ? qq|| : qq||; - $column_data{source} = qq||; - - $column_data{accno} = qq||; - - if ($ca->{id} != $sameid) { - $i++; $i %= 2; - } - $sameid = $ca->{id}; - print qq| + foreach $ca ( @{ $form->{CA} } ) { + + if ( $form->{l_subtotal} eq 'Y' ) { + if ( $sameitem ne $ca->{ $form->{sort} } ) { + &ca_subtotal; + } + } + + # construct link to source + $href = +"{module}.pl?path=$form->{path}&action=edit&id=$ca->{id}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$form->{callback}>$ca->{reference}"; + + $column_data{debit} = + ""; + $column_data{credit} = + ""; + + $form->{balance} += $ca->{amount}; + $column_data{balance} = + ""; + + $subtotaldebit += $ca->{debit}; + $subtotalcredit += $ca->{credit}; + + $totaldebit += $ca->{debit}; + $totalcredit += $ca->{credit}; + + $column_data{transdate} = qq||; + $column_data{reference} = qq||; + $column_data{description} = qq||; + + $column_data{cleared} = + ( $ca->{cleared} ) ? qq|| : qq||; + $column_data{source} = qq||; + + $column_data{accno} = qq||; + + if ( $ca->{id} != $sameid ) { + $i++; + $i %= 2; + } + $sameid = $ca->{id}; + + print qq| |; - for (@column_index) { print "$column_data{$_}\n" } + for (@column_index) { print "$column_data{$_}\n" } - print qq| + print qq| |; - } - + } - if ($form->{l_subtotal} eq 'Y') { - &ca_subtotal; - } - + if ( $form->{l_subtotal} eq 'Y' ) { + &ca_subtotal; + } - for (@column_index) { $column_data{$_} = "" } - - $column_data{debit} = ""; - $column_data{credit} = ""; - $column_data{balance} = ""; + for (@column_index) { $column_data{$_} = "" } + + $column_data{debit} = + ""; + $column_data{credit} = + ""; + $column_data{balance} = + ""; - print qq| + print qq| |; - for (@column_index) { print "$column_data{$_}\n" } - - print qq| + for (@column_index) { print "$column_data{$_}\n" } + + print qq|
 ".$form->format_amount(\%myconfig, $form->{balance} * $ml, 2, 0)." " + . $form->format_amount( \%myconfig, $form->{balance} * $ml, 2, 0 ) + . "
".$form->format_amount(\%myconfig, $ca->{debit}, 2, " ")."".$form->format_amount(\%myconfig, $ca->{credit}, 2, " ")."".$form->format_amount(\%myconfig, $form->{balance} * $ml, 2, 0)."$ca->{transdate}$href$ca->{description} * $ca->{source} |; - for (@{ $ca->{accno} }) { $column_data{accno} .= "$_ " } - $column_data{accno} .= qq| " + . $form->format_amount( \%myconfig, $ca->{debit}, 2, " " ) + . "" + . $form->format_amount( \%myconfig, $ca->{credit}, 2, " " ) + . "" + . $form->format_amount( \%myconfig, $form->{balance} * $ml, 2, 0 ) + . "$ca->{transdate}$href$ca->{description} * $ca->{source} |; + for ( @{ $ca->{accno} } ) { + $column_data{accno} .= "$_ "; + } + $column_data{accno} .= qq| 
 ".$form->format_amount(\%myconfig, $totaldebit, 2, " ")."".$form->format_amount(\%myconfig, $totalcredit, 2, " ")."".$form->format_amount(\%myconfig, $form->{balance} * $ml, 2, 0)." " + . $form->format_amount( \%myconfig, $totaldebit, 2, " " ) . "" + . $form->format_amount( \%myconfig, $totalcredit, 2, " " ) . "" + . $form->format_amount( \%myconfig, $form->{balance} * $ml, 2, 0 ) + . "
@@ -504,29 +599,34 @@ sub list_transactions { |; - -} +} sub ca_subtotal { - 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; + for (@column_index) { $column_data{$_} = " " } - $sameitem = $ca->{$form->{sort}}; + $column_data{debit} = + "" + . $form->format_amount( \%myconfig, $subtotaldebit, 2, " " ) + . ""; + $column_data{credit} = + "" + . $form->format_amount( \%myconfig, $subtotalcredit, 2, " " ) + . ""; - print qq| + $subtotaldebit = 0; + $subtotalcredit = 0; + + $sameitem = $ca->{ $form->{sort} }; + + print qq| |; - for (@column_index) { print "$column_data{$_}\n" } + for (@column_index) { print "$column_data{$_}\n" } - print qq| + print qq| |; -- cgit v1.2.3