BUSINESS.md — domain model for the greige fabric system
This document captures how the system must model the business: greige (grey) fabric woven from yarn, with an in-house weaving unit, outsourced sizing, and outsourced weaving at local weavers. Read this before building any module — every screen and report hangs off these entities and formulas.
1. Core entities
| Entity | What it is | Key fields |
|---|---|---|
Yarn (yarn_master) |
raw material master | type (warp / weft / both), count (Ne), quality/party, supplier preference, current rate |
Construction (construction_master) |
the fabric recipe | name (e.g. "20×16 64×48 63""), reed space (inches), EPI, PPI, warp count, weft count, warp crimp %, weft crimp %, size pickup %, width (mtrs), theoretical GSM |
| PO (yarn purchase) | buying yarn | supplier, yarn, count/qty (kgs), rate, promised date, status (open/partial/closed/cancelled) |
| PO delivery | receipts against a PO | lot no., received kgs, date, supplier challan no., quality check result |
| Yarn lot / stock | physical stock | PO link, in kgs, location (godown), status: in-transit → available → allocated/committed → in-process (sizing/weaving) → consumed |
| Allocation | which lot is assigned to which SO (editable any time) | lot, SO line, kgs, is sizing consumed?, created/edited by, history |
| SO (fabric sale order) | customer order — order-driven or stock-driven mode | customer, quality + design, qty (mtrs OR beams) + Taga/lumps, delivery form + per-piece mtr, rate, market-dhara payment terms, promised completion days (sales promise), amendments, status |
| Job-work contract | party-material conversion order | party, Party Contract No, loom class (e.g. Airjet 190/250), quality/design, qty mtrs OR beams (brim-filled beam assumption), jobRate ₹/pick → Rate ₹/m = jobRate×picks (market rate, NO costing), payment days, tolerance/amendments, status + hishob flags |
| Stock/production order (stock-driven mode) | internal make-to-stock demand — an SO-shaped order with NO customer | design, mtrs target, stock trigger, drives yarn/beams/weaving like an SO; sells later from FG stock (avg-cost) |
| Sample | small-order path (drawn from sample stock or woven on order) | party, design, qty, charged/waived (explicit waive action), result |
| Sample | strike-off / sample sent to a party | construction, qty (mtrs), party, sent date, purpose (approval/lead), follow-up, result |
| Lead | new enquiry pipeline | party, construction, qty, expected price, source, status (new → quoted → follow-up → order / lost), last activity |
| Beam | warp beam (after warping/sizing) — flange no = physical id (movements); beam no = system production id (inward→fabric) | construction-warp, ends, length, sized?, kgs, flange+beam no, unit, status |
| Parts | warping beams a single finished beam's ends split into (krill-bound) | f(total ends, warp mtrs, krill, cone measure), soft |
| Sizing job | outsourced sizing order | beams to size, unit (sizer), kgs/vs/mtr basis, rate, out-date, in-date (sized beams returned) |
| Weaving job | weaving order placed on a unit | beams, construction, meters to weave, unit (inhouse/out-house), rate, target date |
| Production entry | meters woven per day per job | job, unit, date, mtrs, beam consumed (partial), off-standard note |
| Checking / grading | post-weave inspection | job/piece, mtrs checked, grade (A/B/C/seconds), defect points per 100 m, checked-by, date |
| Dispatch / delivery | goods out | SO line, grade, mtrs, date, vehicle/challan no., party challan |
| Hishob statement (job-work) | yarn-given vs fabric-delivered reconciliation PER CONTRACT, issued with the contract's last dispatch | contract, yarn in (kgs/lots), fabric out (mtrs/grade), balance, status pending→sent→accepted |
| Park-lot yarn | material received before its contract exists | unmarked placeholder lots, assigned to a contract later (soft) |
| Beam-out intimation / outward | planning marks beam nos per contract (intimation); gate guard taps the same list on outward | contract, beam nos, tap-out events, transporter pickup |
| Gatepass | yarn dispatch note (trader→godown, endorsed to transporter/sizer/weaver) | source/target, count+ticket, bags, gross/net, image, status entered→picked→delivered→confirmed |
| Direct-delivery intimation | precursor for direct deliveries (trader unloads at our premises or named sizer godown), closes with delivery confirmation | expected count/bags, destination, date; evidence + WhatsApp confirm |
| Reservation (verbal) | soft stock hold on verbal commitment — a tag, not an allocation | lot, order, qty, by/expiry, converts on confirm, auto-drops |
| Krill / creel | winding machine min–max cones it can hold | per-winder master (krill size) |
| Loomgate adapter | machine vendor SQL Server → their Supabase → our adapter → loom events (picks/RPM/breaks/stops/doffs, serial↔machine, beam info) | adapter + event log (idempotent) |
| Sizing tippan | plan/intimation to sizing: construction + yarn usage (at sizer/gatepass) + target weaver + pick-up intimation + beam count | tippan doc; system proposes, planner confirms |
| Weaver yarn account | job-work: saved weft (5% allowance − efficiency) transferred to weaver-owned | transfer event + kgs; weaver sells later |
| Out-house beam ledger | per-beam production tracking at sizer/weaver (gatepass copies) — never mixes in-house beam stock | separate tracking space |
| WIP roll (doff) | machine roll-doff event → WIP barcode (printed at checking gate) tracked checking→FG→dispatch; reconciles beam warp vs fabric mtrs | doff event + barcode |
| Beam-end reason & disposition | beam end (warped-out) vs cut beam: manual warp DRAWING (weight+return form), re-sizing return, defective warp removed→weighed→returned to party, JOB-RATE renegotiation (contract amendment) — each affects reconciliation |
end event + disposition + linked forms/amendments |
| Knotting / Gatting | same-warp = knot (fast); different warp = gate; marked per new beam; feeds changeover/downtime reports | beam-start event |
| Party yarn loan | weft issued from party-2 to run party-1's beam (same count); netted inter-party owed at close | loan events, netted |
| Rounder collect | out-house daily data (machine meters, mended mtrs) | daily collect entry |
| Bale | 5–6 lumps tied + poly bag; bale barcode. Dispatch by mode: job-work lumps unbaled; TRADING lumps baled; out-house inwarded AS-IS → bales created in-system → barcode dispatch | bale entity + barcode + mode rule |
| Defect master + grades | defect list (points per 4-point system for mending-IoT later); manual grades NOW: A/B/C/R | master + grade field |
| L2L / lasa | lasa = sizer's warp marks (~110 m); L2L = their distance in fabric → warp shrinkage = (lasa−L2L)/lasa; sampled per batch on checking report; RS-on-loom measured loom-wise | checking sample rows |
The central rule: yarn is bought and stocked in kgs, fabric is sold and woven in mtrs. Every planning screen converts between the two using the construction's recipe (see §3). Double-entry in different units is the #1 source of errors in this trade — the system must never ask the user to enter a conversion factor by hand.
2. Stock & apportionment model (the "how much to procure" question)
Two procurement scenarios, one stock model:
- Order-driven: SO confirmed → system computes yarn requirement (kgs) → suggests how much to buy beyond what is free in stock.
- Market-driven: yarn is bought on market trend → sits in stock → later apportioned against future SOs.
The stock ledger for each yarn (count/quality):
in-transit (PO placed, not received)
+ available (received, uncommitted) ← the "free stock" number to buy against
+ allocated (soft-assigned to SOs) ← editable at runtime
= gross stock
- Allocations are soft: a planner may un-assign a lot from SO-A and assign it to SO-B at any time. Every assignment change is logged (who/when/from-to), because it affects both stock views and order fulfilment promises.
- Demand visibility: for each SO line, show
requirement (kgs) − allocated (kgs) = still-to-procure (kgs), and in the yarn stock screen showavailable + allocated + in-transitper yarn so procurement sees one number to act on. - When a lot moves into sizing/weaving (consumed), its kgs leave
available/allocatedonly when actually issued (issue slip). Until then it stays allocatable — the runtime re-assignment requirement.
3. Conversions & formulas (kgs ↔ mtrs)
Locked to the owner's costing sheet — it is the reference implementation, verified cell-by-cell (see docs/COSTING.md); this section summarises it and supersedes earlier drafts.
Constants: count system Ne (English count) with a denier branch for
polyester; kg per 1000 m of a yarn of count Ne = 0.5905 / Ne.
3.1 Yarn required for an order (given construction + mtrs)
Per the costing sheet (ends = Reed × WarpReedSpace; warp allowance via
Lasa/L2L ≈ 1.055; weft waste % on top):
total ends (warp) = reed × warpReedSpace(in) (allow manual override)
warp kg/m = ends × 0.5905/Ne_warp × K_warp/1000 (K_warp ≈ Lasa/L2L)
weft kg/m = Pick×39.37 × weftReedSpace(m) × 0.5905/Ne_weft / 1000
weft kg/m (with 5%) = weft kg/m × (1 + WeftWaste%)
sized warp kg/m = warp kg/m × (1 + SizingWajanVaad%) (×1.10 typical)
fabric weight kg/m = sizedWarp + weftBase (informational)
costing weight kg/m = warp(unsized) + weft(with waste) ← GSM/GLM/costing basis
order requirement = warpKgPerM × order_mtrs + weftKgPerM(with waste) × order_mtrs
(+ any beam/warping allowances entered per contract)
3.2 Sizing (warp must be sized before weaving)
- Warp is warped on a warp beam (total ends × beam length, kgs from 3.1 for the beam length).
- Sizing adds Sizing Wajan Vaad % (10% typical) and is charged per kg
of greige warp (23 ₹/kg in the sheet):
sized warp kg = greige kg × (1 + pickup%); sizing charge = greige kg × rate. - The beam is the unit of hand-over (ends + length + cuts + cut-mark); kgs are computed for accounting; "Used kgs" on the sizing receipt returns actual consumption.
3.3 Weaving (in-house unit or outsourced)
- Meters of fabric obtainable from a beam:
fabric mtrs per beam = beam_length / (1 + warp_crimp)(minus leader/waste). - Capacity planning: each unit (in-house machines × sets, or an out-house weaver) gets a Weaving job = beams + construction + meters target + per-day production entries. Assignment of sized beams to in-house vs out-house is a planning decision, editable until production starts.
- Once a beam starts weaving, it is "in-process" and cannot be re-assigned.
- Production pickup: manual daily entry (Phase 2); ERP integration for partner weavers (Phase 5).
3.4 Checking / grading & GSM sanity
- After weaving, greige fabric goes to the checking table: mtrs checked, defects recorded (per 100 m points), grade assigned (A / B / C / seconds).
- Checking report is generated in-system (date, unit, beam/job, mtrs, grade-wise summary, defect list) and is printable.
- GSM check: measured GSM at checking is compared against the design's GLM/GSM basis (per the costing sheet conventions — COSTING.md §4, widths to be confirmed) and the computed weight for costing; the checking report shows all three.
- Dispatch happens by grade: an SO line can be fulfilled with graded mtrs; the system tracks delivered mtrs per grade against the SO.
4. Flow map (end to end)
Lead/enquiry ──► quote ──► SO (mtrs, construction, schedule)
│ │
│ yarn requirement (kgs, §3.1)
│ │
│ ┌───────────┴────────────┐
│ order-driven PO market-driven stock purchase
│ └───────────┬────────────┘
│ yarn lots in stock (kgs)
│ │ soft allocations (editable)
│ ▼
│ warping ──► sizing job (out-house) ──► sized beams
│ │
│ ▼
│ weaving job: in-house unit OR out-house weaver
│ │ production entries (mtrs/day)
│ ▼
│ checking ──► grade ──► checking report
│ │
│ ▼
│ dispatch/delivery by grade ──► SO delivery tracking
└── samples to parties (strike-offs) at any design stage
Order model — owner rules (rounds 2–3, 2026-09-01)
- Quantity unit is mtrs OR beams (either per contract). Beam-quantum assumes beams received filled to the brim; beam capacity varies by construction, so beams-mode contracts are common. Order lines carry the chosen unit.
- Warp vs weft legs: yarn is tagged warp|weft as a SOFT label at receipt — changeable until actual usage/sizing-outward, never locked at inward. Warp goes sizing+beam-fill; weft used direct. Job-work: no yarn booking — yarn arrives via gatepass; party's filled beams + weft in parts, concurrent. Out-house: sizing picks weaver's empty beams, fills, returns to weaver; weaver takes weft from us.
- Sizing-set no: tracks beams from one sizing set + its yarn/fabric to the end; assigned at sizing-set issue (trading) or beam inward (job-work) — NOT at yarn inward. Yarn is marked to a CONTRACT (JW contract / SO / internal production order), not to a set.
- Booking (trading only): count + TICKET (mill) chosen by suggestion; bags × fixed packaging (cones/bag, bag wt → per-cone wt) prefilled from history; warp bag-counts are SIZING-SET multiples (construction × ends ÷ per-cone wt).
- Lots & shade: every yarn inward carries a LOT NO (from gatepass); a sizing set's warp must come from a SINGLE lot (shade-consistency rule, enforced at tippan/issue). Beams can be REASSIGNED to another contract (cancelled orders) and transferred sizer→sizer via intimation (like a GP). ALL in/out movements carry a VEHICLE NO (gate-camera OCR of the number plate; typed fallback; driver face/biometric = future door access control).
- Bag barcodes (QR, mobile-scannable): gate guard scans the transporter's inward code (from gatepass), picks partial/all, the system PRINTS bag barcodes (party, construction, contract no, count, ticket, wt) the transporter applies while unloading; every later movement scans the bag and states cones moved → weft-usage tracking basis.
- Job-work pricing: JobRate = ₹/pick; Rate ₹/m = JobRate × picks; rate is market (demand/supply) — no costing sheet in job-work. The costing engine is trading-side only.
- Quality vs Design: quality = the fabric's name/sales identity; design = the actual construction snapshot (a quality has many designs: pick changes frequently). Contracts map to quality; production maps to the specific design (party's most-used design prefilled). New model: versioned designs under a quality, no id-sprawl.
- Costing supports multiple warps & wefts in one construction (W1/W2…, F1/F2… with % splits and per-row rates/GST toggles — the sheet's Warp-2/Weft-2 rows). Quote carries a LAST-QUOTE cross-check panel.
- Yarn rate board (procurement manager): daily rates per count/ticket, ingested from rate-list images/WhatsApp msgs via share-target + OCR with clarification queue; feeds quotes (prefill) and trend analytics.
- Two trading modes: (1) against order — SO precedes production, P&L per SO is direct; (2) stock & sell — produce into finished goods stock (stock/production order drives yarn/beams), sell later; profitability uses a lot-cost valuation method (FIFO/avg — method to be decided) on FG stock: each production lot carries its lane cost (yarn + conversion), dispatch consumes stock, COGS per the chosen method, profit computed vs sale rate. Yarn-rate board + trend feeds the stock-mode buy timing.
- Brokerage: brokerage% with a passed-on to buyer / kept with us split. When the broker passes part to the buyer: bill CD% = contract CD% + passed-on brokerage; the kept portion opens/feeds the broker's account (statement).
- Order kinds now four: trading SO (with MODE flag MTO|stock prefilled per quality + LOT SIZE memory per party+quality), job-work contract (party conversion), outsourced-weaving contract (same forward→OCR→ prefill drill; feeds planning out-house section + tippan), production order (stock). Sample REQUEST form is capture-fed and approved.
- Amendments (B2.6 suggestion): an amendment object on the contract (line before/after, reason-code: sizing-set spillover, party requirement change…; auto-flag when a sizing receipt creates an extra beam beyond contract count). A small deviation inside tolerance (Diff. Mtr./Diff. Beam.) auto-adjusts; beyond tolerance requires an approve action. Amendments are logged, never rewritten.
- Sample path: request is capture-fed & approved → auto-creates a DISPATCH INTIMATION (courier leg; runner due-list, printable party sticker, courier receipt OCR'd for tracking); rate prefills from the quality's recent order rate (new quality → ask); charge waiver ≤ ₹1000 by user, beyond → owner approval, else billing via Tally.
- Sample path: separate small-order flow; draw from sample stock (pieces kept from previous productions — today untracked) or weave on order; sample charge auto-priced, explicit waive action required for small/waived samples.
- Two date families: SO promised completion days (sales promise); production target vs actual completion (planning metric, separate — to be defined later).
The system is a tracking + planning system, not a financial ledger: costing/billing remain outside (export hooks later if wanted).
5. Local working style (design for zero-friction adoption)
- Terminology and units on screens: use the shop-floor words (kgs, mtrs, pieces/rolls, beam, sets, challan). Sanity-check glossary in Phase 0 with staff (see open questions below).
- Challan printouts: every in/out movement (yarn issue, sized beams, fabric dispatch) prints an issue/receipt challan — this is how the godown and units actually talk to each other.
- Mobile-first entry: floor staff (sizing unit, weavers) should be able to log production/auctions from a phone in 2–3 taps; desktop is for planning screens (procurement, apportionment, reports).
- Big obvious buttons / minimal forms, local language labels (see questions), tolerant of partial data (save-draft on movements).
- Everything printable: PO, SO, picking/issue lists, checking report, delivery challan.
- Audit trail on allocations — the owner re-assigns stock; staff must see why numbers changed.
6. Open questions — answer these before/during Phase 0–1
- Count system: yarn counts in Ne (English) as assumed, or are some yarns in tex/denier? (Stripe/fancy constructions may mix.)
- Defaults to validate: warp crimp & weft crimp %, process waste %, size pickup % — I'll put local mill values in, or as-adjustable defaults?
- Width measure: reed space (loom width in inches) — confirm this is how the mill quotes construction (e.g. "20×16 64×48 63"").
- Weavers' ERP: which ERP/filename do the local weavers run (e.g. a known loom-factory package, Excel sheets, WhatsApp)? Phase 5 integration is far cheaper if we know the format now.
- Language: should screen labels be Hindi/vernacular with English fallback, or English first?
- Who enters what: which staff roles (owner, planner, godown, checking clerk, each weaving unit) exist today, and who is willing to type daily entries? This decides screen design per role.
- Scale: approximate orders/week, active constructions, number of beams in flight — to size tables and reports.
(These stay open until you answer; the plan below does not block on them.)