diff --git a/API/ROLAC.API/Controllers/Form1099ReportController.cs b/API/ROLAC.API/Controllers/Form1099ReportController.cs new file mode 100644 index 0000000..fde93e3 --- /dev/null +++ b/API/ROLAC.API/Controllers/Form1099ReportController.cs @@ -0,0 +1,25 @@ +using Microsoft.AspNetCore.Mvc; +using ROLAC.API.Authorization; +using ROLAC.API.Services; + +namespace ROLAC.API.Controllers; + +[ApiController] +[Route("api/form1099-report")] +[HasPermission(Modules.Form1099, PermissionActions.Read)] +public class Form1099ReportController : ControllerBase +{ + private readonly IForm1099ReportService _svc; + public Form1099ReportController(IForm1099ReportService svc) => _svc = svc; + + [HttpGet("boxes")] + public async Task Boxes() => Ok(await _svc.GetBoxesAsync()); + + [HttpGet("summary")] + public async Task Summary([FromQuery] int taxYear) + => Ok(await _svc.GetAnnualSummaryAsync(taxYear)); + + [HttpGet("recipient/{payeeId:int}")] + public async Task Recipient(int payeeId, [FromQuery] int taxYear) + => await _svc.GetRecipientDetailAsync(payeeId, taxYear) is { } d ? Ok(d) : NotFound(); +} diff --git a/API/ROLAC.API/Controllers/Payee1099Controller.cs b/API/ROLAC.API/Controllers/Payee1099Controller.cs new file mode 100644 index 0000000..8a4fdfc --- /dev/null +++ b/API/ROLAC.API/Controllers/Payee1099Controller.cs @@ -0,0 +1,44 @@ +using Microsoft.AspNetCore.Mvc; +using ROLAC.API.Authorization; +using ROLAC.API.DTOs.Payee; +using ROLAC.API.Services; + +namespace ROLAC.API.Controllers; + +[ApiController] +[Route("api/payee-1099")] +[HasPermission(Modules.Form1099, PermissionActions.Read)] +public class Payee1099Controller : ControllerBase +{ + private readonly IPayee1099Service _svc; + public Payee1099Controller(IPayee1099Service svc) => _svc = svc; + + [HttpGet] + public async Task GetAll([FromQuery] bool includeInactive = false) + => Ok(await _svc.GetAllAsync(includeInactive)); + + [HttpGet("{id:int}")] + public async Task GetById(int id) + => await _svc.GetByIdAsync(id) is { } dto ? Ok(dto) : NotFound(); + + [HttpPost] + [HasPermission(Modules.Form1099, PermissionActions.Write)] + public async Task Create([FromBody] SavePayee1099Request r) + => Ok(new { id = await _svc.CreateAsync(r) }); + + [HttpPut("{id:int}")] + [HasPermission(Modules.Form1099, PermissionActions.Write)] + public async Task Update(int id, [FromBody] SavePayee1099Request r) + { await _svc.UpdateAsync(id, r); return NoContent(); } + + [HttpDelete("{id:int}")] + [HasPermission(Modules.Form1099, PermissionActions.Delete)] + public async Task Delete(int id) + { await _svc.DeleteAsync(id); return NoContent(); } + + // Full TIN reveal is gated on Write (a stronger right than Read). + [HttpGet("{id:int}/tin")] + [HasPermission(Modules.Form1099, PermissionActions.Write)] + public async Task RevealTin(int id) + => Ok(new { tin = await _svc.RevealTinAsync(id) }); +}