Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@anhskohbo
Created December 3, 2018 08:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anhskohbo/15f4a2bceb252d9c9ef53de6aa62de57 to your computer and use it in GitHub Desktop.
Save anhskohbo/15f4a2bceb252d9c9ef53de6aa62de57 to your computer and use it in GitHub Desktop.
India tax rates for AweBooking
<?php
/**
* An array of India GST tax rates.
*
* @see https://cleartax.in/s/luxury-tax-in-india
*
* @return array
*/
function abrs_get_india_gst_taxes() {
return [
0 => 0, // No tax.
1000 => 12, // From 1000 - 2499 will attract 12% GST.
2500 => 18, // From 2500 - 7499 will attract 18% GST.
7500 => 28, // From 7500 to above.
];
}
// Force the "per_room" mode for the tax rate model.
add_filter( 'abrs_tax_rate_model', function () {
return 'per_room';
}, 10001 );
add_filter( 'abrs_room_stay_tax_rates', function ( $tax_rates, $room_stay ) {
if ( ! $room_stay->data instanceof \AweBooking\Availability\Room_Rate ) {
return $tax_rates;
}
// Use price average.
$room_price_average = $room_stay->data->get_price( 'rate_average' );
$india_taxes = array_reverse( abrs_get_india_gst_taxes(), true );
// Reset the tax rates.
$tax_rates = [];
foreach ( $india_taxes as $from_amount => $tax_rate ) {
if ( $room_price_average >= $from_amount ) {
$tax_rates[] = [
'id' => -1,
'rate' => $tax_rate,
'priority' => 10,
'compound' => false,
];
break;
}
}
return $tax_rates;
}, 10, 2 );
@anhskohbo
Copy link
Author

anhskohbo commented Dec 3, 2018

Copy the code above and put into the {your-theme}/functions.php

@girish327
Copy link

Hello anhskohbo,
Have you updated script?
Thank you

@anhskohbo
Copy link
Author

Hello @girish327, sorry but we can not calculate the tax by total (room price + service price) right now.
The awebooking calculate the room + tax before calculate the service, so I can't get the service price at this moment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment