Code:
//...got the Purchasing Data for the supplier of the item
$LeadTime = $PurchRow['leadtime'];
} else { // no purchasing data setup
$PurchPrice = 0;
$ConversionFactor = 1;
$SupplierDescription = $ItemRow['description'];
$SuppliersUnitOfMeasure = $ItemRow['units'];
$SuppliersPartNo = '';
$LeadTime = $ItemRow['leadtime'];
}
/* Work out the delivery date based on today + lead time
* if > header DeliveryDate then set DeliveryDate to today + leadtime
*/
$DeliveryDate = DateAdd(Date($_SESSION['DefaultDateFormat']),'d',$LeadTime);
if (! Date1GreaterThanDate2($DeliveryDate,$_SESSION['PO'.$identifier]->DeliveryDate)){
$DeliveryDate = $_SESSION['PO'.$identifier]->DeliveryDate;
}
So the delivery date is defaulted to today + the lead time from the supplier purchasing data unless the header delivery date is later than this - in which case the header delivery date is defaulted for the line item delivery date.
The system was not using the stock item lead time (it was using the purchasing data lead time specific to the supplier). However, I have modified it as above to now use the stock master lead time if no supplier specific lead time is set up.
I also added the link to print the order after creation as suggested by MacPhotoBiker ... not sure why that was not there already!