Metadata-Version: 2.4
Name: jobmargin
Version: 0.1.1
Summary: Job margin tracker: per-job P&L, margins, markup, break-even and price-to-target from a CSV
Author: calasdan-sketch
License-Expression: MIT
Keywords: margin,job costing,break-even,markup,profit,construction,csv
Classifier: Programming Language :: Python :: 3
Classifier: Environment :: Console
Classifier: Topic :: Office/Business :: Financial
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# jobmargin

**Know which jobs actually made money.** A CSV in, per-job P&L out: margin, markup, break-even revenue, portfolio totals, and a floor check that fails the run when a job lands under your minimum margin.

## Install

```bash
pip install jobmargin
```

## Compute job margins

`jobs.csv`:

```csv
job,revenue,labour_hours,labour_rate,materials,subs,other,overhead_pct
Kitchen,10000,40,50,2000,1000,500,10
Bath,8000,30,50,1500,500,0,10
```

```bash
jobmargin compute jobs.csv --min-margin 0.25
```

```
job                   revenue       cost     profit    margin    markup
--------------------------------------------------------------------
Kitchen             10,000.00   6,050.00   3,950.00    39.5%    65.3%
Bath                 8,000.00   4,650.00   3,350.00    41.9%    72.0%
--------------------------------------------------------------------
PORTFOLIO           18,000.00  10,700.00   7,300.00    40.6%

0 job(s) below the 25% floor: none
```

Exit `1` when any job is below `--min-margin` — drop it into a weekly cron and find the leak before the quarter ends. Defaults for missing columns come from `--overhead-pct` and friends; `--json` for automation.

## Price to a target margin

```bash
jobmargin price 600 --target-margin 0.4
# Cost 600.00 at 40% margin -> price 1,000.00 (profit 400.00)
```

The target is a fraction **of the price** (40% margin ≠ 40% markup): `price = cost / (1 − margin)`.

## Break-even

```bash
jobmargin breakeven --fixed 1000 --price 50 --variable 30
# Break-even: 50.00 units at 50.00 (revenue 2,500.00)
```

## The formulas

| Metric | Definition |
|---|---|
| total cost | labour (hours × rate) + materials + subs + other + overhead (`overhead_pct` of direct costs + fixed) |
| margin | profit ÷ **revenue** |
| markup | profit ÷ **cost** |
| break-even revenue (a job) | equals its cost — job costs are fixed once scope is fixed |
| break-even units | fixed ÷ (price − variable per unit) |

Zero-revenue jobs report margin as `—` rather than dividing by zero, and count as "below any floor" so they can't hide.

## Notes

- Pure stdlib, single file of inputs, deterministic output — safe to pipe into spreadsheets or dashboards.
- Currencies are unitless: pass everything in the same dollars.
- Pairs well with `holdbackcalc` (deadline cash drag) and `gstwatch` (threshold tracking) for a small-operator finance kit.

## License

MIT-style: use it, ship it, no warranty.
