'-labels' => \%project_labels));
# use JavaScript Calendar or not
- $form->{jsscript} = $jscalendar;
+ $form->{jsscript} = 1;
$jsscript = "";
if ($form->{jsscript}) {
if ($init) {
$korrektur =
- qq|<td><input type="checkbox" name="korrektur_$i" value="1"</td>|;
+ qq|<td><input type="checkbox" name="korrektur_$i" value="1"></td>|;
if ($form->{transfer}) {
$fx_transaction = qq|
<td><input name="fx_transaction_$i" class=checkbox type=checkbox value=1></td>
qq|<td><input name=transdate id=transdate size=11 title="$myconfig{dateformat}" value="$form->{transdate}" $readonly onBlur=\"check_right_date_format(this)\"></td>|;
}
+ $form->{previous_id} ||= "--";
+ $form->{previous_gldate} ||= "--";
+
$form->header;
print qq|
<form method=post name="gl" action=$form->{script}>
|;
- $form->hide_form(qw(id closedto locked storno storno_id));
+ $form->hide_form(qw(id closedto locked storno storno_id previous_id previous_gldate));
print qq|
<input type=hidden name=title value="$title">
<tr>
<td>
<table width=100%>
+ <tr>
+ <td colspan="6" align="left">|
+ . $locale->text("Previous transnumber text")
+ . " $form->{previous_id} "
+ . $locale->text("Previous transdate text")
+ . " $form->{previous_gldate}"
+ . qq|</td>
+ </tr>
<tr>
<th align=right>| . $locale->text('Reference') . qq|</th>
<td><input name=reference size=20 value="$form->{reference}" $readonly></td>
$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|
if ($form->{id}) {
if (!$form->{storno}) {
- print qq|<input class=submit type=submit name=action value="|
- . $locale->text('Storno') . qq|">|;
+ 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
-
if (!$form->{locked} && $radieren) {
print qq|
- <input class=submit type=submit name=action value="|
- . $locale->text('Post') . qq|" accesskey="b">
- <input class=submit type=submit name=action value="|
- . $locale->text('Delete') . qq|">|;
+ <input class=submit type=submit name=action value="| . $locale->text('Post') . qq|" accesskey="b">
+ <input class=submit type=submit name=action value="| . $locale->text('Delete') . qq|">|;
}
- # if ($transdate > $closedto) {
- # print qq|
- # <input class=submit type=submit name=action value="|.$locale->text('Post as new').qq|">|;
- # }
} else {
if ($transdate > $closedto) {
- print qq|<input class=submit type=submit name=action id=update_button value="|
- . $locale->text('Update') . qq|">
- <input class=submit type=submit name=action value="|
- . $locale->text('Post') . qq|">|;
+ print qq|
+ <input class=submit type=submit name=action id=update_button value="| . $locale->text('Update') . qq|">
+ <input class=submit type=submit name=action value="| . $locale->text('Post') . qq|">|;
}
}
}
-sub post {
+sub post_transaction {
$lxdebug->enter_sub();
- $form->{title} = $locale->text("$form->{title} General Ledger Transaction");
-
# check if there is something in reference and date
$form->isblank("reference", $locale->text('Reference missing!'));
$form->isblank("transdate", $locale->text('Transaction Date missing!'));
$creditlock = 0;
$debitlock = 0;
- my @flds =
- qw(accno debit credit projectnumber fx_transaction source memo tax taxchart);
+ 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;
- } 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"};
- }
+ $form->{"debit_$i"} = $form->{"debit_$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) {
$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!'
- ));
- }
- 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;
- }
+ $form->error($locale->text('Cannot post transaction with a debit and credit entry for the same account!'));
}
+ $debit += $dr + $tax if $dr;
+ $credit += $cr + $tax if $cr;
+ $taxtotal += $tax if $form->{taxincluded}
}
- if (!$taxtotal) {
- $form->{taxincluded} = 0;
- }
+
+ $form->{taxincluded} = 0 if !$taxtotal;
# this is just for the wise guys
$form->error($locale->text('Cannot post transaction for a closed period!'))
# saving the history
if(!exists $form->{addition} && $form->{id} ne "") {
$form->{snumbers} = qq|ordnumber_| . $form->{ordnumber};
- $form->{addition} = "SAVED";
- $form->{what_done} = $locale->text("Buchungsnummer") . " = " . $form->{id};
- $form->save_history($form->dbconnect(\%myconfig));
+ $form->{addition} = "SAVED";
+ $form->{what_done} = $locale->text("Buchungsnummer") . " = " . $form->{id};
+ $form->save_history($form->dbconnect(\%myconfig));
}
# /saving the history
+ $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 {
}
}
- post();
+ post_transaction();
# saving the history
if(!exists $form->{addition} && $form->{id} ne "") {
}
# /saving the history
+ $form->redirect(sprintf $locale->text("Transaction %d cancelled."), $form->{storno_id});
+
$lxdebug->leave_sub();
}