function commerce_vat_calculate_place_of_supply in Commerce VAT 7
Calculates the Country.
Parameters
$vat_type: The vat type object whose rates should be calculated.
$line_item: The line item to which the vates should be applied.
1 call to commerce_vat_calculate_place_of_supply()
- commerce_vat_rules_place_of_supply in ./
commerce_vat.rules.inc - Rules action: checks for the application of each vat country.
File
- ./
commerce_vat.module, line 236 - Defines VAT rates and Rules integration for configuring vat rules for applicability and display.
Code
function commerce_vat_calculate_place_of_supply($line_item) {
// Prepare an array of rules components to load.
$component_names = array();
// Loop over each vat rate in search of matching components.
foreach (commerce_vat_countries() as $name => $vat_country) {
$country_rates = commerce_vat_country_rates($vat_country['iso2']);
// If the current rate matches the type and specifies a default component...
if (!empty($vat_country['rules_component']) && !empty($country_rates)) {
$component_names[] = $vat_country['rules_component'];
}
}
// Load and invoke the vat country rules components.
if (!empty($component_names)) {
foreach (rules_config_load_multiple($component_names) as $component_name => $component) {
rules_invoke_component($component_name, $line_item);
}
}
}