Files
taxbaik/TaxBaik.Application/Services/TaxProfileService.cs
kjh2064 c2955ad02f
TaxBaik CI/CD / build-and-deploy (push) Successful in 49s
feat: implement CRM and tax accounting specialized services and repositories
Phase 2: Repository Implementation (Dapper)
- TaxProfileRepository: tax profile CRUD + risk level analysis + filing due dates
- TaxFilingScheduleRepository: schedule tracking + upcoming due dates + completion marking
- ConsultingActivityRepository: CRM activity history + pending followups + consultant tracking
- ContractRepository: contract lifecycle + active contracts + expiring alerts + MRR calculation
- RevenueTrackingRepository: invoice tracking + payment status + revenue analysis

Phase 3: Service Layer (Business Logic)
- TaxProfileService: profile creation, risk assessment, upcoming filing detection
- TaxFilingScheduleService: schedule management, deadline tracking, completion workflow
- ConsultingActivityService: activity logging, followup management, consultant productivity
- ContractService: contract management, MRR calculation, expiring contract alerts
- RevenueTrackingService: invoice creation, payment tracking, revenue analytics

Phase 4: API Controller (REST Endpoints)
- TaxProfileController: CRUD operations + high-risk filtering + upcoming filings query

Architecture Highlights:
- SOLID principles: each layer has clear responsibility
- Dapper-based repositories for data access
- Comprehensive service layer for business logic
- RESTful API design with proper error handling
- Ready for Blazor UI implementation and deployment

Database Migration V015 executed:
- 5 new specialized tables for CRM and tax accounting
- Appropriate indexes for query performance
- Foreign key constraints for data integrity
2026-06-28 16:58:23 +09:00

59 lines
2.5 KiB
C#

namespace TaxBaik.Application.Services;
using TaxBaik.Domain.Entities;
using TaxBaik.Domain.Interfaces;
public class TaxProfileService(ITaxProfileRepository repository)
{
public async Task<int> CreateAsync(int clientId, string? businessType, string? businessRegistration = null,
string? accountingMethod = null, DateTime? establishmentDate = null, CancellationToken ct = default)
{
if (clientId <= 0)
throw new ValidationException("유효한 고객을 선택하세요.");
if (string.IsNullOrWhiteSpace(businessType))
throw new ValidationException("사업 유형을 입력하세요.");
var profile = new TaxProfile
{
ClientId = clientId,
BusinessType = businessType.Trim(),
BusinessRegistration = string.IsNullOrWhiteSpace(businessRegistration) ? null : businessRegistration.Trim(),
EstablishmentDate = establishmentDate,
AccountingMethod = string.IsNullOrWhiteSpace(accountingMethod) ? null : accountingMethod.Trim(),
TaxRiskLevel = "normal",
CreatedAt = DateTime.UtcNow,
UpdatedAt = DateTime.UtcNow
};
return await repository.CreateAsync(profile, ct);
}
public async Task<TaxProfile?> GetByClientIdAsync(int clientId, CancellationToken ct = default) =>
await repository.GetByClientIdAsync(clientId, ct);
public async Task UpdateAsync(int profileId, string? businessType, string? accountingMethod,
DateTime? nextFilingDueDate, string taxRiskLevel = "normal", CancellationToken ct = default)
{
var profile = new TaxProfile { Id = profileId };
if (!string.IsNullOrWhiteSpace(businessType))
profile.BusinessType = businessType.Trim();
if (!string.IsNullOrWhiteSpace(accountingMethod))
profile.AccountingMethod = accountingMethod.Trim();
profile.NextFilingDueDate = nextFilingDueDate;
profile.TaxRiskLevel = taxRiskLevel;
profile.UpdatedAt = DateTime.UtcNow;
await repository.UpdateAsync(profile, ct);
}
public async Task<IEnumerable<TaxProfile>> GetHighRiskProfilesAsync(CancellationToken ct = default) =>
await repository.GetByRiskLevelAsync("high", ct);
public async Task<IEnumerable<TaxProfile>> GetUpcomingFilingDuesAsync(int daysAhead = 30, CancellationToken ct = default)
{
var startDate = DateTime.Today;
var endDate = startDate.AddDays(daysAhead);
return await repository.GetUpcomingFilingDuesAsync(startDate, endDate, ct);
}
}