Initial commit

This commit is contained in:
2026-04-23 21:38:24 -04:00
commit 63e12a9636
1762 changed files with 1672620 additions and 0 deletions
@@ -0,0 +1,90 @@
using PowderCoating.Core.Enums;
using System.ComponentModel.DataAnnotations;
namespace PowderCoating.Application.DTOs.Accounting;
public class AccountListDto
{
public int Id { get; set; }
public string AccountNumber { get; set; } = string.Empty;
public string Name { get; set; } = string.Empty;
public AccountType AccountType { get; set; }
public AccountSubType AccountSubType { get; set; }
public bool IsSystem { get; set; }
public bool IsActive { get; set; }
public int? ParentAccountId { get; set; }
public string? ParentAccountName { get; set; }
public decimal OpeningBalance { get; set; }
public DateTime? OpeningBalanceDate { get; set; }
public decimal CurrentBalance { get; set; }
}
public class AccountDto : AccountListDto
{
public string? Description { get; set; }
public DateTime CreatedAt { get; set; }
public List<AccountListDto> SubAccounts { get; set; } = new();
}
public class CreateAccountDto
{
[Required, MaxLength(20)]
public string AccountNumber { get; set; } = string.Empty;
[Required, MaxLength(150)]
public string Name { get; set; } = string.Empty;
[Required]
public AccountType AccountType { get; set; }
[Required]
public AccountSubType AccountSubType { get; set; }
public string? Description { get; set; }
public int? ParentAccountId { get; set; }
public bool IsActive { get; set; } = true;
[Display(Name = "Opening Balance")]
public decimal OpeningBalance { get; set; } = 0;
[Display(Name = "Opening Balance Date")]
[DataType(DataType.Date)]
public DateTime? OpeningBalanceDate { get; set; }
}
public class EditAccountDto : CreateAccountDto
{
public int Id { get; set; }
}
public class LedgerEntryDto
{
public DateTime Date { get; set; }
public string Reference { get; set; } = string.Empty;
public string Source { get; set; } = string.Empty;
public string? Description { get; set; }
public decimal Debit { get; set; }
public decimal Credit { get; set; }
public decimal RunningBalance { get; set; }
public string? LinkController { get; set; }
public int? LinkId { get; set; }
}
public class AccountLedgerDto
{
public int Id { get; set; }
public string AccountNumber { get; set; } = string.Empty;
public string Name { get; set; } = string.Empty;
public AccountType AccountType { get; set; }
public AccountSubType AccountSubType { get; set; }
public DateTime From { get; set; }
public DateTime To { get; set; }
public decimal OpeningBalance { get; set; } // Balance at start of the requested period
public decimal PeriodDebits { get; set; }
public decimal PeriodCredits { get; set; }
public decimal ClosingBalance { get; set; }
public List<LedgerEntryDto> Entries { get; set; } = new();
}
@@ -0,0 +1,186 @@
using PowderCoating.Core.Enums;
using System.ComponentModel.DataAnnotations;
namespace PowderCoating.Application.DTOs.Accounting;
/// <summary>Unified row for the combined Bills / Expenses list view.</summary>
public class BillExpenseListDto
{
public string EntryType { get; set; } = "Bill"; // "Bill" | "Expense"
public int Id { get; set; }
public string Number { get; set; } = string.Empty;
public DateTime Date { get; set; }
public string? VendorName { get; set; }
public string? Memo { get; set; }
public string? AccountName { get; set; }
public decimal Total { get; set; }
public decimal BalanceDue { get; set; }
public string StatusLabel { get; set; } = string.Empty;
public string StatusColor { get; set; } = "secondary";
public DateTime? DueDate { get; set; }
public bool IsOverdue { get; set; }
public bool HasReceipt { get; set; }
}
public class BillListDto
{
public int Id { get; set; }
public string BillNumber { get; set; } = string.Empty;
public string? VendorInvoiceNumber { get; set; }
public int VendorId { get; set; }
public string VendorName { get; set; } = string.Empty;
public BillStatus Status { get; set; }
public DateTime BillDate { get; set; }
public DateTime? DueDate { get; set; }
public decimal Total { get; set; }
public decimal AmountPaid { get; set; }
public decimal BalanceDue { get; set; }
public bool IsOverdue => Status != BillStatus.Paid && Status != BillStatus.Voided
&& DueDate.HasValue && DueDate.Value.Date < DateTime.Today;
}
public class BillDto
{
public int Id { get; set; }
public string BillNumber { get; set; } = string.Empty;
public string? VendorInvoiceNumber { get; set; }
public int VendorId { get; set; }
public string VendorName { get; set; } = string.Empty;
public string? VendorEmail { get; set; }
public string? VendorPhone { get; set; }
public int APAccountId { get; set; }
public string APAccountName { get; set; } = string.Empty;
public BillStatus Status { get; set; }
public DateTime BillDate { get; set; }
public DateTime? DueDate { get; set; }
public string? Terms { get; set; }
public string? Memo { get; set; }
public decimal SubTotal { get; set; }
public decimal TaxPercent { get; set; }
public decimal TaxAmount { get; set; }
public decimal Total { get; set; }
public decimal AmountPaid { get; set; }
public decimal BalanceDue { get; set; }
public string? ReceiptFilePath { get; set; }
public List<BillLineItemDto> LineItems { get; set; } = new();
public List<BillPaymentDto> Payments { get; set; } = new();
}
public class BillLineItemDto
{
public int Id { get; set; }
public int? AccountId { get; set; }
public string AccountName { get; set; } = string.Empty;
public string AccountNumber { get; set; } = string.Empty;
public int? JobId { get; set; }
public string? JobNumber { get; set; }
public string Description { get; set; } = string.Empty;
public decimal Quantity { get; set; }
public decimal UnitPrice { get; set; }
public decimal Amount { get; set; }
public int DisplayOrder { get; set; }
}
public class BillPaymentDto
{
public int Id { get; set; }
public string PaymentNumber { get; set; } = string.Empty;
public DateTime PaymentDate { get; set; }
public decimal Amount { get; set; }
public PaymentMethod PaymentMethod { get; set; }
public string? CheckNumber { get; set; }
public string? Memo { get; set; }
public int BankAccountId { get; set; }
public string BankAccountName { get; set; } = string.Empty;
}
public class CreateBillDto
{
[Required]
public int VendorId { get; set; }
public int APAccountId { get; set; }
[MaxLength(100)]
public string? VendorInvoiceNumber { get; set; }
[Required]
public DateTime BillDate { get; set; } = DateTime.Today;
public DateTime? DueDate { get; set; }
public string? Terms { get; set; }
public string? Memo { get; set; }
public decimal TaxPercent { get; set; }
/// <summary>When set, the created bill is linked back to this PO.</summary>
public int? PurchaseOrderId { get; set; }
public List<CreateBillLineItemDto> LineItems { get; set; } = new();
}
public class CreateBillLineItemDto
{
public int? AccountId { get; set; }
public int? JobId { get; set; }
[Required, MaxLength(500)]
public string Description { get; set; } = string.Empty;
[Required]
public decimal Quantity { get; set; } = 1;
[Required]
public decimal UnitPrice { get; set; }
public int DisplayOrder { get; set; }
}
public class EditBillDto : CreateBillDto
{
public int Id { get; set; }
public string? ReceiptFilePath { get; set; }
}
public class RecordBillPaymentDto
{
public int BillId { get; set; }
[Required]
public DateTime PaymentDate { get; set; } = DateTime.Today;
[Required, Range(0.01, double.MaxValue, ErrorMessage = "Amount must be greater than zero")]
public decimal Amount { get; set; }
[Required]
public PaymentMethod PaymentMethod { get; set; }
[Required]
public int BankAccountId { get; set; }
[MaxLength(50)]
public string? CheckNumber { get; set; }
[MaxLength(500)]
public string? Memo { get; set; }
}
public class EditBillPaymentDto
{
public int PaymentId { get; set; }
public int BillId { get; set; }
[Required]
public DateTime PaymentDate { get; set; }
[Required]
public PaymentMethod PaymentMethod { get; set; }
[Required]
public int BankAccountId { get; set; }
[MaxLength(50)]
public string? CheckNumber { get; set; }
[MaxLength(500)]
public string? Memo { get; set; }
}
@@ -0,0 +1,62 @@
using PowderCoating.Core.Enums;
using System.ComponentModel.DataAnnotations;
namespace PowderCoating.Application.DTOs.Accounting;
public class ExpenseListDto
{
public int Id { get; set; }
public string ExpenseNumber { get; set; } = string.Empty;
public DateTime Date { get; set; }
public int? VendorId { get; set; }
public string? VendorName { get; set; }
public int ExpenseAccountId { get; set; }
public string ExpenseAccountName { get; set; } = string.Empty;
public string ExpenseAccountNumber { get; set; } = string.Empty;
public int PaymentAccountId { get; set; }
public string PaymentAccountName { get; set; } = string.Empty;
public PaymentMethod PaymentMethod { get; set; }
public decimal Amount { get; set; }
public string? Memo { get; set; }
public int? JobId { get; set; }
public string? JobNumber { get; set; }
public bool HasReceipt { get; set; }
}
public class ExpenseDto : ExpenseListDto
{
public string? ReceiptFilePath { get; set; }
public DateTime CreatedAt { get; set; }
}
public class CreateExpenseDto
{
[Required]
public DateTime Date { get; set; } = DateTime.Today;
public int? VendorId { get; set; }
[Required]
public int ExpenseAccountId { get; set; }
[Required]
public int PaymentAccountId { get; set; }
public int? JobId { get; set; }
[Required]
public PaymentMethod PaymentMethod { get; set; }
[Required, Range(0.01, double.MaxValue, ErrorMessage = "Amount must be greater than zero")]
public decimal Amount { get; set; }
[MaxLength(500)]
public string? Memo { get; set; }
public string? ReceiptFilePath { get; set; }
}
public class EditExpenseDto : CreateExpenseDto
{
public int Id { get; set; }
}
@@ -0,0 +1,161 @@
using PowderCoating.Core.Enums;
namespace PowderCoating.Application.DTOs.Accounting;
// ── Profit & Loss ─────────────────────────────────────────────────────────────
public class ProfitAndLossDto
{
public DateTime From { get; set; }
public DateTime To { get; set; }
public string CompanyName { get; set; } = string.Empty;
public List<FinancialReportLine> RevenueLines { get; set; } = new();
public decimal TotalRevenue { get; set; }
public List<FinancialReportLine> CogsLines { get; set; } = new();
public decimal TotalCogs { get; set; }
public decimal GrossProfit => TotalRevenue - TotalCogs;
public decimal GrossMarginPercent => TotalRevenue == 0 ? 0 : Math.Round(GrossProfit / TotalRevenue * 100, 1);
public List<FinancialReportLine> ExpenseLines { get; set; } = new();
public decimal TotalExpenses { get; set; }
public decimal OperatingIncome => GrossProfit - TotalExpenses;
public decimal NetIncome => OperatingIncome; // Extend later for other income/tax
}
public class FinancialReportLine
{
public int AccountId { get; set; }
public string AccountNumber { get; set; } = string.Empty;
public string AccountName { get; set; } = string.Empty;
public decimal Amount { get; set; }
}
// ── Balance Sheet ─────────────────────────────────────────────────────────────
public class BalanceSheetDto
{
public DateTime AsOf { get; set; }
public string CompanyName { get; set; } = string.Empty;
// Assets
public List<FinancialReportLine> CurrentAssets { get; set; } = new();
public List<FinancialReportLine> FixedAssets { get; set; } = new();
public List<FinancialReportLine> OtherAssets { get; set; } = new();
public decimal TotalAssets { get; set; }
// Liabilities
public List<FinancialReportLine> CurrentLiabilities { get; set; } = new();
public List<FinancialReportLine> LongTermLiabilities { get; set; } = new();
public decimal TotalLiabilities { get; set; }
// Equity
public List<FinancialReportLine> EquityLines { get; set; } = new();
public decimal RetainedEarnings { get; set; } // Computed net income to date
public decimal TotalEquity { get; set; }
public decimal TotalLiabilitiesAndEquity => TotalLiabilities + TotalEquity;
// Helper: is the sheet balanced?
public bool IsBalanced => Math.Abs(TotalAssets - TotalLiabilitiesAndEquity) < 0.01m;
}
// ── AR Aging ──────────────────────────────────────────────────────────────────
public class ArAgingReportDto
{
public DateTime AsOf { get; set; }
public string CompanyName { get; set; } = string.Empty;
public List<ArAgingCustomerDto> Customers { get; set; } = new();
public decimal TotalCurrent { get; set; }
public decimal Total1to30 { get; set; }
public decimal Total31to60 { get; set; }
public decimal Total61to90 { get; set; }
public decimal TotalOver90 { get; set; }
public decimal TotalOutstanding => TotalCurrent + Total1to30 + Total31to60 + Total61to90 + TotalOver90;
}
public class ArAgingCustomerDto
{
public int CustomerId { get; set; }
public string CustomerName { get; set; } = string.Empty;
public List<ArAgingInvoiceDto> Invoices { get; set; } = new();
public decimal TotalCurrent { get; set; }
public decimal Total1to30 { get; set; }
public decimal Total31to60 { get; set; }
public decimal Total61to90 { get; set; }
public decimal TotalOver90 { get; set; }
public decimal TotalBalance => TotalCurrent + Total1to30 + Total31to60 + Total61to90 + TotalOver90;
}
public class ArAgingInvoiceDto
{
public int InvoiceId { get; set; }
public string InvoiceNumber { get; set; } = string.Empty;
public DateTime InvoiceDate { get; set; }
public DateTime? DueDate { get; set; }
public decimal BalanceDue { get; set; }
public int DaysOverdue { get; set; }
}
// ── Sales & Income ────────────────────────────────────────────────────────────
public class SalesIncomeReportDto
{
public DateTime From { get; set; }
public DateTime To { get; set; }
public string CompanyName { get; set; } = string.Empty;
public decimal TotalInvoiced { get; set; }
public decimal TotalCollected { get; set; }
public decimal TotalTax { get; set; }
public decimal TotalDiscount { get; set; }
public decimal NetRevenue => TotalInvoiced - TotalDiscount;
public int InvoiceCount { get; set; }
public int CustomerCount { get; set; }
public decimal AverageInvoiceValue => InvoiceCount == 0 ? 0 : Math.Round(TotalInvoiced / InvoiceCount, 2);
public List<SalesByCustomerDto> ByCustomer { get; set; } = new();
public List<SalesByMonthDto> ByMonth { get; set; } = new();
public List<SalesInvoiceLineDto> Invoices { get; set; } = new();
}
public class SalesByCustomerDto
{
public int CustomerId { get; set; }
public string CustomerName { get; set; } = string.Empty;
public int InvoiceCount { get; set; }
public decimal TotalInvoiced { get; set; }
public decimal TotalPaid { get; set; }
public decimal BalanceDue { get; set; }
}
public class SalesByMonthDto
{
public int Year { get; set; }
public int Month { get; set; }
public string Label { get; set; } = string.Empty;
public decimal TotalInvoiced { get; set; }
public decimal TotalCollected { get; set; }
public int InvoiceCount { get; set; }
}
public class SalesInvoiceLineDto
{
public int InvoiceId { get; set; }
public string InvoiceNumber { get; set; } = string.Empty;
public string CustomerName { get; set; } = string.Empty;
public DateTime InvoiceDate { get; set; }
public DateTime? DueDate { get; set; }
public string Status { get; set; } = string.Empty;
public decimal SubTotal { get; set; }
public decimal TaxAmount { get; set; }
public decimal Total { get; set; }
public decimal AmountPaid { get; set; }
public decimal BalanceDue { get; set; }
}