diff --git a/src/components/CompanySetupDialog.jsx b/src/components/CompanySetupDialog.jsx index 4bf8bef..a25fecd 100644 --- a/src/components/CompanySetupDialog.jsx +++ b/src/components/CompanySetupDialog.jsx @@ -34,6 +34,7 @@ import TuneIcon from '@mui/icons-material/Tune'; import AutoAwesomeIcon from '@mui/icons-material/AutoAwesome'; import RequestQuoteIcon from '@mui/icons-material/RequestQuote'; import ShoppingCartIcon from '@mui/icons-material/ShoppingCart'; +import AssignmentReturnIcon from '@mui/icons-material/AssignmentReturn'; import BackendError from './BackendError'; import { company } from '../api'; import authAutomat, { bootstrapAuthMe } from '../automats/authAutomat'; @@ -51,13 +52,15 @@ const NUMBER_SCHEMES = [ { type: 'adjustment', label: 'Bestandskorrektur', icon: TuneIcon }, { type: 'quote', label: 'Angebot', icon: RequestQuoteIcon }, { type: 'order', label: 'Bestellung', icon: ShoppingCartIcon }, + { type: 'return', label: 'Rücksendung (Lieferant)', icon: AssignmentReturnIcon }, + { type: 'retoure', label: 'Retoure (Kunde)', icon: AssignmentReturnIcon }, ]; const PRESETS = [ { id: 'standard', label: 'Standard', - hint: 'Klassische Kürzel (ART-, KD-, LS-, KORR-, ANG-, AUF-)', + hint: 'Klassische Kürzel (ART-, KD-, LS-, KORR-, ANG-, AUF-, RTN-, RET-)', values: { sku: { prefix: 'ART-', padding: 6, next: 1 }, entity: { prefix: 'KD-', padding: 6, next: 1001 }, @@ -65,6 +68,8 @@ const PRESETS = [ adjustment: { prefix: 'KORR-', padding: 5, next: 1 }, quote: { prefix: 'ANG-', padding: 6, next: 1 }, order: { prefix: 'AUF-', padding: 6, next: 1 }, + return: { prefix: 'RTN-', padding: 6, next: 1 }, + retoure: { prefix: 'RET-', padding: 6, next: 1 }, }, }, { @@ -78,12 +83,14 @@ const PRESETS = [ adjustment: { prefix: '', padding: 5, next: 90001 }, quote: { prefix: '', padding: 5, next: 40001 }, order: { prefix: '', padding: 5, next: 50001 }, + return: { prefix: 'RTN', padding: 5, next: 1 }, + retoure: { prefix: 'RET', padding: 5, next: 1 }, }, }, { id: 'compact', label: 'Kurzkürzel', - hint: 'Einbuchstabige Präfixe (A-, K-, L-, B-, AG-, AU-)', + hint: 'Einbuchstabige Präfixe (A-, K-, L-, B-, AG-, AU-, RTN-, RET-)', values: { sku: { prefix: 'A-', padding: 5, next: 1 }, entity: { prefix: 'K-', padding: 5, next: 1001 }, @@ -91,12 +98,14 @@ const PRESETS = [ adjustment: { prefix: 'B-', padding: 5, next: 1 }, quote: { prefix: 'AG-', padding: 5, next: 1 }, order: { prefix: 'AU-', padding: 5, next: 1 }, + return: { prefix: 'RTN-', padding: 5, next: 1 }, + retoure: { prefix: 'RET-', padding: 5, next: 1 }, }, }, { id: 'international', label: 'International', - hint: 'Englische Kürzel (SKU-, C-, DEL-, ADJ-, Q-, ORD-)', + hint: 'Englische Kürzel (SKU-, C-, DEL-, ADJ-, Q-, ORD-, RTN-, RET-)', values: { sku: { prefix: 'SKU-', padding: 5, next: 1 }, entity: { prefix: 'C-', padding: 5, next: 1001 }, @@ -104,6 +113,8 @@ const PRESETS = [ adjustment: { prefix: 'ADJ-', padding: 4, next: 1 }, quote: { prefix: 'Q-', padding: 5, next: 1 }, order: { prefix: 'ORD-', padding: 5, next: 1 }, + return: { prefix: 'RTN-', padding: 5, next: 1 }, + retoure: { prefix: 'RET-', padding: 5, next: 1 }, }, }, ]; diff --git a/src/utils/documentNumber.js b/src/utils/documentNumber.js index aa41b46..28324c5 100644 --- a/src/utils/documentNumber.js +++ b/src/utils/documentNumber.js @@ -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 (