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

@byteinnov/fiscal-invoice

v0.1.0

Published

Calcul des totaux d'une facture fiscale : TVA par groupe de taxation, accises, impôts de sécurité (AIRSI, AIB…), remises et timbre — arithmétique décimale exacte (decimal.js)

Readme

@byteinnov/fiscal-invoice

Calcul des totaux d'une facture fiscale : cascade par ligne (remise → accise → TVA) puis document (impôts de sécurité, timbre).

Port TypeScript de fiscal-invoice-starter (Kotlin), à la virgule près : mêmes règles, mêmes arrondis (HALF_UP, échelle 2), mêmes tests. Arithmétique décimale exacte (decimal.js), aucune dépendance métier — le module ne connaît ni PDV, ni certification, ni paiement.

Installation

npm install @byteinnov/fiscal-invoice

Utilisation

import { calculateInvoice } from '@byteinnov/fiscal-invoice';

const result = calculateInvoice({
  lines: [
    {
      description: 'Ordinateur portable',
      quantity: 2,
      price: '3000',                    // prix unitaire
      priceDefinitionMode: 'TTC',       // ... défini TTC (accise comprise)
      taxGroup: { code: 'B', vatRatePercent: 18 },
      taxSpecific: { amount: '10' },    // accise forfaitaire par unité
      discountPercent: '5',             // remise de ligne
    },
  ],
  discountPercent: '3',                          // remise document
  securityTaxes: [{ code: 'AIB1', ratePercent: 1 }], // surcharge sur la base taxable
  stamp: '100',                                   // timbre
});

result.total.total.ttc.toFixed(2); // total toutes taxes comprises
result.total.securityTaxAmount;    // montant de l'AIB
result.taxBreakdown;               // ventilation par groupe de TVA (taux décroissant)

Les montants d'entrée acceptent number, string ou Decimal ; les montants de sortie sont des Decimal (decimal.js) — utilisez .toFixed(2) ou .toNumber() selon le besoin.

Règles de calcul

Par ligne

| Mode de prix | HT unitaire dérivé | Accise | |---|---|---| | HT | le prix est le HT | valeur forfaitaire, ou % du HT | | TTC (accise en valeur) | prix / (1 + tva) − accise | la valeur forfaitaire | | TTC (accise en %) | prix / ((1 + accise%) × (1 + tva)) | HT × accise% |

Cascade : HT brut → remise de ligne → remise document → HT net. Base TVA = HT net + accise (l'accise n'est pas remisée).

En mode TTC, le TTC prime : le TTC de la ligne vaut exactement quantité × prix saisi (moins les remises converties en TTC) et la TVA est le complément (TTC − base taxable). Sans cela, recomposer base + arrondi(base × taux) dérive d'un centime.

Au niveau document

  • Impôts de sécurité (AIRSI, AIB…) : taux toujours appliqué sur la base taxable (HT net + accise), plusieurs surcharges possibles.
  • TTC document = TTC des biens + impôts de sécurité + timbre.
  • Ventilation TVA triée par taux décroissant.

Développement

npm test        # tests (portés depuis le starter Kotlin)
npm run build   # ESM + CJS + déclarations de types