Skip to content

Instantly share code, notes, and snippets.

@goldhat
Created November 25, 2016 18:26
Show Gist options
  • Save goldhat/8093ad7c6d310baf17b7fcbaa9ccc980 to your computer and use it in GitHub Desktop.
Save goldhat/8093ad7c6d310baf17b7fcbaa9ccc980 to your computer and use it in GitHub Desktop.
WaitList calcShippableCap() method
/*
* Calculate the ShippableCap that represents current maximum shippable units
* ShippableCap varies during OrderPeriod
* Takes into account potential gain/loss of shippable subscribers
* Returns ShippableCap that is compared to current OrderLimit
*/
public function calcShippableCap( $orderLimit, $shippableCount ) {
$dailyLossRate = 0.0065;
$daysRemaining = $this->daysRemainingOrderPeriod();
$periodLossRate = $daysRemaining * $dailyLossRate;
$shippableCapPeriod = $this->calcShippableCapPeriod();
switch( $shippableCapPeriod ) {
case 10:
return floor($orderLimit + ( $shippableCount * $periodLossRate ));
break;
case 20:
return floor($orderLimit + ( $shippableCount * $periodLossRate * 0.5 ));
break;
case 30:
return $orderLimit;
break;
case 40:
return floor( $orderLimit - ($daysRemaining * 25) + 10 );
break;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment