/** * sets the TXN ID on an EE_Line_Item if passed a valid EE_Transaction object * @param EE_Line_Item $line_item * @param EE_Transaction $transaction * @return void */ public static function set_TXN_ID(EE_Line_Item $line_item, $transaction = NULL) { if ($transaction) { /** @type EEM_Transaction $EEM_Transaction */ $EEM_Transaction = EE_Registry::instance()->load_model('Transaction'); $transaction = $EEM_Transaction->ensure_is_ID($transaction); $line_item->set_TXN_ID($transaction); } }
/** * Adds the line item as a child to this line item. If there is another child line * item with the same LIN_code, it is overwritten by this new one * @param EE_Line_Item $line_item * @return boolean success */ function add_child_line_item(EE_Line_Item $line_item) { if ($this->ID()) { //check for any duplicate line items (with the same code), if so, this replaces it $line_item_with_same_code = $this->get_child_line_item($line_item->code()); if ($line_item_with_same_code instanceof EE_Line_Item && $line_item_with_same_code !== $line_item) { $this->delete_child_line_item($line_item_with_same_code->code()); } $line_item->set_parent_ID($this->ID()); if ($this->TXN_ID()) { $line_item->set_TXN_ID($this->TXN_ID()); } return $line_item->save(); } else { $this->_Line_Item[$line_item->code()] = $line_item; return TRUE; } }
/** * Creates a line item for the taxes subtotal and finds all the tax prices * and applies taxes to it * @param EE_Line_Item $total_line_item of type EEM_Line_Item::type_total * @param EE_Transaction $transaction * @return EE_Line_Item */ protected static function create_default_taxes_subtotal(EE_Line_Item $total_line_item, $transaction = NULL) { $tax_line_item = EE_Line_Item::new_instance(array('LIN_code' => 'taxes', 'LIN_name' => __('Taxes', 'event_espresso'), 'LIN_type' => EEM_Line_Item::type_tax_sub_total)); if ($transaction) { $transaction = EEM_Transaction::instance()->ensure_is_ID($transaction); $total_line_item->set_TXN_ID($transaction); } $total_line_item->add_child_line_item($tax_line_item); //and lastly, add the actual taxes self::apply_taxes($total_line_item); return $tax_line_item; }