X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Far.pl;h=a8937506f6356b0626e3ad20e142f39ee57b9aff;hb=2e7983737542b36d9962073a7d04f2edcf6b8bb0;hp=11a12e440dbc75f9a594d3ab07fc406c323bbe53;hpb=3505ff1bb654d331bd384461d471fa895635e7b4;p=kivitendo-erp.git diff --git a/bin/mozilla/ar.pl b/bin/mozilla/ar.pl index 11a12e440..a8937506f 100644 --- a/bin/mozilla/ar.pl +++ b/bin/mozilla/ar.pl @@ -32,26 +32,21 @@ #====================================================================== use POSIX qw(strftime); +use List::Util qw(sum first); use SL::AR; +use SL::FU; use SL::IS; use SL::PE; use SL::ReportGenerator; -# use strict; -#use warnings; - -# imports -our ($cgi, $form, $lxdebug, $locale, %myconfig); - require "bin/mozilla/arap.pl"; require "bin/mozilla/common.pl"; require "bin/mozilla/drafts.pl"; require "bin/mozilla/reportgenerator.pl"; -1; - -# end of main +use strict; +#use warnings; # this is for our long dates # $locale->text('January') @@ -81,10 +76,17 @@ require "bin/mozilla/reportgenerator.pl"; # $locale->text('Nov') # $locale->text('Dec') +my $totalpaid; + sub add { - $lxdebug->enter_sub(); + $main::lxdebug->enter_sub(); + + $main::auth->assert('general_ledger'); + + my $form = $main::form; + my %myconfig = %main::myconfig; - return $lxdebug->leave_sub() if (load_draft_maybe()); + return $main::lxdebug->leave_sub() if (load_draft_maybe()); # saving the history if(!exists $form->{addition} && ($form->{id} ne "")) { @@ -92,23 +94,26 @@ sub add { $form->{addition} = "ADDED"; $form->save_history($form->dbconnect(\%myconfig)); } - # /saving the history - + # /saving the history + $form->{title} = "Add"; - $form->{callback} = - "$form->{script}?action=add&login=$form->{login}&password=$form->{password}" - unless $form->{callback}; + $form->{callback} = "ar.pl?action=add" unless $form->{callback}; AR->get_transdate(\%myconfig, $form); $form->{initial_transdate} = $form->{transdate}; &create_links; $form->{transdate} = $form->{initial_transdate}; &display_form; - $lxdebug->leave_sub(); + $main::lxdebug->leave_sub(); } sub edit { - $lxdebug->enter_sub(); + $main::lxdebug->enter_sub(); + + $main::auth->assert('general_ledger'); + + my $form = $main::form; + # show history button $form->{javascript} = qq||; #/show hhistory button @@ -118,20 +123,29 @@ sub edit { &create_links; &display_form; - $lxdebug->leave_sub(); + $main::lxdebug->leave_sub(); } sub display_form { - $lxdebug->enter_sub(); + $main::lxdebug->enter_sub(); + + $main::auth->assert('general_ledger'); + + my $form = $main::form; &form_header; &form_footer; - $lxdebug->leave_sub(); + $main::lxdebug->leave_sub(); } sub create_links { - $lxdebug->enter_sub(); + $main::lxdebug->enter_sub(); + + $main::auth->assert('general_ledger'); + + my $form = $main::form; + my %myconfig = %main::myconfig; my ($duedate, $taxincluded, @curr); @@ -194,16 +208,23 @@ sub create_links { ($form->datetonum($form->{transdate}, \%myconfig) <= $form->datetonum($form->{closedto}, \%myconfig)); - $lxdebug->leave_sub(); + $main::lxdebug->leave_sub(); } sub form_header { - $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 ($title, $readonly, $exchangerate, $rows); my ($taxincluded, $notes, $department, $customer, $employee, $amount, $project); my ($jsscript, $button1, $button2, $onload); - my ($selectAR_amount, $selectAR_paid, $korrektur_checked, $ARselected, $tax); + my ($selectAR_amount, $selectAR_paid, $ARselected, $tax); my (@column_index, %column_data); @@ -250,13 +271,8 @@ sub form_header { s/option>\Q$form->{$item}\E/option selected>$form->{$item}/; } - $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}; # format amounts $form->{exchangerate} = @@ -312,8 +328,8 @@ sub form_header { my $n = ($form->{creditremaining} =~ /-/) ? "0" : "1"; - $customer = ($form->{selectcustomer}) - ? qq|| + $customer = ($form->{selectcustomer}) + ? qq|| : qq||; $employee = qq| @@ -334,12 +350,13 @@ sub form_header { map({ push(@old_project_ids, $form->{"project_id_$_"}) if ($form->{"project_id_$_"}); } (1..$form->{"rowcount"})); - $form->get_lists("projects" => { "key" => "ALL_PROJECTS", - "all" => 0, - "old_id" => \@old_project_ids }, - "charts" => { "key" => "ALL_CHARTS", - "transdate" => $form->{transdate} }, - "taxcharts" => "ALL_TAXCHARTS"); + $form->get_lists("projects" => { "key" => "ALL_PROJECTS", + "all" => 0, + "old_id" => \@old_project_ids }, + "charts" => { "key" => "ALL_CHARTS", + "transdate" => $form->{transdate} }, + "taxcharts" => { "key" => "ALL_TAXCHARTS", + "module" => "AR" },); map({ $_->{link_split} = [ split(/:/, $_->{link}) ]; } @{ $form->{ALL_CHARTS} }); @@ -422,9 +439,14 @@ sub form_header { qq||; } + my $follow_up_vc = $form->{customer}; + $follow_up_vc =~ s/--.*?//; + my $follow_up_trans_info = "$form->{invnumber} ($follow_up_vc)"; + $form->{javascript} .= qq|| . - qq||; + qq|| . + qq||; $form->header; $onload = qq|focus()|; @@ -440,6 +462,10 @@ sub form_header { {closedto}> {locked}> + + + + | . ($form->{saved_message} ? qq|

$form->{saved_message}

| : "") . qq| @@ -456,7 +482,7 @@ sub form_header { - + @@ -529,8 +555,6 @@ $jsscript - @@ -563,7 +587,13 @@ $jsscript $selected_taxchart = "$item->{id}--$item->{rate}"; } - $selected_taxchart = $taxchart_init unless ($form->{"taxchart_$i"}); + 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", @@ -585,8 +615,6 @@ $jsscript '-default' => $selected_taxchart)) . qq||; - $korrektur_checked = ($form->{"korrektur_$i"} ? 'checked' : ''); - my $projectnumber = NTI($cgi->popup_menu('-name' => "project_id_$i", '-values' => \@project_values, @@ -597,8 +625,7 @@ $jsscript - - + $tax @@ -668,8 +695,8 @@ $jsscript $column_data{exchangerate} = ""; $column_data{AR_paid} = ""; $column_data{source} = ""; - $column_data{memo} = ""; - $column_data{paid_project_id} = ""; + $column_data{memo} = ""; + $column_data{paid_project_id} = ""; print " @@ -781,22 +808,38 @@ $jsscript
| . $locale->text('Customer') . qq|$customer $customer | . $locale->text('Tax') . qq| | - . $locale->text('Korrektur') . qq|| . $locale->text('Taxkey') . qq| | . $locale->text('Project') . qq|
$selectAR_amount {"amount_$i"}>{"tax_$i"}>$form->{"tax_$i"}$projectnumber
" . $locale->text('Exch') . "" . $locale->text('Account') . "" . $locale->text('Source') . "" . $locale->text('Memo') . "" . $locale->text('Project Number') . "" . $locale->text('Memo') . "" . $locale->text('Project Number') . "
|; - $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 + - -{login}> -{password}> | . $cgi->hidden('-name' => 'draft_id', '-default' => [$form->{draft_id}]) . $cgi->hidden('-name' => 'draft_description', '-default' => [$form->{draft_description}]) @@ -821,7 +864,7 @@ sub form_footer { # 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')); + 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}) { @@ -834,7 +877,10 @@ sub form_footer { |; } print qq| - |; + + |; } else { if ($transdate > $closedto) { @@ -852,9 +898,9 @@ sub form_footer { 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 @@ -866,24 +912,38 @@ sub form_footer { "; - $lxdebug->leave_sub(); + $main::lxdebug->leave_sub(); } sub mark_as_paid { - $lxdebug->enter_sub(); - &mark_as_paid_common(\%myconfig,"ar"); - $lxdebug->leave_sub(); + $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(); + + $main::auth->assert('general_ledger'); + + my $form = $main::form; + my %myconfig = %main::myconfig; my $display = shift; - my ($totaltax, $exchangerate, $totalpaid); + my ($totaltax, $exchangerate); $form->{invtotal} = 0; + delete @{ $form }{ grep { m/^tax_\d+$/ } keys %{ $form } }; + map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) } qw(exchangerate creditlimit creditremaining); @@ -897,17 +957,15 @@ sub update { if ($form->{"amount_$i"}) { push @a, {}; my $j = $#a; - if (!$form->{"korrektur_$i"}) { - 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"} = $form->{"amount_$i"} * $rate; - } + 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); @@ -921,18 +979,23 @@ 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}; - my $save_AR = $form->{AR}; - check_name("customer"); - $form->{AR} = $save_AR; + + $form->{invdate} = $form->{transdate}; + + 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; @@ -946,13 +1009,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"}; } } @@ -964,14 +1022,20 @@ sub update { &display_form; - $lxdebug->leave_sub(); + $main::lxdebug->leave_sub(); } # # ToDO: fix $closedto and $invdate # sub post_payment { - $lxdebug->enter_sub(); + $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); @@ -982,7 +1046,7 @@ sub post_payment { $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); @@ -996,16 +1060,27 @@ sub post_payment { $form->redirect($locale->text('Payment posted!')) if (AR->post_payment(\%myconfig, \%$form)); $form->error($locale->text('Cannot post payment!')); - $lxdebug->leave_sub(); + $main::lxdebug->leave_sub(); } sub _post { + + $main::auth->assert('general_ledger'); + + my $form = $main::form; + # 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) = @_; @@ -1018,9 +1093,9 @@ sub post { 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 ($transdate <= $closedto); + $form->error($locale->text('Cannot post transaction for a closed period!')) if ($form->date_closed($form->{"transdate"}, \%myconfig)); - $form->error($locale->text('Zero amount posting!')) + $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!')) @@ -1035,7 +1110,7 @@ sub post { $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); @@ -1054,7 +1129,7 @@ sub post { $form->{AR}{receivables} = $form->{ARselected}; $form->{storno} = 0; - $lxdebug->message(0, $form->{amount}); + $main::lxdebug->message(0, $form->{amount}); $form->{id} = 0 if $form->{postasnew}; $form->error($locale->text('Cannot post transaction!')) unless AR->post_transaction(\%myconfig, \%$form); @@ -1064,16 +1139,21 @@ sub post { $form->{addition} = "POSTED"; $form->save_history($form->dbconnect(\%myconfig)); } - # /saving the history + # /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 @@ -1082,14 +1162,19 @@ sub post_as_new { $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; @@ -1097,11 +1182,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!'); @@ -1116,6 +1206,7 @@ sub delete { |; foreach my $key (keys %$form) { + next if (($key eq 'login') || ($key eq 'password') || ('' ne ref $form->{$key})); $form->{$key} =~ s/\"/"/g; print qq|\n|; } @@ -1135,11 +1226,18 @@ sub delete { |; - $lxdebug->leave_sub(); + $main::lxdebug->leave_sub(); } sub yes { - $lxdebug->enter_sub(); + $main::lxdebug->enter_sub(); + + $main::auth->assert('general_ledger'); + + my $form = $main::form; + my %myconfig = %main::myconfig; + my $locale = $main::locale; + if (AR->delete_transaction(\%myconfig, \%$form)) { # saving the history if(!exists $form->{addition}) { @@ -1147,16 +1245,23 @@ sub yes { $form->{addition} = "DELETED"; $form->save_history($form->dbconnect(\%myconfig)); } - # /saving the history + # /saving the history $form->redirect($locale->text('Transaction deleted!')); } $form->error($locale->text('Cannot delete transaction!')); - $lxdebug->leave_sub(); + $main::lxdebug->leave_sub(); } sub search { - $lxdebug->enter_sub(); + $main::lxdebug->enter_sub(); + + $main::auth->assert('general_ledger | invoice_edit'); + + my $form = $main::form; + my %myconfig = %main::myconfig; + my $locale = $main::locale; + my $cgi = $main::cgi; my ($customer, $department); my ($jsscript, $button1, $button2, $onload); @@ -1190,9 +1295,9 @@ sub search { | if $form->{selectdepartment}; $form->{title} = $locale->text('AR Transactions'); - + $form->{javascript} .= qq||; - + # use JavaScript Calendar or not $form->{jsscript} = 1; $jsscript = ""; @@ -1333,7 +1438,7 @@ sub search { | . $locale->text('Notes') . qq| - + | . $locale->text('Salesperson') . qq| | . $locale->text('Shipping Point') . qq| @@ -1341,10 +1446,12 @@ sub search { | . $locale->text('Ship via') . qq| - | - . $locale->text('Ertrag') . qq| - | - . $locale->text('Ertrag prozentual') . qq| + + | . $locale->text('Ertrag') . qq| + + | . $locale->text('Ertrag prozentual') . qq| + + | . $locale->text('Employee') . qq| @@ -1354,6 +1461,26 @@ sub search { | . $locale->text('Transaction description') . qq| + + | . $locale->text('Customer') . qq| + + + + | . $locale->text('Customer Number') . qq| + + | . $locale->text('Country') . qq| + + | . $locale->text('USt-IdNr.') . qq| + + | . $locale->text('Steuersatz') . qq| + + + + | . $locale->text('Payment Terms') . qq| + + | . $locale->text('Buchungskonto') . qq| + + @@ -1367,9 +1494,6 @@ sub search { {nextsub}> -{login}> -{password}> -
@@ -1383,14 +1507,17 @@ $jsscript |; - $lxdebug->leave_sub(); + $main::lxdebug->leave_sub(); } sub create_subtotal_row { - $lxdebug->enter_sub(); + $main::lxdebug->enter_sub(); my ($totals, $columns, $column_alignment, $subtotal_columns, $class) = @_; + my $form = $main::form; + my %myconfig = %main::myconfig; + my $row = { map { $_ => { 'data' => '', 'class' => $class, 'align' => $column_alignment->{$_}, } } @{ $columns } }; map { $row->{$_}->{data} = $form->format_amount(\%myconfig, $totals->{$_}, 2) } @{ $subtotal_columns }; @@ -1399,20 +1526,26 @@ sub create_subtotal_row { map { $totals->{$_} = 0 } @{ $subtotal_columns }; - $lxdebug->leave_sub(); + $main::lxdebug->leave_sub(); return $row; } sub ar_transactions { - $lxdebug->enter_sub(); + $main::lxdebug->enter_sub(); + + $main::auth->assert('general_ledger | invoice_edit'); + + my $form = $main::form; + my %myconfig = %main::myconfig; + my $locale = $main::locale; my ($callback, $href, @columns); $form->{customer} = $form->unescape($form->{customer}); ($form->{customer}, $form->{customer_id}) = split(/--/, $form->{customer}); - $form->{sort} ||= 'transdate'; + report_generator_set_default_sort('transdate', 1); AR->ar_transactions(\%myconfig, \%$form); @@ -1422,8 +1555,8 @@ sub ar_transactions { @columns = qw(transdate id type invnumber ordnumber name netamount tax amount paid - datepaid due duedate transaction_description notes employee shippingpoint shipvia - marge_total marge_percent globalprojectnumber); + datepaid due duedate transaction_description notes salesman employee shippingpoint shipvia + marge_total marge_percent globalprojectnumber customernumber country ustid taxzone payment_terms charts); my @hidden_variables = map { "l_${_}" } @columns; push @hidden_variables, "l_subtotal", qw(open closed customer invnumber ordnumber transaction_description notes project_id transdatefrom transdateto); @@ -1446,17 +1579,24 @@ sub ar_transactions { 'duedate' => { 'text' => $locale->text('Due Date'), }, 'transaction_description' => { 'text' => $locale->text('Transaction description'), }, 'notes' => { 'text' => $locale->text('Notes'), }, - 'employee' => { 'text' => $locale->text('Salesperson'), }, + 'salesman' => { 'text' => $locale->text('Salesperson'), }, + 'employee' => { 'text' => $locale->text('Employee'), }, 'shippingpoint' => { 'text' => $locale->text('Shipping Point'), }, 'shipvia' => { 'text' => $locale->text('Ship via'), }, 'globalprojectnumber' => { 'text' => $locale->text('Project Number'), }, 'marge_total' => { 'text' => $locale->text('Ertrag'), }, 'marge_percent' => { 'text' => $locale->text('Ertrag prozentual'), }, + 'customernumber' => { 'text' => $locale->text('Customer Number'), }, + 'country' => { 'text' => $locale->text('Country'), }, + 'ustid' => { 'text' => $locale->text('USt-IdNr.'), }, + 'taxzone' => { 'text' => $locale->text('Steuersatz'), }, + 'payment_terms' => { 'text' => $locale->text('Payment Terms'), }, + 'charts' => { 'text' => $locale->text('Buchungskonto'), }, ); - foreach my $name (qw(id transdate duedate invnumber ordnumber name datepaid - employee shippingpoint shipvia)) { - $column_defs{$name}->{link} = $href . "&sort=$name"; + foreach my $name (qw(id transdate duedate invnumber ordnumber name datepaid employee shippingpoint shipvia transaction_description)) { + my $sortdir = $form->{sort} eq $name ? 1 - $form->{sortdir} : $form->{sortdir}; + $column_defs{$name}->{link} = $href . "&sort=$name&sortdir=$sortdir"; } my %column_alignment = map { $_ => 'right' } qw(netamount tax amount paid due); @@ -1467,9 +1607,9 @@ sub ar_transactions { $report->set_columns(%column_defs); $report->set_column_order(@columns); - $report->set_export_options('ar_transactions', @hidden_variables); + $report->set_export_options('ar_transactions', @hidden_variables, qw(sort sortdir)); - $report->set_sort_indicator($form->{sort}, 1); + $report->set_sort_indicator($form->{sort}, $form->{sortdir}); my @options; if ($form->{customer}) { @@ -1492,10 +1632,10 @@ sub ar_transactions { push @options, $locale->text('Transaction description') . " : $form->{transaction_description}"; } if ($form->{transdatefrom}) { - push @options, $locale->text('From') . " " . $locale->date(\%myconfig, $form->{transdatefrom}, 1); + push @options, $locale->text('From') . " " . $locale->date(\%myconfig, $form->{transdatefrom}, 1); } if ($form->{transdateto}) { - push @options, $locale->text('Bis') . " " . $locale->date(\%myconfig, $form->{transdateto}, 1); + push @options, $locale->text('Bis') . " " . $locale->date(\%myconfig, $form->{transdateto}, 1); } if ($form->{open}) { push @options, $locale->text('Open'); @@ -1537,8 +1677,8 @@ sub ar_transactions { map { $ar->{$_} = $form->format_amount(\%myconfig, $ar->{$_}, 2) } qw(netamount tax amount paid due marge_total marge_percent); - my $is_storno = $ar->{storno} && !$ar->{storno_id}; - my $has_storno = $ar->{storno} && $ar->{storno_id}; + my $is_storno = $ar->{storno} && $ar->{storno_id}; + my $has_storno = $ar->{storno} && !$ar->{storno_id}; $ar->{type} = $has_storno ? $locale->text("Invoice with Storno (abbreviation)") : @@ -1577,11 +1717,17 @@ sub ar_transactions { $report->generate_with_headers(); - $lxdebug->leave_sub(); + $main::lxdebug->leave_sub(); } sub storno { - $lxdebug->enter_sub(); + $main::lxdebug->enter_sub(); + + $main::auth->assert('general_ledger'); + + my $form = $main::form; + my %myconfig = %main::myconfig; + my $locale = $main::locale; # don't cancel cancelled transactions if (IS->has_storno(\%myconfig, $form, 'ar')) { @@ -1597,9 +1743,11 @@ sub storno { $form->{addition} = "STORNO"; $form->save_history($form->dbconnect(\%myconfig)); } - # /saving the history + # /saving the history - $form->redirect(sprintf $locale->text("Transaction %d cancelled."), $form->{storno_id}); + $form->redirect(sprintf $locale->text("Transaction %d cancelled."), $form->{storno_id}); - $lxdebug->leave_sub(); + $main::lxdebug->leave_sub(); } + +1;