miniCal
Search…
⌃K

Tax Helper Functions

The helper you can use to create, delete, get and update Tax details.

function add_tax($tax) {.....}

Supported hooks

Filter name: before_add_tax Description: This filter would be executed before add tax into the database in add_tax helper. Usage:
// The filter callback function is based on the filter.
add_filter( ‘before_add_tax’, ‘before_add_tax_callback_fun’, 10, 1 );
function before_add_tax_callback_fun($tax) {
// code
}
Filter name: should_add_tax Description: This filter would be executed before add tax into database in add_tax helper. Usage:
// The filter callback function is based on the filter.
add_filter( ‘should_add_tax’, ‘should_add_tax_callback_fun’, 10, 1 );
function should_add_tax_callback_fun($tax) {
// code
}
hook name: pre.add.tax Description: This hook would be executed before add tax into the database in add_tax helper. Usage:
// The filter callback function is based on the filter.
add_action('pre.add.tax', 'pre_add_tax_callback_fun', 10, 1);
function pre_add_tax_callback_fun($tax) {
// code
}
hook name: post.add.tax Description: This hook would be executed after add tax into the database in add_tax helper. Usage:
// The filter callback function is based on the filter.
add_action('post.add.tax', 'post_add_tax_callback_fun', 10, 1);
function post_add_tax_callback_fun($tax) {
// code
}
Usage
// for use tax helper you need to add this helper on controller or
// you can autoload this helper.
$this->load->helper('includes/tax');
// add a new tax in tax table.
$tax_id = add_tax($tax);
Request Parameters
Parameters in array format includes following attributes:
Param
Type
Required
Default
Description
tax_type
Character
Yes
Null
The tax_type of specific tax.
tax_rate
Decimal Integer
0
the tax_rate for specific tax.
is_percentage
Integer
Yes
1
The is_percentage is conformed tax in percentage or not for specific tax.
is_brackets_active
Integer
Yes
Null
The is_brackets_active if active then create price bracket data for specific tax.
is_tax_inclusive
Integer
0
The is_tax_inclusive for specific tax.
start_range
Integer
Null
The start_range for specific tax price_bracket.
end_range
Integer
Null
The end_range for specific tax price_bracket.
tax_rate_price_bracket
Integer
0
The tax_rate for specific tax price_bracket.
is_percentage_price_bracket
Integer
1
The is_percentage for specific tax price_bracket.
company_id
Integer
Yes
Null
The company_id for specific tax.
Response
Response includes the following attributes:
if data have been added successfully it would return the key of specific tax id.
return $tax_id;
if data does not add it will return null.

function get_tax($tax_type_id) {....}

Supported hooks

Filter name: before_get_tax Description: This filter would be executed before retrieving tax details from database in get_tax helper. Usage:
// The filter callback function is based on the filter.
add_filter( ‘before_get_tax’, ‘before_get_tax_callback_fun’, 10, 1 );
function before_get_tax_callback_fun($tax_type_id) {
// code
}
Filter name: should_get_tax Description: This filter would be executed before retrieving tax details from database in get_tax helper. Usage:
// The filter callback function is based on the filter.
add_filter( ‘should_get_tax’, ‘should_get_tax_callback_fun’, 10, 1 );
function should_get_tax_callback_fun($tax_type_id) {
// code
}
hook name: pre.get.tax Description: This hook would be executed before retrieving tax details from database in get_tax helper. Usage:
// The filter callback function is based on the filter.
add_action('pre.get.tax', 'pre_get_tax_callback_fun', 10, 1);
function pre_get_tax_callback_fun($tax_type_id) {
// code
}
hook name: post.get.tax Description: This hook would be executed after retrieving tax details from database in get_tax helper. Usage:
// The filter callback function is based on the filter.
add_action('post.get.tax', 'post_get_tax_callback_fun', 10, 1);
function post_get_tax_callback_fun($tax_type_id) {
// code
}
Usage
// Retrieves tax data based on a tax_type_id.
$tax_data = get_tax($tax_type_id);
Request Parameters
Param
Type
Required
Default
Description
$tax_type_id
Integer
Yes
Null
The id of the tax corresponds to the tax_type table
Response
// $response array includes following attributes:
// $response['tax_type'] : the tax_type of specific tax.
// $response['tax_rate'] : the tax_rate for specific tax .
// $response['is_percentage'] : the is_percentage for specific tax.
// $response['company_id'] : the company_id for specific tax.
// $response['is_brackets_active'] : the is_brackets_active for specific tax.
// $response['is_tax_inclusive'] : the is_tax_inclusive for specific tax.
// $response['start_range'] : the start_range for specific tax price_bracket.
// $response['end_range'] : the end_range for specific tax price_bracket.
// $response['tax_rate_price_bracket'] : the tax_rate for specific tax price_bracket.
// $response['is_percentage_price_bracket'] : the is_percentage for specific tax price_bracket.
// and many more attributes for table tax and join with tax_price_bracket table.
// Successfully response giving you array of tax data.
Array
(
[tax_type] => gst
[tax_rate] => 12.000
[company_id] => 1
[tax_type_id] => 2
[is_deleted] => 0
[is_percentage] => 1
[is_brackets_active] => 1
[is_tax_inclusive] => 0
[start_range] => 12
[end_range] => 19
[price_tax_rate] => 1
[price_percentage] => 1
)
// if there is no tax data for any tax id provided in input or any error will return null.

function get_taxes($filter) {.....}

Supported hooks
Filter name: before_get_taxes Description: This filter would be executed before retrieving tax details from database in get_taxes helper. Usage:
// The filter callback function is based on the filter.
add_filter( ‘before_get_taxes’, ‘before_get_taxes_callback_fun’, 10, 1 );
function before_get_taxes_callback_fun($filter) {
// code
}
Filter name: should_get_taxes Description: This filter would be executed before retrieving tax details from database in get_taxes helper. Usage:
// The filter callback function is based on the filter.
add_filter( ‘should_get_taxes’, ‘should_get_taxes_callback_fun’, 10, 1 );
function should_get_taxes_callback_fun($filter) {
// code
}
hook name: pre.get.taxes Description: This hook would be executed before retrieving tax details from database in get_taxes helper. Usage:
// The filter callback function is based on the filter.
add_action('pre.get.taxes', 'pre_get_taxes_callback_fun', 10, 1);
function pre_get_taxes_callback_fun($filter) {
// code
}
hook name: post.get.taxes Description: This hook would be executed after retrieving tax details from database in get_taxes helper. Usage:
// The filter callback function is based on the filter.
add_action('post.get.taxes', 'post_get_taxes_callback_fun', 10, 1);
function post_get_taxes_callback_fun($filter) {
// code
}
Usage
// Retrieves tax data based on a filter array.
$tax_data = get_taxes($filter);
Request Parameters
parameter array filter required for tax details.
Param
Type
Required
Default
Description
tax_type
Character
Yes
Null
The tax type for a specific tax table.
company_id
Integer
Yes
Null
The company_id for specific tax.
tax_type_id
Integer
yes
Null
The tax_type_id primary key of tax type table for specific tax.
Response
// $response array includes following attributes:
// $response['tax_type'] : the tax_type of specific tax.
// $response['tax_rate'] : the tax_rate for specific tax .
// $response['is_percentage'] : the is_percentage for specific tax.
// $response['company_id'] : the company_id for specific tax.
// $response['is_brackets_active'] : the is_brackets_active for specific tax.
// $response['is_tax_inclusive'] : the is_tax_inclusive for specific tax.
// $response['start_range'] : the start_range for specific tax price_bracket.
// $response['end_range'] : the end_range for specific tax price_bracket.
// $response['tax_rate_price_bracket'] : the tax_rate for specific tax price_bracket.
// $response['is_percentage_price_bracket'] : the is_percentage for specific tax price_bracket.
// and many more attributes for table tax and join with tax_price_bracket table.
// Successfully response giving you array of tax data.
Array
(
[tax_type] => gst
[tax_rate] => 12.000
[company_id] => 1
[tax_type_id] => 2
[is_deleted] => 0
[is_percentage] => 1
[is_brackets_active] => 1
[is_tax_inclusive] => 0
[start_range] => 12
[end_range] => 19
[price_tax_rate] => 1
[price_percentage] => 1
)
// if there is no tax data for filter provided in input or any error will return null.

function update_tax($tax, $tax_type_id) {....}

Usage
//update tax data based on a update data and tax_type_id.
update_tax($tax, $tax_type_id);
Supported hooks
Filter name: before_update_tax Description: This filter would be executed before update tax into the database in update_tax helper. Usage:
// The filter callback function is based on the filter.
add_filter( ‘before_update_tax’, ‘before_update_tax_callback_fun’, 10, 1 );
function before_update_tax_callback_fun($tax, $tax_type_id) {
// code
}
Filter name: should_update_tax Description: This filter would be executed before update tax into database in update_tax helper. Usage:
// The filter callback function is based on the filter.
add_filter( ‘should_update_tax’, ‘should_update_tax_callback_fun’, 10, 1 );
function should_update_tax_callback_fun($tax, $tax_type_id) {
// code
}
hook name: pre.update.tax Description: This hook would be executed before update tax into the database in update_tax helper. Usage:
// The filter callback function is based on the filter.
add_action('pre.update.tax', 'pre_update_tax_callback_fun', 10, 1);
function pre_update_tax_callback_fun($tax, $tax_type_id) {
// code
}
hook name: post.update.tax Description: This hook would be executed after update tax into the database in update_tax helper. Usage:
// The filter callback function is based on the filter.
add_action('post.update.tax', 'post_update_tax_callback_fun', 10, 1);
function post_update_tax_callback_fun($tax, $tax_type_id) {
// code
}
Request Parameters
Request required tax_type_id and array format data includes following attributes:
Param
Type
Required
Default
Description
tax_type_id
Integer
Yes
Null
The tax type id primary key or tax_type table.
tax_type
Character
Yes
Null
The tax_type of specific tax.
tax_rate
Decimal Integer
0
the tax_rate for specific tax.
is_percentage
Integer
Yes
1
The is_percentage is conformed tax in percentage or not for specific tax.
is_brackets_active
Integer
Yes
Null
The is_brackets_active if active then create price bracket data for specific tax.
is_tax_inclusive
Integer
0
The is_tax_inclusive for specific tax.
company_id
Integer
Yes
Null
The company_id for specific tax.
Response
Response return mixed Either true or null if tax data is updated then true else null.

function delete_tax($tax_type_id) {.....}

Usage
// delete a tax data from the tex_type table. it's a soft delete process only status will change data still existing in the backend database.
delete_tax($tax_type_id);
Request Parameters
Param
Type
Required
Default
Description
$tax_type_id
Integer
Yes
Null
The id of the tax corresponds to the tax type table
Response
Response return mixed Either true or null if tax data is deleted then true
else null.