@@ 348-363 (lines=16) @@ | ||
345 | * @param EE_Transaction $transaction |
|
346 | * @return \EE_Line_Item of type total |
|
347 | */ |
|
348 | public static function create_total_line_item( $transaction = NULL ){ |
|
349 | $total_line_item = EE_Line_Item::new_instance( array( |
|
350 | 'LIN_code' => 'total', |
|
351 | 'LIN_name' => __('Grand Total', 'event_espresso'), |
|
352 | 'LIN_type' => EEM_Line_Item::type_total, |
|
353 | 'OBJ_type' =>'Transaction' |
|
354 | )); |
|
355 | $total_line_item = apply_filters( |
|
356 | 'FHEE__EEH_Line_Item__create_total_line_item__total_line_item', |
|
357 | $total_line_item |
|
358 | ); |
|
359 | self::set_TXN_ID( $total_line_item, $transaction ); |
|
360 | self::create_pre_tax_subtotal( $total_line_item, $transaction ); |
|
361 | self::create_taxes_subtotal( $total_line_item, $transaction ); |
|
362 | return $total_line_item; |
|
363 | } |
|
364 | ||
365 | ||
366 | ||
@@ 373-387 (lines=15) @@ | ||
370 | * @param EE_Transaction $transaction |
|
371 | * @return EE_Line_Item |
|
372 | */ |
|
373 | protected static function create_pre_tax_subtotal( EE_Line_Item $total_line_item, $transaction = NULL ){ |
|
374 | $pre_tax_line_item = EE_Line_Item::new_instance( array( |
|
375 | 'LIN_code' => 'pre-tax-subtotal', |
|
376 | 'LIN_name' => __( 'Pre-Tax Subtotal', 'event_espresso' ), |
|
377 | 'LIN_type' => EEM_Line_Item::type_sub_total |
|
378 | ) ); |
|
379 | $pre_tax_line_item = apply_filters( |
|
380 | 'FHEE__EEH_Line_Item__create_pre_tax_subtotal__pre_tax_line_item', |
|
381 | $pre_tax_line_item |
|
382 | ); |
|
383 | self::set_TXN_ID( $pre_tax_line_item, $transaction ); |
|
384 | $total_line_item->add_child_line_item( $pre_tax_line_item ); |
|
385 | self::create_event_subtotal( $pre_tax_line_item, $transaction ); |
|
386 | return $pre_tax_line_item; |
|
387 | } |
|
388 | ||
389 | ||
390 | ||
@@ 398-414 (lines=17) @@ | ||
395 | * @param EE_Transaction $transaction |
|
396 | * @return EE_Line_Item |
|
397 | */ |
|
398 | protected static function create_taxes_subtotal( EE_Line_Item $total_line_item, $transaction = NULL ){ |
|
399 | $tax_line_item = EE_Line_Item::new_instance(array( |
|
400 | 'LIN_code' => 'taxes', |
|
401 | 'LIN_name' => __('Taxes', 'event_espresso'), |
|
402 | 'LIN_type' => EEM_Line_Item::type_tax_sub_total, |
|
403 | 'LIN_order' => 1000,//this should always come last |
|
404 | )); |
|
405 | $tax_line_item = apply_filters( |
|
406 | 'FHEE__EEH_Line_Item__create_taxes_subtotal__tax_line_item', |
|
407 | $tax_line_item |
|
408 | ); |
|
409 | self::set_TXN_ID( $tax_line_item, $transaction ); |
|
410 | $total_line_item->add_child_line_item( $tax_line_item ); |
|
411 | //and lastly, add the actual taxes |
|
412 | self::apply_taxes( $total_line_item ); |
|
413 | return $tax_line_item; |
|
414 | } |
|
415 | ||
416 | ||
417 |