This commit is contained in:
seb
2026-10-28 18:33:35 +01:00
parent e45f35e97b
commit 3c51de06c2
2 changed files with 31 additions and 7 deletions

View File

@@ -63,8 +63,10 @@ export function getNextDocumentNumber(kind) {
const prefixStyle = refSeq?.prefix ?? '';
if (kind === 'retoure') {
prefix = 'RET-';
pad = 5;
prefix = prefixStyle.endsWith('-') || !prefixStyle ? 'RET-' : 'RET';
startNum = 1;
} else if (kind === 'return') {
prefix = prefixStyle.endsWith('-') || !prefixStyle ? 'RTN-' : 'RTN';
startNum = 1;
} else if (kind === 'delivery') {
prefix = prefixStyle.startsWith('DEL-') ? 'DEL-' : (prefixStyle.startsWith('L-') ? 'L-' : 'LS-');
@@ -160,7 +162,16 @@ export async function ensureDocumentNumber(kind) {
const seq = numbers.find((r) => r.type === kind);
let prefix = seq?.prefix;
if (prefix == null) {
prefix = kind === 'quote' ? 'ANG-' : (kind === 'order' ? 'AUF-' : (kind === 'retoure' ? 'RET-' : 'LS-'));
prefix =
kind === 'quote'
? 'ANG-'
: kind === 'order'
? 'AUF-'
: kind === 'retoure'
? 'RET-'
: kind === 'return'
? 'RTN-'
: 'LS-';
}
let maxFound = maxKnownNumberByKind.get(kind) ?? 0;
@@ -215,7 +226,9 @@ export function getMaxDocumentNumber(kind = 'quote') {
let prefix = '';
if (kind === 'retoure') {
return `RET-${'9'.repeat(5)}`;
prefix = prefixStyle.endsWith('-') || !prefixStyle ? 'RET-' : 'RET';
} else if (kind === 'return') {
prefix = prefixStyle.endsWith('-') || !prefixStyle ? 'RTN-' : 'RTN';
} else if (kind === 'delivery') {
prefix = prefixStyle.startsWith('DEL-') ? 'DEL-' : (prefixStyle.startsWith('L-') ? 'L-' : 'LS-');
} else if (