Poseidonas

payload tax eu

by Poseidonas
Stores & catalogs
v3
>=3.88 <4
MIT

Overview

Summary generated from the README

Works out EU VAT for a Payload shop and writes the rate, taxable base, tax, country and reverse charge status onto each order through a group field and a beforeChange hook. It works with the official ecommerce plugin or any orders collection, uses integer minor units, and has no runtime dependencies. It exposes a quote endpoint and an OSS report endpoint. Requires Payload 3.88 or newer.

Features

  • Built-in standard and reduced rates for the 27 member states, overridable with dated custom rates
  • B2B reverse charge with offline VAT number format check and optional VIES validation that fails open
  • Line or total rounding, with prices that include or exclude VAT, in integer minor units
  • Standalone calculateTax function for checkout use
  • POST quote endpoint and GET OSS report endpoint split into OSS, domestic, reverse charge and outside EU
  • Adds one tax group field to the orders collection with a per-rate breakdown

Use cases

  • Record the VAT applied to each order so past charges can be explained later
  • Prepare quarterly OSS return totals by country and rate from stored orders
  • Apply reverse charge to valid EU business customers and print the required invoice wording

From the author

EU VAT for Payload ecommerce: rates by country, B2B reverse charge, VAT number validation and OSS totals.

Installation

npm i payload-tax-eu

1

Stars

0

Forks

0

Open Issues

2 weeks ago

Last Updated

12

Weekly Downloads

v1.0.1

npm Version

65.5 KB

Unpacked Size

0

Dependencies

GitHub stars

10 since Sep 6

Show data
GitHub stars by day (UTC)
DateStars
Dec 5, 20261
Dec 4, 20261
Dec 3, 20261
Dec 2, 20261
Dec 1, 20261
Nov 30, 20261
Nov 29, 20261
Nov 28, 20261
Nov 27, 20261
Nov 26, 20261
Nov 25, 20261
Nov 24, 20261
Nov 23, 20261
Nov 22, 20261
Nov 21, 20261
Nov 20, 20261
Nov 19, 20261
Nov 18, 20261
Nov 17, 20261
Nov 16, 20261
Nov 15, 20261
Nov 14, 20261
Nov 13, 20261
Nov 12, 20261
Nov 11, 20261
Nov 10, 20261
Nov 9, 20261
Nov 8, 20261
Nov 7, 20261
Nov 6, 20261
Nov 5, 20261
Nov 4, 20261
Nov 3, 20261
Nov 2, 20261
Nov 1, 20261
Oct 31, 20261
Oct 30, 20261
Oct 29, 20261
Oct 28, 20261
Oct 27, 20261
Oct 26, 20261
Oct 25, 20261
Oct 24, 20261
Oct 23, 20261
Oct 22, 20261
Oct 21, 20261
Oct 20, 20261
Oct 19, 20261
Oct 18, 20261
Oct 17, 20261
Oct 16, 20261
Oct 15, 20261
Oct 14, 20261
Oct 13, 20261
Oct 12, 20261
Oct 11, 20261
Oct 10, 20261
Oct 9, 20261
Oct 8, 20261
Oct 7, 20261
Oct 6, 20261
Oct 5, 20261
Oct 4, 20261
Oct 3, 20261
Oct 2, 20261
Oct 1, 20261
Sep 30, 20261
Sep 29, 20261
Sep 28, 20261
Sep 27, 20261
Sep 26, 20261
Sep 25, 20261
Sep 24, 20261
Sep 23, 20261
Sep 22, 20261
Sep 21, 20261
Sep 20, 20261
Sep 19, 20261
Sep 18, 20261
Sep 17, 20261
Sep 16, 20261
Sep 15, 20261
Sep 14, 20261
Sep 13, 20261
Sep 12, 20261
Sep 11, 20261
Sep 10, 20261
Sep 9, 20261
Sep 8, 20261
Sep 7, 20261
Sep 6, 20261
npm weekly downloads

7−15 since Sep 6

Show data
npm weekly downloads by day (UTC)
DateWeekly downloads
Dec 5, 20267
Dec 4, 202611
Dec 3, 202615
Dec 2, 202619
Dec 1, 202622
Nov 30, 202622
Nov 29, 202624
Nov 28, 202632
Nov 27, 202633
Nov 26, 2026191
Nov 25, 2026186
Nov 24, 2026183
Nov 23, 2026182
Nov 22, 2026178
Nov 21, 2026170
Nov 20, 2026165
Nov 19, 20265
Nov 18, 20265
Nov 17, 20265
Nov 16, 20267
Nov 15, 20267
Nov 14, 20267
Nov 13, 20268
Nov 12, 20268
Nov 11, 20268
Nov 10, 20268
Nov 9, 20268
Nov 8, 20269
Nov 7, 202610
Nov 6, 20268
Nov 5, 20268
Nov 4, 20268
Nov 3, 20268
Nov 2, 20267
Nov 1, 20266
Oct 31, 20267
Oct 30, 20267
Oct 29, 20265
Oct 28, 20265
Oct 27, 20266
Oct 26, 20265
Oct 25, 20265
Oct 24, 20264
Oct 23, 20264
Oct 22, 20267
Oct 21, 20267
Oct 20, 20266
Oct 19, 20266
Oct 18, 20266
Oct 17, 20266
Oct 16, 20266
Oct 15, 20265
Oct 14, 20266
Oct 13, 20265
Oct 12, 20265
Oct 11, 20265
Oct 10, 20264
Oct 9, 20264
Oct 8, 20264
Oct 7, 20263
Oct 6, 20264
Oct 5, 20265
Oct 4, 20266
Oct 3, 20266
Oct 2, 20269
Oct 1, 20267
Sep 30, 20268
Sep 29, 20268
Sep 28, 20268
Sep 27, 20267
Sep 26, 202611
Sep 25, 20269
Sep 24, 20269
Sep 23, 20269
Sep 22, 20269
Sep 21, 20268
Sep 20, 20268
Sep 19, 20265
Sep 18, 20264
Sep 17, 20267
Sep 16, 202614
Sep 15, 202614
Sep 14, 202617
Sep 13, 202617
Sep 12, 202617
Sep 11, 202619
Sep 10, 202616
Sep 9, 202610
Sep 8, 202612
Sep 7, 202615
Sep 6, 202622

Each point is npm's rolling 7-day download count.

Health Score

68/100Good

Composite score based on GitHub activity, stars, npm downloads, publish recency, dependency count, and package size.

Badge for your README

Payload Directory health badge
Markdown
[![Payload Directory](https://payloaddirectory.dev/badge/1340410807-root.svg)](https://payloaddirectory.dev/plugins/1340410807-root)
HTML
<a href="https://payloaddirectory.dev/plugins/1340410807-root"><img src="https://payloaddirectory.dev/badge/1340410807-root.svg" alt="Payload Directory"></a>
Updated Nov 17, 2026Created Aug 20, 2026Published Nov 17, 2026

README

payload-tax-eu

npm node license payload

Works out EU VAT for a Payload shop and writes the result onto the order: the rate applied, the taxable base, the VAT, the country and whether reverse charge took over, so that a quarter later you can still say why a customer was charged what they were charged.

  • Works with @payloadcms/plugin-ecommerce and with any collection that holds orders
  • Integer minor units from end to end, so nothing is ever held as a fraction
  • No runtime dependencies. VIES, when you switch it on, uses fetch
  • No admin components, so it survives minor releases

Install

Requires Payload 3.88 or newer and @payloadcms/plugin-ecommerce 3.88 or newer. Verified against Payload 3.88.0 with the official plugin installed.

pnpm add payload-tax-eu
import { taxEuPlugin } from 'payload-tax-eu'

export default buildConfig({
  plugins: [
    taxEuPlugin({
      sellerCountry: 'GR',
      pricesIncludeTax: true,
    }),
  ],
})

sellerCountry has no default and no sensible guess behind it. It is what separates a domestic sale from a cross border one, and without it the package refuses to work rather than pick for you.

Working out what to charge

The plugin records. It does not charge. The amount that reaches the payment provider is decided by your checkout, so that is where the calculation belongs:

import { calculateTax } from 'payload-tax-eu'

const vat = calculateTax(
  {
    country: 'DE',
    lines: [{ amount: 2000 }, { amount: 1500, rateType: 'reduced' }],
  },
  { sellerCountry: 'GR' },
)

// vat.net 3500, vat.tax 485, vat.gross 3985

Pass vatNumber as well and a valid number from another member state turns the same call into a zero rated reverse charge, with vat.reverseChargeNote carrying the wording the invoice has to show.

Every amount is an integer in minor units, the same unit @payloadcms/plugin-ecommerce stores: 2000 is twenty euros.

What was measured

Measured on 19 August 2026 against the published contents of @payloadcms/[email protected].

The official plugin has no tax of any kind. A case insensitive search for tax across the whole of its dist, every file including the twenty translation bundles and the source maps, returns nothing:

SearchFiles matched
tax, case insensitive, whole dist0

The orders collection it creates carries items, shippingAddress, customer, customerEmail, transactions, status, amount and currency. There is no tax field, no tax rate, no VAT number and no place of supply. The survey behind this kit found no third party Payload package covering tax either.

Amounts are already in minor units. From dist/ui/utilities.js:

Math.round(floatValue * Math.pow(10, currency.decimals))

EUR, USD and GBP are all declared with decimals: 2. This package therefore works in whole minor units throughout and never converts to a float, not once, not even to round.

Countries are ISO 3166-1 alpha-2. dist/collections/addresses/defaultCountries.js states it and uses it. The rate table and the place of supply rules use the same codes, with the one exception below.

Greece is two codes. Its ISO code is GR and its VAT prefix is EL. Both are accepted everywhere a country is read, EL normalises to GR, and a Greek VAT number is sent to VIES as EL.

Rounding, measured on this package

Rounding is not a detail here, it is the whole job. Three lines of 333 at 19 per cent:

roundingLine taxOrder tax
'line', the default63, 63, 63189
'total'64, 63, 63190

Both are defensible and both are in use across the EU. What is not defensible is a total that does not equal the sum of its lines, so under 'total' the rounded group tax is shared back out by largest remainder and the lines always add up to it exactly.

Halves round away from zero, in both directions, so that a credit note is the exact mirror of the sale it reverses: 50 at 19 per cent gives 10, and -50 gives -10.

Inclusive and exclusive are not the same number read two ways. 1000 at 24 per cent adds 240 when prices exclude VAT, and contains 194 when they include it. Both are correct; they answer different questions.

Options

OptionDefaultMeaning
amountPath'amount'Dot path to the order total the hook reads
countryPath'shippingAddress.country'Dot path to the customer country on the order
datePath'createdAt'Dot path to the date of supply, which picks the rate version
defaultRateType'standard'Band used by lines that do not name one
disabledfalseStops the hook writing but keeps the fields, so the database keeps its shape
fieldName'tax'Name of the group field holding the breakdown
onUnknownCountry'error''error' refuses, 'zero' applies no tax and marks the result unresolved
ordersSlug'orders'Slug of the orders collection
placeOfSupply'destination''origin' charges your own rate on cross border consumer sales
pricesIncludeTaxfalseWhether the amounts you pass already contain VAT
quoteEndpointtrueMounts POST /api/tax/quote
quoteEndpointAccesseveryoneWho may ask for a quote
rates[]Your own rate entries. They win over the built in table
reportEndpointtrueMounts GET /api/tax/oss-report
reportEndpointAccessroles contains 'admin'Who may read the report
reportPageSize500Orders read per page while building the report
reportStatuses['processing', 'completed']Statuses counted. An empty array counts every status
reverseChargeNote'Reverse charge. VAT to be accounted for by the recipient.'Wording written onto a zero rated order
rounding'line''line' rounds each line, 'total' rounds each rate group once
routePrefix'/tax'Path both endpoints sit under
sellerCountrynoneYour country. Required for any supply inside the EU
useBuiltInRatestrueSet false to use only the rates you supply
vatNumberPath'<fieldName>.vatNumber'Dot path to the customer VAT number on the order
vies.enabledfalseTurns on the online check. This is a network call
vies.endpointthe VIES REST APIURL template, {country} and {number} are replaced
vies.timeoutMs3000Milliseconds before the call is abandoned
vies.useInQuotefalseLets the public quote endpoint call VIES too
vies.fetchglobal fetchReplacement, for a proxy or for tests

A value that cannot be used is replaced by its default rather than being applied. A reportPageSize of 0 becomes 500, an unknown rounding becomes 'line', and a routePrefix of vat/ becomes /vat.

Place of supply

CustomerVAT numberWhat happens
Your own countrynone or anyYour rate. Reverse charge does not apply inside one member state
Another member statenone, or one that fails validationThe customer country rate, and the reason is written to note
Another member statevalid, issued by a state other than yoursZero rated, reverseCharge true, and note carries the invoice wording
Outside the EUanyNo EU VAT, scope is outside-eu
Not givenanyRefused, unless onUnknownCountry is 'zero'

A VAT number is checked for the shape its country uses, offline and instantly. Turning on vies.enabled adds a call to the European Commission's VIES service. That call fails open: a timeout, a network error, a refusal or an answer with no verdict in it all leave the offline result standing. A VIES outage never turns a sale away, and the outcome is recorded on the order so you can see which orders were accepted without confirmation.

Endpoints

POST /api/tax/quote, public by default. Arithmetic on numbers the caller supplied; it reads nothing from the database.

{ "country": "DE", "lines": [{ "amount": 2000, "id": "line-1" }], "vatNumber": "DE123456789" }

Answers with the full calculation. A refusal comes back as { "code": "unknown-country", "message": "..." } with the right status, not as an empty object.

GET /api/tax/oss-report?from=2026-01-01&to=2026-03-31, admins only by default. Totals per country per period, split the way a return needs them:

KeyWhat is in it
ossCross border consumer sales by country, then by rate. The OSS return itself
domesticSales in your own country. These belong in the national return
reverseChargeZero rated business sales. These belong in the recapitulative statement
outsideEuSales outside the EU VAT area
unresolvedOrders whose place of supply was never established, listed by id
totalsTaxable base and VAT across everything counted

The report reads orders through the request it was called on, so it stays inside the transaction that request already opened.

What it adds to your database

One group field on your orders collection. Nothing else, and no collection of its own.

FieldTypeNotes
tax.countrytextCountry whose rate was applied. Indexed
tax.scopeselectdomestic, intra-eu-b2c, intra-eu-b2b, outside-eu, unknown
tax.ratenumberPer cent, when one single rate applied. Null when the order mixes bands
tax.taxableBasenumberMinor units
tax.taxAmountnumberMinor units
tax.reverseChargecheckbox
tax.resolvedcheckboxFalse when the place of supply was never established
tax.pricesIncludeTaxcheckboxHow the amount was read
tax.vatNumbertextThe one field here your checkout writes, the rest are computed
tax.vatNumberCheckselectnone, format, vies-valid, vies-invalid, vies-unavailable
tax.notetextReverse charge wording, or why the result is what it is
tax.calculatedAtdate
tax.breakdownarrayrate, taxableBase, taxAmount per rate

The hook runs beforeChange on create only. It never touches the order total, and it leaves a breakdown alone if your checkout has already written one.

Honest limits

Rates change, and keeping them right is yours. The built in table holds the standard and reduced rates of the twenty seven member states as compiled on 19 August 2026, exported as euVatRates and dated as euVatRatesUpdated. It is a starting point, not an authority, and it is not legal advice. Check it against your tax authority and override what is out of date:

taxEuPlugin({
  sellerCountry: 'GR',
  rates: [
    { country: 'DE', from: '2027-01-01', standard: 20 },
  ],
})

An entry with a from date wins over one without, so adding a future rate does not rewrite the orders you already took. Give a rate a to date and it stops applying after it. Orders are always rated on their own date of supply.

The plugin records, it does not charge. @payloadcms/plugin-ecommerce sends amount to the payment provider and this package never alters it. With pricesIncludeTax: true that is the whole story: the amount is the gross and the breakdown splits it. With pricesIncludeTax: false the amount is the net, and unless your checkout adds calculateTax(...).tax to the figure it sends, the customer will not be charged the VAT the order records. Exclusive pricing is only safe if you do that step.

An order can be saved without a resolved tax. If the country is missing or a rate cannot be found, the hook writes resolved: false with the reason and logs the error, and the order still saves. Losing a sale is worse than losing a label. The report lists these orders by id so that nothing hides: fix them before you file.

calculateTax behaves the other way round. Called directly it throws a TaxError rather than returning zero, because a checkout that quietly charges no VAT is worse than one that stops.

A format check is not a registration check. The offline check knows the shape of a VAT number in each member state, including Northern Ireland's XI. It does not verify checksums and it cannot know whether a number is registered, or to whom. Only VIES knows that, and VIES here fails open by design.

Territory level rules are not applied. Rates are held per country. The Canary Islands, Ceuta and Melilla, Madeira and the Azores, Åland, Büsingen, Campione and the rest of the special territories are not separated out, and postcode level rules do not exist here. If you sell into them, add your own entries and route those orders yourself.

Northern Ireland is recognised, not rated. XI VAT numbers pass the format check because VIES issues them. XI is not in the rate table. Add it yourself if you supply goods there.

The small business threshold is not applied for you. Below the EU wide distance selling threshold a micro business may charge its own rate on cross border consumer sales. Set placeOfSupply: 'origin' when that applies to you. The package will not work out whether it does, and will not warn you when you cross the threshold.

Amounts have a ceiling. Anything above 1,000,000,000,000 minor units is refused rather than risking a loss of precision.

No admin interface. The breakdown is visible on the order and the report is an endpoint. Reading it into a spreadsheet, or filing it, is your part.

License

MIT. Copyright George Vasiliades, https://github.com/Poseidonas

Similar plugins