X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;ds=sidebyside;f=bin%2Fmozilla%2Far.pl;h=585301c25a22139e6fe9c8e19aad833e49801a07;hb=782fd7884fb686cd2e336756dadeb4ab5d05a415;hp=b5bd9be6c37da269a011878ef291c6e46086aa07;hpb=2d3f862b7af94f31860dd264eef7c1bc7de7eae2;p=kivitendo-erp.git
diff --git a/bin/mozilla/ar.pl b/bin/mozilla/ar.pl
index b5bd9be6c..585301c25 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"})) {
@@ -1127,7 +1131,7 @@ 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};
@@ -1140,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};
@@ -1163,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;
@@ -1246,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!'));
@@ -1275,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 });
@@ -1335,7 +1346,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);
@@ -1371,6 +1382,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)) {
@@ -1398,6 +1410,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}";
}
@@ -1430,6 +1445,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}";
@@ -1520,7 +1536,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