Start forecast demand at first sale
This commit is contained in:
1 parent
185dfcdb38
commit
91ac3a6828
2 files changed
+5
-4
No files matched your search
@@ -131,13 +131,15 @@ function lager_forecast_calculate(
|
||||
?DateTimeImmutable $forecastStartDate = null
|
||||
): array
|
||||
{
|
||||
$lookbackDays = 365;
|
||||
$firstSaleDate = empty($dailySales) ? null : min(array_keys($dailySales));
|
||||
$lookbackDays = $firstSaleDate === null
|
||||
? 0
|
||||
: $asOfDate->diff(new DateTimeImmutable($firstSaleDate))->days + 1;
|
||||
$halfLifeDays = 60;
|
||||
$weightedUnits = 0.0;
|
||||
$weightTotal = 0.0;
|
||||
$salesUnits = 0.0;
|
||||
$salesDays = 0;
|
||||
$firstSaleDate = null;
|
||||
$lastSaleDate = null;
|
||||
|
||||
for ($age = 0; $age < $lookbackDays; $age++) {
|
||||
@@ -150,7 +152,6 @@ function lager_forecast_calculate(
|
||||
if ($units > 0) {
|
||||
$salesUnits += $units;
|
||||
$salesDays++;
|
||||
$firstSaleDate = $dateKey;
|
||||
$lastSaleDate ??= $dateKey;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user