Files
PowderCoatingLogix/src/PowderCoating.Web/Views/Accounts/Edit.cshtml
T
2026-04-23 21:38:24 -04:00

166 lines
11 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
@model PowderCoating.Application.DTOs.Accounting.EditAccountDto
@{
ViewData["Title"] = "Edit Account";
ViewData["PageIcon"] = "bi-pencil-square";
ViewData["PageHelpTitle"] = "Edit Account";
ViewData["PageHelpContent"] = "You can change number, name, type, sub-type, parent, and opening balance. Changing the account type or sub-type on an account that already has transactions is allowed but use caution — it changes how balances are reported going forward. Inactive accounts are hidden from pickers but preserved in history.";
}
<div class="d-flex justify-content-start mb-4">
<a asp-action="Index" class="btn btn-sm btn-outline-secondary"><i class="bi bi-arrow-left"></i></a>
</div>
<div class="row justify-content-center">
<div class="col-lg-7">
<div class="card shadow-sm">
<div class="card-body">
<form asp-action="Edit" method="post">
@Html.AntiForgeryToken()
<input asp-for="Id" type="hidden" />
<div asp-validation-summary="ModelOnly" class="alert alert-danger mb-3"></div>
<div class="row g-3">
<div class="col-sm-4">
<div class="d-flex align-items-center gap-1 mb-1">
<label asp-for="AccountNumber" class="form-label fw-medium mb-0">Account Number <span class="text-danger">*</span></label>
<a tabindex="0" class="help-icon" role="button"
data-bs-toggle="popover" data-bs-placement="right" data-bs-trigger="focus"
data-bs-title="Account Number"
data-bs-content="A numeric code for sorting and organizing accounts. Convention: 10001999 Assets, 20002999 Liabilities, 30003999 Equity, 40004999 Revenue, 50005999 Cost of Goods, 60009999 Expenses. Must be unique.">
<i class="bi bi-question-circle"></i>
</a>
</div>
<input asp-for="AccountNumber" class="form-control" />
<span asp-validation-for="AccountNumber" class="text-danger small"></span>
</div>
<div class="col-sm-8">
<label asp-for="Name" class="form-label fw-medium">Account Name <span class="text-danger">*</span></label>
<input asp-for="Name" class="form-control" />
<span asp-validation-for="Name" class="text-danger small"></span>
</div>
<div class="col-sm-6">
<div class="d-flex align-items-center gap-1 mb-1">
<label asp-for="AccountType" class="form-label fw-medium mb-0">Account Type <span class="text-danger">*</span></label>
<a tabindex="0" class="help-icon" role="button"
data-bs-toggle="popover" data-bs-placement="right" data-bs-trigger="focus"
data-bs-title="Account Type"
data-bs-content="Asset: things you own. Liability: things you owe. Equity: owner's investment and retained earnings. Revenue: income from sales. Cost of Goods Sold: direct production costs. Expense: operating overhead. Changing this on an account with existing transactions affects how it appears in financial reports.">
<i class="bi bi-question-circle"></i>
</a>
</div>
<select asp-for="AccountType" asp-items="ViewBag.AccountTypes" class="form-select" id="accountTypeSelect"></select>
<span asp-validation-for="AccountType" class="text-danger small"></span>
</div>
<div class="col-sm-6">
<div class="d-flex align-items-center gap-1 mb-1">
<label asp-for="AccountSubType" class="form-label fw-medium mb-0">Sub-Type <span class="text-danger">*</span></label>
<a tabindex="0" class="help-icon" role="button"
data-bs-toggle="popover" data-bs-placement="right" data-bs-trigger="focus"
data-bs-title="Account Sub-Type"
data-bs-content="A finer classification that determines where the account appears in pickers. For example, only Checking and Savings sub-types appear in the 'Paid From' selector on expenses. Choosing a sub-type also auto-sets the Account Type.">
<i class="bi bi-question-circle"></i>
</a>
</div>
<select asp-for="AccountSubType" asp-items="ViewBag.AccountSubTypes" class="form-select" id="accountSubTypeSelect"></select>
<span asp-validation-for="AccountSubType" class="text-danger small"></span>
<div class="form-text text-primary" id="typeAutoSetHint" style="display:none">
<i class="bi bi-magic me-1"></i>Account type auto-set based on sub-type.
</div>
</div>
<div class="col-12">
<label asp-for="Description" class="form-label fw-medium">Description</label>
<textarea asp-for="Description" class="form-control" rows="2"></textarea>
</div>
<div class="col-12">
<div class="d-flex align-items-center gap-1 mb-1">
<label asp-for="ParentAccountId" class="form-label fw-medium mb-0">Parent Account</label>
<a tabindex="0" class="help-icon" role="button"
data-bs-toggle="popover" data-bs-placement="right" data-bs-trigger="focus"
data-bs-title="Parent Account"
data-bs-content="Nest this account under a parent to create a hierarchy — e.g. 'Powder Costs' under 'Cost of Goods Sold'. Sub-accounts roll up into their parent on financial reports. Most accounts work fine without a parent.">
<i class="bi bi-question-circle"></i>
</a>
</div>
<select asp-for="ParentAccountId" asp-items="ViewBag.ParentAccounts" class="form-select">
<option value="">— None —</option>
</select>
</div>
<div class="col-12">
<hr class="my-1" />
<p class="text-muted small mb-2">
<i class="bi bi-info-circle me-1"></i>
Opening balance represents the account's value before transactions were recorded in this system.
</p>
</div>
<div class="col-sm-6">
<div class="d-flex align-items-center gap-1 mb-1">
<label asp-for="OpeningBalance" class="form-label fw-medium mb-0">Opening Balance</label>
<a tabindex="0" class="help-icon" role="button"
data-bs-toggle="popover" data-bs-placement="right" data-bs-trigger="focus"
data-bs-title="Opening Balance"
data-bs-content="The account's balance before transactions were recorded in this system. Changing this retroactively adjusts the running balance across all historical ledger entries. Set the As of Date to indicate when this balance was accurate.">
<i class="bi bi-question-circle"></i>
</a>
</div>
<div class="input-group">
<span class="input-group-text">$</span>
<input asp-for="OpeningBalance" class="form-control" type="number" step="0.01" min="0" placeholder="0.00" />
</div>
<span asp-validation-for="OpeningBalance" class="text-danger small"></span>
</div>
<div class="col-sm-6">
<label asp-for="OpeningBalanceDate" class="form-label fw-medium">As of Date</label>
<input asp-for="OpeningBalanceDate" class="form-control" type="date" />
<div class="form-text">Leave blank to apply before all transactions.</div>
</div>
<div class="col-12">
<div class="form-check form-switch">
<input asp-for="IsActive" class="form-check-input" type="checkbox" />
<label asp-for="IsActive" class="form-check-label">Active</label>
</div>
</div>
</div>
<div class="d-flex gap-2 mt-4">
<button type="submit" class="btn btn-primary">
<i class="bi bi-check-lg me-1"></i>Save Changes
</button>
<a asp-action="Index" class="btn btn-outline-secondary">Cancel</a>
</div>
</form>
</div>
</div>
</div>
</div>
@section Scripts {
@{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
<script>
// Auto-set AccountType when SubType is changed
const subTypeToAccountType = {
1: 1, 2: 1, 3: 1, 4: 1, 5: 1, 6: 1, 7: 1, // Asset
10: 2, 11: 2, 12: 2, 13: 2, // Liability
20: 3, 21: 3, // Equity
30: 4, 31: 4, 32: 4, // Revenue
40: 5, // CostOfGoods
50: 6, 51: 6, 52: 6, 53: 6, 54: 6, 55: 6, 56: 6,
57: 6, 58: 6, 59: 6, 60: 6, 61: 6, 62: 6, 63: 6, 99: 6 // Expense
};
document.getElementById('accountSubTypeSelect').addEventListener('change', function () {
const mapped = subTypeToAccountType[parseInt(this.value)];
if (mapped) {
document.getElementById('accountTypeSelect').value = mapped;
document.getElementById('typeAutoSetHint').style.display = '';
} else {
document.getElementById('typeAutoSetHint').style.display = 'none';
}
});
</script>
}