+
+ |
+ . $locale->text("Previous transnumber text")
+ . " $form->{previous_id} "
+ . $locale->text("Previous transdate text")
+ . " $form->{previous_gldate}"
+ . qq| |
+
- | . $locale->text('Reference') . qq| |
- |
+ | . $locale->text('Reference') . qq| |
+ |
@@ -1358,7 +1397,7 @@ sub form_header {
@@ -1369,13 +1408,13 @@ sub form_header {
if ($form->{id}) {
print qq|
- | . $locale->text('Description') . qq| |
+ | . $locale->text('Description') . qq| |
$description |
|
@@ -1383,7 +1422,7 @@ sub form_header {
@@ -1397,12 +1436,18 @@ sub form_header {
|;
}
+
+ print qq|
+ | . $locale->text('Show details') . qq| |
+ |
+ |;
+
print qq|
@@ -1419,12 +1464,17 @@ sub form_header {
| |
. $locale->text('Korrektur') . qq| |
|
- . $locale->text('Taxkey') . qq| |
- |
- . $locale->text('Source') . qq| |
+ . $locale->text('Taxkey') . qq||;
+
+ if ($form->{show_details}) {
+ print qq|
+ | . $locale->text('Source') . qq| |
| . $locale->text('Memo') . qq| |
- |
- . $locale->text('Project Number') . qq| |
+ | . $locale->text('Project Number') . qq| |
+|;
+ }
+
+ print qq|
$jsscript
@@ -1441,8 +1491,7 @@ sub form_footer {
$radieren = ($form->current_date(\%myconfig) eq $form->{gldate}) ? 1 : 0;
map {
- $form->{$_} =
- $form->format_amount(\%myconfig, $form->{$_}, 2, " ")
+ $form->{$_} = $form->format_amount(\%myconfig, $form->{$_}, 2, " ")
} qw(totaldebit totalcredit);
print qq|
@@ -1457,7 +1506,6 @@ sub form_footer {
-{path}>
{login}>
{password}>
@@ -1471,29 +1519,22 @@ 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
-
if (!$form->{locked} && $radieren) {
print qq|
-
- |;
+
+ |;
}
- # if ($transdate > $closedto) {
- # print qq|
- # |;
- # }
} else {
if ($transdate > $closedto) {
- print qq|
- |;
+ print qq|
+
+ |;
}
}
@@ -1546,6 +1587,7 @@ sub yes {
if (GL->delete_transaction(\%myconfig, \%$form)){
# saving the history
if(!exists $form->{addition} && $form->{id} ne "") {
+ $form->{snumbers} = qq|ordnumber_| . $form->{ordnumber};
$form->{addition} = "DELETED";
$form->save_history($form->dbconnect(\%myconfig));
}
@@ -1557,7 +1599,7 @@ sub yes {
}
-sub post {
+sub post_transaction {
$lxdebug->enter_sub();
# check if there is something in reference and date
@@ -1577,104 +1619,87 @@ sub post {
$creditlock = 0;
$debitlock = 0;
- 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"} = "";
- }
- }
- }
- }
+ my @flds = qw(accno debit credit projectnumber fx_transaction source memo tax taxchart);
for my $i (1 .. $form->{rowcount}) {
+ next if $form->{"debit_$i"} eq "" && $form->{"credit_$i"} eq "";
- unless (($form->{"debit_$i"} eq "") && ($form->{"credit_$i"} eq "")) {
- for (qw(debit credit tax)) {
- $form->{"${_}_$i"} =
- $form->parse_amount(\%myconfig, $form->{"${_}_$i"});
- }
+ for (qw(debit credit tax)) {
+ $form->{"${_}_$i"} = $form->parse_amount(\%myconfig, $form->{"${_}_$i"});
+ }
- push @a, {};
- $debitcredit = ($form->{"debit_$i"} == 0) ? "0" : "1";
+ push @a, {};
+ $debitcredit = ($form->{"debit_$i"} == 0) ? "0" : "1";
- if ($debitcredit) {
- $debitcount++;
- } else {
- $creditcount++;
- }
+ if ($debitcredit) {
+ $debitcount++;
+ } else {
+ $creditcount++;
+ }
- if (($debitcount >= 2) && ($creditcount == 2)) {
- $form->{"credit_$i"} = 0;
- $form->{"tax_$i"} = 0;
- $creditcount--;
- $creditlock = 1;
- }
- if (($creditcount >= 2) && ($debitcount == 2)) {
- $form->{"debit_$i"} = 0;
- $form->{"tax_$i"} = 0;
- $debitcount--;
- $debitlock = 1;
- }
- if (($creditcount == 1) && ($debitcount == 2)) {
- $creditlock = 1;
- }
- if (($creditcount == 2) && ($debitcount == 1)) {
- $debitlock = 1;
- }
- if ($debitcredit && $credittax) {
- $form->{"taxchart_$i"} = "0--0.00";
- }
- if (!$debitcredit && $debittax) {
- $form->{"taxchart_$i"} = "0--0.00";
- }
- $amount =
- ($form->{"debit_$i"} == 0)
- ? $form->{"credit_$i"}
- : $form->{"debit_$i"};
- $j = $#a;
- if (($debitcredit && $credittax) || (!$debitcredit && $debittax)) {
- $form->{"taxchart_$i"} = "0--0.00";
- $form->{"tax_$i"} = 0;
- }
- if (!$form->{"korrektur_$i"}) {
- ($taxkey, $rate) = split(/--/, $form->{"taxchart_$i"});
- if ($taxkey > 1) {
+ if (($debitcount >= 2) && ($creditcount == 2)) {
+ $form->{"credit_$i"} = 0;
+ $form->{"tax_$i"} = 0;
+ $creditcount--;
+ $creditlock = 1;
+ }
+ if (($creditcount >= 2) && ($debitcount == 2)) {
+ $form->{"debit_$i"} = 0;
+ $form->{"tax_$i"} = 0;
+ $debitcount--;
+ $debitlock = 1;
+ }
+ if (($creditcount == 1) && ($debitcount == 2)) {
+ $creditlock = 1;
+ }
+ if (($creditcount == 2) && ($debitcount == 1)) {
+ $debitlock = 1;
+ }
+ if ($debitcredit && $credittax) {
+ $form->{"taxchart_$i"} = "0--0.00";
+ }
+ if (!$debitcredit && $debittax) {
+ $form->{"taxchart_$i"} = "0--0.00";
+ }
+ $amount = ($form->{"debit_$i"} == 0)
+ ? $form->{"credit_$i"}
+ : $form->{"debit_$i"};
+ $j = $#a;
+ if (($debitcredit && $credittax) || (!$debitcredit && $debittax)) {
+ $form->{"taxchart_$i"} = "0--0.00";
+ $form->{"tax_$i"} = 0;
+ }
+ if (!$form->{"korrektur_$i"}) {
+ ($taxkey, $rate) = split(/--/, $form->{"taxchart_$i"});
+ if ($taxkey > 1) {
+ if ($debitcredit) {
+ $debittax = 1;
+ } else {
+ $credittax = 1;
+ }
+ if ($form->{taxincluded}) {
+ $form->{"tax_$i"} = $amount / ($rate + 1) * $rate;
if ($debitcredit) {
- $debittax = 1;
+ $form->{"debit_$i"} = $form->{"debit_$i"} - $form->{"tax_$i"};
} else {
- $credittax = 1;
- }
- if ($form->{taxincluded}) {
- $form->{"tax_$i"} = $amount / ($rate + 1) * $rate;
- if ($debitcredit) {
- $form->{"debit_$i"} = $form->{"debit_$i"} - $form->{"tax_$i"};
- } else {
- $form->{"credit_$i"} = $form->{"credit_$i"} - $form->{"tax_$i"};
- }
- } else {
- $form->{"tax_$i"} = $amount * $rate;
+ $form->{"credit_$i"} = $form->{"credit_$i"} - $form->{"tax_$i"};
}
} else {
- $form->{"tax_$i"} = 0;
- }
- } elsif ($form->{taxincluded}) {
- if ($debitcredit) {
- $form->{"debit_$i"} = $form->{"debit_$i"} - $form->{"tax_$i"};
- } else {
- $form->{"credit_$i"} = $form->{"credit_$i"} - $form->{"tax_$i"};
+ $form->{"tax_$i"} = $amount * $rate;
}
+ } else {
+ $form->{"tax_$i"} = 0;
+ }
+ } elsif ($form->{taxincluded}) {
+ if ($debitcredit) {
+ $form->{"debit_$i"} = $form->{"debit_$i"} - $form->{"tax_$i"};
+ } else {
+ $form->{"credit_$i"} = $form->{"credit_$i"} - $form->{"tax_$i"};
}
-
- for (@flds) { $a[$j]->{$_} = $form->{"${_}_$i"} }
- $count++;
}
+
+ for (@flds) { $a[$j]->{$_} = $form->{"${_}_$i"} }
+ $count++;
}
for $i (1 .. $count) {
@@ -1691,31 +1716,14 @@ sub post {
$cr = $form->{"credit_$i"};
$tax = $form->{"tax_$i"};
if ($dr && $cr) {
- $form->error(
- $locale->text(
- 'Cannot post transaction with a debit and credit entry for the same account!'
- ));
+ $form->error($locale->text('Cannot post transaction with a debit and credit entry for the same account!'));
}
- if ($form->{taxincluded}) {
- if ($dr) {
- $debit += $dr + $tax;
- }
- if ($cr) {
- $credit += $cr + $tax;
- }
- $taxtotal += $tax;
- } else {
- if ($dr) {
- $debit += $dr + $tax;
- }
- if ($cr) {
- $credit += $cr + $tax;
- }
- }
- }
- if (!$taxtotal) {
- $form->{taxincluded} = 0;
+ $debit += $dr + $tax if $dr;
+ $credit += $cr + $tax if $cr;
+ $taxtotal += $tax if $form->{taxincluded}
}
+
+ $form->{taxincluded} = 0 if !$taxtotal;
# this is just for the wise guys
$form->error($locale->text('Cannot post transaction for a closed period!'))
@@ -1739,14 +1747,28 @@ sub post {
undef($form->{callback});
# saving the history
if(!exists $form->{addition} && $form->{id} ne "") {
- $form->{addition} = "SAVED";
- $form->{what_done} = $locale->text("Buchungsnummer") . " = " . $form->{id};
- $form->save_history($form->dbconnect(\%myconfig));
+ $form->{snumbers} = qq|ordnumber_| . $form->{ordnumber};
+ $form->{addition} = "SAVED";
+ $form->{what_done} = $locale->text("Buchungsnummer") . " = " . $form->{id};
+ $form->save_history($form->dbconnect(\%myconfig));
}
# /saving the history
- $form->redirect("Buchung gespeichert. Buchungsnummer = " . $form->{id});
+
$lxdebug->leave_sub();
+}
+
+sub post {
+ $lxdebug->enter_sub();
+
+ $form->{title} = $locale->text("$form->{title} General Ledger Transaction");
+ $form->{storno} = 0;
+
+ post_transaction();
+ $form->{callback} = build_std_url("action=add", "show_details");
+ $form->redirect($form->{callback});
+
+ $lxdebug->leave_sub();
}
sub post_as_new {
@@ -1761,15 +1783,57 @@ 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_transaction();
+
# saving the history
if(!exists $form->{addition} && $form->{id} ne "") {
+ $form->{snumbers} = qq|ordnumber_| . $form->{ordnumber};
$form->{addition} = "STORNO";
$form->save_history($form->dbconnect(\%myconfig));
}
# /saving the history
- &post;
+
+ $form->redirect(sprintf $locale->text("Transaction %d cancelled."), $form->{storno_id});
+
$lxdebug->leave_sub();
}
| |