removed unneccesary files
This commit is contained in:
@@ -297,6 +297,7 @@ async function getInputs(
|
||||
currentFundedCents: true,
|
||||
dueOn: true,
|
||||
priority: true,
|
||||
fundingMode: true,
|
||||
needsFundingThisPeriod: true,
|
||||
paymentSchedule: true,
|
||||
autoPayEnabled: true,
|
||||
@@ -328,7 +329,8 @@ export function buildPlanStates(
|
||||
userIncomeType?: string,
|
||||
isScheduledIncome?: boolean
|
||||
): PlanState[] {
|
||||
const timezone = config.timezone;
|
||||
const timezone = config.timezone ?? "UTC";
|
||||
const firstIncomeDate = config.firstIncomeDate ?? null;
|
||||
const freqDays = frequencyDays[config.incomeFrequency];
|
||||
|
||||
// Only handle regular income frequencies
|
||||
@@ -342,7 +344,8 @@ export function buildPlanStates(
|
||||
const remainingCents = Math.max(0, total - funded);
|
||||
const hasPaymentSchedule = p.paymentSchedule !== null && p.paymentSchedule !== undefined;
|
||||
const needsFundingThisPeriod = p.needsFundingThisPeriod ?? true;
|
||||
const autoFundEnabled = !!p.autoPayEnabled;
|
||||
const autoFundEnabled =
|
||||
!p.fundingMode || String(p.fundingMode).toLowerCase() !== "manual";
|
||||
|
||||
// Calculate preliminary crisis status to determine if we should override funding restrictions
|
||||
// Use timezone-aware date comparison
|
||||
@@ -357,14 +360,14 @@ export function buildPlanStates(
|
||||
let isPrelimCrisis = false;
|
||||
let dueBeforeNextPayday = false;
|
||||
let daysUntilPayday = 0;
|
||||
if (isPaymentPlanUser && config.firstIncomeDate) {
|
||||
const nextPayday = calculateNextPayday(config.firstIncomeDate, config.incomeFrequency, now, timezone);
|
||||
if (isPaymentPlanUser && firstIncomeDate) {
|
||||
const nextPayday = calculateNextPayday(firstIncomeDate, config.incomeFrequency, now, timezone);
|
||||
const normalizedNextPayday = getUserMidnight(timezone, nextPayday);
|
||||
daysUntilPayday = Math.max(0, Math.ceil((normalizedNextPayday.getTime() - userNow.getTime()) / DAY_MS));
|
||||
dueBeforeNextPayday = userDueDate.getTime() < normalizedNextPayday.getTime();
|
||||
}
|
||||
if (remainingCents >= CRISIS_MINIMUM_CENTS) {
|
||||
if (isPaymentPlanUser && config.firstIncomeDate) {
|
||||
if (isPaymentPlanUser && firstIncomeDate) {
|
||||
isPrelimCrisis = daysUntilDuePrelim < daysUntilPayday && fundedPercent < 90;
|
||||
} else {
|
||||
isPrelimCrisis = fundedPercent < 70 && daysUntilDuePrelim <= 14;
|
||||
@@ -430,10 +433,10 @@ export function buildPlanStates(
|
||||
|
||||
// Calculate payment periods more accurately using firstIncomeDate
|
||||
let cyclesLeft: number;
|
||||
if (config.firstIncomeDate) {
|
||||
if (firstIncomeDate) {
|
||||
// Count actual pay dates between now and due date based on the recurring pattern
|
||||
// established by firstIncomeDate (pass timezone for correct date handling)
|
||||
cyclesLeft = countPayPeriodsBetween(userNow, userDueDate, config.firstIncomeDate, config.incomeFrequency, timezone);
|
||||
cyclesLeft = countPayPeriodsBetween(userNow, userDueDate, firstIncomeDate, config.incomeFrequency, timezone);
|
||||
} else {
|
||||
// Fallback to old calculation if firstIncomeDate not set
|
||||
cyclesLeft = Math.max(1, Math.ceil(daysUntilDue / freqDays));
|
||||
@@ -1377,7 +1380,9 @@ function computeBudgetAllocation(
|
||||
const availableBudget = inputs.availableBefore;
|
||||
const totalPool = availableBudget + newIncome;
|
||||
|
||||
const eligiblePlans = inputs.plans.filter((plan) => plan.autoPayEnabled);
|
||||
const eligiblePlans = inputs.plans.filter(
|
||||
(plan) => !plan.fundingMode || String(plan.fundingMode).toLowerCase() !== "manual"
|
||||
);
|
||||
const planStates = buildBudgetPlanStates(eligiblePlans, now, inputs.config.timezone);
|
||||
|
||||
// Calculate total remaining needed across all fixed plans
|
||||
@@ -1505,7 +1510,8 @@ function buildBudgetPlanStates(
|
||||
const userDueDate = getUserMidnightFromDateOnly(timezone, p.dueOn);
|
||||
const daysUntilDue = Math.max(0, Math.ceil((userDueDate.getTime() - userNow.getTime()) / DAY_MS));
|
||||
const hasPaymentSchedule = p.paymentSchedule !== null && p.paymentSchedule !== undefined;
|
||||
const autoFundEnabled = !!p.autoPayEnabled;
|
||||
const autoFundEnabled =
|
||||
!p.fundingMode || String(p.fundingMode).toLowerCase() !== "manual";
|
||||
const needsFundingThisPeriod = p.needsFundingThisPeriod ?? true;
|
||||
|
||||
// For irregular income, crisis mode triggers earlier (14 days)
|
||||
|
||||
Reference in New Issue
Block a user