X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Far.pl;h=0e5ab85a9b54265a2c6926236c7d35d3527ecb4a;hb=595799f4a2b96153522fe307a4f6aad4fb257806;hp=3d6704262eb34b87c566f0142be75c873f7342cf;hpb=5f4f93b36e5cac5cba49224bde12284034b44f49;p=kivitendo-erp.git diff --git a/bin/mozilla/ar.pl b/bin/mozilla/ar.pl index 3d6704262..0e5ab85a9 100644 --- a/bin/mozilla/ar.pl +++ b/bin/mozilla/ar.pl @@ -76,8 +76,6 @@ use strict; # $locale->text('Nov') # $locale->text('Dec') -my $totalpaid; - sub add { $main::lxdebug->enter_sub(); @@ -92,12 +90,12 @@ sub add { if(!exists $form->{addition} && ($form->{id} ne "")) { $form->{snumbers} = qq|invnumber_| . $form->{invnumber}; $form->{addition} = "ADDED"; - $form->save_history($form->dbconnect(\%myconfig)); + $form->save_history; } # /saving the history $form->{title} = "Add"; - $form->{callback} = "ar.pl?action=add" unless $form->{callback}; + $form->{callback} = "ar.pl?action=add&DONT_LOAD_DRAFT=1" unless $form->{callback}; AR->get_transdate(\%myconfig, $form); $form->{initial_transdate} = $form->{transdate}; @@ -705,7 +703,7 @@ $jsscript "; my @triggers = (); - my $totalpaid = 0; + $form->{totalpaid} = 0; $form->{paidaccounts}++ if ($form->{"paid_$form->{paidaccounts}"}); for my $i (1 .. $form->{paidaccounts}) { @@ -720,7 +718,7 @@ $jsscript '-labels' => \%AR_paid_labels, '-default' => $form->{"AR_paid_$i"})); - $totalpaid += $form->{"paid_$i"}; + $form->{totalpaid} += $form->{"paid_$i"}; # format amounts if ($form->{"paid_$i"}) { @@ -778,14 +776,14 @@ $jsscript push(@triggers, "datepaid_$i", "BL", "trigger_datepaid_$i"); } - my $paid_missing = $form->{invtotal_unformatted} - $totalpaid; + my $paid_missing = $form->{invtotal_unformatted} - $form->{totalpaid}; print qq| | . $locale->text('Total') . qq| - | . H($form->format_amount(\%myconfig, $totalpaid, 2)) . qq| + | . H($form->format_amount(\%myconfig, $form->{totalpaid}, 2)) . qq| @@ -862,7 +860,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') && (($totalpaid == 0) || ($totalpaid eq ""))); + 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}) { @@ -984,10 +982,14 @@ sub update { $form->{invdate} = $form->{transdate}; - my %saved_variables = map +( $_ => $form->{$_} ), qw(AR AR_amount_1 taxchart_1); + my %saved_variables = map +( $_ => $form->{$_} ), qw(AR AR_amount_1 taxchart_1 oldcustomer); &check_name("customer"); + # check_name ruft get_customer auf, oldcustomer wird überschrieben, daher wird dies vorher gemerkt + # get_customer holt Bemerkungen als intnotes, für Debitorenbuchungen gibt es aber nur das Feld notes + $form->{notes} = $form->{intnotes} if $saved_variables{oldcustomer} ne $form->{customer}; + $form->{AR} = $saved_variables{AR}; if ($saved_variables{AR_amount_1} =~ m/.--./) { map { $form->{$_} = $saved_variables{$_} } qw(AR_amount_1 taxchart_1); @@ -1005,7 +1007,7 @@ sub update { $form->parse_amount(\%myconfig, $form->{"${_}_$i"}) } qw(paid exchangerate); - $totalpaid += $form->{"paid_$i"}; + $form->{totalpaid} += $form->{"paid_$i"}; $form->{"forex_$i"} = $form->check_exchangerate( \%myconfig, $form->{currency}, $form->{"datepaid_$i"}, 'buy'); $form->{"exchangerate_$i"} = $form->{"forex_$i"} if $form->{"forex_$i"}; @@ -1013,10 +1015,10 @@ sub update { } $form->{creditremaining} -= - ($form->{invtotal} - $totalpaid + $form->{oldtotalpaid} - + ($form->{invtotal} - $form->{totalpaid} + $form->{oldtotalpaid} - $form->{oldinvtotal}); $form->{oldinvtotal} = $form->{invtotal}; - $form->{oldtotalpaid} = $totalpaid; + $form->{oldtotalpaid} = $form->{totalpaid}; &display_form; @@ -1037,6 +1039,8 @@ sub post_payment { $form->{defaultcurrency} = $form->get_default_currency(\%myconfig); + my $invdate = $form->datetonum($form->{transdate}, \%myconfig); + for my $i (1 .. $form->{paidaccounts}) { if ($form->parse_amount(\%myconfig, $form->{"paid_$i"})) { @@ -1089,6 +1093,12 @@ sub post { $form->isblank("duedate", $locale->text('Due Date missing!')); $form->isblank("customer", $locale->text('Customer missing!')); + if ($myconfig{mandatory_departments} && !$form->{department}) { + $form->{saved_message} = $::locale->text('You have to specify a department.'); + update(); + exit; + } + 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)); @@ -1121,13 +1131,12 @@ sub post { my ($customer) = split /--/, $form->{customer}; if ($form->{oldcustomer} ne "$customer--$form->{customer_id}") { update(); - exit; + ::end_of_request(); } $form->{AR}{receivables} = $form->{ARselected}; $form->{storno} = 0; - $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); @@ -1135,7 +1144,7 @@ sub post { if(!exists $form->{addition} && $form->{id} ne "") { $form->{snumbers} = "invnumber_$form->{invnumber}"; $form->{addition} = "POSTED"; - $form->save_history($form->dbconnect(\%myconfig)); + $form->save_history; } # /saving the history remove_draft() if $form->{remove_draft}; @@ -1158,7 +1167,7 @@ sub post_as_new { if(!exists $form->{addition} && $form->{id} ne "") { $form->{snumbers} = qq|invnumber_| . $form->{invnumber}; $form->{addition} = "POSTED AS NEW"; - $form->save_history($form->dbconnect(\%myconfig)); + $form->save_history; } # /saving the history &post; @@ -1241,7 +1250,7 @@ sub yes { if(!exists $form->{addition}) { $form->{snumbers} = qq|invnumber_| . $form->{invnumber}; $form->{addition} = "DELETED"; - $form->save_history($form->dbconnect(\%myconfig)); + $form->save_history; } # /saving the history $form->redirect($locale->text('Transaction deleted!')); @@ -1270,13 +1279,20 @@ sub search { $form->{title} = $locale->text('AR Transactions'); $form->{jsscript} = 1; - $form->get_lists("projects" => { "key" => "ALL_PROJECTS", "all" => 1 }, - "departments" => "ALL_DEPARTMENTS", - "customers" => "ALL_VC"); + # Auch in Rechnungsübersicht nach Kundentyp filtern - jan + $form->get_lists("projects" => { "key" => "ALL_PROJECTS", "all" => 1 }, + "departments" => "ALL_DEPARTMENTS", + "customers" => "ALL_VC", + "employees" => "ALL_EMPLOYEES", + "salesmen" => "ALL_SALESMEN", + "business_types" => "ALL_BUSINESS_TYPES"); + $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->{employee_labels} = sub { $_[0]->{"name"} || $_[0]->{"login"} }; + $form->{salesman_labels} = $form->{employee_labels}; $form->header; print $form->parse_html_template('ar/search', { %myconfig }); @@ -1393,6 +1409,9 @@ sub ar_transactions { my ($department) = split /--/, $form->{department}; push @options, $locale->text('Department') . " : $department"; } + if ($form->{department_id}) { + push @options, $locale->text('Department Id') . " : $form->{department_id}"; + } if ($form->{invnumber}) { push @options, $locale->text('Invoice Number') . " : $form->{invnumber}"; } @@ -1425,6 +1444,7 @@ sub ar_transactions { 'attachment_basename' => $locale->text('invoice_list') . strftime('_%Y%m%d', localtime time), ); $report->set_options_from_form(); + $locale->set_numberformat_wo_thousands_separator(\%myconfig) if lc($report->{options}->{output_format}) eq 'csv'; # add sort and escape callback, this one we use for the add sub $form->{callback} = $href .= "&sort=$form->{sort}"; @@ -1515,7 +1535,7 @@ sub storno { if(!exists $form->{addition} && $form->{id} ne "") { $form->{snumbers} = "ordnumber_$form->{ordnumber}"; $form->{addition} = "STORNO"; - $form->save_history($form->dbconnect(\%myconfig)); + $form->save_history; } # /saving the history