diff --git a/src/app/admin/contract-management/components/contractEditor.tsx b/src/app/admin/contract-management/components/contractEditor.tsx index f8c739e..86493d7 100644 --- a/src/app/admin/contract-management/components/contractEditor.tsx +++ b/src/app/admin/contract-management/components/contractEditor.tsx @@ -24,6 +24,7 @@ export default function ContractEditor({ onSaved, editingTemplateId, onCancelEdi const [type, setType] = useState<'contract' | 'invoice' | 'other'>('contract'); const [contractType, setContractType] = useState<'contract' | 'gdpr' | 'abo'>('contract'); const [userType, setUserType] = useState<'personal' | 'company' | 'both'>('personal'); + const [taxMode, setTaxMode] = useState<'standard' | 'reverse_charge' | 'both'>('both'); const [description, setDescription] = useState(''); const [editingMeta, setEditingMeta] = useState<{ id: string; version: number; state: string } | null>(null); @@ -38,6 +39,7 @@ export default function ContractEditor({ onSaved, editingTemplateId, onCancelEdi setName(''); setHtmlCode(''); setDescription(''); + setTaxMode('both'); setIsPreview(false); setEditingMeta(null); }; @@ -60,6 +62,7 @@ export default function ContractEditor({ onSaved, editingTemplateId, onCancelEdi setType(((tpl.type as any) || 'contract') as 'contract' | 'invoice' | 'other'); setContractType(((tpl.contract_type as any) || 'contract') as 'contract' | 'gdpr' | 'abo'); setUserType(((tpl.user_type as any) || 'both') as 'personal' | 'company' | 'both'); + setTaxMode(((tpl.tax_mode as any) || 'both') as 'standard' | 'reverse_charge' | 'both'); setEditingMeta({ id: editingTemplateId, version: Number(tpl.version || 1), @@ -175,6 +178,7 @@ export default function ContractEditor({ onSaved, editingTemplateId, onCancelEdi contract_type: type === 'contract' ? contractType : null, lang, user_type: userType, + tax_mode: type === 'invoice' ? taxMode : null, descriptionLength: description ? description.length : 0, htmlLength: html.length, }); @@ -193,6 +197,7 @@ export default function ContractEditor({ onSaved, editingTemplateId, onCancelEdi name, type, contract_type: type === 'contract' ? contractType : undefined, + tax_mode: type === 'invoice' ? taxMode : undefined, lang, description: description || undefined, user_type: userType, @@ -210,6 +215,7 @@ export default function ContractEditor({ onSaved, editingTemplateId, onCancelEdi name, type, contract_type: type === 'contract' ? contractType : undefined, + tax_mode: type === 'invoice' ? taxMode : undefined, lang, description: description || undefined, user_type: userType, @@ -237,7 +243,10 @@ export default function ContractEditor({ onSaved, editingTemplateId, onCancelEdi : type === 'invoice' ? 'Invoice' : 'Other'; - setPublishConfirmMessage(`This will deactivate other active ${kind} templates that apply to the same user type and language.`) + const scope = type === 'invoice' + ? 'same user type, tax mode and language' + : 'same user type and language'; + setPublishConfirmMessage(`This will deactivate other active ${kind} templates that apply to the ${scope}.`) setPublishConfirmOpen(true) return } @@ -323,6 +332,18 @@ export default function ContractEditor({ onSaved, editingTemplateId, onCancelEdi )} + {type === 'invoice' && ( + + )}