-
- |
+ |
+ |
. $locale->text('Account') . qq| |
- |
+ | |
. $locale->text('Amount') . qq| |
|
. $locale->text('Tax') . qq| |
|
- . $locale->text('Korrektur') . qq| |
- |
. $locale->text('Taxkey') . qq| |
|
. $locale->text('Project') . qq| |
-
+
|;
$amount = $locale->text('Amount');
$project = $locale->text('Project');
- for $i (1 .. $form->{rowcount}) {
+ for my $i (1 .. $form->{rowcount}) {
# format amounts
$form->{"amount_$i"} =
$form->format_amount(\%myconfig, $form->{"amount_$i"}, 2);
$form->{"tax_$i"} = $form->format_amount(\%myconfig, $form->{"tax_$i"}, 2);
- $selectAR_amount = $selectAR_amount_unquoted;
- $selectAR_amount =~
- s/option value=\"$form->{"AR_amount_$i"}\"/option value=\"$form->{"AR_amount_$i"}\" selected/;
- $tax = $taxchart;
- $tax_selected = $form->{"taxchart_$i"};
- $tax =~ s/value=\"$tax_selected\"/value=\"$tax_selected\" selected/;
- $tax =
- qq| | |;
- $korrektur_checked = ($form->{"korrektur_$i"} ? 'checked' : '');
+
+ my $selected_accno_full;
+ my ($accno_row) = split(/--/, $form->{"AR_amount_$i"});
+ my $item = $charts{$accno_row};
+ $selected_accno_full = "$item->{accno}--$item->{tax_id}";
+
+ my $selected_taxchart = $form->{"taxchart_$i"};
+ my ($selected_accno, $selected_tax_id) = split(/--/, $selected_accno_full);
+ my ($previous_accno, $previous_tax_id) = split(/--/, $form->{"previous_AR_amount_$i"});
+
+ if ($previous_accno &&
+ ($previous_accno eq $selected_accno) &&
+ ($previous_tax_id ne $selected_tax_id)) {
+ my $item = $taxcharts{$selected_tax_id};
+ $selected_taxchart = "$item->{id}--$item->{rate}";
+ }
+
+ if (!$form->{"taxchart_$i"}) {
+ if ($form->{"AR_amount_$i"} =~ m/.--./) {
+ $selected_taxchart = join '--', map { ($_->{id}, $_->{rate}) } first { $_->{id} == $item->{tax_id} } @{ $form->{ALL_TAXCHARTS} };
+ } else {
+ $selected_taxchart = $taxchart_init;
+ }
+ }
+
+ $selectAR_amount =
+ NTI($cgi->popup_menu('-name' => "AR_amount_$i",
+ '-id' => "AR_amount_$i",
+ '-style' => 'width:400px',
+ '-onChange' => "setTaxkey(this, $i)",
+ '-values' => \@AR_amount_values,
+ '-labels' => \%AR_amount_labels,
+ '-default' => $selected_accno_full))
+ . $cgi->hidden('-name' => "previous_AR_amount_$i",
+ '-default' => $selected_accno_full);
+
+ $tax = qq|| .
+ NTI($cgi->popup_menu('-name' => "taxchart_$i",
+ '-id' => "taxchart_$i",
+ '-style' => 'width:200px',
+ '-values' => \@taxchart_values,
+ '-labels' => \%taxchart_labels,
+ '-default' => $selected_taxchart))
+ . qq| | |;
my $projectnumber =
NTI($cgi->popup_menu('-name' => "project_id_$i",
@@ -617,21 +620,27 @@ $jsscript
'-default' => $form->{"project_id_$i"} ));
print qq|
-
- |
+
+ $selectAR_amount |
{"amount_$i"}> |
- {"tax_$i"}> |
- |
+ $form->{"tax_$i"} |
$tax
$projectnumber |
-
+
|;
$amount = "";
$project = "";
}
+ $form->{invtotal_unformatted} = $form->{invtotal};
$form->{invtotal} = $form->format_amount(\%myconfig, $form->{invtotal}, 2);
+ $ARselected =
+ NTI($cgi->popup_menu('-name' => "ARselected", '-id' => "ARselected",
+ '-style' => 'width:400px',
+ '-values' => \@AR_values, '-labels' => \%AR_labels,
+ '-default' => $form->{ARselected}));
+
print qq|
@@ -639,16 +648,15 @@ $jsscript
|
- |
-
- $form->{invtotal} |
+ ${ARselected} |
+ $form->{invtotal} |
- {oldinvtotal}>
- {oldtotalpaid}>
+ {oldinvtotal}>
+ {oldtotalpaid}>
-
+
- |
+ |
@@ -659,22 +667,22 @@ $jsscript
- | . $locale->text('Notes') . qq| |
- $notes |
-
+ | . $locale->text('Notes') . qq| |
+ $notes |
+
|
-
- |
+ |
+ |
. $locale->text('Incoming Payments') . qq| |
-
+
|;
- if ($form->{currency} eq $form->{defaultcurrency}) {
+ if ($form->{defaultcurrency} && ($form->{currency} eq $form->{defaultcurrency})) {
@column_index = qw(datepaid source memo paid AR_paid paid_project_id);
} else {
@column_index = qw(datepaid source memo paid exchangerate AR_paid paid_project_id);
@@ -685,8 +693,8 @@ $jsscript
$column_data{exchangerate} = "" . $locale->text('Exch') . " | ";
$column_data{AR_paid} = "" . $locale->text('Account') . " | ";
$column_data{source} = "" . $locale->text('Source') . " | ";
- $column_data{memo} = "" . $locale->text('Memo') . " | ";
- $column_data{paid_project_id} = "" . $locale->text('Project Number') . " | ";
+ $column_data{memo} = "" . $locale->text('Memo') . " | ";
+ $column_data{paid_project_id} = "" . $locale->text('Project Number') . " | ";
print "
@@ -696,16 +704,23 @@ $jsscript
";
- my @triggers = ();
+ my @triggers = ();
+ my $totalpaid = 0;
+
$form->{paidaccounts}++ if ($form->{"paid_$form->{paidaccounts}"});
- for $i (1 .. $form->{paidaccounts}) {
+ for my $i (1 .. $form->{paidaccounts}) {
print "
";
- $form->{"selectAR_paid_$i"} = $form->{selectAR_paid};
- $form->{"selectAR_paid_$i"} =~
- s/option value=\"$form->{"AR_paid_$i"}\">/option value=\"$form->{"AR_paid_$i"}\" selected>/;
+ $selectAR_paid =
+ NTI($cgi->popup_menu('-name' => "AR_paid_$i",
+ '-id' => "AR_paid_$i",
+ '-values' => \@AR_paid_values,
+ '-labels' => \%AR_paid_labels,
+ '-default' => $form->{"AR_paid_$i"}));
+
+ $totalpaid += $form->{"paid_$i"};
# format amounts
if ($form->{"paid_$i"}) {
@@ -715,8 +730,12 @@ $jsscript
$form->{"exchangerate_$i"} =
$form->format_amount(\%myconfig, $form->{"exchangerate_$i"});
+ if ($form->{"exchangerate_$i"} == 0) {
+ $form->{"exchangerate_$i"} = "";
+ }
+
$exchangerate = qq| |;
- if ($form->{currency} ne $form->{defaultcurrency}) {
+ if ($form->{defaultcurrency} && ($form->{currency} ne $form->{defaultcurrency})) {
if ($form->{"forex_$i"}) {
$exchangerate =
qq|{"exchangerate_$i"}>$form->{"exchangerate_$i"}|;
@@ -731,12 +750,12 @@ $jsscript
|;
$column_data{paid} =
- qq|{"paid_$i"}> | |;
+ qq| | |;
$column_data{AR_paid} =
- qq| | |;
+ qq|${selectAR_paid} | |;
$column_data{exchangerate} = qq|$exchangerate | |;
$column_data{datepaid} =
- qq|{"datepaid_$i"}>
+ qq| |
| |;
$column_data{source} =
qq| | |;
@@ -758,12 +777,25 @@ $jsscript
";
push(@triggers, "datepaid_$i", "BL", "trigger_datepaid_$i");
}
- map { $form->{$_} =~ s/\"/"/g } qw(selectAR_paid);
- print $form->write_trigger(\%myconfig, scalar(@triggers) / 3, @triggers) .
+ my $paid_missing = $form->{invtotal_unformatted} - $totalpaid;
+
+ print qq|
+
+ |
+ |
+ | . $locale->text('Total') . qq| |
+ | . H($form->format_amount(\%myconfig, $totalpaid, 2)) . qq| |
+
+
+ |
+ |
+ | . $locale->text('Missing amount') . qq| |
+ | . H($form->format_amount(\%myconfig, $paid_missing, 2)) . qq| |
+
+| . $form->write_trigger(\%myconfig, scalar(@triggers) / 3, @triggers) .
qq|
{paidaccounts}>
-
|
@@ -774,72 +806,103 @@ $jsscript
|;
- $lxdebug->leave_sub();
+ $main::lxdebug->leave_sub();
}
sub form_footer {
- $lxdebug->enter_sub();
+ $main::lxdebug->enter_sub();
+
+ $main::auth->assert('general_ledger');
+
+ my $form = $main::form;
+ my %myconfig = %main::myconfig;
+ my $locale = $main::locale;
+ my $cgi = $main::cgi;
+
+ my ($transdate, $closedto);
+
+ my $follow_ups_block;
+ if ($form->{id}) {
+ my $follow_ups = FU->follow_ups('trans_id' => $form->{id});
+
+ if (@{ $follow_ups} ) {
+ my $num_due = sum map { $_->{due} * 1 } @{ $follow_ups };
+ $follow_ups_block = qq|| . $locale->text("There are #1 unfinished follow-ups of which #2 are due.", scalar @{ $follow_ups }, $num_due) . qq| |;
+ }
+ }
print qq|
+$follow_ups_block
+
-
-{path}>
-{login}>
-{password}>
+|
+. $cgi->hidden('-name' => 'draft_id', '-default' => [$form->{draft_id}])
+. $cgi->hidden('-name' => 'draft_description', '-default' => [$form->{draft_description}])
+. qq|
|;
+ if (!$form->{id} && $form->{draft_id}) {
+ print(NTI($cgi->checkbox('-name' => 'remove_draft', '-id' => 'remove_draft',
+ '-value' => 1, '-checked' => $form->{remove_draft},
+ '-label' => '')) .
+ qq| |);
+ }
+
$transdate = $form->datetonum($form->{transdate}, \%myconfig);
$closedto = $form->datetonum($form->{closedto}, \%myconfig);
- print qq|
-|;
+ print qq|\n|;
+
+ # ToDO: - insert a global check for stornos, so that a storno is only possible a limited time after saving it
+ print qq| |
+ if ($form->{id} && !IS->has_storno(\%myconfig, $form, 'ar') && !IS->is_storno(\%myconfig, $form, 'ar') && (($totalpaid == 0) || ($totalpaid eq "")));
+
if ($form->{id}) {
if ($form->{radier}) {
print qq|
-
-
- |;
+
+ |;
}
if ($transdate > $closedto) {
print qq|
-
- |;
+ |;
}
print qq|
-
- |;
+
+ |;
} else {
if ($transdate > $closedto) {
- print qq||;
+ print qq| | .
+ NTI($cgi->submit('-name' => 'action', '-value' => $locale->text('Save draft'), '-class' => 'submit'));
}
}
if ($form->{menubar}) {
- require "$form->{path}/menu.pl";
+ require "bin/mozilla/menu.pl";
&menubar;
}
# button for saving history
if($form->{id} ne "") {
- print qq|
- {id}
- . qq|); name=history id=history value=|
- . $locale->text('history')
- . qq|>|;
+ print qq| {id}); name=history id=history value=| . $locale->text('history') . qq|> |;
}
# /button for saving history
+ # mark_as_paid button
+ if($form->{id} ne "") {
+ print qq||;
+ }
+ # /mark_as_paid button
+
print "
@@ -847,57 +910,60 @@ sub form_footer {
";
- $lxdebug->leave_sub();
+ $main::lxdebug->leave_sub();
+}
+
+sub mark_as_paid {
+ $main::lxdebug->enter_sub();
+
+ $main::auth->assert('general_ledger');
+
+ my $form = $main::form;
+ my %myconfig = %main::myconfig;
+
+ &mark_as_paid_common(\%myconfig,"ar");
+
+ $main::lxdebug->leave_sub();
}
sub update {
- $lxdebug->enter_sub();
+ $main::lxdebug->enter_sub();
- my $display = shift;
+ $main::auth->assert('general_ledger');
- # if ($display) {
- # goto TAXCALC;
- # }
+ my $form = $main::form;
+ my %myconfig = %main::myconfig;
- $form->{invtotal} = 0;
+ my $display = shift;
- # $form->{selectAR_amount} = $form->{AR_amount};
- # $form->{selectAR_amount} =~
- # s/value=\"$form->{AR_amountselected}\"/value=\"$form->{AR_amountselected}\" selected/;
+ my ($totaltax, $exchangerate);
- ($AR_amountaccno, $AR_amounttaxkey) =
- split(/--/, $form->{AR_amountselected});
- $form->{selecttaxchart} = $form->{taxchart};
- $form->{selecttaxchart} =~
- s/value=\"$AR_amounttaxkey--([^\"]*)\"/value=\"$AR_amounttaxkey--$1\" selected/;
+ $form->{invtotal} = 0;
- $form->{rate} = $1;
+ delete @{ $form }{ grep { m/^tax_\d+$/ } keys %{ $form } };
map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
qw(exchangerate creditlimit creditremaining);
- @flds = qw(amount AR_amount projectnumber oldprojectnumber project_id);
- $count = 0;
- @a = ();
+ my @flds = qw(amount AR_amount projectnumber oldprojectnumber project_id);
+ my $count = 0;
+ my @a = ();
- for $i (1 .. $form->{rowcount}) {
- $form->{"amount_$i"} =
- $form->parse_amount(\%myconfig, $form->{"amount_$i"});
+ for my $i (1 .. $form->{rowcount}) {
+ $form->{"amount_$i"} = $form->parse_amount(\%myconfig, $form->{"amount_$i"});
$form->{"tax_$i"} = $form->parse_amount(\%myconfig, $form->{"tax_$i"});
if ($form->{"amount_$i"}) {
push @a, {};
- $j = $#a;
- if (!$form->{"korrektur_$i"}) {
- ($taxkey, $rate) = split(/--/, $form->{"taxchart_$i"});
- if ($taxkey > 1) {
- if ($form->{taxincluded}) {
- $form->{"tax_$i"} = $form->{"amount_$i"} / ($rate + 1) * $rate;
- } else {
- $form->{"tax_$i"} = $form->{"amount_$i"} * $rate;
- }
+ my $j = $#a;
+ my ($taxkey, $rate) = split(/--/, $form->{"taxchart_$i"});
+ if ($taxkey > 1) {
+ if ($form->{taxincluded}) {
+ $form->{"tax_$i"} = $form->{"amount_$i"} / ($rate + 1) * $rate;
} else {
- $form->{"tax_$i"} = 0;
+ $form->{"tax_$i"} = $form->{"amount_$i"} * $rate;
}
+ } else {
+ $form->{"tax_$i"} = 0;
}
$form->{"tax_$i"} = $form->round_amount($form->{"tax_$i"}, 2);
@@ -911,23 +977,28 @@ sub update {
$form->{rowcount} = $count + 1;
map { $form->{invtotal} += $form->{"amount_$_"} } (1 .. $form->{rowcount});
- $form->{exchangerate} = $exchangerate
- if (
- $form->{forex} = (
- $exchangerate =
- $form->check_exchangerate(
- \%myconfig, $form->{currency}, $form->{transdate}, 'buy'
- )));
+ $form->{forex} = $form->check_exchangerate( \%myconfig, $form->{currency}, $form->{transdate}, 'buy');
+ $form->{exchangerate} = $form->{forex} if $form->{forex};
+
+ $form->{invdate} = $form->{transdate};
$form->{invdate} = $form->{transdate};
- $save_AR = $form->{AR};
- &check_name(customer);
- $form->{AR} = $save_AR;
+
+ my %saved_variables = map +( $_ => $form->{$_} ), qw(AR AR_amount_1 taxchart_1);
+
+ &check_name("customer");
+
+ $form->{AR} = $saved_variables{AR};
+ if ($saved_variables{AR_amount_1} =~ m/.--./) {
+ map { $form->{$_} = $saved_variables{$_} } qw(AR_amount_1 taxchart_1);
+ } else {
+ delete $form->{taxchart_1};
+ }
$form->{invtotal} =
($form->{taxincluded}) ? $form->{invtotal} : $form->{invtotal} + $totaltax;
- for $i (1 .. $form->{paidaccounts}) {
+ for my $i (1 .. $form->{paidaccounts}) {
if ($form->parse_amount(\%myconfig, $form->{"paid_$i"})) {
map {
$form->{"${_}_$i"} =
@@ -936,13 +1007,8 @@ sub update {
$totalpaid += $form->{"paid_$i"};
- $form->{"exchangerate_$i"} = $exchangerate
- if (
- $form->{"forex_$i"} = (
- $exchangerate =
- $form->check_exchangerate(
- \%myconfig, $form->{currency}, $form->{"datepaid_$i"}, 'buy'
- )));
+ $form->{"forex_$i"} = $form->check_exchangerate( \%myconfig, $form->{currency}, $form->{"datepaid_$i"}, 'buy');
+ $form->{"exchangerate_$i"} = $form->{"forex_$i"} if $form->{"forex_$i"};
}
}
@@ -954,125 +1020,158 @@ sub update {
&display_form;
- $lxdebug->leave_sub();
+ $main::lxdebug->leave_sub();
}
+#
+# ToDO: fix $closedto and $invdate
+#
sub post_payment {
- $lxdebug->enter_sub();
- for $i (1 .. $form->{paidaccounts}) {
- if ($form->{"paid_$i"}) {
- $datepaid = $form->datetonum($form->{"datepaid_$i"}, \%myconfig);
+ $main::lxdebug->enter_sub();
+
+ $main::auth->assert('general_ledger');
+
+ my $form = $main::form;
+ my %myconfig = %main::myconfig;
+ my $locale = $main::locale;
+
+ $form->{defaultcurrency} = $form->get_default_currency(\%myconfig);
+
+ for my $i (1 .. $form->{paidaccounts}) {
+
+ if ($form->parse_amount(\%myconfig, $form->{"paid_$i"})) {
+ my $datepaid = $form->datetonum($form->{"datepaid_$i"}, \%myconfig);
$form->isblank("datepaid_$i", $locale->text('Payment date missing!'));
- $form->error($locale->text('Cannot post payment for a closed period!'))
- if ($datepaid <= $closedto);
+ $form->error($locale->text('Cannot post payment for a closed period!')) if ($form->date_closed($form->{"datepaid_$i"}, \%myconfig));
- if ($form->{currency} ne $form->{defaultcurrency}) {
- $form->{"exchangerate_$i"} = $form->{exchangerate}
- if ($invdate == $datepaid);
- $form->isblank("exchangerate_$i",
- $locale->text('Exchangerate for payment missing!'));
+ if ($form->{defaultcurrency} && ($form->{currency} ne $form->{defaultcurrency})) {
+# $form->{"exchangerate_$i"} = $form->{exchangerate} if ($invdate == $datepaid);
+ $form->isblank("exchangerate_$i", $locale->text('Exchangerate for payment missing!'));
}
}
}
($form->{AR}) = split /--/, $form->{AR};
($form->{AR_paid}) = split /--/, $form->{AR_paid};
- $form->redirect($locale->text(' Payment posted!'))
- if (AR->post_payment(\%myconfig, \%$form));
- $form->error($locale->text('Cannot post payment!'));
+ $form->redirect($locale->text('Payment posted!')) if (AR->post_payment(\%myconfig, \%$form));
+ $form->error($locale->text('Cannot post payment!'));
+
+ $main::lxdebug->leave_sub();
+}
+
+sub _post {
+
+ $main::auth->assert('general_ledger');
+ my $form = $main::form;
- $lxdebug->leave_sub();
+ # inline post
+ post(1);
}
sub post {
- $lxdebug->enter_sub();
+ $main::lxdebug->enter_sub();
+
+ $main::auth->assert('general_ledger');
+
+ my $form = $main::form;
+ my %myconfig = %main::myconfig;
+ my $locale = $main::locale;
+
+ my ($inline) = @_;
+
+ my ($datepaid);
# check if there is an invoice number, invoice and due date
$form->isblank("transdate", $locale->text('Invoice Date missing!'));
$form->isblank("duedate", $locale->text('Due Date missing!'));
$form->isblank("customer", $locale->text('Customer missing!'));
- $closedto = $form->datetonum($form->{closedto}, \%myconfig);
- $transdate = $form->datetonum($form->{transdate}, \%myconfig);
+ my $closedto = $form->datetonum($form->{closedto}, \%myconfig);
+ my $transdate = $form->datetonum($form->{transdate}, \%myconfig);
+ $form->error($locale->text('Cannot post transaction for a closed period!')) if ($form->date_closed($form->{"transdate"}, \%myconfig));
- $form->error($locale->text('Cannot post transaction for a closed period!'))
- if ($transdate <= $closedto);
+ $form->error($locale->text('Zero amount posting!'))
+ unless grep $_*1, map $form->parse_amount(\%myconfig, $form->{"amount_$_"}), 1..$form->{rowcount};
$form->isblank("exchangerate", $locale->text('Exchangerate missing!'))
- if ($form->{currency} ne $form->{defaultcurrency});
+ if ($form->{defaultcurrency} && ($form->{currency} ne $form->{defaultcurrency}));
delete($form->{AR});
- for $i (1 .. $form->{paidaccounts}) {
+ for my $i (1 .. $form->{paidaccounts}) {
if ($form->parse_amount(\%myconfig, $form->{"paid_$i"})) {
$datepaid = $form->datetonum($form->{"datepaid_$i"}, \%myconfig);
$form->isblank("datepaid_$i", $locale->text('Payment date missing!'));
$form->error($locale->text('Cannot post payment for a closed period!'))
- if ($datepaid <= $closedto);
+ if ($form->date_closed($form->{"datepaid_$i"}, \%myconfig));
- if ($form->{currency} ne $form->{defaultcurrency}) {
- $form->{"exchangerate_$i"} = $form->{exchangerate}
- if ($transdate == $datepaid);
- $form->isblank("exchangerate_$i",
- $locale->text('Exchangerate for payment missing!'));
+ if ($form->{defaultcurrency} && ($form->{currency} ne $form->{defaultcurrency})) {
+ $form->{"exchangerate_$i"} = $form->{exchangerate} if ($transdate == $datepaid);
+ $form->isblank("exchangerate_$i", $locale->text('Exchangerate for payment missing!'));
}
}
}
# if oldcustomer ne customer redo form
- ($customer) = split /--/, $form->{customer};
+ my ($customer) = split /--/, $form->{customer};
if ($form->{oldcustomer} ne "$customer--$form->{customer_id}") {
- &update;
+ update();
exit;
}
- my ($creditaccno, $credittaxkey) = split /--/, $form->{AR_amountselected};
- my ($taxkey, $NULL) = split /--/, $form->{taxchartselected};
- my ($receivablesaccno, $payablestaxkey) = split /--/, $form->{ARselected};
- $form->{AR}{amount_1} = $creditaccno;
- $form->{AR}{receivables} = $receivablesaccno;
- $form->{taxkey} = $taxkey;
-
- $form->{invnumber} = $form->update_defaults(\%myconfig, "invnumber")
- unless $form->{invnumber};
+ $form->{AR}{receivables} = $form->{ARselected};
+ $form->{storno} = 0;
$form->{id} = 0 if $form->{postasnew};
- if (AR->post_transaction(\%myconfig, \%$form)) {
- # saving the history
- if(!exists $form->{addition} && $form->{id} ne "") {
- $form->{addition} = "POSTED";
- $form->save_history($form->dbconnect(\%myconfig));
- }
- # /saving the history
- $form->redirect($locale->text('Transaction posted!'));
+ $form->error($locale->text('Cannot post transaction!')) unless AR->post_transaction(\%myconfig, \%$form);
+
+ # saving the history
+ if(!exists $form->{addition} && $form->{id} ne "") {
+ $form->{snumbers} = "invnumber_$form->{invnumber}";
+ $form->{addition} = "POSTED";
+ $form->save_history($form->dbconnect(\%myconfig));
}
- $form->error($locale->text('Cannot post transaction!'));
+ # /saving the history
+ remove_draft() if $form->{remove_draft};
+
+ $form->redirect($locale->text('Transaction posted!')) unless $inline;
- $lxdebug->leave_sub();
+ $main::lxdebug->leave_sub();
}
sub post_as_new {
- $lxdebug->enter_sub();
+ $main::lxdebug->enter_sub();
+
+ $main::auth->assert('general_ledger');
+
+ my $form = $main::form;
+ my %myconfig = %main::myconfig;
$form->{postasnew} = 1;
# saving the history
if(!exists $form->{addition} && $form->{id} ne "") {
- $form->{addition} = "POSTED AS NEW";
- $form->save_history($form->dbconnect(\%myconfig));
+ $form->{snumbers} = qq|invnumber_| . $form->{invnumber};
+ $form->{addition} = "POSTED AS NEW";
+ $form->save_history($form->dbconnect(\%myconfig));
}
- # /saving the history
+ # /saving the history
&post;
- $lxdebug->leave_sub();
+ $main::lxdebug->leave_sub();
}
sub use_as_template {
- $lxdebug->enter_sub();
+ $main::lxdebug->enter_sub();
+
+ $main::auth->assert('general_ledger');
+
+ my $form = $main::form;
+ my %myconfig = %main::myconfig;
map { delete $form->{$_} } qw(printed emailed queued invnumber invdate deliverydate id datepaid_1 source_1 memo_1 paid_1 exchangerate_1 AP_paid_1 storno);
$form->{paidaccounts} = 1;
@@ -1080,11 +1179,16 @@ sub use_as_template {
$form->{invdate} = $form->current_date(\%myconfig);
&update;
- $lxdebug->leave_sub();
+ $main::lxdebug->leave_sub();
}
sub delete {
- $lxdebug->enter_sub();
+ $main::lxdebug->enter_sub();
+
+ $main::auth->assert('general_ledger');
+
+ my $form = $main::form;
+ my $locale = $main::locale;
$form->{title} = $locale->text('Confirm!');
@@ -1098,7 +1202,8 @@ sub delete {
|