Skip to content

Taxation

Overview

No one likes taxes! But we have to deal with them... Lunar provides manual tax rules to implement the correct sales tax for each order. For complex taxation (e.g. US States) we suggest integrating with a service such as TaxJar.

Tax Classes

Tax Classes are assigned to Products and allow us to classify products to certain taxable groups that may have differing tax rates.

php
Lunar\Models\TaxClass
FieldDescription
id
namee.g. Clothing
created_at
updated_at
php
$taxClass = TaxClass::create([
    'name' => 'Clothing',
]);

Tax Zones

These specify a geographic zone for tax rates to be applied. Tax Zones can be based upon countries, states or zip/post codes.

php
Lunar\Models\TaxZone
FieldDescription
id
namee.g. UK
zone_typecountry, states, or postcodes
price_displaytax_inclusive or tax_exclusive
activetrue/false
defaulttrue/false
created_at
updated_at
php
$taxZone = TaxZone::create([
    'name' => 'UK',
    'zone_type' => 'country',
    'price_display' => 'tax_inclusive',
    'active' => true,
    'default' => true,
]);
php
Lunar\Models\TaxZoneCountry
FieldDescription
id
tax_zone_id
country_id
created_at
updated_at
php
$taxZone->countries()->create([
    'country_id' => \Lunar\Models\Country::first()->id,
]);
php
Lunar\Models\TaxZoneState
FieldDescription
id
tax_zone_id
state_id
created_at
updated_at
php
$taxZone->states()->create([
    'state_id' => \Lunar\Models\State::first()->id,
]);
php
Lunar\Models\TaxZonePostcode
FieldDescription
id
tax_zone_id
country_id
postcodewildcard, e.g. 9021*
created_at
updated_at
php
Lunar\Models\TaxZoneCustomerGroup
FieldDescription
id
tax_zone_id
customer_group_id
created_at
updated_at

Tax Rates

Tax Zones have one or many tax rates. E.g. you might have a tax rate for the State and also the City, which would collectively make up the total tax amount.

php
Lunar\Models\TaxRate
FieldDescription
id
tax_zone_id
namee.g. UK
created_at
updated_at
php
Lunar\Models\TaxRateAmount
FieldDescription
id
tax_rate_id
tax_class_id
percentagee.g. 6 for 6%
created_at
updated_at

Settings

  • Shipping and other specific costs are assigned to tax classes in the settings.
  • Calculate tax based upon Shipping or Billing address?
  • Default Tax Zone

Extending

Sometimes the standard tax calculations aren't enough, and you may want to implement your own logic, perhaps connecting to a Tax service such as TaxJar.

Lunar allows you to implement your own tax driver, check the Extending Lunar section for more information.