X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;ds=sidebyside;f=bin%2Fmozilla%2Fgl.pl;h=f4f87cc8f23142c731edcfa2bef7c45a63917093;hb=3adb0cb772af4bcdbd867b5688b3e02356a2e613;hp=4417615e1b25a1d8e33e2fd718ed02e572918725;hpb=c7f9bb36eb122b2d79f5aa8c4d080279705ddc7e;p=kivitendo-erp.git diff --git a/bin/mozilla/gl.pl b/bin/mozilla/gl.pl index 4417615e1..f4f87cc8f 100644 --- a/bin/mozilla/gl.pl +++ b/bin/mozilla/gl.pl @@ -31,15 +31,21 @@ # #====================================================================== +use utf8; +use strict; +use POSIX qw(strftime); +use List::Util qw(sum); + +use SL::FU; use SL::GL; +use SL::IS; use SL::PE; +use SL::ReportGenerator; -require "$form->{path}/arap.pl"; - -1; -# end of main - +require "bin/mozilla/common.pl"; +require "bin/mozilla/drafts.pl"; +require "bin/mozilla/reportgenerator.pl"; # this is for our long dates # $locale->text('January') @@ -69,884 +75,822 @@ require "$form->{path}/arap.pl"; # $locale->text('Nov') # $locale->text('Dec') - sub add { + $main::lxdebug->enter_sub(); + + $main::auth->assert('general_ledger'); + + my $form = $main::form; + my %myconfig = %main::myconfig; + + return $main::lxdebug->leave_sub() if (load_draft_maybe()); $form->{title} = "Add"; - - $form->{callback} = "$form->{script}?action=add&path=$form->{path}&login=$form->{login}&password=$form->{password}" unless $form->{callback}; + + $form->{callback} = "gl.pl?action=add" unless $form->{callback}; # we use this only to set a default date + # yep. aber er holt hier auch schon ALL_CHARTS. Aufwand / Nutzen? jb GL->transaction(\%myconfig, \%$form); - map { $chart .= "{accno}--$_->{taxkey_id}\">$_->{accno}--$_->{description}" } @{ $form->{chart} }; - map { $tax .= qq|$_->{taxdescription} |.($_->{rate} * 100).qq| %|} @{ $form->{TAX} }; - - $form->{chart} = $chart; - $form->{chartinit} = $chart; - $form->{rowcount} = 2; - - $form->{debitchart} = $chart; - $form->{creditchart} = $chart; - $form->{taxchart} = $tax; - - $form->{debit} = 0; + $form->{rowcount} = 2; + + $form->{debit} = 0; $form->{credit} = 0; - $form->{tax} = 0; - + $form->{tax} = 0; # departments $form->all_departments(\%myconfig); - if (@{ $form->{all_departments} }) { + if (@{ $form->{all_departments} || [] }) { $form->{selectdepartment} = "\n"; - map { $form->{selectdepartment} .= "$_->{description}--$_->{id}\n" } (@{ $form->{all_departments} }); + map { + $form->{selectdepartment} .= + "$_->{description}--$_->{id}\n" + } (@{ $form->{all_departments} || [] }); } - + + $form->{show_details} = $myconfig{show_form_details} unless defined $form->{show_details}; + &display_form(1); - + $main::lxdebug->leave_sub(); + } +sub prepare_transaction { + $main::lxdebug->enter_sub(); -sub edit { + $main::auth->assert('general_ledger'); + + my $form = $main::form; + my %myconfig = %main::myconfig; GL->transaction(\%myconfig, \%$form); - map { if ($form->{debitaccno} eq $_->{accno}) {$form->{debitchart} .= "{accno}--$_->{taxkey_id}\">$_->{accno}--$_->{description}"} } @{ $form->{chart} }; - map { if ($form->{creditaccno} eq $_->{accno}) {$form->{creditchart} .= "{accno}--$_->{taxkey_id}\">$_->{accno}--$_->{description}"} } @{ $form->{chart} }; - map { $tax .= qq|$_->{taxdescription} |.($_->{rate} * 100).qq| %|} @{ $form->{TAX} }; - - $form->{chart} = $chart; + $form->{amount} = $form->format_amount(\%myconfig, $form->{amount}, 2); - $form->{taxchart} = $tax; - - if ($form->{tax} < 0) { - $form->{tax} = $form->{tax} * (-1); - } - - $form->{amount}=$form->format_amount(\%myconfig, $form->{amount}, 2); - # departments $form->all_departments(\%myconfig); - if (@{ $form->{all_departments} }) { + if (@{ $form->{all_departments} || [] }) { $form->{selectdepartment} = "\n"; - map { $form->{selectdepartment} .= "$_->{description}--$_->{id}\n" } (@{ $form->{all_departments} }); + map { + $form->{selectdepartment} .= + "$_->{description}--$_->{id}\n" + } (@{ $form->{all_departments} || [] }); } - $i = 1; - foreach $ref (@{ $form->{GL} }) { - $form->{"accno_$i"} = "$ref->{accno}--$ref->{description}"; + my $i = 1; + my $tax = 0; + my $taxaccno = ""; + foreach my $ref (@{ $form->{GL} }) { + my $j = $i - 1; + if ($tax && ($ref->{accno} eq $taxaccno)) { + $form->{"tax_$j"} = abs($ref->{amount}); + $form->{"taxchart_$j"} = $ref->{id} . "--" . $ref->{taxrate}; + if ($form->{taxincluded}) { + if ($ref->{amount} < 0) { + $form->{"debit_$j"} += $form->{"tax_$j"}; + } else { + $form->{"credit_$j"} += $form->{"tax_$j"}; + } + } + $form->{"project_id_$j"} = $ref->{project_id}; - $form->{"projectnumber_$i"} = "$ref->{projectnumber}--$ref->{project_id}"; - for (qw(fx_transaction source memo)) { $form->{"${_}_$i"} = $ref->{$_} } - - if ($ref->{amount} < 0) { - $form->{totaldebit} -= $ref->{amount}; - $form->{"debit_$i"} = $ref->{amount} * -1; } else { - $form->{totalcredit} += $ref->{amount}; - $form->{"credit_$i"} = $ref->{amount}; + $form->{"accno_$i"} = "$ref->{accno}--$ref->{tax_id}"; + for (qw(fx_transaction source memo)) { $form->{"${_}_$i"} = $ref->{$_} } + if ($ref->{amount} < 0) { + $form->{totaldebit} -= $ref->{amount}; + $form->{"debit_$i"} = $ref->{amount} * -1; + } else { + $form->{totalcredit} += $ref->{amount}; + $form->{"credit_$i"} = $ref->{amount}; + } + $form->{"taxchart_$i"} = "0--0.00"; + $form->{"project_id_$i"} = $ref->{project_id}; + $i++; + } + if ($ref->{taxaccno} && !$tax) { + $taxaccno = $ref->{taxaccno}; + $tax = 1; + } else { + $taxaccno = ""; + $tax = 0; } - - $i++; } $form->{rowcount} = $i; - $form->{locked} = ($form->datetonum($form->{transdate}, \%myconfig) <= $form->datetonum($form->{closedto}, \%myconfig)); + $form->{locked} = + ($form->datetonum($form->{transdate}, \%myconfig) <= + $form->datetonum($form->{closedto}, \%myconfig)); - $form->{title} = "Edit"; - - &form_header; - &display_rows; - &form_footer; - + $main::lxdebug->leave_sub(); } +sub edit { + $main::lxdebug->enter_sub(); + $main::auth->assert('general_ledger'); -sub search { + my $form = $main::form; + my %myconfig = %main::myconfig; - $form->{title} = $locale->text('Buchungsjournal'); - - $form->all_departments(\%myconfig); - # departments - if (@{ $form->{all_departments} }) { - $form->{selectdepartment} = "\n"; + prepare_transaction(); - map { $form->{selectdepartment} .= "$_->{description}--$_->{id}\n" } (@{ $form->{all_departments} }); - } - - $department = qq| - - |.$locale->text('Department').qq| - $form->{selectdepartment} - -| if $form->{selectdepartment}; - - # use JavaScript Calendar or not - $form->{jsscript} = $jscalendar; - $jsscript = ""; - if ($form->{jsscript}) - { - # with JavaScript Calendar - $button1 = qq| - - text('button').qq|> - |; - $button2 = qq| - - text('button').qq|> - |; - #write Trigger - $jsscript = Form->write_trigger(\%myconfig,"2","datefrom","BR","trigger1","dateto","BL","trigger2"); - } - else - { - # without JavaScript Calendar - $button1 = qq||; - $button2 = qq||; - } + $form->{title} = "Edit"; - $form->header; + $form->{show_details} = $myconfig{show_form_details} unless defined $form->{show_details}; - print qq| - + form_header(); + display_rows(); + form_footer(); -{script}> + $main::lxdebug->leave_sub(); +} - - - - $form->{title} - - - - - - - |.$locale->text('Reference').qq| - - |.$locale->text('Source').qq| - - - $department - - |.$locale->text('Description').qq| - - - - |.$locale->text('Notes').qq| - - - - |.$locale->text('From').qq| - $button1 - $button2 - - - |.$locale->text('Include in Report').qq| - - - - - |.$locale->text('All').qq| - |.$locale->text('Asset').qq| - |.$locale->text('Contra').qq| - |.$locale->text('Liability').qq| - |.$locale->text('Equity').qq| - |.$locale->text('Revenue').qq| - |.$locale->text('Expense').qq| - - - - - - - |.$locale->text('ID').qq| - - |.$locale->text('Date').qq| - - |.$locale->text('Reference').qq| - - |.$locale->text('Description').qq| - - |.$locale->text('Notes').qq| - - - - |.$locale->text('Debit').qq| - - |.$locale->text('Credit').qq| - - |.$locale->text('Source').qq| - - |.$locale->text('Account').qq| - - |.$locale->text('GIFI').qq| - - - - |.$locale->text('Subtotal').qq| - - - - - - - - - - - - +sub search { + $::lxdebug->enter_sub; + $::auth->assert('general_ledger'); + + $::form->all_departments(\%::myconfig); + $::form->get_lists( + projects => { key => "ALL_PROJECTS", all => 1 }, + employees => "ALL_EMPLOYEES", + ); + + my $onload = "focus()" + . qq|;setupDateFormat('|. $::myconfig{dateformat} . qq|', '| . $::locale->text("Falsches Datumsformat!") . qq|')| + . qq|;setupPoints('|. $::myconfig{numberformat} . qq|', '| . $::locale->text("wrongformat") . qq|')|; + + $::form->header; + print $::form->parse_html_template('gl/search', { + onload => $onload, + department_label => sub { ("$_[0]{description}--$_[0]{id}")x2 }, + employee_label => sub { "$_[0]{id}--$_[0]{name}" }, + }); + + $::lxdebug->leave_sub; +} -$jsscript +sub create_subtotal_row { + $main::lxdebug->enter_sub(); - + my ($totals, $columns, $column_alignment, $subtotal_columns, $class) = @_; -{path}> -{login}> -{password}> + my $form = $main::form; + my %myconfig = %main::myconfig; - - - + my $row = { map { $_ => { 'data' => '', 'class' => $class, 'align' => $column_alignment->{$_}, } } @{ $columns } }; - -