total calcs

This commit is contained in:
Mike Jolley 2013-10-24 13:41:42 +01:00
parent 51aba21d76
commit 0d8d95e8e6
6 changed files with 21 additions and 7 deletions

View File

@ -471,7 +471,7 @@ jQuery( function($){
tax = parseFloat( accounting.toFixed( tax, woocommerce_admin_meta_boxes.rounding_precision ) );
// Set Total
$('#_order_total').val( parseFloat( accounting.toFixed( line_totals + tax + shipping - order_discount, woocommerce_admin_meta_boxes.rounding_precision ) ) ).change();
$('#_order_total').val( parseFloat( accounting.toFixed( line_totals + tax + shipping - order_discount, woocommerce_admin_meta_boxes.currency_format_num_decimals ) ) ).change();
}
$('#woocommerce-order-totals').unblock();

File diff suppressed because one or more lines are too long

View File

@ -1134,6 +1134,10 @@ class WC_Cart {
}
// Tax rows - merge the totals we just got
if ( ! $this->round_at_subtotal ) {
$discounted_taxes = array_map( 'woocommerce_round_tax_total', $discounted_taxes );
}
foreach ( array_keys( $this->taxes + $discounted_taxes ) as $key ) {
$this->taxes[ $key ] = ( isset( $discounted_taxes[ $key ] ) ? $discounted_taxes[ $key ] : 0 ) + ( isset( $this->taxes[ $key ] ) ? $this->taxes[ $key ] : 0 );
}
@ -1154,6 +1158,10 @@ class WC_Cart {
$line_total = $tax_result['price_excl_tax'];
// Tax rows - merge the totals we just got
if ( ! $this->round_at_subtotal ) {
$discounted_taxes = array_map( 'woocommerce_round_tax_total', $discounted_taxes );
}
foreach ( array_keys( $this->taxes + $discounted_taxes ) as $key ) {
$this->taxes[ $key ] = ( isset( $discounted_taxes[ $key ] ) ? $discounted_taxes[ $key ] : 0 ) + ( isset( $this->taxes[ $key ] ) ? $this->taxes[ $key ] : 0 );
}

View File

@ -164,7 +164,13 @@ function woocommerce_trim_zeros( $price ) {
*/
function woocommerce_round_tax_total( $tax ) {
$dp = (int) get_option( 'woocommerce_price_num_decimals' );
return round( $tax, $dp, WOOCOMMERCE_TAX_ROUNDING_MODE );
if ( version_compare( phpversion(), '5.3', '<' ) ) {
$tax = round( $tax, $dp );
} else {
$tax = round( $tax, $dp, WOOCOMMERCE_TAX_ROUNDING_MODE );
}
return $tax;
}
/**

View File

@ -1295,8 +1295,8 @@ function woocommerce_calc_line_taxes() {
$item['name'] = $tax_codes[ $key ];
$item['label'] = $tax->get_rate_label( $key );
$item['compound'] = $tax->is_compound( $key ) ? 1 : 0;
$item['tax_amount'] = $tax->round( isset( $taxes[ $key ] ) ? $taxes[ $key ] : 0 );
$item['shipping_tax_amount'] = $tax->round( isset( $shipping_taxes[ $key ] ) ? $shipping_taxes[ $key ] : 0 );
$item['tax_amount'] = woocommerce_format_decimal( woocommerce_round_tax_total( isset( $taxes[ $key ] ) ? $taxes[ $key ] : 0 ), false );
$item['shipping_tax_amount'] = woocommerce_format_decimal( woocommerce_round_tax_total( isset( $shipping_taxes[ $key ] ) ? $shipping_taxes[ $key ] : 0 ), false );
if ( ! $item['label'] )
$item['label'] = $woocommerce->countries->tax_or_vat();

View File

@ -126,7 +126,7 @@ final class WooCommerce {
define( 'WOOCOMMERCE_VERSION', $this->version );
define( 'WOOCOMMERCE_TEMPLATE_PATH', $this->template_path() );
define( 'WOOCOMMERCE_ROUNDING_PRECISION', 4 );
define( 'WOOCOMMERCE_TAX_ROUNDING_MODE', PHP_ROUND_HALF_DOWN );
define( 'WOOCOMMERCE_TAX_ROUNDING_MODE', 2 ); // 2 = PHP_ROUND_HALF_DOWN
if ( ! defined( 'WOOCOMMERCE_DELIMITER' ) )
define( 'WOOCOMMERCE_DELIMITER', '|' );