#======================================================================
use SL::GL;
+use SL::IS;
use SL::PE;
require "bin/mozilla/arap.pl";
}
-sub edit {
+sub prepare_transaction {
$lxdebug->enter_sub();
GL->transaction(\%myconfig, \%$form);
($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();
<body onLoad="fokus()">
<form method=post name="gl" action=$form->{script}>
+|;
-<input name=id type=hidden value=$form->{id}>
+ $form->hide_form(qw(id closedto locked storno storno_id));
-<input type=hidden name=closedto value=$form->{closedto}>
-<input type=hidden name=locked value=$form->{locked}>
+ print qq|
<input type=hidden name=title value="$title">
if ($form->{id}) {
- print qq|<input class=submit type=submit name=action value="|
- . $locale->text('Storno') . qq|">|;
+ if (!$form->{storno}) {
+ print qq|<input class=submit type=submit name=action value="|
+ . $locale->text('Storno') . qq|">|;
+ }
# Löschen und Ändern von Buchungen nicht mehr möglich (GoB) nur am selben Tag möglich
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}) {
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};
$form->save_history($form->dbconnect(\%myconfig));
}
# /saving the history
- &post;
+
$lxdebug->leave_sub();
}