<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Tobias Halloran</title>
    <description>The latest articles on DEV Community by Tobias Halloran (@tobias_halloran).</description>
    <link>https://dev.to/tobias_halloran</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4275814%2Ff52e5c74-0ec2-4329-9a24-2de332cab072.png</url>
      <title>DEV Community: Tobias Halloran</title>
      <link>https://dev.to/tobias_halloran</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/tobias_halloran"/>
    <language>en</language>
    <item>
      <title>Deterministic 3-Statement Accounting in TypeScript: Tying a 60-Month Balance Sheet to $0.00</title>
      <dc:creator>Tobias Halloran</dc:creator>
      <pubDate>Tue, 01 Dec 2026 13:58:47 +0000</pubDate>
      <link>https://dev.to/tobias_halloran/deterministic-3-statement-accounting-in-typescript-tying-a-60-month-balance-sheet-to-000-518</link>
      <guid>https://dev.to/tobias_halloran/deterministic-3-statement-accounting-in-typescript-tying-a-60-month-balance-sheet-to-000-518</guid>
      <description>&lt;p&gt;Ask a general-purpose chatbot to generate a 5-year small business financial projection (Income Statement, Cash Flow Statement, and Balance Sheet), and check &lt;code&gt;Assets - (Liabilities + Equity)&lt;/code&gt; in Year 3. Almost every time, it drifts by thousands of dollars — or invents a "plug" line to hide the mismatch.&lt;/p&gt;

&lt;p&gt;When we built &lt;a href="https://www.proformaplan.com/?utm_source=devto&amp;amp;utm_campaign=ts_accounting" rel="noopener noreferrer"&gt;ProFormaPlan&lt;/a&gt; to generate SBA 7(a)-ready business plans and unlocked Excel (&lt;code&gt;.xlsx&lt;/code&gt;) financial models, our #1 architectural rule was simple: &lt;strong&gt;never let a language model invent financial numbers.&lt;/strong&gt; Every single dollar figure comes from a deterministic TypeScript 3-statement accounting engine that runs identically in the browser (live as users edit assumptions) and on Cloudflare Workers (when compiling &lt;code&gt;.xlsx&lt;/code&gt; formulas and binding audited numbers into the narrative).&lt;/p&gt;

&lt;p&gt;Here is the exact architecture that guarantees &lt;code&gt;Assets - (Liabilities + Equity) === 0&lt;/code&gt; across all 60 months.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Start With an Audited Opening Balance Sheet (Month 0)
&lt;/h2&gt;

&lt;p&gt;Every balance-sheet bug begins at Month 0. If &lt;code&gt;Sources != Uses&lt;/code&gt; before Day 1 operations start, no downstream formula can save you.&lt;/p&gt;

&lt;p&gt;In our model, &lt;strong&gt;Startup Fees &amp;amp; Pre-Launch Licenses&lt;/strong&gt; are expensed immediately at Month 0 into negative opening Retained Earnings, while &lt;strong&gt;CapEx&lt;/strong&gt; lands in Net Fixed Assets, &lt;strong&gt;Opening Inventory&lt;/strong&gt; lands in Inventory, and residual cash lands in Opening Cash:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Opening Balance Sheet (Month 0)&lt;/span&gt;
&lt;span class="c1"&gt;// Paid-in Capital + Opening Loan = Opening Cash + Opening Inventory + Net Fixed Assets + Pre-Launch Expenses&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;openingRetainedEarnings&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;input&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;startupFeesLicenses&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;openingTotalEquity&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;paidInCapital&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;openingRetainedEarnings&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;openingTotalAssets&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;openingCash&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;openingInventory&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;openingNetFA&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;openingBalanceCheck&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;openingTotalAssets&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;openingLoan&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;openingTotalEquity&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;// Invariant: Math.abs(openingBalanceCheck) &amp;lt; 1e-6&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If a founder changes Owner Equity or SBA Loan Amount, opening cash absorbs the exact residual so Day 0 always balances to &lt;code&gt;$0.00&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Close the Loop With the Indirect Cash Flow Identity
&lt;/h2&gt;

&lt;p&gt;For each month &lt;code&gt;1..60&lt;/code&gt;, we compute Income Statement -&amp;gt; Debt Amortization -&amp;gt; Working Capital (&lt;code&gt;AR&lt;/code&gt;, &lt;code&gt;Inventory&lt;/code&gt;, &lt;code&gt;AP&lt;/code&gt;) -&amp;gt; Indirect Cash Flow -&amp;gt; Ending Balance Sheet strictly in order:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// 1. Income Statement&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;ebitda&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;grossProfit&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;totalOpex&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;remainingDepreciable&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;input&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;capexEquipmentBuildout&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;prevAccumDep&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;depreciation&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;min&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;remainingDepreciable&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;monthlyDepreciation&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;netFixedAssets&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;input&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;capexEquipmentBuildout&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;prevAccumDep&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;depreciation&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// 2. Debt Amortization (monthly compounding)&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;interest&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;prevDebt&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;monthlyRate&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;debtPayment&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;prevDebt&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="mf"&gt;1e-6&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;min&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;prevDebt&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;interest&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;monthlyPmt&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;principal&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;debtPayment&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;interest&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;endingDebt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;prevDebt&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;principal&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;ebt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ebitda&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;depreciation&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;interest&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;taxes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ebt&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="n"&gt;ebt&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;input&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;taxRate&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;netIncome&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ebt&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;taxes&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// 3. Working Capital Timing (30-day month basis)&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;ar&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;revenue&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;input&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;arDays&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;inventory&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;cogs&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;input&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;inventoryDays&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;ap&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;cogs&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;input&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;apDays&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;dAR&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ar&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;prevAR&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;dInv&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;inventory&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;prevInv&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;dAP&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ap&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;prevAP&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// 4. Indirect Cash Flow&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;operatingCashFlow&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;netIncome&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;depreciation&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;dAR&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;dInv&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;dAP&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;financingCashFlow&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;principal&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;endingCash&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;prevCash&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;operatingCashFlow&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;financingCashFlow&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// 5. Ending Balance Sheet &amp;amp; Tie-Out Verification&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;totalAssets&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;endingCash&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;ar&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;inventory&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;netFixedAssets&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;totalLiabilities&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ap&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;endingDebt&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;retainedEarnings&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;prevRetainedEarnings&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;netIncome&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;totalEquity&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;paidInCapital&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;retainedEarnings&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;balanceCheck&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;totalAssets&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;totalLiabilities&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;totalEquity&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Why does &lt;code&gt;balanceCheck&lt;/code&gt; mathematically equal zero on every single step? Take the first difference of &lt;code&gt;Assets - Liabilities - Equity&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ΔCash + ΔAR + ΔInv - Dep - ΔAP + Principal - NetIncome = 0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Because &lt;code&gt;endingCash - prevCash&lt;/code&gt; is literally &lt;code&gt;NetIncome + Dep - dAR - dInv + dAP - Principal&lt;/code&gt;, every single term cancels algebraically. No plugs. No drift.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Why Working Capital Timing Breaks Profitable Startups
&lt;/h2&gt;

&lt;p&gt;Notice lines &lt;code&gt;ar = revenue * (arDays / 30)&lt;/code&gt; and &lt;code&gt;dAR = ar - prevAR&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;In a B2B commercial cleaning or home-health agency where invoices clear in 45 days (&lt;code&gt;arDays = 45&lt;/code&gt;) while biweekly W-2 payroll leaves the checking account immediately, &lt;code&gt;dAR&lt;/code&gt; drains cash faster than &lt;code&gt;NetIncome&lt;/code&gt; accumulates during Months 1–4. Running a deterministic monthly cash-flow loop lets us compute the exact &lt;strong&gt;Minimum Cash Trough&lt;/strong&gt; across 60 months and flag whether the founder's working capital reserve survives ramp-up — before an SBA underwriter rejects the file.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Mirroring the Exact Math in Live Excel Formulas
&lt;/h2&gt;

&lt;p&gt;Computing the numbers in TypeScript is only half the problem — bankers want to click into Excel cells and change revenue or rent themselves. So our OpenXML &lt;code&gt;.xlsx&lt;/code&gt; compiler writes native &lt;code&gt;=SUM(...)&lt;/code&gt;, &lt;code&gt;=PMT(...)&lt;/code&gt;, and cross-sheet cell references (&lt;code&gt;'4_5Yr_Income_Stmt'!C22&lt;/code&gt;, &lt;code&gt;'7_SBA_Debt_Schedule'!C15&lt;/code&gt;) directly into the worksheet XML so the Balance Sheet tie-out row stays &lt;code&gt;$0.00&lt;/code&gt; live inside Excel, Google Sheets, and LibreOffice even after the user edits blue input cells on &lt;code&gt;2_Assumptions&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Inspect the Output &amp;amp; Tools Directly (Zero Sign-Up)
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Download our unlocked 8-tab 5-year &lt;code&gt;.xlsx&lt;/code&gt; sample (979 live formulas, &lt;code&gt;$0.00&lt;/code&gt; balance check):&lt;/strong&gt; &lt;a href="https://www.proformaplan.com/samples/proformaplan-sample-5yr-model.xlsx" rel="noopener noreferrer"&gt;https://www.proformaplan.com/samples/proformaplan-sample-5yr-model.xlsx&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Free SBA 7(a) Loan &amp;amp; DSCR Underwriting Calculator:&lt;/strong&gt; &lt;a href="https://www.proformaplan.com/sba-dscr-calculator?utm_source=devto&amp;amp;utm_campaign=ts_accounting" rel="noopener noreferrer"&gt;https://www.proformaplan.com/sba-dscr-calculator?utm_source=devto&amp;amp;utm_campaign=ts_accounting&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Free Small Business Startup Cost Calculator (16 US Industry Benchmarks):&lt;/strong&gt; &lt;a href="https://www.proformaplan.com/startup-cost-calculator?utm_source=devto&amp;amp;utm_campaign=ts_accounting" rel="noopener noreferrer"&gt;https://www.proformaplan.com/startup-cost-calculator?utm_source=devto&amp;amp;utm_campaign=ts_accounting&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you've built financial engines in TypeScript or OpenXML, I'd love to hear how you handle floating-point display rounding vs exact cell invariants!&lt;/p&gt;

</description>
      <category>typescript</category>
      <category>webdev</category>
      <category>architecture</category>
      <category>saas</category>
    </item>
    <item>
      <title>Compiling a 60-Month 3-Statement Excel (.xlsx) Workbook From Scratch in Cloudflare Workers</title>
      <dc:creator>Tobias Halloran</dc:creator>
      <pubDate>Tue, 01 Dec 2026 07:44:19 +0000</pubDate>
      <link>https://dev.to/tobias_halloran/compiling-a-60-month-3-statement-excel-xlsx-workbook-from-scratch-in-cloudflare-workers-58ii</link>
      <guid>https://dev.to/tobias_halloran/compiling-a-60-month-3-statement-excel-xlsx-workbook-from-scratch-in-cloudflare-workers-58ii</guid>
      <description>&lt;p&gt;57-second formula walkthrough video: &lt;a href="https://www.youtube.com/watch?v=pftPAlYpABQ" rel="noopener noreferrer"&gt;https://www.youtube.com/watch?v=pftPAlYpABQ&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When small-business founders ask a chatbot to write a 5-year financial model for an SBA loan or commercial lease, they almost always hit the same wall: the prose looks polished, the markdown tables look neat, and the accounting doesn't actually add up. Assets don't equal Liabilities plus Equity, debt amortization doesn't match the cash flow statement, and exporting to Excel gives you dead hardcoded numbers instead of live formulas.&lt;/p&gt;

&lt;p&gt;To fix that in &lt;a href="https://www.proformaplan.com/?utm_source=devto&amp;amp;utm_campaign=openxml_article" rel="noopener noreferrer"&gt;ProFormaPlan&lt;/a&gt;, we built a deterministic 60-month 3-statement accounting engine in TypeScript that compiles real OpenXML (&lt;code&gt;.xlsx&lt;/code&gt;) workbooks directly inside Cloudflare Workers using nothing but &lt;code&gt;fflate&lt;/code&gt; for ZIP compression—no heavy spreadsheet libraries, no headless LibreOffice container, and &amp;lt;15ms runtime per workbook.&lt;/p&gt;

&lt;p&gt;You can download an actual 8-tab output right now without signing up and inspect the XML/formulas directly in Excel, LibreOffice, or Google Sheets:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Free 8-tab 5-year sample &lt;code&gt;.xlsx&lt;/code&gt; (979 live formulas):&lt;/strong&gt; &lt;a href="https://www.proformaplan.com/samples/proformaplan-sample-5yr-model.xlsx" rel="noopener noreferrer"&gt;https://www.proformaplan.com/samples/proformaplan-sample-5yr-model.xlsx&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Live customizer (free 12-month &lt;code&gt;.xlsx&lt;/code&gt; for your own numbers):&lt;/strong&gt; &lt;a href="https://www.proformaplan.com/?utm_source=devto&amp;amp;utm_campaign=openxml_article" rel="noopener noreferrer"&gt;https://www.proformaplan.com/?utm_source=devto&amp;amp;utm_campaign=openxml_article&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Why Skip Heavy Excel Libraries in Edge Workers?
&lt;/h2&gt;

&lt;p&gt;Popular Node &lt;code&gt;.xlsx&lt;/code&gt; libraries pull in megabytes of polyfills, stream wrappers, and XML DOM abstractions that bloat Cloudflare Worker bundles or break in non-Node runtimes. Yet an &lt;code&gt;.xlsx&lt;/code&gt; file is just a ZIP archive of straightforward XML files:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[Content_Types].xml
_rels/.rels
xl/workbook.xml
xl/_rels/workbook.xml.rels
xl/styles.xml
xl/worksheets/sheet1.xml ... sheet8.xml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Using &lt;code&gt;fflate&lt;/code&gt;'s synchronous &lt;code&gt;zipSync&lt;/code&gt;, emitting all 8 linked worksheets with inline strings (&lt;code&gt;t="inlineStr"&lt;/code&gt;), explicit style indices (&lt;code&gt;xl/styles.xml&lt;/code&gt;), frozen panes, column widths, and both formula strings (&lt;code&gt;&amp;lt;f&amp;gt;&lt;/code&gt;) and cached evaluated values (&lt;code&gt;&amp;lt;v&amp;gt;&lt;/code&gt;) takes roughly 400 lines of plain TypeScript and produces a clean ~29 KB &lt;code&gt;.xlsx&lt;/code&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Two Rules That Keep 3-Statement Models Tied to &lt;code&gt;$0.00&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;Most automated spreadsheets break balance-sheet reconciliation by month 3 because they treat the Income Statement, Cash Flow Statement, and Balance Sheet as separate tables instead of one closed double-entry loop.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Compute Every Monthly Ledger Period Deterministically First
&lt;/h3&gt;

&lt;p&gt;For each month &lt;code&gt;m = 0..60&lt;/code&gt; (starting from Opening Balance Sheet &lt;code&gt;M0&lt;/code&gt; where owner equity + loan proceeds fund CapEx, startup expenses, initial inventory, and opening cash):&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Income Statement:&lt;/strong&gt; Revenue (with seasonal curve and ramp), COGS, Gross Profit, Payroll + Payroll Burden, Fixed OpEx, Rent, Marketing, Depreciation (straight-line over useful life), Loan Interest (&lt;code&gt;openingDebt * monthlyRate&lt;/code&gt;), Pre-Tax Income, Income Tax (zero on losses), Net Income.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Working Capital:&lt;/strong&gt; Accounts Receivable (&lt;code&gt;revenue * arDays / 30&lt;/code&gt;), Inventory (&lt;code&gt;cogs * invDays / 30&lt;/code&gt;), Accounts Payable (&lt;code&gt;cogs * apDays / 30&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Indirect Cash Flow:&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;Operating Cash Flow = Net Income + Depreciation - ΔAR - ΔInventory + ΔAP&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Investing Cash Flow = -CapEx&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Financing Cash Flow = Loan Draw - Principal Repayment + Equity Injection - Owner Distributions&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Ending Cash = Opening Cash + OCF + ICF + FCF&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Balance Sheet:&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;Total Assets = Ending Cash + AR + Inventory + Net PP&amp;amp;E&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Total Liabilities = AP + Ending Debt&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Total Equity = Contributed Capital + Retained Earnings&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Audit invariant:&lt;/strong&gt; &lt;code&gt;Math.abs(Total Assets - (Total Liabilities + Total Equity)) &amp;lt; 0.01&lt;/code&gt; across all 60 months.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In our test suite (&lt;code&gt;tests/finance.test.ts&lt;/code&gt;), every single one of our 16 NAICS industry presets—plus edge cases like debt-free models and high-working-capital businesses—is asserted against that &lt;code&gt;$0.00&lt;/code&gt; invariant across all 60 monthly periods before deploy.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Emit Live Formulas (&lt;code&gt;&amp;lt;f&amp;gt;&lt;/code&gt;) Alongside Cached Values (&lt;code&gt;&amp;lt;v&amp;gt;&lt;/code&gt;)
&lt;/h3&gt;

&lt;p&gt;One subtle &lt;code&gt;.xlsx&lt;/code&gt; gotcha: if you emit &lt;code&gt;&amp;lt;f&amp;gt;SUM(B6:M6)&amp;lt;/f&amp;gt;&lt;/code&gt; without a &lt;code&gt;&amp;lt;v&amp;gt;&lt;/code&gt; cached value, Excel recalculates on open, &lt;strong&gt;but&lt;/strong&gt; mobile viewers, macOS Quick Look, and Python readers show blank cells or &lt;code&gt;0&lt;/code&gt;. Emitting both:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight xml"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;c&lt;/span&gt; &lt;span class="na"&gt;r&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"N6"&lt;/span&gt; &lt;span class="na"&gt;s&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"8"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;f&amp;gt;&lt;/span&gt;SUM(B6:M6)&lt;span class="nt"&gt;&amp;lt;/f&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;v&amp;gt;&lt;/span&gt;1297175&lt;span class="nt"&gt;&amp;lt;/v&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/c&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;ensures that every viewer renders exact formatted dollar values immediately &lt;em&gt;and&lt;/em&gt; clicking any total, gross profit, EBITDA, DSCR, or Balance Check cell in Microsoft Excel reveals the live formula and updates dynamically when a banker edits an assumption cell on Tab 1.&lt;/p&gt;




&lt;h2&gt;
  
  
  Avoiding the Biggest Trap in Narrative + Spreadsheet Generation
&lt;/h2&gt;

&lt;p&gt;Once the 60-month math is locked, the prose business plan (editable &lt;code&gt;.docx&lt;/code&gt; and typeset PDF) is generated strictly from that verified &lt;code&gt;ModelOutput&lt;/code&gt; JSON—never letting a text model invent its own revenue, payroll, or DSCR figures. Every dollar in the Executive Summary, Use of Funds, and SBA Underwriting Memo reconciles penny-for-penny with Tab 1 through Tab 8 of the &lt;code&gt;.xlsx&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;If you're curious about the OpenXML output, grab the free 8-tab sample &lt;code&gt;.xlsx&lt;/code&gt; (no signup) or try the 2027 budget generator at &lt;a href="https://www.proformaplan.com/2027-budget" rel="noopener noreferrer"&gt;https://www.proformaplan.com/2027-budget&lt;/a&gt; and inspect the formula bar in Excel or LibreOffice. Feedback on formula compatibility or edge cases is always welcome.&lt;/p&gt;

</description>
      <category>typescript</category>
      <category>cloudflare</category>
      <category>excel</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
