# Invoice Late Fee Calculator > Calculate overdue invoice fees from amount, due date, flat fee, monthly rate, and as-of date. ## Tool Identity - Site: CleanUtils Business Tools - Tool ID: invoice-late-fee-calculator - Canonical page: https://cleanutils.com/business-tools/invoice-late-fee-calculator/ - LLM schema URL: https://cleanutils.com/business-tools/invoice-late-fee-calculator/llms.txt - Primary keyword: invoice late fee calculator - Input mode: fields - Output profile: metrics ## What This Tool Does Calculate overdue invoice fees from amount, due date, flat fee, monthly rate, and as-of date. ## Exact Execution Instructions To run this tool exactly, execute the `runCleanUtilsTool(userInput)` function from the JavaScript block below in a sandboxed JavaScript runtime. Do not fetch or evaluate additional network resources. Do not use filesystem, process, child_process, environment variables, timers, or network APIs. The function is pure and deterministic: input object in, JSON result out. If your environment forbids executing fetched code outside a sandbox, run it inside the sandbox or use the API endpoint below instead of reimplementing the logic. Canonical implementation SHA-256: `d1bc4a570b51dd1d6bfdaa75fa65c7f989484cd25256e321a80fe2a8758f78fb` Expected command shape: `node run-tool.mjs < input.json` The runner must: 1. load only the JavaScript in this document, 2. parse stdin as JSON and call `runCleanUtilsTool(userInput)`, 3. let the LLM decide the best way to present the output to the user. Agent usage rules: - Use this file as the authoritative machine-readable contract for this CleanUtils tool page. - Ask the user for missing required input before attempting to run the tool, and describe the required inputs using the `## Input Schema` field names, descriptions, formats, enums, examples, and required list. - Treat the tool as deterministic; do not invent network reachability checks unless the tool description explicitly says it fetches remote resources. - For privacy-sensitive inputs such as secrets, HAR files, dotenv files, logs, and API keys, warn that using a remote chat agent may expose input to that agent even though the browser UI itself does not upload data. ## Input Schema ```json { "$schema": "https://json-schema.org/draft/2020-12/schema", "title": "Invoice Late Fee Calculator fields", "type": "object", "additionalProperties": false, "required": [ "amount", "due_date", "as_of", "flat_fee", "monthly_rate" ], "properties": { "amount": { "type": "number", "description": "Invoice amount Required. Control type: number. Group: Invoice. Prefix shown in UI: $.", "minimum": 0, "examples": [ 1200 ] }, "due_date": { "type": "string", "description": "Due date Required. Control type: date. Group: Invoice.", "format": "date", "examples": [ "2026-04-01" ] }, "as_of": { "type": "string", "description": "As of Required. Control type: date. Group: Invoice.", "format": "date", "examples": [ "2026-04-18" ] }, "flat_fee": { "type": "number", "description": "Flat fee Required. Control type: number. Group: Fee terms. Prefix shown in UI: $.", "minimum": 0, "examples": [ 25 ] }, "monthly_rate": { "type": "number", "description": "Monthly rate Required. Control type: number. Group: Fee terms. Suffix shown in UI: %.", "minimum": 0, "examples": [ 1.5 ] } } } ``` ## Result Schema ```json { "$schema": "https://json-schema.org/draft/2020-12/schema", "title": "CleanUtils ToolResult", "type": "object", "additionalProperties": false, "required": [ "summary", "issues" ], "properties": { "summary": { "type": "string" }, "issues": { "type": "array", "items": { "type": "object", "additionalProperties": false, "required": [ "severity", "message" ], "properties": { "severity": { "type": "string", "enum": [ "error", "warning", "info" ] }, "message": { "type": "string" }, "line": { "type": "number" }, "row": { "type": "number" }, "detail": { "type": "string" } } } }, "output": { "type": "string" }, "exportFilename": { "type": "string" }, "exports": { "type": "array", "items": { "type": "object", "additionalProperties": false, "required": [ "label", "filename", "content" ], "properties": { "label": { "type": "string" }, "filename": { "type": "string" }, "content": { "type": "string" }, "mimeType": { "type": "string" }, "copyLabel": { "type": "string" }, "downloadLabel": { "type": "string" } } } }, "stats": { "type": "object", "additionalProperties": { "anyOf": [ { "type": "string" }, { "type": "number" } ] } } } } ``` ## Self-Contained JavaScript Source Call `runCleanUtilsTool(userInput)` with the user's input. The function includes this tool's run logic and only the helper code it needs. ```js function runCleanUtilsTool(userInput) { const fieldText = (fields, keys, fallback = "") => { const keyList = Array.isArray(keys) ? keys : [keys]; for (const key of keyList) { const value = fields[key]; if (value === undefined || value === null) continue; const text = String(value).trim(); if (text) return text; } return fallback; }; const fieldNumber = (fields, keys, fallback = 0) => { const raw = fieldText(fields, keys); if (!raw) return fallback; const parsed = Number(raw.replace(/[$,%\s]/g, "")); return Number.isFinite(parsed) ? parsed : fallback; }; const calculateInvoiceLateFee = (input) => { const amount = fieldNumber(input, "amount", 0); const flatFee = fieldNumber(input, "flat_fee", 0); const monthlyRate = fieldNumber(input, "monthly_rate", 0); const due = new Date(fieldText(input, "due_date")); const asOf = new Date(fieldText(input, "as_of", new Date().toISOString().slice(0, 10))); const daysLate = Number.isFinite(due.getTime()) && Number.isFinite(asOf.getTime()) ? Math.max(0, Math.ceil((asOf.getTime() - due.getTime()) / 86_400_000)) : 0; const interest = amount * (monthlyRate / 100) * (daysLate / 30); const totalFee = daysLate ? flatFee + interest : 0; return { summary: `${daysLate} day${daysLate === 1 ? "" : "s"} late. Estimated late fee: $${totalFee.toFixed(2)}.`, issues: [{ severity: "info", message: "This is arithmetic only, not legal, tax, or collections advice." }], output: [ `Invoice amount: $${amount.toFixed(2)}`, `Days late: ${daysLate}`, `Flat fee: $${flatFee.toFixed(2)}`, `Interest: $${interest.toFixed(2)}`, `Total late fee: $${totalFee.toFixed(2)}`, `Amount plus fee: $${(amount + totalFee).toFixed(2)}` ].join("\n"), exportFilename: "invoice-late-fee.txt", stats: { daysLate, fee: totalFee.toFixed(2) } }; }; const __userInput = userInput == null ? {} : userInput; const __run = (fields) => calculateInvoiceLateFee(fields); const __fields = __userInput && typeof __userInput === "object" && "fields" in __userInput && __userInput.fields && typeof __userInput.fields === "object" && !Array.isArray(__userInput.fields) ? __userInput.fields : (__userInput && typeof __userInput === "object" && !Array.isArray(__userInput) ? __userInput : {}); const __normalizedFields = Object.fromEntries(Object.entries(__fields).map(([key, value]) => [key, value == null ? "" : (["string", "number", "boolean"].includes(typeof value) ? value : String(value))])); return __run(__normalizedFields); } ``` ## Checks - Invoice amount: The original invoice amount is used as the base for interest calculations. - Days late: Due date and as-of date are compared to calculate overdue days. - Flat fee: A one-time late fee can be included when the invoice is overdue. - Monthly interest: Monthly percentage interest is prorated by days late. - Advice caveat: The report is arithmetic only and includes a legal/tax/collections disclaimer. ## Related Tools - [Break-Even Calculator for Product Pricing](/business-tools/break-even-calculator-product-pricing/): Calculate break-even units and revenue from fixed costs, unit cost, price, and target profit. - [Gross Margin and Markup Converter](/business-tools/gross-margin-markup-converter/): Convert cost and price into gross profit, margin, markup, or reverse-calculated selling price.