> For the complete documentation index, see [llms.txt](https://helpcenter.etron.info/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://helpcenter.etron.info/onretail-wiki/sonstiges/ean13-generieren.md).

# EAN13 generieren

EAN13 prüfen, generator, validierung

<img src="https://2354692687-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fs4jXYu4QaEYCte4gphc6%2Fuploads%2FfY042tZpx9Q6xg3a2K6O%2Fimage.png?alt=media&amp;token=6ed70529-89c2-408e-9d66-3c9dfea9a10e" alt="" data-size="original">

### Online Prüfung

Kann zB mittels Website geschehen: <https://www.getnewidentity.com/validate-ean.php>\
Oder Sie verwenden die Javascript Tools aus dem nächsten Abschnitt

### Generieren von EAN 13 Barcodes (und Prüfen)

In Javascript. Das kann über jede Browser Konsole geschehen.\
ZB in Google Chrome via F12 oder das Menu die Entwickler Tools öffnen, dann "Console" anwählen und nachstehend Code hineinkopieren und ENTER.\
Danach können die Funktionen laut Beschreibung aufgerufen werden.

```
/**
    EAN13 Hilfsfunktionen
    (copyright) 2022 ETRON Software

Verwendung:

Liste von EANs generieren, Startwert und Anzahl:
> generateEans(100000000000, 5)
-> ['1000000000009', '1000000000016', '1000000000023', '1000000000030']


Liste von EANs im CSV Format ausgeben. 
Der String kann direkt nach Excel kopiert, bzw in .csv Datei abgespeichert werden
> generateEanCsv(100000000000, 5)


Prüfen eines EAN13:
> isEanOK('1000000000009')
-> True
> isEanOK('1000000000007')
-> False


Einzelne Prüfzahl generieren:
> addCheckDigit(10000000000)
-> '1000000000009'

*/


function addCheckDigit(ean) {
    ean = `${ean}`
    if (ean.length != 12) { 
        throw('Bitte EAN13 ohne Prüfziffer angeben, 12 Stellen erwartet!') 
    }
    let checkDigit = (10 - `${ean}0`.split('').reduce(reduceHelper, 0) % 10) % 10
    return `${ean}${checkDigit}`
}

function isEanOK(ean) {
    ean = `${ean}`
    return  ean.split('').reduce(reduceHelper, 0) % 10 == 0 && 
            ean.length == 13
}

function generateEans(start, count) {
    let eans = []
    for (let i=0; i<count; i++) {
        eans.push(addCheckDigit(start+i))
    }
    return eans
}

function generateEanCsv(start, count) {
    let csv = `"${generateEans(start, count).join('";\n"')}";\n`
    copy(csv)
    console.log(csv)
    console.log("CSV String erstellt, in Zwischenablage kopiert")
    return csv
}

function reduceHelper(p,v,i) {
    return i % 2 == 0 ? p + 1 * v : p + 3 * v
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://helpcenter.etron.info/onretail-wiki/sonstiges/ean13-generieren.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
