npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@86d-app/tax

v0.0.30

Published

Tax calculation and management module for 86d commerce platform

Readme

[!WARNING] This project is under active development and is not ready for production use. Please proceed with caution. Use at your own risk.

Tax Module

📚 Documentation: 86d.app/docs/modules/tax

Tax calculation, nexus management, transaction auditing, and compliance reporting for the 86d commerce platform.

Installation

npm install @86d-app/tax

Usage

import tax from "@86d-app/tax";

const module = tax({
  taxShipping: false,
});

Configuration

| Option | Type | Default | Description | |---|---|---|---| | taxShipping | boolean | false | Whether to apply tax to shipping amounts |

Features

  • Multi-jurisdiction tax rates — country, state, city, and postal code specificity with automatic best-match scoring
  • Tax categories — assign products to categories with different rates (e.g., clothing, food, digital)
  • Customer exemptions — full or category-specific exemptions with optional expiration dates and tax ID/VAT storage
  • Compound rate stacking — priority-based rate groups with compound and additive rate application
  • Tax-inclusive pricing — extract tax from VAT/GST-inclusive prices instead of adding on top
  • Nexus management — track physical, economic, and voluntary tax obligations by jurisdiction; tax only collected where nexus exists
  • Transaction audit log — immutable record of every tax calculation for compliance and reporting
  • Compliance reporting — aggregate tax collected by jurisdiction with date range filters

Store Endpoints

| Method | Path | Description | |---|---|---| | POST | /tax/calculate | Calculate tax for line items at an address | | GET | /tax/rates?country=...&state=... | Get applicable tax rates for a jurisdiction |

Admin Endpoints

Tax Rates

| Method | Path | Description | |---|---|---| | GET | /admin/tax/rates | List all tax rates (filterable by country, state, enabled) | | POST | /admin/tax/rates/create | Create a new tax rate | | GET | /admin/tax/rates/:id | Get a tax rate by ID | | POST | /admin/tax/rates/:id/update | Update a tax rate | | POST | /admin/tax/rates/:id/delete | Delete a tax rate |

Tax Categories

| Method | Path | Description | |---|---|---| | GET | /admin/tax/categories | List tax categories | | POST | /admin/tax/categories/create | Create a tax category | | POST | /admin/tax/categories/:id/delete | Delete a tax category |

Tax Exemptions

| Method | Path | Description | |---|---|---| | GET | /admin/tax/exemptions | List tax exemptions for a customer | | POST | /admin/tax/exemptions/create | Create a tax exemption | | POST | /admin/tax/exemptions/:id/delete | Delete a tax exemption |

Nexus Management

| Method | Path | Description | |---|---|---| | GET | /admin/tax/nexus | List nexus entries (filterable by country, enabled) | | POST | /admin/tax/nexus/create | Register nexus in a jurisdiction | | POST | /admin/tax/nexus/:id/delete | Remove a nexus entry |

Transaction Audit & Reporting

| Method | Path | Description | |---|---|---| | GET | /admin/tax/transactions | List tax transactions (filterable by country, state, date range) | | POST | /admin/tax/transactions/:id/link | Link a transaction to an order | | GET | /admin/tax/report | Get aggregated tax report by jurisdiction |

Controller API

interface TaxController {
  // Tax Rates
  createRate(params: CreateTaxRateParams): Promise<TaxRate>;
  getRate(id: string): Promise<TaxRate | null>;
  listRates(params?: { country?; state?; enabled?; take?; skip? }): Promise<TaxRate[]>;
  updateRate(id: string, params: UpdateTaxRateParams): Promise<TaxRate | null>;
  deleteRate(id: string): Promise<boolean>;

  // Tax Categories
  createCategory(params: { name: string; description?: string }): Promise<TaxCategory>;
  getCategory(id: string): Promise<TaxCategory | null>;
  listCategories(): Promise<TaxCategory[]>;
  deleteCategory(id: string): Promise<boolean>;

  // Tax Exemptions
  createExemption(params: CreateTaxExemptionParams): Promise<TaxExemption>;
  getExemption(id: string): Promise<TaxExemption | null>;
  listExemptions(customerId: string): Promise<TaxExemption[]>;
  deleteExemption(id: string): Promise<boolean>;

  // Tax Calculation
  calculate(params: {
    address: TaxAddress;
    lineItems: TaxLineItem[];
    shippingAmount?: number;
    customerId?: string;
  }): Promise<TaxCalculation>;
  getRatesForAddress(address: TaxAddress): Promise<TaxRate[]>;

  // Nexus Management
  createNexus(params: CreateTaxNexusParams): Promise<TaxNexus>;
  getNexus(id: string): Promise<TaxNexus | null>;
  listNexus(params?: { country?; enabled? }): Promise<TaxNexus[]>;
  deleteNexus(id: string): Promise<boolean>;
  hasNexus(address: TaxAddress): Promise<boolean>;

  // Transaction Logging
  logTransaction(params: { orderId?; customerId?; address; calculation; subtotal; shippingAmount }): Promise<TaxTransaction>;
  listTransactions(params?: TaxReportParams): Promise<TaxTransaction[]>;
  linkTransactionToOrder(transactionId: string, orderId: string): Promise<TaxTransaction | null>;

  // Reporting
  getReport(params?: TaxReportParams): Promise<TaxReportSummary[]>;
}

Types

type TaxRateType = "percentage" | "fixed";
type TaxExemptionType = "full" | "category";
type TaxNexusType = "physical" | "economic" | "voluntary";

interface TaxAddress {
  country: string;
  state: string;
  city?: string;
  postalCode?: string;
}

interface TaxCalculation {
  totalTax: number;
  shippingTax: number;
  lines: TaxLineResult[];
  effectiveRate: number;
  inclusive: boolean;
  jurisdiction: { country: string; state: string; city: string };
}

interface TaxLineResult {
  productId: string;
  taxableAmount: number;
  taxAmount: number;
  rate: number;
  rateNames: string[];
}

interface TaxNexus {
  id: string;
  country: string;
  state: string;
  type: TaxNexusType;
  enabled: boolean;
  notes?: string;
  createdAt: Date;
}

interface TaxTransaction {
  id: string;
  orderId?: string;
  customerId?: string;
  country: string;
  state: string;
  city?: string;
  postalCode?: string;
  subtotal: number;
  shippingAmount: number;
  totalTax: number;
  shippingTax: number;
  effectiveRate: number;
  inclusive: boolean;
  exempt: boolean;
  lineDetails: TaxLineResult[];
  rateNames: string[];
  createdAt: Date;
}

interface TaxReportSummary {
  jurisdiction: { country: string; state: string };
  totalTax: number;
  totalShippingTax: number;
  totalSubtotal: number;
  transactionCount: number;
  effectiveRate: number;
}

Store Components

TaxEstimate

Displays applicable tax rates for a given address. Useful on product pages or cart summary.

| Prop | Type | Description | |------|------|-------------| | country | string | Country code | | state | string | State/region | | city | string | Optional city | | postalCode | string | Optional postal code |

<TaxEstimate country="US" state="CA" />

TaxBreakdown

Displays a detailed tax breakdown for a completed calculation. Used in checkout summary and order receipts.

| Prop | Type | Description | |------|------|-------------| | calculation | TaxCalculation | Tax calculation result |

<TaxBreakdown calculation={taxCalculation} />

Notes

  • Jurisdiction matching uses a scoring system: country=1, +state=10, +city=100, +postal=1000. Most specific match wins.
  • Tax-inclusive pricing extracts tax from the price (tax = price - price/(1+rate)) — used for VAT/GST regions.
  • When nexus records exist, the calculation engine only applies tax in jurisdictions where the store has nexus. When no nexus records exist, enforcement is off.
  • Transaction logging creates an immutable audit trail. Transactions can be linked to orders after checkout.
  • Reports aggregate by country + state, sorted by highest tax collected.