Add, update, or remove material cost lines on a job. Use when the user wants to add stock/materials to a job, update quantities or prices, or manage material lines on a job's cost set.
Manage material cost lines on a job. This skill is interactive — the user may ask you to:
The user may provide:
https://<instance>.docketworks.site/jobs/<uuid>?tab=actual — extract the UUIDapps.job.models.Job by name)Use the same search strategy as the /stock skill — parse shorthand for thickness, metal type, alloy, finish, form, and search apps.purchasing.models.Stock. Present matches and confirm with the user before proceeding.
actual (the job's latest actual cost set). Override if user specifies estimate or quote.unit_cost and unit_revenue from the matched Stock record. User can override.Use the proper data model. Required fields:
from apps.job.models import CostLine, CostSet, Job
from apps.purchasing.models import Stock
from django.utils import timezone
CostLine.objects.create(
cost_set=cost_set, # The job's actual CostSet
kind="material",
desc=stock_item.description, # From the Stock record
quantity=qty, # User-provided
unit_cost=stock_item.unit_cost,
unit_rev=stock_item.unit_revenue,
accounting_date=timezone.now().date(),
ext_refs={"stock_id": str(stock_item.id)}, # Links back to Stock record
meta={"consumed_by": "a9bd99fa-c9fb-43e3-8b25-578c35b56fa6"}, # Corrin Lakeland
)
scripts/, run dry first, show the user what will happen, then run live after confirmation.If the user asks to update a price or quantity on an existing line:
A standard sheet (2400x1200) is divided into a 5x2 grid of 10 segments (called "tenths"), each 480x600mm:
480 480 480 480 480
┌───────┬───────┬───────┬───────┬───────┐
│ │ │ │ │ │
600 │ 1 │ 2 │ 3 │ 4 │ 5 │
│ │ │ │ │ │
├───────┼───────┼───────┼───────┼───────┤
│ │ │ │ │ │
600 │ 6 │ 7 │ 8 │ 9 │ 10 │
│ │ │ │ │ │
└───────┴───────┴───────┴───────┴───────┘
◄─────────── 2400mm ──────────────►
When a piece is cut from a sheet, count how many segments are touched (even partially). That count is the quantity in tenths.
Examples:
The quantity field stores tenths as a decimal fraction of a whole sheet: 4 tenths = 0.4, 10 tenths = 1.0.
Always show the user the segment calculation and confirm before creating the cost line.