{
  "id": 22455421,
  "title": "Which paycheck pays which bill? A tiny rule for paycheck budgeting (with JS)",
  "url": "https://urgent.news/2026/11/28/which-paycheck-pays-which-bill-a-tiny-rule-for-paycheck-budgeting",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-11-28T21:55:58.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/unverco/which-paycheck-pays-which-bill-a-tiny-rule-for-paycheck-budgeting-with-js-3m33"
  },
  "original_language": null,
  "account": "Most budgeting applications work with monthly budgets. However, individuals typically receive their paychecks weekly or bi-weekly. This discrepancy can cause financial strain between paychecks, leading to budgeting disasters. PaycheckPlan, an offline budgeting Progressive Web App (PWA), helps address this issue by answering a simple question: which paycheck pays which bill? The following explains the rule, code, and edge cases to test.\n\nThe rule states that a bill due on day D is paid from the latest paycheck arriving on or before D. For example, if rent is due on the 3rd and payments are received on the 1st and the 15th, the rent payment belongs to the 1st paycheck. In the code, dates are represented as ISO strings (YYYY-MM-DD), which sort correctly as strings. Money is stored as integer cents to prevent floating-point errors.\n\nThe code consists of two exported functions: assignBills and dailyAmount. The assignBills function takes paydays and bills as input and returns an array of groups, each containing a paycheck and its associated bills. The dailyAmount function calculates the daily amount for a given paycheck, group, and the number of days in the window.\n\nHere are some edge cases to test:\n1. Bill due on the same day as the paycheck: This bill should be paid from the paycheck it's due on.\n2. Bill due before the first known payday: If there is no paycheck in the window, decide how to display this bill instead of silently dropping it.\n3. Irregular income: If the amount is unknown until it arrives, leave \"left after bills\" as null, not 0. This will convey the message \"you have nothing left\" rather than \"you have $0.\"\n4. Paying a bill one paycheck earlier: Some individuals prefer to allocate funds from an earlier paycheck for bills like rent, creating a tighter budgeting window. Although this can be implemented as a per-bill override, it should use the same function and not a separate rule.\n5. Month lengths: If payments are made on the last day of the month, bills due on the 31st must be clamped in shorter months, such as February. Test this scenario to ensure accuracy.",
  "summary": "Most budgeting apps think in months. Most people get paid every week or every two weeks. That mismatch is why a monthly budget can look fine while the week before payday is a disaster. While building PaycheckPlan, an offline budgeting PWA, we needed one small rule to answer a simple question: which paycheck pays which bill? Here is the rule, a minimal version of the code, and the edge cases worth…",
  "summary_source": "publisher",
  "key_points": [],
  "editors_take": null,
  "opinion": false,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "machine_translated": false,
  "ai_generated": true,
  "disclaimer": "Accounts, briefs, key points, the editor’s take and translations are written by software from other outlets’ reporting and may contain errors. A summary whose summary_source is \"publisher\" is the outlet’s own feed text. Always check the linked original."
}