# transdate madness.
my $transdate = "";
- if ($form->{type} eq "invoice") {
- if (($form->{vc} eq "vendor") || !$form->{deliverydate}) {
+ if ($form->{type} eq "invoice" or $form->{type} eq "credit_note") {
+ # use deliverydate for sales and purchase invoice, if it exists
+ # also use deliverydate for credit notes
+ if (!$form->{deliverydate}) {
+ $transdate = $form->{invdate};
+ } else {
+ $transdate = $form->{deliverydate};
+ }
+ } elsif ($form->{script} eq 'ir.pl') {
+ # when a purchase invoice is opened from the report of purchase invoices
+ # $form->{type} isn't set, but $form->{script} is, not sure why this is or
+ # whether this distinction matters in some other scenario. Otherwise one
+ # could probably take out this elsif and add a
+ # " or $form->{script} eq 'ir.pl' "
+ # to the above if-statement
+ if (!$form->{deliverydate}) {
$transdate = $form->{invdate};
} else {
$transdate = $form->{deliverydate};
my $transdate = "";
if ($form->{type} eq "invoice") {
- $transdate = $form->{invdate} ? $dbh->quote($form->{invdate}) : "current_date";
+ $transdate = $form->{deliverydate} ? $dbh->quote($form->{deliverydate})
+ : $form->{invdate} ? $dbh->quote($form->{invdate})
+ : "current_date";
} else {
$transdate = $form->{transdate} ? $dbh->quote($form->{transdate}) : "current_date";
}
--- /dev/null
+-- @tag: ap_deliverydate
+-- @description: deliverydate zu Einkaufsrechnung hinzufügen
+-- @depends: release_3_0_0
+-- @charset: utf-8
+ALTER TABLE ap ADD COLUMN deliverydate date;