feat(BillingManager): add functionality to calculate next payment date by adding one month to the last payment date
Publish Fast Tabler Docker image / build-and-push-fast (push) Successful in 4m46s
Publish Fast Tabler Docker image / build-and-push-fast (push) Successful in 4m46s
This commit is contained in:
@@ -295,6 +295,14 @@ function BillingManager() {
|
||||
return Math.ceil((nextPayment - now) / (1000 * 60 * 60 * 24));
|
||||
};
|
||||
|
||||
// Добавить 1 месяц к дате (для обновления nextPaymentDate после платежа)
|
||||
const addMonthToDate = (dateString) => {
|
||||
if (!dateString) return '';
|
||||
const d = new Date(dateString);
|
||||
d.setMonth(d.getMonth() + 1);
|
||||
return d.toISOString().slice(0, 10);
|
||||
};
|
||||
|
||||
// Форматирование
|
||||
function formatDate(dateString) {
|
||||
if (!dateString) return '—';
|
||||
@@ -459,12 +467,14 @@ function BillingManager() {
|
||||
const payments = [...(s.payments || [])];
|
||||
payments.splice(index, 1);
|
||||
const last = payments.slice().sort((a,b) => new Date(b.date) - new Date(a.date))[0];
|
||||
const nextPaymentDate = addMonthToDate(last?.date);
|
||||
return {
|
||||
...s,
|
||||
payments,
|
||||
lastPaymentDate: last?.date || '',
|
||||
lastPaymentAmount: last?.amount || 0,
|
||||
lastPaymentCurrency: last?.currency || 'USD'
|
||||
lastPaymentCurrency: last?.currency || 'USD',
|
||||
nextPaymentDate: nextPaymentDate || s.nextPaymentDate
|
||||
};
|
||||
}));
|
||||
setShowDeletePaymentModal(false);
|
||||
@@ -1081,7 +1091,8 @@ function BillingManager() {
|
||||
note: paymentDraft.note || ''
|
||||
};
|
||||
const last = payments.slice().sort((a,b) => new Date(b.date) - new Date(a.date))[0];
|
||||
return { ...s, payments, lastPaymentDate: last?.date || '', lastPaymentAmount: last?.amount || 0, lastPaymentCurrency: last?.currency || 'USD' };
|
||||
const nextPaymentDate = addMonthToDate(last?.date);
|
||||
return { ...s, payments, lastPaymentDate: last?.date || '', lastPaymentAmount: last?.amount || 0, lastPaymentCurrency: last?.currency || 'USD', nextPaymentDate: nextPaymentDate || s.nextPaymentDate };
|
||||
}));
|
||||
setEditingPayment(null);
|
||||
} else {
|
||||
@@ -1094,7 +1105,8 @@ function BillingManager() {
|
||||
note: paymentDraft.note || ''
|
||||
}];
|
||||
const last = payments.slice().sort((a,b) => new Date(b.date) - new Date(a.date))[0];
|
||||
return { ...s, payments, lastPaymentDate: last?.date || '', lastPaymentAmount: last?.amount || 0, lastPaymentCurrency: last?.currency || 'USD' };
|
||||
const nextPaymentDate = addMonthToDate(last?.date);
|
||||
return { ...s, payments, lastPaymentDate: last?.date || '', lastPaymentAmount: last?.amount || 0, lastPaymentCurrency: last?.currency || 'USD', nextPaymentDate: nextPaymentDate || s.nextPaymentDate };
|
||||
}));
|
||||
}
|
||||
setShowPaymentModal(false);
|
||||
|
||||
Reference in New Issue
Block a user