Example #1
0
 /**
  * Take any Line Items from the Quote and Convert them into a RevenueLineItem and attach them to the Opportunity
  *
  * @param Quote $quote
  * @param Opportunity $opp
  */
 protected function convertQuoteLineItemsToRevenueLineItems(Quote $quote, Opportunity $opp)
 {
     $forecastConfig = $this->getForecastConfig();
     // TODO: this will need to change when we have the switch for Opportunities,
     // TODO: but since that is not done yet this will use the forecast_by.
     if ($forecastConfig['forecast_by'] !== 'RevenueLineItems') {
         return false;
     }
     // load the revenue line items
     $opp->load_relationship('revenuelineitems');
     $products = $quote->get_linked_beans('products', 'Products');
     /* @var $product Product */
     foreach ($products as $product) {
         $rli = $product->convertToRevenueLineItem();
         $rli->date_closed = $quote->date_quote_expected_closed;
         $rli->sales_stage = isset($app_list_strings['sales_stage_dom']['Proposal/Price Quote']) ? 'Proposal/Price Quote' : null;
         $rli->assigned_user_id = $quote->assigned_user_id;
         $rli->save();
         // save the RLI to the relationship
         $opp->revenuelineitems->add($rli);
     }
 }