X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Far.pl;h=3d4fe26649274218c5fc0d053ee13fa96def30d7;hb=b3caa17585a69e0c5092483f709dd1227b9acaaf;hp=3d6704262eb34b87c566f0142be75c873f7342cf;hpb=3e17e2b64326dc5b21ccc9874792d475022d3109;p=kivitendo-erp.git diff --git a/bin/mozilla/ar.pl b/bin/mozilla/ar.pl index 3d6704262..3d4fe2664 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}; @@ -273,17 +271,9 @@ sub form_header { $form->{exchangerate} = $form->{forex} if $form->{forex}; # format amounts - $form->{exchangerate} = - $form->format_amount(\%myconfig, $form->{exchangerate}); - - if ($form->{exchangerate} == 0) { - $form->{exchangerate} = ""; - } - - $form->{creditlimit} = - $form->format_amount(\%myconfig, $form->{creditlimit}, 0, "0"); - $form->{creditremaining} = - $form->format_amount(\%myconfig, $form->{creditremaining}, 0, "0"); + $form->{exchangerate} = $form->{exchangerate} ? $form->format_amount(\%myconfig, $form->{exchangerate}) : ''; + $form->{creditlimit} = $form->format_amount(\%myconfig, $form->{creditlimit}, 0, "0"); + $form->{creditremaining} = $form->format_amount(\%myconfig, $form->{creditremaining}, 0, "0"); $exchangerate = qq| {forex}> @@ -705,7 +695,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 +710,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 +768,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 +852,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 +974,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 +999,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 +1007,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 +1031,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 +1085,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 +1123,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 +1136,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 +1159,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 +1242,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 +1271,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 }); @@ -1330,7 +1338,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 customernumber country ustid taxzone payment_terms charts); + 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); @@ -1366,6 +1374,7 @@ sub ar_transactions { 'taxzone' => { 'text' => $locale->text('Steuersatz'), }, 'payment_terms' => { 'text' => $locale->text('Payment Terms'), }, 'charts' => { 'text' => $locale->text('Buchungskonto'), }, + 'customertype' => { 'text' => $locale->text('Customer type'), }, ); foreach my $name (qw(id transdate duedate invnumber ordnumber name datepaid employee shippingpoint shipvia transaction_description)) { @@ -1393,6 +1402,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 +1437,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 +1528,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