X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;ds=sidebyside;f=bin%2Fmozilla%2Fap.pl;h=ae2bda36b605e454bf2a4fafe93000ffa59dd66d;hb=2508bbb1ab2056ec40635f4dda1c7023a5f3254f;hp=a6d5cdc5c1073cfbf6c21b9e956e7101fe66fa8d;hpb=dc8f62cf5df4a7f8473e7d76fdd98846cea5721f;p=kivitendo-erp.git diff --git a/bin/mozilla/ap.pl b/bin/mozilla/ap.pl index a6d5cdc5c..ae2bda36b 100644 --- a/bin/mozilla/ap.pl +++ b/bin/mozilla/ap.pl @@ -156,11 +156,9 @@ sub create_links { $form->{notes} = $form->{intnotes} unless $form->{notes}; # currencies - my @curr = split(/:/, $form->{currencies}); - chomp $curr[0]; - $form->{defaultcurrency} = $curr[0]; + $form->{defaultcurrency} = $form->get_default_currency(\%myconfig); - map { $form->{selectcurrency} .= "$_\n" } @curr; + map { $form->{selectcurrency} .= "$_\n" } $form->get_all_currencies(\%myconfig); # vendors if (@{ $form->{all_vendor} || [] }) { @@ -261,7 +259,7 @@ sub form_header { my $exchangerate = qq| {forex}> |; - if ($form->{currency} ne $form->{defaultcurrency}) { + if ($form->{defaultcurrency} && ($form->{currency} ne $form->{defaultcurrency})) { if ($form->{forex}) { $exchangerate .= qq| @@ -639,7 +637,7 @@ $jsscript |; my @column_index; - if ($form->{currency} eq $form->{defaultcurrency}) { + if ($form->{defaultcurrency} && ($form->{currency} eq $form->{defaultcurrency})) { @column_index = qw(datepaid source memo paid AP_paid paid_project_id); } else { @column_index = qw(datepaid source memo paid exchangerate AP_paid paid_project_id); @@ -663,7 +661,7 @@ $jsscript "; my @triggers = (); - my $totalpaid = 0; + $form->{totalpaid} = 0; $form->{paidaccounts}++ if ($form->{"paid_$form->{paidaccounts}"}); for my $i (1 .. $form->{paidaccounts}) { @@ -678,7 +676,7 @@ $jsscript '-labels' => \%AP_paid_labels, '-default' => $form->{"AP_paid_$i"})); - $totalpaid += $form->{"paid_$i"}; + $form->{totalpaid} += $form->{"paid_$i"}; # format amounts if ($form->{"paid_$i"}) { @@ -692,7 +690,7 @@ $jsscript } $exchangerate = qq| |; - if ($form->{currency} ne $form->{defaultcurrency}) { + if ($form->{defaultcurrency} && ($form->{currency} ne $form->{defaultcurrency})) { if ($form->{"forex_$i"}) { $exchangerate = qq|{"exchangerate_$i"}>$form->{"exchangerate_$i"}|; @@ -734,14 +732,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| @@ -820,9 +818,8 @@ $follow_ups_block |; } # ToDO: - insert a global check for stornos, so that a storno is only possible a limited time after saving it - our $total_paid; print qq| | - if ($form->{id} && !IS->has_storno(\%myconfig, $form, 'ap') && !IS->is_storno(\%myconfig, $form, 'ap', $form->{id}) && (($total_paid == 0) || ($total_paid eq ""))); + if ($form->{id} && !IS->has_storno(\%myconfig, $form, 'ap') && !IS->is_storno(\%myconfig, $form, 'ap', $form->{id}) && (($form->{totalpaid} == 0) || ($form->{totalpaid} eq ""))); print qq| @@ -975,7 +972,8 @@ sub post_payment { $form->{defaultcurrency} = $form->get_default_currency(\%myconfig); - our $invdate; + my $invdate = $form->datetonum($form->{transdate}, \%myconfig); + for my $i (1 .. $form->{paidaccounts}) { if ($form->parse_amount(\%myconfig, $form->{"paid_$i"})) { my $datepaid = $form->datetonum($form->{"datepaid_$i"}, \%myconfig); @@ -985,7 +983,7 @@ sub post_payment { $form->error($locale->text('Cannot post payment for a closed period!')) if ($form->date_closed($form->{"datepaid_$i"}, \%myconfig)); - if ($form->{currency} ne $form->{defaultcurrency}) { + if ($form->{defaultcurrency} && ($form->{currency} ne $form->{defaultcurrency})) { $form->{"exchangerate_$i"} = $form->{exchangerate} if ($invdate == $datepaid); $form->isblank("exchangerate_$i", @@ -1019,6 +1017,12 @@ sub post { $form->isblank("duedate", $locale->text("Due Date missing!")); $form->isblank("vendor", $locale->text('Vendor 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)); @@ -1034,7 +1038,7 @@ sub post { $form->error($locale->text('Zero amount posting!')) if $zero_amount_posting; $form->isblank("exchangerate", $locale->text('Exchangerate missing!')) - if ($form->{currency} ne $form->{defaultcurrency}); + if ($form->{defaultcurrency} && ($form->{currency} ne $form->{defaultcurrency})); delete($form->{AP}); for my $i (1 .. $form->{paidaccounts}) { @@ -1046,7 +1050,7 @@ sub post { $form->error($locale->text('Cannot post payment for a closed period!')) if ($form->date_closed($form->{"datepaid_$i"}, \%myconfig)); - if ($form->{currency} ne $form->{defaultcurrency}) { + if ($form->{defaultcurrency} && ($form->{currency} ne $form->{defaultcurrency})) { $form->{"exchangerate_$i"} = $form->{exchangerate} if ($transdate == $datepaid); $form->isblank("exchangerate_$i", @@ -1060,7 +1064,7 @@ sub post { my ($vendor) = split /--/, $form->{vendor}; if ($form->{oldvendor} ne "$vendor--$form->{vendor_id}") { &update; - exit; + ::end_of_request(); } my ($debitaccno, $debittaxkey) = split /--/, $form->{AP_amountselected}; my ($taxkey, $NULL) = split /--/, $form->{taxchartselected}; @@ -1292,7 +1296,7 @@ sub ap_transactions { 'duedate' => { 'text' => $locale->text('Due Date'), }, 'transaction_description' => { 'text' => $locale->text('Transaction description'), }, 'notes' => { 'text' => $locale->text('Notes'), }, - 'employee' => { 'text' => $locale->text('Salesperson'), }, + 'employee' => { 'text' => $locale->text('Employee'), }, 'globalprojectnumber' => { 'text' => $locale->text('Project Number'), }, 'vendornumber' => { 'text' => $locale->text('Vendor Number'), }, 'country' => { 'text' => $locale->text('Country'), },