From 716a06ee28a0a227db51d0011420d9cbc1aa3e08 Mon Sep 17 00:00:00 2001 From: Timothy Cardoza Date: Wed, 18 Mar 2026 10:44:13 -0500 Subject: [PATCH] Man hours uses subtotal --- ci-new-app-checklist.md | 43 ++++++++++++++++++++++++++++++++++ src/utils/modifier-registry.ts | 10 ++++++-- 2 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 ci-new-app-checklist.md diff --git a/ci-new-app-checklist.md b/ci-new-app-checklist.md new file mode 100644 index 0000000..faa6837 --- /dev/null +++ b/ci-new-app-checklist.md @@ -0,0 +1,43 @@ +# New App Checklist (Vite + Bun + PM2) + +## 1) Local Repo Changes +- Add `serve` script: + - `"serve": "serve -s dist -l tcp://0.0.0.0:$PORT"` +- Add dependency: + - `serve` (run `bun add serve`) + +## 2) CI Workflow +- Use the template file in `ci-template.yaml`. +- Replace placeholders: + - `` + - `` + - `` + +## 3) Server One-Time Setup +- Create deploy directory: + - `mkdir -p ` +- First PM2 start: + - `cd ` + - `PORT= pm2 start "bun run serve" --name ` + - `pm2 save` + +## 4) Deploy + Restart (CI will do this) +- Files copied to server: + - `dist/`, `package.json`, `bun.lock` (or `bun.lockb`) +- On server: + - `bun install --production` + - `PORT= pm2 restart --update-env` + +## 5) Verification +- PM2 process: + - `pm2 show ` +- Port: + - `pm2 env | grep PORT` +- Bind: + - `pm2 logs --lines 20` + - Expect: `Accepting connections at http://0.0.0.0:` +- Files: + - `ls -la ` + - `ls -la /dist | head -20` +- HTTP: + - `curl -I http://:` \ No newline at end of file diff --git a/src/utils/modifier-registry.ts b/src/utils/modifier-registry.ts index 479ba97..0a54ceb 100644 --- a/src/utils/modifier-registry.ts +++ b/src/utils/modifier-registry.ts @@ -12,6 +12,10 @@ export interface ModifierModule { calculateDisplay?: (modifier: Modifier, subScopeTotalWithMarkup: number, subScopeItems: EstimateItem[]) => number; } +const getPreMarkupSubtotal = (items: EstimateItem[]) => { + return items.reduce((sum, item) => sum + item.quantity * item.unitPrice, 0); +}; + const TaxModule: ModifierModule = { id: 'tax', name: 'Tax', @@ -34,9 +38,11 @@ const ManHoursModule: ModifierModule = { defaultValueType: 'unit', defaultUnitLabel: 'factor', calculate: () => 0, - calculateDisplay: (m, base) => { + calculateDisplay: (m, _, items) => { const factor = m.value || 1; - return base / factor; + if (factor === 0) return 0; + const subtotal = getPreMarkupSubtotal(items); + return subtotal / factor; } };