fix
This commit is contained in:
@@ -43,16 +43,20 @@ function parseLocalDate(dateValue) {
|
||||
return Number.isNaN(d.getTime()) ? null : d;
|
||||
}
|
||||
|
||||
function getLastSentDate(invoice) {
|
||||
function getFirstSentDate(invoice) {
|
||||
const sentDates = Array.isArray(invoice.sent_dates)
|
||||
? invoice.sent_dates.filter(Boolean)
|
||||
: [];
|
||||
|
||||
if (sentDates.length > 0) {
|
||||
return sentDates[sentDates.length - 1];
|
||||
if (sentDates.length === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return null;
|
||||
const sortedDates = sentDates
|
||||
.map(d => String(d).split('T')[0])
|
||||
.sort();
|
||||
|
||||
return sortedDates[0];
|
||||
}
|
||||
|
||||
function getTermDays(invoice) {
|
||||
@@ -79,18 +83,13 @@ function addDays(dateValue, days) {
|
||||
}
|
||||
|
||||
function getEffectiveDueDate(invoice) {
|
||||
const lastSentDate = getLastSentDate(invoice);
|
||||
const firstSentDate = getFirstSentDate(invoice);
|
||||
|
||||
// Nie versendet = kein Reminder/Overdue Text
|
||||
if (!lastSentDate) {
|
||||
if (!firstSentDate) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (invoice.due_date) {
|
||||
return parseLocalDate(invoice.due_date);
|
||||
}
|
||||
|
||||
return addDays(lastSentDate, getTermDays(invoice));
|
||||
return addDays(firstSentDate, getTermDays(invoice));
|
||||
}
|
||||
|
||||
function getOverdueDays(invoice) {
|
||||
|
||||
Reference in New Issue
Block a user