@model PowderCoating.Application.DTOs.Inventory.InventoryLedgerViewModel @using PowderCoating.Application.DTOs.Inventory @{ ViewData["Title"] = "Inventory Activity"; ViewData["PageIcon"] = "bi-clock-history"; var activeTab = Context.Request.Query["tab"].ToString(); if (string.IsNullOrEmpty(activeTab)) activeTab = "transactions"; } @section Styles { }
@if (!string.IsNullOrEmpty(Model.SelectedItemName)) {
@Model.SelectedItemSku — @Model.SelectedItemName
}
Back to Inventory
@* ── Filter Bar ─────────────────────────────────────────────── *@
@* ── Summary Pills ───────────────────────────────────────────── *@
@Model.TotalPurchased.ToString("N2")
lbs Received
@Model.TotalUsed.ToString("N2")
lbs Used / Sold
@(Model.TotalAdjusted >= 0 ? "+" : "")@Model.TotalAdjusted.ToString("N2")
lbs Adjusted
@Model.Transactions.Count
Transactions
@Model.PowderUsageLogs.Count
Usage Records
@* ── Tabs ─────────────────────────────────────────────────────── *@ @* ── Transactions Tab ─────────────────────────────────────────── *@
@if (!Model.Transactions.Any()) {
No transactions found for the selected filters.
} else {
@if (!Model.InventoryItemId.HasValue) { } @foreach (var t in Model.Transactions) { @if (!Model.InventoryItemId.HasValue) { } }
DateItemType Qty Unit Cost Total Balance After Reference Notes
@t.TransactionDate.Tz(ViewBag.CompanyTimeZone as string).ToString("MM/dd/yyyy h:mm tt") @t.ItemName
@t.SKU
@t.TransactionType @(t.Quantity >= 0 ? "+" : "")@t.Quantity.ToString("N2") @t.UnitCost.ToString("C") @t.TotalCost.ToString("C") @t.BalanceAfter.ToString("N2") @if (t.PurchaseOrderId.HasValue) { @(t.PurchaseOrderNumber ?? $"PO #{t.PurchaseOrderId}") } else if (t.JobId.HasValue) { @(t.JobNumber ?? t.Reference ?? $"Job #{t.JobId}") } else if (!string.IsNullOrEmpty(t.Reference)) { @t.Reference } else { } @t.Notes @if (t.TransactionType == "JobUsage" || (t.TransactionType == "Adjustment" && t.PurchaseOrderId == null)) { }
@if (Model.Transactions.Count == 500) {

Showing the 500 most recent transactions. Use filters to narrow results.

} }
@* ── Usage Tab ────────────────────────────────────────────────── *@
@if (!Model.PowderUsageLogs.Any()) {
No powder usage records found for the selected filters.
} else {
@if (!Model.InventoryItemId.HasValue) { } @foreach (var u in Model.PowderUsageLogs) { var variance = u.VarianceLbs; @if (!Model.InventoryItemId.HasValue) { } }
Date Job CustomerPowderColor / Coat Estimated (lbs) Actual (lbs) Variance Notes
@u.RecordedAt.Tz(ViewBag.CompanyTimeZone as string).ToString("MM/dd/yyyy") @if (u.JobId > 0) { @u.JobNumber } else { No job assigned } @u.CustomerName @if (u.InventoryItemId.HasValue) { @u.ItemName
@u.SKU
} else { Custom/External }
@(u.CoatColor ?? "—") @u.EstimatedLbs.ToString("N3") @u.ActualLbsUsed.ToString("N3") @(variance > 0 ? "+" : "")@variance.ToString("N3") @u.Notes @if (u.SourceTransactionId.HasValue) { }
Totals @Model.PowderUsageLogs.Sum(u => u.EstimatedLbs).ToString("N3") @Model.PowderUsageLogs.Sum(u => u.ActualLbsUsed).ToString("N3") @(Model.PowderUsageLogs.Sum(u => u.VarianceLbs) > 0 ? "+" : "")@Model.PowderUsageLogs.Sum(u => u.VarianceLbs).ToString("N3")
@if (Model.PowderUsageLogs.Count == 500) {

Showing the 500 most recent usage records. Use filters to narrow results.

} }
@* ── Edit Usage Modal ─────────────────────────────────────────────── *@ @section Scripts { }