feat: implement CRM and tax accounting specialized services and repositories
TaxBaik CI/CD / build-and-deploy (push) Successful in 49s
TaxBaik CI/CD / build-and-deploy (push) Successful in 49s
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
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
namespace TaxBaik.Infrastructure.Repositories;
|
||||
|
||||
using Dapper;
|
||||
using TaxBaik.Domain.Entities;
|
||||
using TaxBaik.Domain.Interfaces;
|
||||
|
||||
public class TaxFilingScheduleRepository(IDbConnectionFactory connectionFactory) : BaseRepository(connectionFactory), ITaxFilingScheduleRepository
|
||||
{
|
||||
public async Task<int> CreateAsync(TaxFilingSchedule schedule, CancellationToken cancellationToken = default)
|
||||
{
|
||||
using var conn = Conn();
|
||||
return await conn.QueryFirstAsync<int>(
|
||||
@"INSERT INTO tax_filing_schedules (client_id, filing_type, due_date, filing_year, status, assigned_to, notes, created_at, updated_at)
|
||||
VALUES (@ClientId, @FilingType, @DueDate, @FilingYear, @Status, @AssignedToId, @Notes, NOW(), NOW())
|
||||
RETURNING id",
|
||||
schedule);
|
||||
}
|
||||
|
||||
public async Task<TaxFilingSchedule?> GetByIdAsync(int id, CancellationToken cancellationToken = default)
|
||||
{
|
||||
using var conn = Conn();
|
||||
return await conn.QueryFirstOrDefaultAsync<TaxFilingSchedule>(
|
||||
@"SELECT id, client_id, filing_type, due_date, filing_year, status, assigned_to, completed_date, notes, created_at, updated_at
|
||||
FROM tax_filing_schedules WHERE id = @Id",
|
||||
new { Id = id });
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<TaxFilingSchedule>> GetByClientIdAsync(int clientId, CancellationToken cancellationToken = default)
|
||||
{
|
||||
using var conn = Conn();
|
||||
return await conn.QueryAsync<TaxFilingSchedule>(
|
||||
@"SELECT id, client_id, filing_type, due_date, filing_year, status, assigned_to, completed_date, notes, created_at, updated_at
|
||||
FROM tax_filing_schedules WHERE client_id = @ClientId ORDER BY due_date DESC",
|
||||
new { ClientId = clientId });
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<TaxFilingSchedule>> GetUpcomingDuesAsync(int daysAhead = 30, CancellationToken cancellationToken = default)
|
||||
{
|
||||
using var conn = Conn();
|
||||
return await conn.QueryAsync<TaxFilingSchedule>(
|
||||
@"SELECT id, client_id, filing_type, due_date, filing_year, status, assigned_to, completed_date, notes, created_at, updated_at
|
||||
FROM tax_filing_schedules
|
||||
WHERE status = 'pending' AND due_date BETWEEN CURRENT_DATE AND CURRENT_DATE + INTERVAL '1 day' * @DaysAhead
|
||||
ORDER BY due_date ASC",
|
||||
new { DaysAhead = daysAhead });
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<TaxFilingSchedule>> GetByStatusAsync(string status, CancellationToken cancellationToken = default)
|
||||
{
|
||||
using var conn = Conn();
|
||||
return await conn.QueryAsync<TaxFilingSchedule>(
|
||||
@"SELECT id, client_id, filing_type, due_date, filing_year, status, assigned_to, completed_date, notes, created_at, updated_at
|
||||
FROM tax_filing_schedules WHERE status = @Status ORDER BY due_date",
|
||||
new { Status = status });
|
||||
}
|
||||
|
||||
public async Task UpdateAsync(TaxFilingSchedule schedule, CancellationToken cancellationToken = default)
|
||||
{
|
||||
using var conn = Conn();
|
||||
await conn.ExecuteAsync(
|
||||
@"UPDATE tax_filing_schedules SET filing_type = @FilingType, due_date = @DueDate, status = @Status,
|
||||
assigned_to = @AssignedToId, notes = @Notes, updated_at = NOW() WHERE id = @Id",
|
||||
schedule);
|
||||
}
|
||||
|
||||
public async Task MarkCompletedAsync(int id, CancellationToken cancellationToken = default)
|
||||
{
|
||||
using var conn = Conn();
|
||||
await conn.ExecuteAsync(
|
||||
@"UPDATE tax_filing_schedules SET status = 'completed', completed_date = NOW(), updated_at = NOW() WHERE id = @Id",
|
||||
new { Id = id });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user