X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Fgl.pl;h=43f5447cc60b89eaa09382e33356ea8e6704cd9b;hb=e9e216f571e214e1d19c43a2b47f04525f4aaddf;hp=e3a7a471e53725836030e1d60d082ba8be6061fd;hpb=8cef58b276ce4005c0e2ada350fecd5d7a103e89;p=kivitendo-erp.git diff --git a/bin/mozilla/gl.pl b/bin/mozilla/gl.pl index e3a7a471e..43f5447cc 100644 --- a/bin/mozilla/gl.pl +++ b/bin/mozilla/gl.pl @@ -32,9 +32,10 @@ #====================================================================== use SL::GL; +use SL::IS; use SL::PE; -require "$form->{path}/arap.pl"; +require "bin/mozilla/arap.pl"; require "bin/mozilla/common.pl"; 1; @@ -75,7 +76,7 @@ sub add { $form->{title} = "Add"; $form->{callback} = - "$form->{script}?action=add&path=$form->{path}&login=$form->{login}&password=$form->{password}" + "$form->{script}?action=add&login=$form->{login}&password=$form->{password}" unless $form->{callback}; # we use this only to set a default date @@ -109,7 +110,7 @@ sub add { } -sub edit { +sub prepare_transaction { $lxdebug->enter_sub(); GL->transaction(\%myconfig, \%$form); @@ -178,15 +179,24 @@ sub edit { ($form->datetonum($form->{transdate}, \%myconfig) <= $form->datetonum($form->{closedto}, \%myconfig)); + $lxdebug->leave_sub(); +} + +sub edit { + $lxdebug->enter_sub(); + + prepare_transaction(); + $form->{title} = "Edit"; - &form_header; - &display_rows; - &form_footer; - $lxdebug->leave_sub(); + form_header(); + display_rows(); + form_footer(); + $lxdebug->leave_sub(); } + sub search { $lxdebug->enter_sub(); @@ -364,7 +374,6 @@ $jsscript -{path}> {login}> {password}> @@ -387,7 +396,7 @@ sub generate_report { GL->all_transactions(\%myconfig, \%$form); $callback = - "$form->{script}?action=generate_report&path=$form->{path}&login=$form->{login}&password=$form->{password}"; + "$form->{script}?action=generate_report&login=$form->{login}&password=$form->{password}"; $href = $callback; @@ -768,7 +777,7 @@ sub generate_report { $column_data{id} = " $ref->{id} "; $column_data{transdate} = "$transdate"; $column_data{reference} = - "{module}.pl?action=edit&id=$ref->{id}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{reference}"; + "{module}.pl?action=edit&id=$ref->{id}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{reference}"; $column_data{description} = "$ref->{description} "; $column_data{source} = "$ref->{source} "; $column_data{notes} = "$ref->{notes} "; @@ -871,7 +880,6 @@ sub generate_report { -{path}> {login}> {password}> @@ -1319,11 +1327,11 @@ sub form_header {
{script}> +|; -{id}> + $form->hide_form(qw(id closedto locked storno storno_id)); -{closedto}> -{locked}> + print qq| @@ -1455,7 +1463,6 @@ sub form_footer { -{path}> {login}> {password}> @@ -1469,8 +1476,10 @@ sub form_footer { if ($form->{id}) { - print qq||; + if (!$form->{storno}) { + print qq||; + } # Löschen und Ändern von Buchungen nicht mehr möglich (GoB) nur am selben Tag möglich @@ -1578,19 +1587,6 @@ sub post { my @flds = qw(accno debit credit projectnumber fx_transaction source memo tax taxchart); - if ($form->{storno}) { - for my $i (1 .. $form->{rowcount}) { - unless (($form->{"debit_$i"} eq "") && ($form->{"credit_$i"} eq "")) { - if ($form->{"debit_$i"} ne "") { - $form->{"credit_$i"} = $form->{"debit_$i"}; - $form->{"debit_$i"} = ""; - } elsif ($form->{"credit_$i"} ne "") { - $form->{"debit_$i"} = $form->{"credit_$i"}; - $form->{"credit_$i"} = ""; - } - } - } - } for my $i (1 .. $form->{rowcount}) { @@ -1761,8 +1757,47 @@ sub post_as_new { sub storno { $lxdebug->enter_sub(); - $form->{id} = 0; - $form->{storno} = 1; + if (IS->has_storno(\%myconfig, $form, 'gl')) { + $form->{title} = $locale->text("Cancel General Ledger Transaction"); + $form->error($locale->text("Transaction has already been cancelled!")); + } + + my %keep_keys = map { $_, 1 } qw(login password id stylesheet); + map { delete $form->{$_} unless $keep_keys{$_} } keys %{ $form }; + + prepare_transaction(); + + for my $i (1 .. $form->{rowcount}) { + for (qw(debit credit tax)) { + $form->{"${_}_$i"} = + ($form->{"${_}_$i"}) + ? $form->format_amount(\%myconfig, $form->{"${_}_$i"}, 2) + : ""; + } + } + + $form->{storno} = 1; + $form->{storno_id} = $form->{id}; + $form->{id} = 0; + + $form->{reference} = "Storno-" . $form->{reference}; + $form->{description} = "Storno-" . $form->{description}; + + for my $i (1 .. $form->{rowcount}) { + next if (($form->{"debit_$i"} eq "") && ($form->{"credit_$i"} eq "")); + + if ($form->{"debit_$i"} ne "") { + $form->{"credit_$i"} = $form->{"debit_$i"}; + $form->{"debit_$i"} = ""; + + } else { + $form->{"debit_$i"} = $form->{"credit_$i"}; + $form->{"credit_$i"} = ""; + } + } + + post(); + # saving the history if(!exists $form->{addition} && $form->{id} ne "") { $form->{snumbers} = qq|ordnumber_| . $form->{ordnumber}; @@ -1770,7 +1805,7 @@ sub storno { $form->save_history($form->dbconnect(\%myconfig)); } # /saving the history - &post; + $lxdebug->leave_sub(); }