commit - c0c08a12c78e66a4409c14ad8001b1058fa141b6
commit + 51d81f1bb404513593f9196b820658dcff970ccf
blob - d1f1959c1cacc3ff029792cd3d9a2edbe5b39331
blob + 9c0c469c26143c580437d3dc49aa2883d12112d8
--- doom/config.el
+++ doom/config.el
(after! org
(add-to-list 'org-capture-templates
`("k" "ITM Weekly KPI" entry
- (file+olp ,(expand-file-name "notes/itm.works/KPI Log.org" org-directory) "Log")
+ (file+olp ,(expand-file-name "work/itm/KPI Log.org" org-directory) "Log")
,(concat "* %<%Y-%m-%d %a>\n"
- "- Revenue :: YTD $%^{YTD revenue} / MTD $%^{MTD revenue} / Bank $%^{Bank balance}\n"
+ "- Revenue :: YTD $%(+itm-ytd-revenue) / MTD $%(+itm-mtd-revenue) / Bank $%(+itm-bank-balance)\n"
"- Hours :: %^{Hours worked} hr\n"
"- Pipeline :: /prospects in conversation + last contact date; \"none\" counts/\n"
" - %?\n"
:prepend t
:empty-lines 1)))
+;; ITM Monthly Deep Review capture — last Friday, 60–90 min (see todo.org agenda).
+(after! org
+ (add-to-list 'org-capture-templates
+ `("m" "ITM Monthly Deep Review" entry
+ (file+olp ,(expand-file-name "work/itm/Monthly Deep Review.org" org-directory) "Log")
+ ,(concat "* %<%Y-%m> %<%B>\n"
+ "- Revenue vs B1 :: MTD $%(+itm-mtd-revenue) / YTD $%(+itm-ytd-revenue) (B1 target: $100k)\n"
+ "- Burn / B3 buffer :: $%(+itm-mtd-expenses) this month / %(+itm-burn-buffer-months) mo runway (B3 target: ≥4)\n"
+ "- Bank :: $%(+itm-bank-balance)\n"
+ "- Per-scrape gross margin (B5) :: rev $%(+itm-mtd-planner-revenue) − cost $%(+itm-mtd-direct-cost) (Anthropic+Zack) → %(+itm-b5-margin)% (red if <60%)\n"
+ "- Goal status (green/yellow/red) ::\n"
+ " - <goal> — <g/y/r> — <note>\n"
+ "- Decisions (dropping or moving?) ::\n"
+ " - %?\n"
+ "- Note :: ")
+ :prepend t
+ :empty-lines 1)))
+
;; Open treemacs when you open a project
(after! treemacs
(treemacs-follow-mode 1)
(treemacs-project-follow-mode 1)
(add-hook 'projectile-after-switch-project-hook #'treemacs-add-and-display-current-project-exclusively))
+
+;; --- ITM business book: ledger reports + KPI autofill helpers ---
+(defvar +itm-ledger-file
+ (expand-file-name "~/Business/admin.itm.works/accounting/business/main.ledger")
+ "Master ledger for the ITM Works business book.")
+
+(defun +itm-ledger--number (query)
+ "Run `ledger QUERY' against the ITM business book and return the first
+dollar figure in the output as a string, thousands separators intact."
+ (let* ((bin (if (boundp 'ledger-binary-path) ledger-binary-path "ledger"))
+ (cmd (format "%s -f %s %s" bin (shell-quote-argument +itm-ledger-file) query))
+ (out (shell-command-to-string cmd)))
+ (if (string-match "-?[0-9][0-9,]*\\.[0-9][0-9]" out)
+ (match-string 0 out)
+ "0.00")))
+
+(defun +itm-ledger--raw (query)
+ "Like `+itm-ledger--number' but return a float (commas stripped)."
+ (string-to-number (replace-regexp-in-string "," "" (+itm-ledger--number query))))
+
+(defun +itm-ytd-revenue () (+itm-ledger--number "--invert --period \"this year\" balance ^Income"))
+(defun +itm-mtd-revenue () (+itm-ledger--number "--invert --period \"this month\" balance ^Income"))
+(defun +itm-mtd-expenses () (+itm-ledger--number "--period \"this month\" balance ^Expenses"))
+(defun +itm-bank-balance () (+itm-ledger--number "balance \"^Assets:Checking:PNC Business\""))
+
+(defun +itm-burn-buffer-months ()
+ "Months of runway = business bank balance / average monthly burn, where
+average monthly burn is YTD expenses divided by calendar months elapsed.
+Tracks goal B3 (keep >=4 months). Returns a string like \"9.4\"."
+ (let* ((bank (+itm-ledger--raw "balance \"^Assets:Checking:PNC Business\""))
+ (ytd-exp (+itm-ledger--raw "--period \"this year\" balance ^Expenses"))
+ (months (max 1 (string-to-number (format-time-string "%m"))))
+ (avg (/ ytd-exp months)))
+ (if (> avg 0) (format "%.1f" (/ bank avg)) "n/a")))
+
+(defun +itm-mtd-direct-cost ()
+ "MTD direct cost for the B5 per-planner margin: Anthropic/Claude spend +
+Zack labor booked this month."
+ (let ((ai (+itm-ledger--raw "--limit \"payee =~ /Anthropic|Claude/\" --period \"this month\" balance ^Expenses"))
+ (zack (+itm-ledger--raw "--period \"this month\" balance ^Expenses:Zack")))
+ (format "%.2f" (+ ai zack))))
+
+(defun +itm-mtd-planner-revenue ()
+ "MTD SymPro Planner revenue (deposits tagged to the sub-account this month)."
+ (+itm-ledger--number "--period \"this month\" --invert balance \"Em Partners:SymPro Planner\""))
+
+(defun +itm-b5-margin ()
+ "B5 per-planner gross margin %% = (planner revenue - direct cost) / revenue, MTD.
+Returns \"n/a\" when no planner revenue landed this month."
+ (let ((rev (+itm-ledger--raw "--period \"this month\" --invert balance \"Em Partners:SymPro Planner\""))
+ (cost (string-to-number (+itm-mtd-direct-cost))))
+ (if (> rev 0) (format "%.0f" (* 100.0 (/ (- rev cost) rev))) "n/a")))
+
+;; Reusable named reports for `ledger-report' (SPC m r).
+(after! ledger-mode
+ (dolist (r '(("ytd-revenue" "%(binary) -f %(ledger-file) --invert --period \"this year\" bal ^Income")
+ ("mtd-revenue" "%(binary) -f %(ledger-file) --invert --period \"this month\" bal ^Income")
+ ("bank-balance" "%(binary) -f %(ledger-file) bal ^Assets:Checking")))
+ (add-to-list 'ledger-reports r t)))