-
-
Save anhskohbo/15f4a2bceb252d9c9ef53de6aa62de57 to your computer and use it in GitHub Desktop.
India tax rates for AweBooking
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 ); |
Hello anhskohbo,
Have you updated script?
Thank you
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
Copy the code above and put into the
{your-theme}/functions.php