Skip to main content
Lunar provides configurable tax rules for calculating sales tax on orders.

Overview

Lunar provides manual tax rules to implement the correct sales tax for each order. For complex taxation scenarios (e.g. US states), integrating with a service such as TaxJar is recommended.

Tax Classes

Tax Classes are assigned to products and allow classification into taxable groups that may have differing tax rates.
Lunar\Models\TaxClass
FieldTypeDescription
ididPrimary key
namestringe.g. Clothing
defaultbooleanWhether this is the default tax class
created_attimestamp
updated_attimestamp
use Lunar\Models\TaxClass;

$taxClass = TaxClass::create([
    'name' => 'Clothing',
]);

Tax Zones

Tax Zones specify a geographic zone for tax rates to be applied. They can be based on countries, states, or zip/postcodes.
Lunar\Models\TaxZone
FieldTypeDescription
ididPrimary key
namestringe.g. UK
zone_typestringcountry, states, or postcodes
price_displaystringtax_inclusive or tax_exclusive
activebooleanWhether the zone is active
defaultbooleanWhether the zone is the default
created_attimestamp
updated_attimestamp
use Lunar\Models\TaxZone;

$taxZone = TaxZone::create([
    'name' => 'UK',
    'zone_type' => 'country',
    'price_display' => 'tax_inclusive',
    'active' => true,
    'default' => true,
]);

Tax Zone Countries

Lunar\Models\TaxZoneCountry
FieldTypeDescription
ididPrimary key
tax_zone_idforeignId nullable
country_idforeignId nullable
created_attimestamp
updated_attimestamp
$taxZone->countries()->create([
    'country_id' => \Lunar\Models\Country::first()->id,
]);

Tax Zone States

Lunar\Models\TaxZoneState
FieldTypeDescription
ididPrimary key
tax_zone_idforeignId nullable
state_idforeignId nullable
created_attimestamp
updated_attimestamp
$taxZone->states()->create([
    'state_id' => \Lunar\Models\State::first()->id,
]);

Tax Zone Postcodes

Lunar\Models\TaxZonePostcode
FieldTypeDescription
ididPrimary key
tax_zone_idforeignId nullable
country_idforeignId nullable
postcodestringSupports wildcards, e.g. 9021*
created_attimestamp
updated_attimestamp

Tax Zone Customer Groups

Lunar\Models\TaxZoneCustomerGroup
FieldTypeDescription
ididPrimary key
tax_zone_idforeignId nullable
customer_group_idforeignId nullable
created_attimestamp
updated_attimestamp

Tax Rates

Tax Zones have one or many tax rates. For example, a zone might have a tax rate for the state and also the city, which collectively make up the total tax amount.
Lunar\Models\TaxRate
FieldTypeDescription
ididPrimary key
tax_zone_idforeignId nullable
prioritytinyIntegerThe priority order for this rate (default 1)
namestringe.g. UK
created_attimestamp
updated_attimestamp

Tax Rate Amounts

Lunar\Models\TaxRateAmount
FieldTypeDescription
ididPrimary key
tax_class_idforeignId nullable
tax_rate_idforeignId nullable
percentagedecimal(7,3)e.g. 6 for 6%
created_attimestamp
updated_attimestamp

Settings

  • Shipping and other specific costs are assigned to tax classes in the settings.
  • Tax calculation can be based on the shipping or billing address.
  • A default Tax Zone can be configured.

Extending

Sometimes the standard tax calculations are not sufficient, and custom logic may be needed, perhaps connecting to a tax service such as TaxJar. Lunar allows custom tax drivers to be implemented. See the Extending Taxation section for more information.