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

cry-eracun

v1.0.1

Published

Knjižnica za izdajo e-računov po standardu e-SLOG 2.0

Readme

cry-eracun

Knjižnica za izdelavo e-računov po standardu e-SLOG 2.0 za Slovenijo.

Funkcionalnosti

  • Generiranje XML e-računov v formatu e-SLOG 2.0
  • Podpora za več davčnih stopenj (22%, 9.5%, ...)
  • Popusti na postavkah
  • Validacija XML strukture
  • Avtomatski izračun BIC iz IBAN

Namestitev

bun install cry-eracun

Build

# Namestitev odvisnosti
bun install

# Build knjižnice
bun run build

# Zagon testov
bun test

Uporaba

import { sestaviERacun, validateEslog20 } from "cry-eracun";
import type { PodatkiERacuna, PostavkaERacuna } from "cry-eracun";

// Podatki računa
const racun: PodatkiERacuna = {
  _id: "racun-001",
  stevilka: "2024-0001",
  datum: "2024-01-15",
  postavke: [
    { text: "Storitev A", quantity: 2, netPrice: 100, taxRate: 0.22 },
    { text: "Storitev B", quantity: 1, netPrice: 50, discountPrc: 0.1, taxRate: 0.22 },
    { text: "Knjiga", quantity: 3, netPrice: 25, taxRate: 0.095 },
  ],
  prc: NaN,  // NaN = izračunaj iz postavk
  dav: NaN,
  mpc: NaN,
  valutaDni: 30,
};

// Podatki stranke (kupec)
const stranka = {
  _id: "kupec-1",
  firma: "Podjetje d.o.o.",
  ulica: "Glavna ulica",
  hs: 1,
  ps: 1000,
  posta: "Ljubljana",
  idDdv: "SI12345678",
  maticnaSt: "1234567000",
  TRR: "SI56 1234 5678 9012 345",
};

// Podatki izdajatelja (prodajalec)
const izdajatelj = {
  _id: "prodajalec-1",
  firma: "Moje podjetje d.o.o.",
  ulica: "Poslovna cesta",
  hs: 10,
  ps: 1000,
  posta: "Ljubljana",
  idDdv: "SI87654321",
  maticnaSt: "7654321000",
  TRR: "SI56 9876 5432 1098 765",
};

// Generiranje XML
const xml = sestaviERacun(racun, stranka, izdajatelj, "Mesečna naročnina");

// Validacija strukture
const validacija = validateEslog20(xml);
if (validacija.ok) {
  console.log("E-račun je veljaven");
} else {
  console.error("Napake:", validacija.errors);
}

Tipi

PostavkaERacuna

interface PostavkaERacuna {
  text: string;           // Opis postavke
  quantity: number;       // Količina
  unitOfMeasure?: string; // Merska enota (privzeto "C62" = kos)
  netPrice: number;       // Cena brez DDV in popusta
  discountPrc?: number;   // Popust (0-1, npr. 0.1 = 10%)
  taxRate: number;        // Davčna stopnja (0-1, npr. 0.22 = 22%)
}

PodatkiERacuna

interface PodatkiERacuna {
  _id: string;
  stevilka: string;       // Številka računa
  datum: string;          // Datum (YYYY-MM-DD)
  postavke: PostavkaERacuna[];
  prc: number;            // Neto znesek (NaN = izračunaj)
  mpc: number;            // Bruto znesek (NaN = izračunaj)
  dav: number;            // Znesek DDV (NaN = izračunaj)
  valutaDni: number;      // Rok plačila v dneh
}

Pomožne funkcije

strankaOkZaERacun

Preveri, ali ima stranka dovolj podatkov za izdajo e-računa.

import { strankaOkZaERacun } from "cry-eracun";

const stranka = {
  _id: "kupec-1",
  firma: "Podjetje d.o.o.",
  ulica: "Glavna ulica",
  hs: 1,
  ps: 1000,
  posta: "Ljubljana",
  idDdv: "SI12345678",
  TRR: "SI56 1234 5678 9012 345",
};

if (strankaOkZaERacun(stranka)) {
  // Stranka ima vse potrebne podatke
} else {
  // Manjkajo podatki
}

Preverja:

  • Identifikacija: firma ALI (ime + priimek)
  • Naslov: ulica, hs, ps, posta
  • Za pravne osebe: idDdv ALI maticnaSt
  • TRR: obvezen (BIC se izračuna avtomatsko)

iban2bic

Pretvori slovenski IBAN (TRR) v BIC kodo banke.

import { iban2bic } from "cry-eracun";

iban2bic("SI56 0201 0001 1234 567");  // "LJBASI2X" (NLB)
iban2bic("SI56 3300 0000 0297 296");  // "HAABSI22" (Addiko Bank)
iban2bic("SI56 6100 0001 0541 822");  // "HLONSI22" (Hranilnica LON)
iban2bic("DE89 3704 0044 0532 0130"); // "" (ni slovenski IBAN)

Podprte banke (vir: Banka Slovenije):

  • NLB, OTP Banka, Gorenjska banka, Banka Intesa Sanpaolo
  • Deželna banka Slovenije, UniCredit, Addiko Bank, Banka Sparkasse
  • BKS Banka, SID banka, Hranilnica LON, Delavska hranilnica
  • Primorska hranilnica Vipava, KDD, Paywiser

Specifikacija

Knjižnica implementira standard e-SLOG 2.0 po uradni specifikaciji:

Licenca

CC-BY-NC-ND-4.0 (Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International)

Copyright (c) 2026 Primož Krajnik

  • Dovoljeno: deljenje nespremenjenega materiala za nekomercialne namene
  • Prepovedano: komercialna uporaba, spreminjanje, predelava

Celotno besedilo licence: https://creativecommons.org/licenses/by-nc-nd/4.0/legalcode