This commit is contained in:
2026-08-20 19:22:46 +02:00
parent 647cbbbdd0
commit 686b3da3cf
5 changed files with 67 additions and 24 deletions
+4 -2
View File
@@ -2,13 +2,15 @@ import ExcelJS from 'exceljs';
import PDFDocument from 'pdfkit';
const MONTHS=['Januar','Februar','März','April','Mai','Juni','Juli','August','September','Oktober','November','Dezember'];
const INTERVALS={monthly:{label:'Monatlich',step:1},quarterly:{label:'Vierteljährlich',step:3},semiannual:{label:'Halbjährlich',step:6},yearly:{label:'Jährlich',step:12}};
const INTERVALS={monthly:{label:'Monatlich',step:1},quarterly:{label:'Vierteljährlich',step:3},semiannual:{label:'Halbjährlich',step:6},yearly:{label:'Jährlich',step:12},once:{label:'Einmalig',step:0}};
const money=new Intl.NumberFormat('de-DE',{style:'currency',currency:'EUR'});
function monthKey(year,monthIndex){return `${year}-${String(monthIndex+1).padStart(2,'0')}`;}
function dateMonth(value){return typeof value==='string'&&/^\d{4}-\d{2}-\d{2}$/.test(value)?value.slice(0,7):null;}
function activeInMonth(item,year,monthIndex){const key=monthKey(year,monthIndex);const end=dateMonth(item.endDate);return !end||key<=end;}
function isOnce(item){return (item?.interval||'monthly')==='once';}
function activeInMonth(item,year,monthIndex){if(isOnce(item)){return dateMonth(item.oneTimeDate)===monthKey(year,monthIndex);}const key=monthKey(year,monthIndex);const end=dateMonth(item.endDate);return !end||key<=end;}
function occursInMonth(item,year,monthIndex){
if(isOnce(item))return dateMonth(item.oneTimeDate)===monthKey(year,monthIndex);
if(!activeInMonth(item,year,monthIndex))return false;
const interval=item.interval||'monthly'; if(interval==='monthly')return true;
const dueMonth=Number(item.dueMonth); if(!Number.isInteger(dueMonth)||dueMonth<1||dueMonth>12)return false;