CUB-37: Implement cost-per-print calculation service #18

Merged
overseer merged 3 commits from agent/dex/CUB-37-cost-per-print into dev 2026-04-27 17:25:38 -04:00
Owner

What

Implement cost-per-print (COGS) calculation service for Extrudex.

New files

  • Domain/Interfaces/ICostPerPrintService.cs — Interface + CostPerPrintResult domain model
  • Infrastructure/Services/CostPerPrintService.cs — Implementation with graceful handling of missing cost data
  • API/DTOs/PrintJobs/CostPerPrintDtos.cs — Request/response DTOs for cost endpoints
  • API/Controllers/CostAnalysisController.cs — Spool-level cost analysis endpoint (POST /api/cost-analysis/spool)

Modified files

  • API/Controllers/PrintJobsController.cs — Added POST /api/printjobs/{id}/cost endpoint + injected ICostPerPrintService
  • Program.cs — Registered ICostPerPrintService in DI

API contracts for Rex

  • POST /api/printjobs/{id}/costCostPerPrintResponse
  • POST /api/cost-analysis/spoolSpoolCostResponse

Design decisions

  • Formula: cost_per_print = grams_derived × (purchase_price / weight_total_grams)
  • Missing cost data returns warnings, never throws
  • Cost per gram rounded to 6 decimal places, cost per print to 4
  • Spool-level aggregation distinguishes jobs with complete vs incomplete cost data

Linear

Closes CUB-37

## What Implement cost-per-print (COGS) calculation service for Extrudex. ### New files - `Domain/Interfaces/ICostPerPrintService.cs` — Interface + `CostPerPrintResult` domain model - `Infrastructure/Services/CostPerPrintService.cs` — Implementation with graceful handling of missing cost data - `API/DTOs/PrintJobs/CostPerPrintDtos.cs` — Request/response DTOs for cost endpoints - `API/Controllers/CostAnalysisController.cs` — Spool-level cost analysis endpoint (`POST /api/cost-analysis/spool`) ### Modified files - `API/Controllers/PrintJobsController.cs` — Added `POST /api/printjobs/{id}/cost` endpoint + injected `ICostPerPrintService` - `Program.cs` — Registered `ICostPerPrintService` in DI ### API contracts for Rex - `POST /api/printjobs/{id}/cost` → `CostPerPrintResponse` - `POST /api/cost-analysis/spool` → `SpoolCostResponse` ### Design decisions - Formula: `cost_per_print = grams_derived × (purchase_price / weight_total_grams)` - Missing cost data returns warnings, never throws - Cost per gram rounded to 6 decimal places, cost per print to 4 - Spool-level aggregation distinguishes jobs with complete vs incomplete cost data ## Linear Closes CUB-37
Dex added 1 commit 2026-04-27 13:59:52 -04:00
CUB-37: implement cost-per-print calculation service
Some checks failed
Dev Build / build-test (pull_request) Failing after 48s
Dev Build / deploy-dev (pull_request) Has been skipped
Dev Build / notify-success (pull_request) Has been skipped
Dev Build / notify-failure (pull_request) Successful in 3s
6aa31f4be3
Rex added 1 commit 2026-04-27 14:30:08 -04:00
Merge remote-tracking branch 'origin/dev' into fix-pr-18
Some checks failed
Dev Build / build-test (pull_request) Failing after 54s
Dev Build / deploy-dev (pull_request) Has been skipped
Dev Build / notify-success (pull_request) Has been skipped
Dev Build / notify-failure (pull_request) Successful in 4s
5b9dde13fe
# Conflicts:
#	backend/API/Controllers/PrintJobsController.cs
overseer added 1 commit 2026-04-27 17:25:24 -04:00
Merge branch 'dev' into agent/dex/CUB-37-cost-per-print
Some checks failed
Dev Build / build-test (pull_request) Failing after 1m0s
Dev Build / deploy-dev (pull_request) Has been skipped
Dev Build / notify-success (pull_request) Has been skipped
Dev Build / notify-failure (pull_request) Successful in 5s
0378aee43e
overseer scheduled this pull request to auto merge when all checks succeed 2026-04-27 17:25:31 -04:00
overseer merged commit 174dd294e9 into dev 2026-04-27 17:25:38 -04:00
overseer deleted branch agent/dex/CUB-37-cost-per-print 2026-04-27 17:25:38 -04:00
Sign in to join this conversation.
No Reviewers
No Label
3 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: CubeCraft-Creations/Extrudex#18