Skip to content

Commit

Permalink
Add ASN format samples
Browse files Browse the repository at this point in the history
  • Loading branch information
pklaschka committed Sep 9, 2024
1 parent 50273b6 commit bbc6d9b
Show file tree
Hide file tree
Showing 3 changed files with 262 additions and 0 deletions.
180 changes: 180 additions & 0 deletions ASN_FORAMT_EXAMPLES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
<!-- deno-fmt-ignore-file -->
<!-- This file is generated by scripts/format-examples.ts -->

# ASN Format Examples

[Back to README](./README.md)


---

## Range 3

Configuration (Environment Variables):

```env
ASN_PREFIX=ASN
ASN_NAMESPACE_RANGE=3
ASN_ENABLE_NAMESPACE_EXTENSION=false
```

Format Description:

```text
Configured ASN Format:
ASN - 1 - 001
(1) - (2) - (3)
(1) Prefix specified in configuration (ASN).
(2) Numeric Namespace, whereas
- 1-2 is reserved for automatic generation, and
- 3-9 is reserved for user defined namespaces.
The user defined namespace can be used for pre-printed ASN barcodes and the like.
(3) Counter, starting from 001, incrementing with each new ASN in the namespace.
After 999, another digit is added.
```


## Range 3 with ASN_ENABLE_NAMESPACE_EXTENSION

Configuration (Environment Variables):

```env
ASN_PREFIX=ASN
ASN_NAMESPACE_RANGE=3
ASN_ENABLE_NAMESPACE_EXTENSION=true
```

Format Description:

```text
Configured ASN Format:
ASN - 1 - 001
(1) - (2) - (3)
(1) Prefix specified in configuration (ASN).
(2) Numeric Namespace, whereas
- 1-2 is reserved for automatic generation, and
- 3-8,
- 90-98,
- 990-998,
- 9990-9998, etc., are reserved for user defined namespaces.
The user defined namespace can be used for pre-printed ASN barcodes and the like.
(3) Counter, starting from 001, incrementing with each new ASN in the namespace.
After 999, another digit is added.
```


## Range 30

Configuration (Environment Variables):

```env
ASN_PREFIX=ASN
ASN_NAMESPACE_RANGE=30
ASN_ENABLE_NAMESPACE_EXTENSION=false
```

Format Description:

```text
Configured ASN Format:
ASN - 10 - 001
(1) - (2) - (3)
(1) Prefix specified in configuration (ASN).
(2) Numeric Namespace, whereas
- 10-29 is reserved for automatic generation, and
- 30-99 is reserved for user defined namespaces.
The user defined namespace can be used for pre-printed ASN barcodes and the like.
(3) Counter, starting from 001, incrementing with each new ASN in the namespace.
After 999, another digit is added.
```


## Range 30 with ASN_ENABLE_NAMESPACE_EXTENSION

Configuration (Environment Variables):

```env
ASN_PREFIX=WBD
ASN_NAMESPACE_RANGE=30
ASN_ENABLE_NAMESPACE_EXTENSION=true
```

Format Description:

```text
Configured ASN Format:
WBD - 10 - 001
(1) - (2) - (3)
(1) Prefix specified in configuration (WBD).
(2) Numeric Namespace, whereas
- 10-29 is reserved for automatic generation, and
- 30-89,
- 900-989,
- 9900-9989,
- 99900-99989, etc., are reserved for user defined namespaces.
The user defined namespace can be used for pre-printed ASN barcodes and the like.
(3) Counter, starting from 001, incrementing with each new ASN in the namespace.
After 999, another digit is added.
```


## Range 300

Configuration (Environment Variables):

```env
ASN_PREFIX=WBD
ASN_NAMESPACE_RANGE=300
ASN_ENABLE_NAMESPACE_EXTENSION=false
```

Format Description:

```text
Configured ASN Format:
WBD - 100 - 001
(1) - (2) - (3)
(1) Prefix specified in configuration (WBD).
(2) Numeric Namespace, whereas
- 100-299 is reserved for automatic generation, and
- 300-999 is reserved for user defined namespaces.
The user defined namespace can be used for pre-printed ASN barcodes and the like.
(3) Counter, starting from 001, incrementing with each new ASN in the namespace.
After 999, another digit is added.
```


## Range 300 with ASN_ENABLE_NAMESPACE_EXTENSION

Configuration (Environment Variables):

```env
ASN_PREFIX=WBD
ASN_NAMESPACE_RANGE=300
ASN_ENABLE_NAMESPACE_EXTENSION=true
```

Format Description:

```text
Configured ASN Format:
WBD - 100 - 001
(1) - (2) - (3)
(1) Prefix specified in configuration (WBD).
(2) Numeric Namespace, whereas
- 100-299 is reserved for automatic generation, and
- 300-899,
- 9000-9899,
- 99000-99899,
- 999000-999899, etc., are reserved for user defined namespaces.
The user defined namespace can be used for pre-printed ASN barcodes and the like.
(3) Counter, starting from 001, incrementing with each new ASN in the namespace.
After 999, another digit is added.
```

4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ Paperless-NGX based document management system at WüSpace e. V.

## Concept / ASN Format

> [!NOTE]
> The exact format of the ASN is configurable through environment variables.
> See [ASN_FORMAT_EXAMPLES.md](./ASN_FORAMT_EXAMPLES.md) for a list of examples with different configurations.
```text
WUE - 100 - 001
(1) - (2) - (3)
Expand Down
78 changes: 78 additions & 0 deletions scripts/format-examples.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
#!/usr/bin/env -S deno run --allow-read --allow-write --allow-env --env
import { resolve } from "node:path";
import { getFormatDescription } from "$common/mod.ts";

const FILE_PATH = resolve(
import.meta.dirname ?? "scripts",
"..",
"ASN_FORAMT_EXAMPLES.md",
);

const EXAMPLES: [string, number, boolean][] = [
["ASN", 3, false],
["ASN", 3, true],
["ASN", 30, false],
["WBD", 30, true],
["WBD", 300, false],
["WBD", 300, true],
];

const md = (
prefix: string,
range: number,
enableExtension: boolean,
output: string,
) => `
## Range ${range} ${
enableExtension ? "with ASN_ENABLE_NAMESPACE_EXTENSION" : ""
}
Configuration (Environment Variables):
\`\`\`env
ASN_PREFIX=${prefix}
ASN_NAMESPACE_RANGE=${range}
ASN_ENABLE_NAMESPACE_EXTENSION=${enableExtension}
\`\`\`
Format Description:
\`\`\`text
${output}
\`\`\`
`;

let content = `<!-- deno-fmt-ignore-file -->
<!-- This file is generated by scripts/format-examples.ts -->
# ASN Format Examples
[Back to README](./README.md)
---
`;

for (const [prefix, range, enableExtension] of EXAMPLES) {
content += md(
prefix,
range,
enableExtension,
getFormatDescription({
ASN_PREFIX: prefix,
ASN_NAMESPACE_RANGE: range,
ASN_ENABLE_NAMESPACE_EXTENSION: enableExtension,
ADDITIONAL_MANAGED_NAMESPACES: [],
PORT: 8080,
ASN_BARCODE_TYPE: "CODE_128",
ASN_LOOKUP_INCLUDE_PREFIX: false,
DATA_DIR: "",
DB_FILE_NAME: "",
}),
);
}

await Deno.writeTextFile(FILE_PATH, content);

console.log(`Generated ${FILE_PATH}`);

0 comments on commit bbc6d9b

Please sign in to comment.