X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Fca.pl;h=e499abe701c6b80319afac572576a8d3130d80bf;hb=62f99e30c191d86af9249b6ec61f410dbe46466d;hp=f92e8774661d8072d4926a3bec2e94b9c97008a5;hpb=4dbb09950c9f5596646537c12d991c99086fe7c1;p=kivitendo-erp.git diff --git a/bin/mozilla/ca.pl b/bin/mozilla/ca.pl index f92e87746..e499abe70 100644 --- a/bin/mozilla/ca.pl +++ b/bin/mozilla/ca.pl @@ -29,13 +29,13 @@ # # module for Chart of Accounts, Income Statement and Balance Sheet # search and edit transactions posted by the GL, AR and AP -# +# #====================================================================== - use SL::CA; 1; + # end of main # this is for our long dates @@ -66,31 +66,33 @@ use SL::CA; # $locale->text('Nov') # $locale->text('Dec') - sub chart_of_accounts { $lxdebug->enter_sub(); - CA->all_accounts(\%myconfig, \%$form); @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'); $colspan = $#column_index + 1; - + $form->header; print qq| - + @@ -102,30 +104,45 @@ sub chart_of_accounts { |; - foreach $ca (@{ $form->{CA} }) { - $description = $form->escape($ca->{description}); + $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}&password=$form->{password}&description=$description&gifi_accno=$ca->{gifi_accno}&gifi_description=$gifi_description|; - + + $href = + qq|$form->{script}?path=$form->{path}&action=list&accno=$ca->{accno}&login=$form->{login}&password=$form->{password}&description=$description&gifi_accno=$ca->{gifi_accno}&gifi_description=$gifi_description|; + if ($ca->{charttype} eq "H") { print qq||; map { $column_data{$_} = ""; } qw(accno description); $column_data{gifi_accno} = ""; } else { - $i++; $i %= 2; + $i++; + $i %= 2; print qq||; - $column_data{accno} = ""; - $column_data{gifi_accno} = ""; + $column_data{accno} = ""; + $column_data{gifi_accno} = + ""; $column_data{description} = ""; } - - $column_data{debit} = "\n"; - $column_data{credit} = "\n"; - - $totaldebit += $ca->{debit}; + my $debit = ""; + my $credit = ""; + if ($ca->{debit}) { + $debit = $form->format_amount(\%myconfig, $ca->{debit}, 2, " "); + } + if ($ca->{credit}) { + $credit = $form->format_amount(\%myconfig, $ca->{credit}, 2, " "); + } + $column_data{debit} = + "\n"; + $column_data{credit} = + "\n"; + + $totaldebit += $ca->{debit}; $totalcredit += $ca->{credit}; map { print $column_data{$_} } @column_index; @@ -135,11 +152,16 @@ sub chart_of_accounts { |; } - map { $column_data{$_} = ""; } qw(accno gifi_accno description); + map { $column_data{$_} = ""; } + qw(accno gifi_accno description); + + $column_data{debit} = + ""; + $column_data{credit} = + ""; - $column_data{debit} = ""; - $column_data{credit} = ""; - print ""; map { print $column_data{$_} } @column_index; @@ -158,16 +180,14 @@ sub chart_of_accounts { $lxdebug->leave_sub(); } - sub list { $lxdebug->enter_sub(); - $form->{title} = $locale->text('List Transactions'); if ($form->{accounttype} eq 'gifi') { - $form->{title} .= " - ".$locale->text('GIFI')." $form->{gifi_accno}"; + $form->{title} .= " - " . $locale->text('GIFI') . " $form->{gifi_accno}"; } else { - $form->{title} .= " - ".$locale->text('Account')." $form->{accno}"; + $form->{title} .= " - " . $locale->text('Account') . " $form->{accno}"; } # get departments @@ -175,21 +195,23 @@ sub list { if (@{ $form->{all_departments} }) { $form->{selectdepartment} = " - + | if $form->{selectdepartment}; - $form->header; - + map { $form->{$_} =~ s/\"/"/g; } qw(description gifi_description); - + print qq| @@ -211,15 +233,16 @@ sub list {
$form->{title}
$ca->{$_}$ca->{gifi_accno} 
$ca->{accno}$ca->{gifi_accno} $ca->{accno}$ca->{gifi_accno} $ca->{description}".$form->format_amount(\%myconfig, $ca->{debit}, 2, " ")."".$form->format_amount(\%myconfig, $ca->{credit}, 2, " ")."" + . $debit + . "" + . $credit + . "  " + . $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|
$department - + - + - + +  | + . $locale->text('Subtotal') . qq|
|.$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('Subtotal').qq|
@@ -231,7 +254,8 @@ sub list { {path}> {password}> -
+
@@ -241,56 +265,68 @@ sub list { $lxdebug->leave_sub(); } - sub list_transactions { $lxdebug->enter_sub(); - CA->all_transactions(\%myconfig, \%$form); - $description = $form->escape($form->{description}); + $description = $form->escape($form->{description}); $gifi_description = $form->escape($form->{gifi_description}); - $department = $form->escape($form->{department}); - $projectnumber = $form->escape($form->{projectnumber}); - $title = $form->escape($form->{title}); + $department = $form->escape($form->{department}); + $projectnumber = $form->escape($form->{projectnumber}); + $title = $form->escape($form->{title}); # construct href - $href = "$form->{script}?path=$form->{path}&action=list_transactions&accno=$form->{accno}&login=$form->{login}&password=$form->{password}&fromdate=$form->{fromdate}&todate=$form->{todate}&description=$description&accounttype=$form->{accounttype}&gifi_accno=$form->{gifi_accno}&gifi_description=$gifi_description&l_heading=$form->{l_heading}&l_subtotal=$form->{l_subtotal}&department=$department&projectnumber=$projectnumber&project_id=$form->{project_id}&title=$title"; - - - $description = $form->escape($form->{description},1); - $gifi_description = $form->escape($form->{gifi_description},1); - $department = $form->escape($form->{department},1); - $projectnumber = $form->escape($form->{projectnumber},1); - $title = $form->escape($form->{title},1); - + $href = + "$form->{script}?path=$form->{path}&action=list_transactions&accno=$form->{accno}&login=$form->{login}&password=$form->{password}&fromdate=$form->{fromdate}&todate=$form->{todate}&description=$description&accounttype=$form->{accounttype}&gifi_accno=$form->{gifi_accno}&gifi_description=$gifi_description&l_heading=$form->{l_heading}&l_subtotal=$form->{l_subtotal}&department=$department&projectnumber=$projectnumber&project_id=$form->{project_id}&title=$title"; + + $description = $form->escape($form->{description}, 1); + $gifi_description = $form->escape($form->{gifi_description}, 1); + $department = $form->escape($form->{department}, 1); + $projectnumber = $form->escape($form->{projectnumber}, 1); + $title = $form->escape($form->{title}, 1); + # construct callback - $callback = "$form->{script}?path=$form->{path}&action=list_transactions&accno=$form->{accno}&login=$form->{login}&password=$form->{password}&fromdate=$form->{fromdate}&todate=$form->{todate}&description=$description&accounttype=$form->{accounttype}&gifi_accno=$form->{gifi_accno}&gifi_description=$gifi_description&l_heading=$form->{l_heading}&l_subtotal=$form->{l_subtotal}&department=$department&projectnumber=$projectnumber&project_id=$form->{project_id}&title=$title"; + $callback = + "$form->{script}?path=$form->{path}&action=list_transactions&accno=$form->{accno}&login=$form->{login}&password=$form->{password}&fromdate=$form->{fromdate}&todate=$form->{todate}&description=$description&accounttype=$form->{accounttype}&gifi_accno=$form->{gifi_accno}&gifi_description=$gifi_description&l_heading=$form->{l_heading}&l_subtotal=$form->{l_subtotal}&department=$department&projectnumber=$projectnumber&project_id=$form->{project_id}&title=$title"; # 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{debit} = qq||.$locale->text('Debit').qq||; - $column_header{credit} = qq||.$locale->text('Credit').qq||; - $column_header{balance} = qq||.$locale->text('Balance').qq||; - - @column_index = $form->sort_columns(qw(transdate reference description debit credit)); - + $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{debit} = qq|| . $locale->text('Debit') . qq||; + $column_header{credit} = qq|| . $locale->text('Credit') . qq||; + $column_header{balance} = qq|| . $locale->text('Balance') . qq||; + + @column_index = + $form->sort_columns(qw(transdate reference description debit credit)); + if ($form->{accounttype} eq 'gifi') { map { $form->{$_} = $form->{"gifi_$_"} } qw(accno description); } if ($form->{accno}) { push @column_index, "balance"; } - - $form->{title} = ($form->{accounttype} eq 'gifi') ? $locale->text('GIFI') : $locale->text('Account'); - + + $form->{title} = + ($form->{accounttype} eq 'gifi') + ? $locale->text('GIFI') + : $locale->text('Account'); + $form->{title} .= " $form->{accno} - $form->{description}"; if ($form->{department}) { ($department) = split /--/, $form->{department}; - $options = $locale->text('Department')." : $department
"; + $options = $locale->text('Department') . " : $department
"; } if ($form->{projectnumber}) { $options .= $locale->text('Project Number'); @@ -304,14 +340,15 @@ sub list_transactions { 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); + $form->{period} = + $locale->date(\%myconfig, $form->current_date(\%myconfig), 1); } $options .= $form->{period}; - + $form->header; print qq| @@ -331,9 +368,9 @@ sub list_transactions { |; -map { print "$column_header{$_}\n" } @column_index; + map { print "$column_header{$_}\n" } @column_index; -print qq| + print qq| |; @@ -341,17 +378,21 @@ print qq| $callback = $form->escape($callback . "&sort=$form->{sort}"); if (@{ $form->{CA} }) { - $sameitem = $form->{CA}->[0]->{$form->{sort}}; + $sameitem = $form->{CA}->[0]->{ $form->{sort} }; } $ml = ($form->{category} =~ /(A|E)/) ? -1 : 1; if ($form->{accno} && $form->{balance}) { - + map { $column_data{$_} = " " } @column_index; - $column_data{balance} = "".$form->format_amount(\%myconfig, $form->{balance} * $ml, 2, 0).""; - - $i++; $i %= 2; + $column_data{balance} = + "" + . $form->format_amount(\%myconfig, $form->{balance} * $ml, 2, 0) + . ""; + + $i++; + $i %= 2; print qq| |; @@ -360,36 +401,43 @@ print qq| |; } - + foreach $ca (@{ $form->{CA} }) { if ($form->{l_subtotal} eq 'Y') { - if ($sameitem ne $ca->{$form->{sort}}) { - &ca_subtotal; + 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}&password=$form->{password}&callback=$callback>$ca->{reference}"; + $href = + "{module}.pl?path=$form->{path}&action=edit&id=$ca->{id}&login=$form->{login}&password=$form->{password}&callback=$callback>$ca->{reference}"; + my $debit = ($ca->{debit} != 0) ? $form->format_amount(\%myconfig, $ca->{debit}, 2, " ") : " "; + $column_data{debit} = + "$debit"; + my $credit = ($ca->{credit} != 0) ? $form->format_amount(\%myconfig, $ca->{credit}, 2, " ") : " "; + $column_data{credit} = + "$credit"; - - $column_data{debit} = "".$form->format_amount(\%myconfig, $ca->{debit}, 2, " ").""; - $column_data{credit} = "".$form->format_amount(\%myconfig, $ca->{credit}, 2, " ").""; - $form->{balance} += $ca->{amount}; - $column_data{balance} = "".$form->format_amount(\%myconfig, $form->{balance} * $ml, 2, 0).""; + $column_data{balance} = + "" + . $form->format_amount(\%myconfig, $form->{balance} * $ml, 2, 0) + . ""; - $subtotaldebit += $ca->{debit}; + $subtotaldebit += $ca->{debit}; $subtotalcredit += $ca->{credit}; - - $totaldebit += $ca->{debit}; + + $totaldebit += $ca->{debit}; $totalcredit += $ca->{credit}; - - $column_data{transdate} = qq|$ca->{transdate}|; - $column_data{reference} = qq|$href|; + + $column_data{transdate} = qq|$ca->{transdate}|; + $column_data{reference} = qq|$href|; $column_data{description} = qq|$ca->{description}|; - - $i++; $i %= 2; + + $i++; + $i %= 2; print qq| |; @@ -401,25 +449,29 @@ print qq| |; } - if ($form->{l_subtotal} eq 'Y') { &ca_subtotal; } - map { $column_data{$_} = " " } @column_index; - - $column_data{debit} = "".$form->format_amount(\%myconfig, $totaldebit, 2, " ").""; - $column_data{credit} = "".$form->format_amount(\%myconfig, $totalcredit, 2, " ").""; - $column_data{balance} = "".$form->format_amount(\%myconfig, $form->{balance} * $ml, 2, 0).""; + + $column_data{debit} = + "" + . $form->format_amount(\%myconfig, $totaldebit, 2, " ") . ""; + $column_data{credit} = + "" + . $form->format_amount(\%myconfig, $totalcredit, 2, " ") . ""; + $column_data{balance} = + "" + . $form->format_amount(\%myconfig, $form->{balance} * $ml, 2, 0) . ""; print qq| |; map { print $column_data{$_} } @column_index; - + print qq| @@ -433,24 +485,26 @@ print qq| |; - + $lxdebug->leave_sub(); } - sub ca_subtotal { $lxdebug->enter_sub(); - map { $column_data{$_} = " " } @column_index; - - $column_data{debit} = "".$form->format_amount(\%myconfig, $subtotaldebit, 2, " ") . ""; - $column_data{credit} = "".$form->format_amount(\%myconfig, $subtotalcredit, 2, " ") . ""; - - $subtotaldebit = 0; + + $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}}; + $sameitem = $ca->{ $form->{sort} }; print qq| @@ -464,4 +518,3 @@ sub ca_subtotal { $lxdebug->leave_sub(); } -