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

@fysc/tax-pricing-engine

v1.1.2

Published

Moteur de calcul de prix avec TVA, remises et taxes spécifiques (déductibles et non déductibles) selon les normes de la DGI.

Readme

Tax Pricing Engine

Moteur de calcul de prix avec TVA, remises et taxes spécifiques (déductibles et non déductibles) selon les normes de la DGI.

Fonctionnalités

  • Calcul à partir d'un prix HT ou TTC
  • TVA configurable (taux en pourcentage)
  • Remises en pourcentage ou en montant fixe
  • Taxe non déductible : s'ajoute à la base imposable et supporte la TVA
  • Taxe déductible : retenue à la source sur le montant net à payer
  • Ligne de taxe spécifique (isSpecificTax) : le prix est déclaré tel quel comme un montant de TVA, sans base HT (ex. groupes L/N du protocole DGI RDC)
  • Arrondi des montants à 2 décimales

Démo interactive

Un playground React est disponible dans examples/ pour évaluer le package en conditions réelles : prix HT/TTC, remises, taxes déductibles et non déductibles, avec recalcul en temps réel via calculateTaxAndPricing (le code buildé dans dist/).

En ligne : https://masshen.github.io/tax-pricing-engine/

En local :

npm install            # dans examples/
npm run dev            # puis ouvre l'URL affichée (Vite)

La démo est automatiquement déployée sur GitHub Pages à chaque push sur main (workflow .github/workflows/deploy-pages.yml).

Installation

npm install @fysc/tax-pricing-engine

Utilisation

import { calculateTaxAndPricing } from '@fysc/tax-pricing-engine';

const result = calculateTaxAndPricing({
  price: 120,
  priceType: 'TTC',
  vatRate: 20,
  discount: { value: 10, type: 'PERCENTAGE' },
  nonDeductibleTax: 5,
  deductibleTax: 2,
});

API

calculateTaxAndPricing(input: TaxCalculationInput): TaxCalculationResult

Entrée (TaxCalculationInput)

| Champ | Type | Description | | --- | --- | --- | | price | number | Prix de départ de l'article | | priceType | 'HT' \| 'TTC' | Indique si le prix est en HT ou TTC | | vatRate | number | Taux de TVA en pourcentage (ex: 20 pour 20%) | | discount? | DiscountOptions | Configuration de la remise (optionnelle) | | nonDeductibleTax? | number \| TaxOptions | Taxe non déductible (augmente la base imposable TVA). number = montant €, TaxOptions = € ou % | | deductibleTax? | number \| TaxOptions | Taxe déductible (retenue à la source sur le net). number = montant €, TaxOptions = € ou % | | isSpecificTax? | boolean | Si true, price est déjà un montant de TVA à déclarer tel quel (ligne de taxe spécifique, ex. groupes L/N DGI) : le calcul HT/TTC/remise/taxes est court-circuité, seul vatAmount = totalTtc = price est renvoyé (le reste à 0) |

DiscountOptions :

  • value : montant de la remise
  • type : 'PERCENTAGE' ou 'AMOUNT'

TaxOptions :

  • value : valeur de la taxe
  • type : 'PERCENTAGE' ou 'AMOUNT'
    • 'AMOUNT' : montant en devise (€)
    • 'PERCENTAGE' : pourcentage de la base de calcul
      • taxe non déductible : % du HT remisé de la ligne
      • taxe déductible : % du total TTC

Sortie (TaxCalculationResult)

| Champ | Description | | --- | --- | | baseHt | Prix HT de base | | discountAmount | Montant de la remise | | discountedHt | HT après remise | | nonDeductibleTax | Taxe non déductible appliquée | | taxableBase | Base imposable (HT remisé + taxe non déductible) | | vatAmount | Montant de la TVA | | totalTtc | Total TTC (base imposable + TVA) | | deductibleTax | Taxe déductible appliquée | | netToPay | Montant net à payer |

Exemples

Article en départ TTC avec remise en pourcentage et taxes

const result = calculateTaxAndPricing({
  price: 120,
  priceType: 'TTC',
  vatRate: 20,
  discount: { value: 10, type: 'PERCENTAGE' },
  nonDeductibleTax: 5,
  deductibleTax: 2,
});
// baseHt: 100, discountAmount: 10, discountedHt: 90
// taxableBase: 95, vatAmount: 19, totalTtc: 114, netToPay: 112

Article en départ HT avec remise en montant fixe

const result = calculateTaxAndPricing({
  price: 500,
  priceType: 'HT',
  vatRate: 20,
  discount: { value: 50, type: 'AMOUNT' },
  deductibleTax: 25,
});
// baseHt: 500, discountedHt: 450, taxableBase: 450
// vatAmount: 90, totalTtc: 540, netToPay: 515

Taxes spécifiques en pourcentage

const result = calculateTaxAndPricing({
  price: 100,
  priceType: 'HT',
  vatRate: 20,
  nonDeductibleTax: { value: 15, type: 'PERCENTAGE' }, // 15% du HT remisé
  deductibleTax: { value: 5, type: 'PERCENTAGE' },     // 5% du TTC
});

Ligne de taxe spécifique (montant de TVA directe, ex. groupe N DGI)

const result = calculateTaxAndPricing({
  price: 480, // 3 x 160, déjà un montant de TVA
  priceType: 'HT', // ignoré
  vatRate: 0, // ignoré
  isSpecificTax: true,
});
// baseHt: 0, vatAmount: 480, totalTtc: 480, netToPay: 480

Formules

  1. baseHt = price si HT, sinon price / (1 + vatRate / 100)
  2. discountAmount = baseHt * (value / 100) (pourcentage) ou value (montant fixe)
  3. discountedHt = baseHt - discountAmount
  4. nonDeductibleTax = discountedHt * (value / 100) (pourcentage) ou value (montant)
  5. taxableBase = discountedHt + nonDeductibleTax
  6. vatAmount = taxableBase * (vatRate / 100)
  7. totalTtc = taxableBase + vatAmount
  8. deductibleTax = totalTtc * (value / 100) (pourcentage) ou value (montant)
  9. netToPay = totalTtc - deductibleTax

Scripts

npm test        # Exécute les tests (vitest)
npm run build   # Build avec tsup (ESM + CJS + types)
npm run test:watch  # Tests en mode watch

Licence

MIT