X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Far.pl;h=fcd9e83c690d05b3b51b35ee604f016f437ee5a5;hb=b6213d3539ccd179cd1f21b9afc54b8de8970774;hp=ad1407cfd03f80121f18d6043d21e5716d209393;hpb=3cd3e832747e15c4fc6b69bd185b0159f1a8dbd3;p=kivitendo-erp.git diff --git a/bin/mozilla/ar.pl b/bin/mozilla/ar.pl index ad1407cfd..fcd9e83c6 100644 --- a/bin/mozilla/ar.pl +++ b/bin/mozilla/ar.pl @@ -100,7 +100,7 @@ sub add { AR->get_transdate(\%myconfig, $form); $form->{initial_transdate} = $form->{transdate}; - &create_links; + create_links(dont_save => 1); $form->{transdate} = $form->{initial_transdate}; &display_form; $main::lxdebug->leave_sub(); @@ -119,7 +119,7 @@ sub edit { $form->{javascript} .= qq||; $form->{title} = "Edit"; - &create_links; + create_links(); &display_form; $main::lxdebug->leave_sub(); @@ -143,21 +143,21 @@ sub create_links { $main::auth->assert('general_ledger'); + my %params = @_; my $form = $main::form; my %myconfig = %main::myconfig; - my ($duedate, $taxincluded); - $form->create_links("AR", \%myconfig, "customer"); - $duedate = $form->{duedate}; - $taxincluded = $form->{taxincluded}; - my $id = $form->{id}; + my %saved; + if (!$params{dont_save}) { + %saved = map { ($_ => $form->{$_}) } qw(direct_debit id taxincluded); + $saved{duedate} = $form->{duedate} if $form->{duedate}; + } + IS->get_customer(\%myconfig, \%$form); - $form->{taxincluded} = $taxincluded; - $form->{id} = $id; - $form->{duedate} = $duedate if $duedate; + $form->{$_} = $saved{$_} for keys %saved; $form->{oldcustomer} = "$form->{customer}--$form->{customer_id}"; $form->{rowcount} = 1; @@ -315,8 +315,6 @@ sub form_header { $taxcharts{$item->{id}} = $item; } - $::request->{layout}->focus("#customer"); - my $follow_up_vc = $form->{customer}; $follow_up_vc =~ s/--.*?//; my $follow_up_trans_info = "$form->{invnumber} ($follow_up_vc)"; @@ -333,7 +331,7 @@ sub form_header { my $transaction = { amount => $form->{"amount_$i"}, tax => $form->{"tax_$i"}, - project_id => $form->{"project_id_$i"}, + project_id => ($i==$form->{rowcount}) ? $form->{globalproject_id} : $form->{"project_id_$i"}, }; my $selected_accno_full; @@ -411,12 +409,15 @@ sub form_header { gldate => $form->{"gldate_$i"}, }; + # default account for current assets (i.e. 1801 - SKR04) if no account is selected + $form->{accno_arap} = IS->get_standard_accno_current_assets(\%myconfig, \%$form); + $payment->{selectAR_paid} = NTI($cgi->popup_menu('-name' => "AR_paid_$i", '-id' => "AR_paid_$i", '-values' => \@AR_paid_values, '-labels' => \%chart_labels, - '-default' => $payment->{AR_paid})); + '-default' => $payment->{AR_paid} || $form->{accno_arap})); @@ -456,89 +457,29 @@ sub form_footer { my $locale = $main::locale; my $cgi = $::request->{cgi}; - my ($transdate, $closedto); - - my $follow_ups_block; - if ($form->{id}) { + 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|

|; + if ( @{ $follow_ups} ) { + $form->{follow_up_length} = scalar(@{$follow_ups}); + $form->{follow_up_due_length} = sum(map({ $_->{due} * 1 } @{ $follow_ups })); } } - print qq| - -$follow_ups_block - - - - -| -. $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); + my $transdate = $form->datetonum($form->{transdate}, \%myconfig); + my $closedto = $form->datetonum($form->{closedto}, \%myconfig); - print qq|\n|; + $form->{is_closed} = $transdate <= $closedto; # 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') && (($form->{totalpaid} == 0) || ($form->{totalpaid} eq ""))); - - if ($form->{id}) { - if ($form->{radier}) { - print qq| - - |; - } - if ($transdate > $closedto) { - print qq| - |; - } - print qq| - - |; + $form->{show_storno_button} = + $form->{id} && + !IS->has_storno(\%myconfig, $form, 'ar') && + !IS->is_storno(\%myconfig, $form, 'ar') && + ($form->{totalpaid} == 0 || $form->{totalpaid} eq ""); - } else { - if ($transdate > $closedto) { - print qq| | . - NTI($cgi->submit('-name' => 'action', '-value' => $locale->text('Save draft'), '-class' => 'submit')); - } - } + $form->{show_mark_as_paid_button} = $form->{id} && $::instance_conf->get_ar_show_mark_as_paid(); - # button for saving history - if($form->{id} ne "") { - print qq| {id}); name=history id=history value=| . $locale->text('history') . qq|> |; - } - # /button for saving history - # mark_as_paid button - if(($form->{id} ne "") && $::instance_conf->get_ar_show_mark_as_paid) { - print qq||; - } - # /mark_as_paid button - - print " - -"; + print $::form->parse_html_template('ar/form_footer'); $main::lxdebug->leave_sub(); } @@ -729,6 +670,9 @@ sub post { my $closedto = $form->datetonum($form->{closedto}, \%myconfig); my $transdate = $form->datetonum($form->{transdate}, \%myconfig); + + $form->error($locale->text('Cannot post transaction above the maximum future booking date!')) + if ($form->date_max_future($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!')) @@ -886,32 +830,27 @@ sub yes { sub search { $main::lxdebug->enter_sub(); - $main::auth->assert('general_ledger | invoice_edit'); + $main::auth->assert('invoice_edit'); my $form = $main::form; my %myconfig = %main::myconfig; my $locale = $main::locale; my $cgi = $::request->{cgi}; - my ($customer, $department); - my ($jsscript, $button1, $button2); - # setup customer selection $form->all_vc(\%myconfig, "customer", "AR"); $form->{title} = $locale->text('AR Transactions'); - $form->{jsscript} = 1; # Auch in Rechnungsübersicht nach Kundentyp filtern - jan $form->get_lists("projects" => { "key" => "ALL_PROJECTS", "all" => 1 }, "departments" => "ALL_DEPARTMENTS", "customers" => "ALL_VC", "business_types" => "ALL_BUSINESS_TYPES"); - $form->{ALL_EMPLOYEES} = SL::DB::Manager::Employee->get_all(query => [ deleted => 0 ]); + $form->{ALL_EMPLOYEES} = SL::DB::Manager::Employee->get_all_sorted(query => [ deleted => 0 ]); $form->{SHOW_BUSINESS_TYPES} = scalar @{ $form->{ALL_BUSINESS_TYPES} } > 0; # constants and subs for template - $form->{jsscript} = 1; $form->{vc_keys} = sub { "$_[0]->{name}--$_[0]->{id}" }; $form->header; @@ -944,7 +883,7 @@ sub create_subtotal_row { sub ar_transactions { $main::lxdebug->enter_sub(); - $main::auth->assert('general_ledger | invoice_edit'); + $main::auth->assert('invoice_edit'); my $form = $main::form; my %myconfig = %main::myconfig; @@ -963,12 +902,12 @@ sub ar_transactions { my $report = SL::ReportGenerator->new(\%myconfig, $form); @columns = - qw(transdate id type invnumber ordnumber name netamount tax amount paid + qw(transdate id type invnumber ordnumber cusordnumber name netamount tax amount paid datepaid due duedate transaction_description notes salesman employee shippingpoint shipvia marge_total marge_percent globalprojectnumber customernumber country ustid taxzone payment_terms charts customertype); my @hidden_variables = map { "l_${_}" } @columns; - push @hidden_variables, "l_subtotal", qw(open closed customer invnumber ordnumber transaction_description notes project_id transdatefrom transdateto employee_id salesman_id business_id); + push @hidden_variables, "l_subtotal", qw(open closed customer invnumber ordnumber cusordnumber transaction_description notes project_id transdatefrom transdateto employee_id salesman_id business_id); $href = build_std_url('action=ar_transactions', grep { $form->{$_} } @hidden_variables); @@ -978,6 +917,7 @@ sub ar_transactions { 'type' => { 'text' => $locale->text('Type'), }, 'invnumber' => { 'text' => $locale->text('Invoice'), }, 'ordnumber' => { 'text' => $locale->text('Order'), }, + 'cusordnumber' => { 'text' => $locale->text('Customer Order Number'), }, 'name' => { 'text' => $locale->text('Customer'), }, 'netamount' => { 'text' => $locale->text('Amount'), }, 'tax' => { 'text' => $locale->text('Tax'), }, @@ -1004,7 +944,7 @@ sub ar_transactions { 'customertype' => { 'text' => $locale->text('Customer type'), }, ); - foreach my $name (qw(id transdate duedate invnumber ordnumber name datepaid employee shippingpoint shipvia transaction_description)) { + foreach my $name (qw(id transdate duedate invnumber ordnumber cusordnumber 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"; } @@ -1038,6 +978,9 @@ sub ar_transactions { if ($form->{ordnumber}) { push @options, $locale->text('Order Number') . " : $form->{ordnumber}"; } + if ($form->{cusordnumber}) { + push @options, $locale->text('Customer Order Number') . " : $form->{cusordnumber}"; + } if ($form->{notes}) { push @options, $locale->text('Notes') . " : $form->{notes}"; }