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,75 @@
using AutoMapper;
using PowderCoating.Application.DTOs.Invoice;
using PowderCoating.Core.Entities;
namespace PowderCoating.Application.Mappings;
public class InvoiceProfile : Profile
{
public InvoiceProfile()
{
CreateMap<Invoice, InvoiceListDto>()
.ForMember(d => d.JobNumber, o => o.MapFrom(s => s.Job != null ? s.Job.JobNumber : string.Empty))
.ForMember(d => d.CustomerName, o => o.MapFrom(s => s.Customer != null
? (s.Customer.IsCommercial
? s.Customer.CompanyName
: $"{s.Customer.ContactFirstName} {s.Customer.ContactLastName}".Trim())
: string.Empty))
.ForMember(d => d.BalanceDue, o => o.MapFrom(s => s.BalanceDue));
CreateMap<Invoice, InvoiceDto>()
.ForMember(d => d.JobNumber, o => o.MapFrom(s => s.Job != null ? s.Job.JobNumber : string.Empty))
.ForMember(d => d.CustomerName, o => o.MapFrom(s => s.Customer != null
? (s.Customer.IsCommercial
? s.Customer.CompanyName
: $"{s.Customer.ContactFirstName} {s.Customer.ContactLastName}".Trim())
: string.Empty))
.ForMember(d => d.CustomerEmail, o => o.MapFrom(s => s.Customer != null ? s.Customer.Email : null))
.ForMember(d => d.CustomerPhone, o => o.MapFrom(s => s.Customer != null ? s.Customer.Phone : null))
.ForMember(d => d.CustomerNotifyByEmail, o => o.MapFrom(s => s.Customer == null || s.Customer.NotifyByEmail))
.ForMember(d => d.PreparedByName, o => o.MapFrom(s => s.PreparedBy != null
? $"{s.PreparedBy.FirstName} {s.PreparedBy.LastName}".Trim()
: null))
.ForMember(d => d.BalanceDue, o => o.MapFrom(s => s.BalanceDue))
.ForMember(d => d.SalesTaxAccountName, o => o.MapFrom(s => s.SalesTaxAccount != null
? $"{s.SalesTaxAccount.AccountNumber} {s.SalesTaxAccount.Name}" : null))
.ForMember(d => d.GiftCertificateRedemptions, o => o.Ignore());
CreateMap<InvoiceItem, InvoiceItemDto>()
.ForMember(d => d.RevenueAccountName, o => o.MapFrom(s => s.RevenueAccount != null
? $"{s.RevenueAccount.AccountNumber} {s.RevenueAccount.Name}" : null));
CreateMap<InvoiceItemDto, InvoiceItem>()
.ForMember(d => d.RevenueAccount, o => o.Ignore())
.ForMember(d => d.Invoice, o => o.Ignore())
.ForMember(d => d.SourceJobItem, o => o.Ignore());
CreateMap<CreateInvoiceDto, Invoice>()
.ForMember(d => d.InvoiceNumber, o => o.Ignore())
.ForMember(d => d.Status, o => o.Ignore())
.ForMember(d => d.SubTotal, o => o.Ignore())
.ForMember(d => d.TaxAmount, o => o.Ignore())
.ForMember(d => d.Total, o => o.Ignore())
.ForMember(d => d.AmountPaid, o => o.Ignore());
CreateMap<CreateInvoiceItemDto, InvoiceItem>()
.ForMember(d => d.CompanyId, o => o.Ignore())
.ForMember(d => d.RevenueAccount, o => o.Ignore())
.ForMember(d => d.Invoice, o => o.Ignore())
.ForMember(d => d.SourceJobItem, o => o.Ignore());
CreateMap<Payment, PaymentDtos.PaymentDto>()
.ForMember(d => d.RecordedByName, o => o.MapFrom(s => s.RecordedBy != null
? $"{s.RecordedBy.FirstName} {s.RecordedBy.LastName}".Trim()
: null))
.ForMember(d => d.DepositAccountName, o => o.MapFrom(s => s.DepositAccount != null
? $"{s.DepositAccount.AccountNumber} {s.DepositAccount.Name}" : null));
CreateMap<PaymentDtos.RecordPaymentDto, Payment>()
.ForMember(d => d.RecordedById, o => o.Ignore())
.ForMember(d => d.CompanyId, o => o.Ignore())
.ForMember(d => d.DepositAccount, o => o.Ignore())
.ForMember(d => d.Invoice, o => o.Ignore())
.ForMember(d => d.RecordedBy, o => o.Ignore());
}
}