protected function _get_tax_added(EE_Price $tax, $ticket)
 {
     $subtotal = empty($ticket) ? 0 : $ticket->get_ticket_subtotal();
     return $subtotal * $tax->get('PRC_amount') / 100;
 }
 /**
  * Tests that if we are joining to a table that has no entries matching the query,
  * but the primary table does that we don't create model objects for the non-existent
  * row, but we do still create model objects for the row that did exist.
  * @group 7634
  */
 function test_get_all_if_related_model_blank_use_nulls()
 {
     $price_sans_price_type = EE_Price::new_instance(array('PRC_name' => 'original', 'PRT_ID' => EEM_Price_Type::instance()->count() + 1));
     $price_sans_price_type->save();
     $fetched_price = EEM_Price::reset()->get_one(array(array('PRC_ID' => $price_sans_price_type->ID()), 'force_join' => array('Price_Type')));
     $this->assertInstanceOf('EE_Price', $fetched_price);
     $this->assertEquals(null, $fetched_price->type_obj());
 }
 function test_desc()
 {
     $p = EE_Price::new_instance(array('PRC_desc' => 'let hte wookie win'));
     $this->assertEquals('let hte wookie win', $p->desc());
 }
 /**
  * used by factory to create price object.
  *
  * @since 4.3.0
  *
  * @param array $args Incoming field values to set on the new object
  *
  * @return EE_Price|false
  */
 public function create_object($args)
 {
     $this->_special_args['PRT_ID'] = isset($args['PRT_ID']) ? $args['PRT_ID'] : 0;
     if (isset($args['PRT_ID'])) {
         unset($args['PRT_ID']);
     }
     $price = EE_Price::new_instance($args);
     $priceID = $price->save();
     $price = $this->_maybe_chained($price, $args);
     return $priceID ? $price : false;
 }
 /**
  *        _sort_event_prices_by_order
  *
  * @access public
  * @param \EE_Price $price_a
  * @param \EE_Price $price_b
  * @return bool false on fail
  */
 public function _sort_event_prices_by_order(EE_Price $price_a, EE_Price $price_b)
 {
     if ($price_a->order() == $price_b->order()) {
         return 0;
     }
     return $price_a->order() < $price_b->order() ? -1 : 1;
 }