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.
Lunar\Models\TaxClass
Field | Description |
---|---|
id | |
name | e.g. Clothing |
created_at | |
updated_at |
$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.
Lunar\Models\TaxZone
Field | Description |
---|---|
id | |
name | e.g. UK |
zone_type | country , state , or postcode |
price_display | tax_inclusive or tax_exclusive |
active | true/false |
default | true/false |
created_at | |
updated_at |
$taxZone = TaxZone::create([
'name' => 'UK',
'zone_type' => 'country',
'price_display' => 'tax_inclusive',
'active' => true,
'default' => true,
]);
Lunar\Models\TaxZoneCountry
Field | Description |
---|---|
id | |
tax_zone_id | |
country_id | |
created_at | |
updated_at |
$taxZone->countries()->create([
'country_id' => \Lunar\Models\Country::first()->id,
]);
Lunar\Models\TaxZoneState
Field | Description |
---|---|
id | |
tax_zone_id | |
state_id | |
created_at | |
updated_at |
$taxZone->states()->create([
'state_id' => \Lunar\Models\State::first()->id,
]);
Lunar\Models\TaxZonePostcode
Field | Description |
---|---|
id | |
tax_zone_id | |
country_id | |
postcode | wildcard, e.g. 9021* |
created_at | |
updated_at |
Lunar\Models\TaxZoneCustomerGroup
Field | Description |
---|---|
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.
Lunar\Models\TaxRate
Field | Description |
---|---|
id | |
tax_zone_id | |
name | e.g. UK |
created_at | |
updated_at |
Lunar\Models\TaxRateAmount
Field | Description |
---|---|
id | |
tax_rate_id | |
tax_class_id | |
percentage | e.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.