@model PowderCoating.Core.Entities.VendorCredit @using PowderCoating.Core.Enums @{ ViewData["Title"] = $"Vendor Credit {Model.CreditNumber}"; var accountMap = ViewBag.AccountMap as Dictionary ?? new(); var billMap = ViewBag.BillMap as Dictionary ?? new(); var openBills = ViewBag.OpenBills as List ?? new(); bool canApply = Model.Status is VendorCreditStatus.Open or VendorCreditStatus.PartiallyApplied; }
Back

@Model.CreditNumber

@{ var (badgeClass, label) = Model.Status switch { VendorCreditStatus.Open => ("bg-success", "Open"), VendorCreditStatus.PartiallyApplied => ("bg-warning text-dark", "Partially Applied"), VendorCreditStatus.Applied => ("bg-secondary", "Applied"), VendorCreditStatus.Voided => ("bg-danger", "Voided"), _ => ("bg-secondary", Model.Status.ToString()) }; } @label
@if (Model.Status == VendorCreditStatus.Open) {
@Html.AntiForgeryToken()
} @if (Model.Status != VendorCreditStatus.Voided && Model.Status != VendorCreditStatus.Applied) {
@Html.AntiForgeryToken()
}
@if (TempData["Success"] != null) {
@TempData["Success"]
} @if (TempData["Error"] != null) {
@TempData["Error"]
}
Credit Number
@Model.CreditNumber
Vendor
@Model.Vendor?.CompanyName
Date
@Model.CreditDate.ToString("MMMM d, yyyy")
AP Account
@Model.APAccount?.AccountNumber – @Model.APAccount?.Name
@if (!string.IsNullOrWhiteSpace(Model.Memo)) {
Memo
@Model.Memo
}
@Model.Total.ToString("C")
Total Credit
@if (Model.RemainingAmount > 0) {
@Model.RemainingAmount.ToString("C")
Remaining
} else {
Fully Applied
}
Line Items
@foreach (var line in Model.LineItems) { }
Account Description Amount
@if (line.AccountId.HasValue && accountMap.TryGetValue(line.AccountId.Value, out var acct)) { @acct } else { } @line.Description @line.Amount.ToString("C")
Total @Model.Total.ToString("C")
@if (Model.Applications.Any()) {
Applied To
@foreach (var app in Model.Applications.OrderByDescending(a => a.AppliedDate)) { }
Bill Applied Date Amount
@if (billMap.TryGetValue(app.BillId, out var billNum)) { @billNum } else { #@app.BillId } @app.AppliedDate.ToLocalTime().ToString("MMM d, yyyy") @app.Amount.ToString("C")
} @if (canApply && openBills.Any()) {
Apply to a Bill
@foreach (var bill in openBills) { var maxApply = Math.Min(Model.RemainingAmount, bill.BalanceDue); }
Bill Due Date Balance Due Apply Amount
@bill.BillNumber @Html.Raw(bill.DueDate?.ToString("MMM d, yyyy") ?? "—") @bill.BalanceDue.ToString("C")
@Html.AntiForgeryToken()
$
} else if (canApply) {
No open bills found for this vendor to apply the credit against.
}