X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Far.pl;h=a8937506f6356b0626e3ad20e142f39ee57b9aff;hb=2dacd2790bb5e0990ec5fe89a9d59370b018c25c;hp=528d2c4edd6fde7a09d05bb1a46d3ec8366ac5c7;hpb=4077825982a622b654888a20121c845d0e15c9c3;p=kivitendo-erp.git diff --git a/bin/mozilla/ar.pl b/bin/mozilla/ar.pl index 528d2c4ed..a8937506f 100644 --- a/bin/mozilla/ar.pl +++ b/bin/mozilla/ar.pl @@ -40,20 +40,13 @@ 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') @@ -83,12 +76,17 @@ require "bin/mozilla/reportgenerator.pl"; # $locale->text('Nov') # $locale->text('Dec') +my $totalpaid; + sub add { - $lxdebug->enter_sub(); + $main::lxdebug->enter_sub(); - $auth->assert('general_ledger'); + $main::auth->assert('general_ledger'); - return $lxdebug->leave_sub() if (load_draft_maybe()); + my $form = $main::form; + my %myconfig = %main::myconfig; + + return $main::lxdebug->leave_sub() if (load_draft_maybe()); # saving the history if(!exists $form->{addition} && ($form->{id} ne "")) { @@ -96,8 +94,8 @@ sub add { $form->{addition} = "ADDED"; $form->save_history($form->dbconnect(\%myconfig)); } - # /saving the history - + # /saving the history + $form->{title} = "Add"; $form->{callback} = "ar.pl?action=add" unless $form->{callback}; @@ -106,13 +104,15 @@ sub add { &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(); - $auth->assert('general_ledger'); + $main::auth->assert('general_ledger'); + + my $form = $main::form; # show history button $form->{javascript} = qq||; @@ -123,24 +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'); - $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(); - $auth->assert('general_ledger'); + $main::auth->assert('general_ledger'); + + my $form = $main::form; + my %myconfig = %main::myconfig; my ($duedate, $taxincluded, @curr); @@ -203,13 +208,18 @@ 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'); - $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); @@ -318,8 +328,8 @@ sub form_header { my $n = ($form->{creditremaining} =~ /-/) ? "0" : "1"; - $customer = ($form->{selectcustomer}) - ? qq|| + $customer = ($form->{selectcustomer}) + ? qq|| : qq||; $employee = qq| @@ -685,8 +695,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 " @@ -798,13 +808,18 @@ $jsscript |; - $lxdebug->leave_sub(); + $main::lxdebug->leave_sub(); } sub form_footer { - $lxdebug->enter_sub(); + $main::lxdebug->enter_sub(); - $auth->assert('general_ledger'); + $main::auth->assert('general_ledger'); + + my $form = $main::form; + my %myconfig = %main::myconfig; + my $locale = $main::locale; + my $cgi = $main::cgi; my ($transdate, $closedto); @@ -849,7 +864,7 @@ $follow_ups_block # 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') && (($total_paid == 0) || ($total_paid eq ""))); + 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}) { @@ -883,9 +898,9 @@ $follow_ups_block 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 @@ -897,27 +912,33 @@ $follow_ups_block "; - $lxdebug->leave_sub(); + $main::lxdebug->leave_sub(); } sub mark_as_paid { - $lxdebug->enter_sub(); + $main::lxdebug->enter_sub(); - $auth->assert('general_ledger'); + $main::auth->assert('general_ledger'); - &mark_as_paid_common(\%myconfig,"ar"); + my $form = $main::form; + my %myconfig = %main::myconfig; - $lxdebug->leave_sub(); + &mark_as_paid_common(\%myconfig,"ar"); + + $main::lxdebug->leave_sub(); } sub update { - $lxdebug->enter_sub(); + $main::lxdebug->enter_sub(); + + $main::auth->assert('general_ledger'); - $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; @@ -1001,16 +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(); - $auth->assert('general_ledger'); + $main::auth->assert('general_ledger'); + + my $form = $main::form; + my %myconfig = %main::myconfig; + my $locale = $main::locale; $form->{defaultcurrency} = $form->get_default_currency(\%myconfig); @@ -1035,21 +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 { - $auth->assert('general_ledger'); + $main::auth->assert('general_ledger'); + + my $form = $main::form; # inline post post(1); } sub post { - $lxdebug->enter_sub(); + $main::lxdebug->enter_sub(); - $auth->assert('general_ledger'); + $main::auth->assert('general_ledger'); + + my $form = $main::form; + my %myconfig = %main::myconfig; + my $locale = $main::locale; my ($inline) = @_; @@ -1064,7 +1095,7 @@ sub post { 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('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!')) @@ -1098,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); @@ -1108,18 +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'); - $auth->assert('general_ledger'); + my $form = $main::form; + my %myconfig = %main::myconfig; $form->{postasnew} = 1; # saving the history @@ -1128,16 +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(); - $auth->assert('general_ledger'); + $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; @@ -1145,13 +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'); - $auth->assert('general_ledger'); + my $form = $main::form; + my $locale = $main::locale; $form->{title} = $locale->text('Confirm!'); @@ -1186,13 +1226,17 @@ sub delete { |; - $lxdebug->leave_sub(); + $main::lxdebug->leave_sub(); } sub yes { - $lxdebug->enter_sub(); + $main::lxdebug->enter_sub(); - $auth->assert('general_ledger'); + $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 @@ -1201,18 +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'); - $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); @@ -1246,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 = ""; @@ -1412,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| + + @@ -1438,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 }; @@ -1454,15 +1526,19 @@ 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(); - $auth->assert('general_ledger | invoice_edit'); + $main::auth->assert('general_ledger | invoice_edit'); + + my $form = $main::form; + my %myconfig = %main::myconfig; + my $locale = $main::locale; my ($callback, $href, @columns); @@ -1480,7 +1556,7 @@ sub ar_transactions { @columns = qw(transdate id type invnumber ordnumber name netamount tax amount paid datepaid due duedate transaction_description notes salesman employee shippingpoint shipvia - marge_total marge_percent globalprojectnumber); + 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); @@ -1510,6 +1586,12 @@ sub ar_transactions { '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 transaction_description)) { @@ -1635,13 +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'); - $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')) { @@ -1657,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;