Version 4.1.19
This commit is contained in:
1 parent
28bd025b35
commit
2bd5025018
2674 files changed
+233518
-77766
No files matched your search
@@ -2,9 +2,9 @@
|
||||
/**
|
||||
* @brief Tax Rate Node
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @package IPS Community Suite
|
||||
* @subpackage Nexus
|
||||
* @since 10 Feb 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
@@ -102,10 +102,11 @@ class _Tax extends \IPS\Node\Model
|
||||
|
||||
$form->addTab( 'tax_rates_tab' );
|
||||
$matrix = new \IPS\Helpers\Form\Matrix;
|
||||
$matrix->squashFields = FALSE;
|
||||
$matrix->columns = array(
|
||||
'tax_rate' => function( $key, $value, $data )
|
||||
{
|
||||
return new \IPS\Helpers\Form\Number( $key, $value, FALSE, array(), NULL, NULL, '%' );
|
||||
return new \IPS\Helpers\Form\Number( $key, $value, FALSE, array( 'decimals' => 2 ), NULL, NULL, '%' );
|
||||
},
|
||||
'tax_locations' => function( $key, $value, $data )
|
||||
{
|
||||
@@ -140,15 +141,18 @@ class _Tax extends \IPS\Node\Model
|
||||
public function formatFormValues( $values )
|
||||
{
|
||||
$rates = array();
|
||||
|
||||
|
||||
if( isset( $values['rates'] ) )
|
||||
{
|
||||
foreach ( $values['rates'] as $rate )
|
||||
{
|
||||
$rates[] = array(
|
||||
'locations' => $rate['tax_locations'],
|
||||
'rate' => $rate['tax_rate']
|
||||
);
|
||||
if ( $rate['tax_locations'] )
|
||||
{
|
||||
$rates[] = array(
|
||||
'locations' => $rate['tax_locations'],
|
||||
'rate' => $rate['tax_rate']
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -159,7 +163,7 @@ class _Tax extends \IPS\Node\Model
|
||||
'rate' => $values['tax_default']
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
$values = array_merge( array( 'rate' => json_encode( $rates ) ), $values );
|
||||
|
||||
unset( $values['tax_default'] );
|
||||
@@ -176,13 +180,25 @@ class _Tax extends \IPS\Node\Model
|
||||
return $values;
|
||||
}
|
||||
|
||||
/**
|
||||
* [Node] Delete
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
\IPS\Db::i()->update( 'nexus_packages', array( 'p_tax' => 0 ), array( "p_tax=?", $this->_id ) );
|
||||
|
||||
parent::delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get rate
|
||||
*
|
||||
* For example, if the rate for the location is 10%, will return 0.1
|
||||
*
|
||||
* @param \IPS\GeoLocation|NULL $billingAddress The billing address
|
||||
* @return float
|
||||
* @return string Result after running through number_format, which is a float represented as a string
|
||||
*/
|
||||
public function rate( \IPS\GeoLocation $billingAddress = NULL )
|
||||
{
|
||||
@@ -197,11 +213,26 @@ class _Tax extends \IPS\Node\Model
|
||||
{
|
||||
if ( $rate['locations'][ $billingAddress->country ] === '*' or in_array( $billingAddress->region, $rate['locations'][ $billingAddress->country ] ) )
|
||||
{
|
||||
return $rate['rate'] / 100;
|
||||
return number_format( ( $rate['rate'] / 100 ), 5, '.', '' );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ( $defaultVal / 100 );
|
||||
|
||||
return number_format( ( $defaultVal / 100 ), 5, '.', '' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get output for API
|
||||
*
|
||||
* @return array
|
||||
* @apiresponse int id ID Number
|
||||
* @apiresponse string name Name
|
||||
*/
|
||||
public function apiOutput()
|
||||
{
|
||||
return array(
|
||||
'id' => $this->id,
|
||||
'name' => $this->_title
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user