Charge Helper Functions

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

function add_charge($charge) {.....}

Supported hooks

Filter name: before_add_charge Description: This filter would be executed before add charge into the database in add_charge helper. Usage:

// The filter callback function is based on the filter.

add_filter( ‘before_add_charge’, ‘before_add_charge_callback_fun’, 10, 1 );

function before_add_charge_callback_fun($charge) {
 // code
}

Filter name: should_add_charge Description: This filter would be executed before add charge into database in add_charge helper. Usage:

// The filter callback function is based on the filter.

add_filter( ‘should_add_charge’, ‘should_add_charge_callback_fun’, 10, 1 );

function should_add_charge_callback_fun($charge) {
    // code
}

hook name: pre.add.charge Description: This hook would be executed before add charge into the database in add_charge helper. Usage:

// The filter callback function is based on the filter.

add_action('pre.add.charge', 'pre_add_charge_callback_fun', 10, 1);

function pre_add_charge_callback_fun($charge) {
    // code
}

hook name: post.add.charge Description: This hook would be executed after add charge into the database in add_charge helper. Usage:

// The filter callback function is based on the filter.

add_action('post.add.charge', 'post_add_charge_callback_fun', 10, 1);

function post_add_charge_callback_fun($charge) {
    // code
}

Usage

// for use charge helper you need to add this helper on controller or
// you can autoload this helper.
$this->load->helper('includes/charge');

// add a new charge in charge table.
$charge_id = add_charge($charge);

Request Parameters

Parameters in array format includes following attributes:

Response

Response includes the following attributes:
if data have been added successfully it would return the key of specific charge id.
return $charge_id;
if data does not add it will return null.

function get_charge($charge_id) {....}

Supported hooks

Filter name: before_get_charge Description: This filter would be executed before retrieving charge details from database in get_charge helper. Usage:

// The filter callback function is based on the filter.

add_filter( ‘before_get_charge’, ‘before_get_charge_callback_fun’, 10, 1 );

function before_get_charge_callback_fun($charge_id) {
 // code
}

Filter name: should_get_charge Description: This filter would be executed before retrieving charge details from database in get_charge helper. Usage:

// The filter callback function is based on the filter.

add_filter( ‘should_get_charge’, ‘should_get_charge_callback_fun’, 10, 1 );

function should_get_charge_callback_fun($charge_id) {
    // code
}

hook name: pre.get.charge Description: This hook would be executed before retrieving charge details from database in get_charge helper. Usage:

// The filter callback function is based on the filter.

add_action('pre.get.charge', 'pre_get_charge_callback_fun', 10, 1);

function pre_get_charge_callback_fun($charge_id) {
    // code
}

hook name: post.get.charge Description: This hook would be executed after retrieving charge details from database in get_charge helper. Usage:

// The filter callback function is based on the filter.

add_action('post.get.charge', 'post_get_charge_callback_fun', 10, 1);

function post_get_charge_callback_fun($charge_id) {
    // code
}

Usage

// Retrieves charge data based on a charge_id.
$charge_data = get_charge($charge_id);

Request Parameters

Response

// $response array includes following attributes:
// $response['description'] : the description of specific charge.
// $response['date_time'] : the date_time  for specific charge.
// $response['booking_id'] : the booking_id  for specific charge.
// $response['amount'] : the amount for specific charge.
// $response['charge_type_id'] : the charge_type_id for specific charge.
// $response['selling_date'] : the selling_date  for specific charge.
// $response['is_night_audit_charge'] : the is_night_audit_charge  for specific charge.
// and many more attributes for table charge.

// Successfully response giving you array of charge data.

Array
(
    [charge_id] => 1
    [description] => mobile charger
    [date_time] => 
    [booking_id] => 1
    [amount] => 25.00
    [is_deleted] => 0
    [charge_type_id] => 1
    [selling_date] => 2021-12-10
    [user_id] => 1
    [customer_id] => 1
    [pay_period] => 
    [is_night_audit_charge] => 0
)

// if there is no charge data for any charge id provided in input or any error will return null. 

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

Supported hooks

Filter name: before_get_charges Description: This filter would be executed before retrieving charge details from database in get_charges helper. Usage:

// The filter callback function is based on the filter.

add_filter( ‘before_get_charges’, ‘before_get_charges_callback_fun’, 10, 1 );

function before_get_charges_callback_fun($filter) {
 // code
}

Filter name: should_get_charges Description: This filter would be executed before retrieving charge details from database in get_charges helper. Usage:

// The filter callback function is based on the filter.

add_filter( ‘should_get_charges’, ‘should_get_charges_callback_fun’, 10, 1 );

function should_get_charges_callback_fun($filter) {
    // code
}

hook name: pre.get.charges Description: This hook would be executed before retrieving charge details from database in get_charges helper. Usage:

// The filter callback function is based on the filter.

add_action('pre.get.charges', 'pre_get_charges_callback_fun', 10, 1);

function pre_get_charges_callback_fun($filter) {
    // code
}

hook name: post.get.charges Description: This hook would be executed after retrieving charge details from database in get_charges helper. Usage:

// The filter callback function is based on the filter.

add_action('post.get.charges', 'post_get_charges_callback_fun', 10, 1);

function post_get_charges_callback_fun($filter) {
    // code
}

Usage

// Retrieves charge data based on a filter array.
$charge_data = get_charges($filter);

Request Parameters

parameter array filter required for charge details.

Response

// $response array includes following attributes:
// $data['description'] : the description of specific charge.
// $data['date_time'] : the date_time  for specific charge.
// $data['booking_id'] : the booking_id  for specific charge.
// $data['amount'] : the amount for specific charge.
// $data['charge_type_id'] : the charge_type_id for specific charge.
// $data['selling_date'] : the selling_date  for specific charge .
// $data['is_night_audit_charge'] : the is_night_audit_charge  for specific charge.
// and many more attributes for charge table and join with customer,booking,user_profiles tables.

// Successfully response giving you array of charge data.
Array
(
    [0] => Array
        (
            [charge_id] => 1
            [description] => mobile charger
            [date_time] => 
            [booking_id] => 1
            [amount] => 25.00
            [is_deleted] => 0
            [charge_type_id] => 1
            [selling_date] => 2021-12-10
            [user_id] => 1
            [customer_id] => 1
            [pay_period] => 0
            [is_night_audit_charge] => 0
            [customer_name] => test user
            [address] => 
            [city] => 
            [region] => 
            [country] => 
            [postal_code] => 
            [phone] => 
            [fax] => 
            [email] => test1@gmail.com
            [company_id] => 1
            [customer_notes] => 
            [customer_type] => PERSON
            [cc_number] => 
            [cc_expiry_month] => 
            [cc_expiry_year] => 
            [stripe_customer_id] => 
            [customer_type_id] => 1
            [address2] => 
            [phone2] => 
            [cc_tokenex_token] => 
            [cc_cvc_encrypted] => 
            [id] => 1
            [name] => Room Charge
            [is_room_charge_type] => 1
            [is_default_room_charge_type] => 1
            [is_tax_exempt] => 0
            [current_company_id] => 1
            [first_name] => support
            [last_name] => minical
            [language] => english
            [language_id] => 1
            [rate] => 10
            [adult_count] => 1
            [children_count] => 0
            [state] => 5
            [booking_notes] => 
            [booking_customer_id] => 1
            [booked_by] => 
            [balance] => 140
            [balance_without_forecast] => 140
            [invoice_hash] => xxxxxxxxxxxxxxxxxxxxxxxx
            [use_rate_plan] => 0
            [rate_plan_id] => 
            [color] => 
            [housekeeping_notes] => 
            [guest_review] => 
            [source] => 0
            [is_ota_booking] => 0
            [revenue] => 0
            [add_daily_charge] => 1
            [residual_rate] => 0
            [is_invoice_auto_sent] => 0
            [charge_type_name] => Room Charge
            [folio_id] => 0
            [user_name] => support minical
        )
)

// if there is no charge data for filter provided in input or any error will return null.

function update_charge($charge, $charge_id) {....}

Usage

// update charge data based on charge update data and charge_id.
 update_charge($charge, $charge_id);

Supported hooks

Filter name: before_update_charge Description: This filter would be executed before update charge into the database in update_charge helper. Usage:

// The filter callback function is based on the filter.

add_filter( ‘before_update_charge’, ‘before_update_charge_callback_fun’, 10, 1 );

function before_update_charge_callback_fun($charge, $charge_id) {
 // code
}

Filter name: should_update_charge Description: This filter would be executed before update charge into database in update_charge helper. Usage:

// The filter callback function is based on the filter.

add_filter( ‘should_update_charge’, ‘should_update_charge_callback_fun’, 10, 1 );

function should_update_charge_callback_fun($charge, $charge_id) {
    // code
}

hook name: pre.update.charge Description: This hook would be executed before update charge into the database in update_charge helper. Usage:

// The filter callback function is based on the filter.

add_action('pre.update.charge', 'pre_update_charge_callback_fun', 10, 1);

function pre_update_charge_callback_fun($charge, $charge_id) {
    // code
}

hook name: post.update.charge Description: This hook would be executed after update charge into the database in update_charge helper. Usage:

// The filter callback function is based on the filter.

add_action('post.update.charge', 'post_update_charge_callback_fun', 10, 1);

function post_update_charge_callback_fun($charge, $charge_id) {
    // code
}

Request Parameters

Request required charge_id and array format data includes following attributes:

Response

Response return mixed Either true or null if charge data is updated then true else null.

function delete_charge($charge_id) {.....}

Usage

// delete a charge data from the charge table. it's a soft delete process only status will change data still existing in the backend database.

 delete_charge($charge_id);

Request Parameters

Response

Response return mixed Either true or null if room data is deleted then true 
else null.

Last updated