using System; using System.Collections.Generic; namespace MMDAL.DTO.MTR { // ── MTR Report Header (TMTRREPORT) ──────────────────────────────────────── // Root of the save/update hierarchy. Carries all 5 UI sections as children. public class MtrReportDTO { public int MtrId { get; set; } public string MtrNo { get; set; } = string.Empty; public DateOnly MtrDate { get; set; } public int DocumentId { get; set; } public int DocumentDetailId { get; set; } public int IndentId { get; set; } public int PartyId { get; set; } // Read-only display — populated by GET, ignored on Save public string? PartyName { get; set; } public int PartyBranchId { get; set; } // Read-only display — joined from MPARTYBRANCH on GET public string? PartyBranchName { get; set; } // PO details (UI Section 1) public string? PoNumber { get; set; } public DateOnly? PoDate { get; set; } // Work Order Ref public string? ReferenceNumber { get; set; } public DateOnly? ReferenceDate { get; set; } public int ItemId { get; set; } // Read-only display — populated by GET, ignored on Save public string? ItemName { get; set; } public int SkuId { get; set; } // Read-only display — joined from MSKU on GET public string? SkuName { get; set; } public decimal TotalQty { get; set; } public int UomId { get; set; } // Read-only display — joined from MUOM on GET public string? UomName { get; set; } // EN 10204 type — FK to MTR type master public int MtrTypeId { get; set; } // 0=Pending, 1=All Pass, 2=Conditional, 3=Fail — computed from source records public byte OverallResult { get; set; } public string? Remarks { get; set; } // 1=Draft, 2=Under Review, 3=Approved, 4=Issued, 5=Revised public byte ReportStatus { get; set; } // Self-ref for revised MTRs; -1 means no parent public int ParentMtrId { get; set; } = -1; // String input on UI — user types the parent MTR number (e.g. "MTR-2024-001"). // BLL resolves this to ParentMtrId before save. // On GET: populated by self-join on TMTRREPORT. public string? ParentMtrNo { get; set; } public int IssuedById { get; set; } // Read-only display — joined from MUSER on GET public string? IssuedByName { get; set; } public DateOnly? IssuedOn { get; set; } public string? MaterialSpec { get; set; } // Section 2 — Heat / Lot rows (TMTRLOT → TMTRSOURCE) public List Lots { get; set; } = new(); // Section 5 — Signatories & Approval (TMTRRESULT) public List Result { get; set; } = new(); // Section 4 — Customer PDF preferences (TMTRCLIENTPREFERENCE) public List ClientPreference { get; set; } = new(); } // ── MTR Lot (TMTRLOT) — one row per heat / lot ──────────────────────────── // HeatNumber and HeatDate are read-only display fields joined from THEAT. public class MtrLotDTO { public int MtrLotId { get; set; } public int MtrId { get; set; } public short SlNo { get; set; } // FK to THEAT; -1 when not linked to a foundry heat public int HeatId { get; set; } = -1; // Read-only display — joined from THEAT on GET, ignored on Save public string? HeatNumber { get; set; } public DateOnly? HeatDate { get; set; } // FK to TLOT; 0 when not linked public int LotId { get; set; } // Read-only display — joined from TLOT on GET public string? LotNumber { get; set; } public DateOnly? LotDate { get; set; } public DateOnly? LotExpiryDate { get; set; } // Lot/heat number as printed on MTR — auto-filled from TLOT or entered manually public string? LotReference { get; set; } public decimal Quantity { get; set; } public int UomId { get; set; } // Material grade per lot — e.g. "EN1563 GJS-400-18-LT" public string? MaterialSpec { get; set; } // 0=Pending, 1=Pass, 2=Conditional, 3=Fail — computed from source records public byte LotResult { get; set; } // Section 3 — Linked inspection / NDT records (TMTRSOURCE) public List Sources { get; set; } = new(); } // ── MTR Source (TMTRSOURCE) — linked inspection / NDT record per lot ────── public class MtrSourceDTO { public int MtrSourceId { get; set; } public int MtrLotId { get; set; } // 1=Chemical, 2=Mechanical, 3=Dimensional, 4=NDT, // 5=Heat Record, 6=Visual, 7=Hardness, 8=Inspection public byte SourceTypeId { get; set; } // INSPECTIONID or NDTREPORTID depending on SourceTypeId public int SourceRecordId { get; set; } // Auto-generated summary: "MT — RAB/MT/003 — 15/09/2025 — Acceptable (Bureau Veritas)" public string? SummaryText { get; set; } public short DisplayOrder { get; set; } // 1=Include in PDF, 0=Exclude (stays linked for audit trail) public byte IncludeInPdf { get; set; } = 1; // 1=Summary line only, 2=Results table, 3=Full report inline public byte DetailLevel { get; set; } = 1; } // ── MTR Result (TMTRRESULT) — signatories & approval (UI Section 5) ─────── // One row per MTR; MtrResultId = 0 means not yet created (will be inserted). public class MtrResultDTO { public int MtrResultId { get; set; } public int MtrId { get; set; } public int PreparedById { get; set; } // Read-only display — joined from MUSER on GET public string? PreparedByName { get; set; } public DateOnly? PreparedOn { get; set; } public int ReviewedById { get; set; } // Read-only display — joined from MUSER on GET public string? ReviewedByName { get; set; } public DateOnly? ReviewedOn { get; set; } public int ApprovedById { get; set; } // Read-only display — joined from MUSER on GET public string? ApprovedByName { get; set; } public DateOnly? ApprovedOn { get; set; } // 0=Pending, 1=All Pass, 2=Conditional, 3=Fail public byte OverallResult { get; set; } public string? Remarks { get; set; } } // ── MTR Client Preference (TMTRCLIENTPREFERENCE) — UI Section 4 ────────── // Keyed by PartyId + ItemId (ItemId = -1 = wildcard for all items). // ClientPreferenceId = 0 means no existing preference — will be inserted. // On Save/Update the record is upserted (insert if new, update if exists). public class MtrClientPreferenceDTO { public int ClientPreferenceId { get; set; } public int PartyId { get; set; } // Read-only display — joined from MPARTY on GET public string? PartyName { get; set; } // -1 = applies to all items for this party (wildcard) public int ItemId { get; set; } = -1; // Read-only display — joined from MITEM on GET public string? ItemName { get; set; } public int MtrFormatId { get; set; } // Read-only display — joined from TMTRFORMAT on GET public string? FormatName { get; set; } // Customer's preferred EN 10204 type public int PreferredMtrTypeId { get; set; } // 0=English, 1=Tamil, 2=Hindi, 3=French, 4=Arabic, 5=Chinese, 6=Spanish public byte ReportLanguage { get; set; } // Section visibility toggles public byte ShowChemical { get; set; } = 1; public byte ShowMechanical { get; set; } = 1; public byte ShowDimensional { get; set; } public byte ShowNdt { get; set; } public byte ShowVisual { get; set; } public byte ShowSignatureBlock { get; set; } = 1; // Detail preferences // 1=Certificate number only, 2=Summary line, 3=Full parameter detail public byte NdtDetailLevel { get; set; } = 1; // JSON array e.g. ["C","Si","Mn","P","S","Mg","Cr","Ni","Mo","Cu","CE","Ti"] public string? ChemColumns { get; set; } // JSON array e.g. ["TS","YS","EL","HB","IS"] public string? MechColumns { get; set; } // 1=Show each lot separately, 0=Combine all lots into one block public byte ShowLotHeatDetail { get; set; } = 1; // 1=MTR requires customer witness before status goes to Issued public byte RequireCustomerSignoff { get; set; } // Customer-specific declaration text at bottom of MTR public string? CustomFooterText { get; set; } // Customer's own numbering format e.g. "ABC-MTR-YYYY-NNN" public string? MtrNoNumberingPattern { get; set; } } // ── MTR Format (TMTRFORMAT) — PDF layout template ───────────────────────── public class MtrFormatDTO { public int MtrFormatId { get; set; } public string FormatName { get; set; } = string.Empty; // 1=Single page consolidated, 2=Section-per-page, // 3=Cover+attachments, 4=Custom template public byte LayoutType { get; set; } public string? TemplateFile { get; set; } public byte ShowLogoHeader { get; set; } public byte ShowSignatureBlock { get; set; } // -1 = system-wide default public int ClientId { get; set; } = -1; } // ── Picklist DTO — lightweight select-list for dropdowns ───────────────── public class MtrPicklistDTO { public int MtrId { get; set; } public string MtrNo { get; set; } = string.Empty; public string MtrDate { get; set; } = string.Empty; } // ── List DTO — flat summary for paginated grid ──────────────────────────── // All *Name / *Code fields are joined from master tables in GET_MTR_LIST. public class MtrListDTO { public int MtrId { get; set; } public string MtrNo { get; set; } = string.Empty; public DateOnly MtrDate { get; set; } public int ItemId { get; set; } public string? ItemName { get; set; } public int PartyId { get; set; } public string? PartyName { get; set; } public decimal TotalQty { get; set; } public string? UomCode { get; set; } public string? UomName { get; set; } // 0=Pending, 1=All Pass, 2=Conditional, 3=Fail public byte OverallResult { get; set; } // 1=Draft, 2=Under Review, 3=Approved, 4=Issued, 5=Revised public byte ReportStatus { get; set; } public int LotCount { get; set; } } }