/**
  * Apply the discount from this or any parent object to
  * a given price.
  *
  * @param ProductCategory|Buyable $obj
  * @param $price
  * @return bool - was any discount applied?
  */
 protected function applyPromoFrom($obj, &$price)
 {
     if (!$obj->hasValidPromotion($obj)) {
         return false;
     }
     // Apply the price
     if ($obj->PromoType == 'Percent') {
         $price -= $price * $obj->PromoPercent;
     } else {
         $price -= $obj->PromoAmount;
     }
     // there can be issues with the charged total being different
     // from the saved Total - sometimes by several cents - if
     // we don't round here.
     $precision = (int) Config::inst()->get('Order', 'rounding_precision');
     $price = round($price, $precision ? $precision : 2);
     if ($price < 0) {
         $price = 0;
     }
     return true;
 }