X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Far.pl;h=31c9cfff48664ecb9b8cf8edfed27fb17ae0a7ae;hb=a295ff26c39f57d4b36a4115309e5a68b08fbee2;hp=161dde9a01803165409f124cc9ae591895cd5ae2;hpb=5a9d765f8503e6c1be32fd5a71d8f551e2f0da94;p=kivitendo-erp.git diff --git a/bin/mozilla/ar.pl b/bin/mozilla/ar.pl index 161dde9a0..31c9cfff4 100644 --- a/bin/mozilla/ar.pl +++ b/bin/mozilla/ar.pl @@ -32,8 +32,10 @@ #====================================================================== use POSIX qw(strftime); +use List::Util qw(sum); use SL::AR; +use SL::FU; use SL::IS; use SL::PE; use SL::ReportGenerator; @@ -84,6 +86,8 @@ require "bin/mozilla/reportgenerator.pl"; sub add { $lxdebug->enter_sub(); + $auth->assert('general_ledger'); + return $lxdebug->leave_sub() if (load_draft_maybe()); # saving the history @@ -95,9 +99,7 @@ sub add { # /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}; @@ -109,6 +111,9 @@ sub add { sub edit { $lxdebug->enter_sub(); + + $auth->assert('general_ledger'); + # show history button $form->{javascript} = qq||; #/show hhistory button @@ -124,6 +129,8 @@ sub edit { sub display_form { $lxdebug->enter_sub(); + $auth->assert('general_ledger'); + &form_header; &form_footer; @@ -133,6 +140,8 @@ sub display_form { sub create_links { $lxdebug->enter_sub(); + $auth->assert('general_ledger'); + my ($duedate, $taxincluded, @curr); $form->create_links("AR", \%myconfig, "customer"); @@ -200,6 +209,8 @@ sub create_links { sub form_header { $lxdebug->enter_sub(); + $auth->assert('general_ledger'); + my ($title, $readonly, $exchangerate, $rows); my ($taxincluded, $notes, $department, $customer, $employee, $amount, $project); my ($jsscript, $button1, $button2, $onload); @@ -250,13 +261,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} = @@ -422,9 +428,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 +451,10 @@ sub form_header { {closedto}> {locked}> + + + + | . ($form->{saved_message} ? qq|

$form->{saved_message}

| : "") . qq| @@ -787,16 +802,27 @@ $jsscript sub form_footer { $lxdebug->enter_sub(); + $auth->assert('general_ledger'); + 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}]) @@ -834,7 +860,10 @@ sub form_footer { |; } print qq| - |; + + |; } else { if ($transdate > $closedto) { @@ -871,13 +900,19 @@ sub form_footer { sub mark_as_paid { $lxdebug->enter_sub(); + + $auth->assert('general_ledger'); + &mark_as_paid_common(\%myconfig,"ar"); + $lxdebug->leave_sub(); } sub update { $lxdebug->enter_sub(); + $auth->assert('general_ledger'); + my $display = shift; my ($totaltax, $exchangerate, $totalpaid); @@ -921,13 +956,8 @@ 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}; @@ -946,13 +976,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"}; } } @@ -973,6 +998,8 @@ sub update { sub post_payment { $lxdebug->enter_sub(); + $auth->assert('general_ledger'); + $form->{defaultcurrency} = $form->get_default_currency(\%myconfig); for my $i (1 .. $form->{paidaccounts}) { @@ -1000,6 +1027,9 @@ sub post_payment { } sub _post { + + $auth->assert('general_ledger'); + # inline post post(1); } @@ -1007,6 +1037,8 @@ sub _post { sub post { $lxdebug->enter_sub(); + $auth->assert('general_ledger'); + my ($inline) = @_; my ($datepaid); @@ -1075,6 +1107,8 @@ sub post { sub post_as_new { $lxdebug->enter_sub(); + $auth->assert('general_ledger'); + $form->{postasnew} = 1; # saving the history if(!exists $form->{addition} && $form->{id} ne "") { @@ -1091,6 +1125,8 @@ sub post_as_new { sub use_as_template { $lxdebug->enter_sub(); + $auth->assert('general_ledger'); + 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; $form->{rowcount}--; @@ -1103,6 +1139,8 @@ sub use_as_template { sub delete { $lxdebug->enter_sub(); + $auth->assert('general_ledger'); + $form->{title} = $locale->text('Confirm!'); $form->header; @@ -1116,6 +1154,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|; } @@ -1140,6 +1179,9 @@ sub delete { sub yes { $lxdebug->enter_sub(); + + $auth->assert('general_ledger'); + if (AR->delete_transaction(\%myconfig, \%$form)) { # saving the history if(!exists $form->{addition}) { @@ -1158,6 +1200,8 @@ sub yes { sub search { $lxdebug->enter_sub(); + $auth->assert('general_ledger | invoice_edit'); + my ($customer, $department); my ($jsscript, $button1, $button2, $onload); @@ -1367,9 +1411,6 @@ sub search { {nextsub}> -{login}> -{password}> -
@@ -1407,6 +1448,8 @@ sub create_subtotal_row { sub ar_transactions { $lxdebug->enter_sub(); + $auth->assert('general_ledger | invoice_edit'); + my ($callback, $href, @columns); $form->{customer} = $form->unescape($form->{customer}); @@ -1532,8 +1575,8 @@ sub ar_transactions { map { $subtotals{$_} += $ar->{$_}; $totals{$_} += $ar->{$_} } @subtotal_columns; - $subtotals{marge_percent} = $subtotals{marge_total} / $subtotals{netamount} * 100; - $totals{marge_percent} = $totals{marge_total} / $totals{netamount} * 100; + $subtotals{marge_percent} = $subtotals{netamount} ? ($subtotals{marge_total} * 100 / $subtotals{netamount}) : 0; + $totals{marge_percent} = $totals{netamount} ? ($totals{marge_total} * 100 / $totals{netamount} ) : 0; map { $ar->{$_} = $form->format_amount(\%myconfig, $ar->{$_}, 2) } qw(netamount tax amount paid due marge_total marge_percent); @@ -1583,6 +1626,8 @@ sub ar_transactions { sub storno { $lxdebug->enter_sub(); + $auth->assert('general_ledger'); + # don't cancel cancelled transactions if (IS->has_storno(\%myconfig, $form, 'ar')) { $form->{title} = $locale->text("Cancel Accounts Receivables Transaction");