import { TransactionI } from "../api/transactions/interface"; /** * resolvePaymentDueDate * * Returns the **effective** `paymentDueDate` (calendar day) to use for downstream * processing / API calls based on a list of transactions. * * ## Key idea * `paymentDueDate` is treated as a **date-only** concept (YYYY-MM-DD). We explicitly * ignore hours/minutes/seconds to avoid timezone shifting bugs (e.g. an ISO UTC * midnight timestamp appearing as the prior day in some local timezones). * * ## Rules (evaluated by calendar day) * 1) If **any** transaction has a valid `paymentDueDate` that is **today or in the past**, * return **today**. * - This matches the behavior where past-due transactions are processed on the current day. * * 2) If **all valid** `paymentDueDate` values are **in the future**, return the **closest / next** * future date (the minimum future date). * * 3) If there are **no valid** `paymentDueDate` values (missing, null, or invalid), * return **today**. * * ## Input handling * - Accepts `paymentDueDate` as a string (ISO timestamp or YYYY-MM-DD), Date, or Dayjs. * - For ISO strings like "2026-03-09T00:00:00.000Z", the resolver preserves the calendar * day by extracting the "YYYY-MM-DD" portion rather than converting to a local Date/instant. * * ## Return value * - Returns a string in "YYYY-MM-DD" format suitable for use as a date-only API parameter. * * ## Examples * - Due dates: [2026-03-09, 2026-03-10], today=2026-03-08 => returns "2026-03-09" * - Due dates: [2026-03-01, 2026-03-10], today=2026-03-08 => returns "2026-03-08" (today) * - Due dates: [2026-03-01, 2026-03-02], today=2026-03-08 => returns "2026-03-08" (today) * - Due dates: [] / all null / invalid => returns "2026-03-08" (today) */ declare function resolvePaymentDueDate(transactionList: TransactionI[]): string; export default resolvePaymentDueDate;