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

@prodestic/fne-sdk-js

v1.0.1

Published

SDK JavaScript/TypeScript pour l'API FNE (Facture Normalisée Électronique) de la DGI Côte d'Ivoire

Readme

FNE SDK JavaScript/TypeScript

SDK non-officiel pour l'intégration avec l'API FNE (Facture Normalisée Électronique) de la DGI Côte d'Ivoire.

Installation

npm install @prodestic/fne-sdk-js

Prérequis

  • Node.js 18+
  • Une clé API FNE (obtenue auprès de la DGI après validation)

Utilisation rapide

import { FneClient, Invoice, InvoiceItem, Constants } from '@prodestic/fne-sdk-js';

// Initialiser le client en mode test
const client = FneClient.test('votre_cle_api');

// Créer une facture B2C
const invoice = new Invoice({
  invoiceType: Constants.INVOICE_TYPE_SALE,
  paymentMethod: Constants.PAYMENT_CASH,
  template: Constants.TEMPLATE_B2C,
  pointOfSale: 'Caisse 1',
  establishment: 'Magasin Principal',
  clientCompanyName: 'Jean Dupont',
  clientPhone: '0709123456',
  clientEmail: '[email protected]'
});

// Ajouter des articles
invoice.addItem(new InvoiceItem({
  description: 'Laptop HP ProBook',
  quantity: 1,
  amount: 650000,
  taxes: [Constants.TAX_TVA]
}));

// Signer la facture
try {
  const response = await client.invoices().signInvoice(invoice);

  console.log('Référence:', response.getReference());
  console.log('NCC:', response.getNcc());
  console.log('QR Code URL:', response.getQrCodeUrl());
  console.log('Solde stickers:', response.getBalanceSticker());
} catch (error) {
  console.error('Erreur:', error.message);
}

Templates de facture

| Template | Description | Champs requis | |----------|-------------|---------------| | B2C | Business to Consumer | Champs de base | | B2B | Business to Business | + clientNcc | | B2F | Business to Foreign (Export) | + foreignCurrency, foreignCurrencyRate | | B2G | Business to Government | Champs de base |

Types de taxes

| Constante | Taux | Description | |-----------|------|-------------| | TAX_TVA | 18% | TVA standard | | TAX_TVAB | 9% | TVA réduite | | TAX_TVAC | 0% | Exonération conventionnelle | | TAX_TVAD | 0% | Exonération légale |

Méthodes de paiement

  • PAYMENT_CASH - Espèces
  • PAYMENT_CARD - Carte bancaire
  • PAYMENT_CHECK - Chèque
  • PAYMENT_MOBILE_MONEY - Mobile Money
  • PAYMENT_TRANSFER - Virement
  • PAYMENT_DEFERRED - Paiement différé

Exemples

Facture B2B (Business to Business)

const invoice = new Invoice({
  invoiceType: Constants.INVOICE_TYPE_SALE,
  paymentMethod: Constants.PAYMENT_TRANSFER,
  template: Constants.TEMPLATE_B2B,
  pointOfSale: 'Caisse 1',
  establishment: 'Siège',
  clientCompanyName: 'Entreprise ABC',
  clientPhone: '0709123456',
  clientEmail: '[email protected]',
  clientNcc: '9500015F' // NCC obligatoire pour B2B
});

invoice.addItem(new InvoiceItem({
  description: 'Prestation de service',
  quantity: 1,
  amount: 1000000,
  taxes: [Constants.TAX_TVA]
}));

Facture B2F (Export)

const invoice = new Invoice({
  invoiceType: Constants.INVOICE_TYPE_SALE,
  paymentMethod: Constants.PAYMENT_TRANSFER,
  template: Constants.TEMPLATE_B2F,
  pointOfSale: 'Caisse 1',
  establishment: 'Export',
  clientCompanyName: 'Foreign Company Ltd',
  clientPhone: '0709123456',
  clientEmail: '[email protected]',
  foreignCurrency: Constants.CURRENCY_EUR,
  foreignCurrencyRate: 655.957
});

invoice.addItem(new InvoiceItem({
  description: 'Produit export',
  quantity: 100,
  amount: 5000,
  taxes: [Constants.TAX_TVAC] // Exonéré pour export
}));

Facture d'achat (agricole)

const purchaseInvoice = client.purchases().createPurchaseInvoice(
  'Point de collecte',
  'Coopérative',
  'Producteur Konan',
  '0709123456',
  '[email protected]',
  Constants.PAYMENT_MOBILE_MONEY
);

purchaseInvoice.addItem(
  client.purchases().createPurchaseItem(
    'Cacao grade A',
    1000,
    1500,
    'kg'
  )
);

const response = await client.purchases().signPurchaseInvoice(purchaseInvoice);

Avoir / Remboursement

const refundRequest = client.refunds().createRefundRequest();
refundRequest.addItem('item-uuid-1', 5); // Rembourser 5 unités
refundRequest.addItem('item-uuid-2', 10);

const response = await client.refunds().createRefund(
  'original-invoice-id',
  refundRequest
);

Gestion des erreurs

import {
  ValidationError,
  ApiError,
  AuthenticationError,
  NetworkError
} from '@prodestic/fne-sdk-js';

try {
  const response = await client.invoices().signInvoice(invoice);
} catch (error) {
  if (error instanceof ValidationError) {
    console.error('Erreurs de validation:', error.getErrors());
    // { clientEmail: "L'adresse email n'est pas valide", ... }
  } else if (error instanceof AuthenticationError) {
    console.error('Erreur d\'authentification:', error.message);
  } else if (error instanceof ApiError) {
    console.error('Erreur API:', error.statusCode, error.message);
  } else if (error instanceof NetworkError) {
    console.error('Erreur réseau:', error.message);
  }
}

Utilitaires

import {
  calculateTTC,
  calculateVAT,
  formatAmount,
  generateQrCodeBase64,
  isValidNcc
} from '@prodestic/fne-sdk-js';

// Calculs TVA
const ttc = calculateTTC(100000, 18); // 118000
const vat = calculateVAT(100000, 18); // 18000

// Formatage
const formatted = formatAmount(1250000); // "1 250 000 FCFA"

// Validation
const isValid = isValidNcc('9500015F'); // true

// QR Code
const qrBase64 = await generateQrCodeBase64(response.getQrCodeUrl());

Configuration

Mode Test vs Production

// Mode test (environnement de test DGI)
const testClient = FneClient.test('votre_cle_api');

// Mode production
const prodClient = FneClient.production(
  'votre_cle_api',
  'https://url-production-dgi.ci/ws'
);

// Basculer entre les modes
testClient.enableProductionMode('https://url-production.ci/ws');
prodClient.enableTestMode();

Options avancées

Le SDK inclut automatiquement :

  • Retry automatique (3 tentatives avec backoff exponentiel)
  • Timeout de 30 secondes
  • Gestion des erreurs réseau

API Reference

FneClient

| Méthode | Description | |---------|-------------| | FneClient.test(apiKey) | Créer un client en mode test | | FneClient.production(apiKey, baseUrl) | Créer un client en mode production | | invoices() | Accéder au service de facturation | | refunds() | Accéder au service d'avoirs | | purchases() | Accéder au service d'achats |

Invoice

| Méthode | Description | |---------|-------------| | addItem(item) | Ajouter un article | | setClientNcc(ncc) | Définir le NCC client (B2B) | | setForeignCurrency(currency, rate) | Définir la devise étrangère (B2F) | | setDiscount(percent) | Définir la remise globale | | addCustomTax(name, amount) | Ajouter une taxe personnalisée |

ApiResponse

| Méthode | Description | |---------|-------------| | getReference() | Référence de la facture | | getNcc() | Numéro de compte contribuable | | getQrCodeUrl() | URL du QR code de vérification | | getBalanceSticker() | Solde de stickers restant | | hasWarning() | Alerte solde faible |

Support

Licence

MIT License - voir LICENSE


Note: Ce SDK est non-officiel et n'est pas affilié à la DGI Côte d'Ivoire. Pour obtenir une clé API, vous devez vous inscrire auprès de la DGI.