X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;ds=sidebyside;f=bin%2Fmozilla%2Fap.pl;h=2cfff88d61574f6e8b013f7bf792a2a1990ec8c3;hb=864b73ffb0964215f287a393ea37ec2eef6eb8eb;hp=b8d677735a783948b56d7ef0a63b2720f4f4e987;hpb=775505daab8863d45240a1a75efafbe2a417dd34;p=kivitendo-erp.git
diff --git a/bin/mozilla/ap.pl b/bin/mozilla/ap.pl
index b8d677735..2cfff88d6 100644
--- a/bin/mozilla/ap.pl
+++ b/bin/mozilla/ap.pl
@@ -79,6 +79,7 @@ sub add {
unless $form->{callback};
&create_links;
+ AP->get_transdate(\%myconfig, $form);
&display_form;
$lxdebug->leave_sub();
@@ -278,6 +279,8 @@ sub create_links {
($form->datetonum($form->{transdate}, \%myconfig) <=
$form->datetonum($form->{closedto}, \%myconfig));
+ $form->{"APselected"} = $form->{"AP_1"};
+
$lxdebug->leave_sub();
}
@@ -320,6 +323,11 @@ sub form_header {
}
$readonly = ($form->{id}) ? "readonly" : "";
+ my $APselected_quoted = quotemeta($form->{"APselected"});
+ $form->{selectAP} = $form->{AP};
+ $form->{selectAP} =~
+ s/value=\"${APselected_quoted}\"/value=\"$form->{APselected}\" selected/;
+
$form->{radier} =
($form->current_date(\%myconfig) eq $form->{gldate}) ? 1 : 0;
$readonly = ($form->{radier}) ? "" : $readonly;
@@ -634,6 +642,7 @@ $jsscript
";
+ my @triggers = ();
$form->{paidaccounts}++ if ($form->{"paid_$form->{paidaccounts}"});
for $i (1 .. $form->{paidaccounts}) {
print "
@@ -673,7 +682,8 @@ $jsscript
qq|
| |;
$column_data{"exchangerate_$i"} = qq|$exchangerate | |;
$column_data{"datepaid_$i"} =
- qq|{"datepaid_$i"}> | |;
+ qq|{"datepaid_$i"}>
+ | |;
$column_data{"source_$i"} =
qq| | |;
$column_data{"memo_$i"} =
@@ -684,9 +694,11 @@ $jsscript
print "
";
+ push(@triggers, "datepaid_$i", "BL", "trigger_datepaid_$i");
}
map { $form->{$_} =~ s/\"/"/g } qw(selectAP_paid);
- print qq|
+ print $form->write_trigger(\%myconfig, scalar(@triggers) / 3, @triggers) .
+ qq|
{paidaccounts}>
@@ -736,7 +748,10 @@ sub form_footer {
|;
-
+ print qq|
+
+|;
} else {
if (($transdate > $closedto) && !$form->{id}) {
print qq|{path}/menu.pl";
- &menubar;
- }
-
print "
@@ -776,10 +786,6 @@ sub update {
# $form->{selectAP_amount} =~
# s/value=\"$form->{AP_amountselected}\"/value=\"$form->{AP_amountselected}\" selected/;
- $form->{selectAP} = $form->{AP};
- $form->{selectAP} =~
- s/value=\"$form->{APselected}\"/value=\"$form->{APselected}\" selected/;
-
($AP_amountaccno, $AP_amounttaxkey) =
split(/--/, $form->{AP_amountselected});
$form->{selecttaxchart} = $form->{taxchart};
@@ -872,6 +878,38 @@ sub update {
$lxdebug->leave_sub();
}
+
+sub post_payment {
+ $lxdebug->enter_sub();
+ for $i (1 .. $form->{paidaccounts}) {
+ if ($form->{"paid_$i"}) {
+ $datepaid = $form->datetonum($form->{"datepaid_$i"}, \%myconfig);
+
+ $form->isblank("datepaid_$i", $locale->text('Payment date missing!'));
+
+ $form->error($locale->text('Cannot post payment for a closed period!'))
+ if ($datepaid <= $closedto);
+
+ if ($form->{currency} ne $form->{defaultcurrency}) {
+ $form->{"exchangerate_$i"} = $form->{exchangerate}
+ if ($invdate == $datepaid);
+ $form->isblank("exchangerate_$i",
+ $locale->text('Exchangerate for payment missing!'));
+ }
+ }
+ }
+
+ ($form->{AP}) = split /--/, $form->{AP};
+ ($form->{AP_paid}) = split /--/, $form->{AP_paid};
+ $form->redirect($locale->text(' Payment posted!'))
+ if (AP->post_payment(\%myconfig, \%$form));
+ $form->error($locale->text('Cannot post payment!'));
+
+
+ $lxdebug->leave_sub();
+}
+
+
sub post {
$lxdebug->enter_sub();
@@ -1482,14 +1520,8 @@ sub ap_transactions {
. $locale->text('AP Transaction') . qq|">
|;
+ . $locale->text('Vendor Invoice') . qq|">
- if ($form->{menubar}) {
- require "$form->{path}/menu.pl";
- &menubar;
- }
-
- print qq|