-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1f6932f
commit f5c56bb
Showing
26 changed files
with
285 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
using Microsoft.AspNetCore.Mvc; | ||
using OpenAdm.Api.Attributes; | ||
using OpenAdm.Application.Dtos.FaturasDtos; | ||
using OpenAdm.Application.Dtos.Response; | ||
using OpenAdm.Application.Interfaces; | ||
using OpenAdm.Application.Models.ContasAReceberModel; | ||
using OpenAdm.Domain.Enuns; | ||
using OpenAdm.Domain.Model; | ||
using OpenAdm.Infra.Paginacao; | ||
|
||
namespace OpenAdm.Api.Controllers; | ||
|
||
[ApiController] | ||
[Route("parcela")] | ||
[IsFuncionario] | ||
[AutenticaParceiro] | ||
[Autentica] | ||
public class ParcelaController : ControllerBase | ||
{ | ||
private readonly IParcelaService _parcelaService; | ||
|
||
public ParcelaController(IParcelaService parcelaService) | ||
{ | ||
_parcelaService = parcelaService; | ||
} | ||
|
||
[HttpPost("paginacao")] | ||
[ProducesResponseType<PaginacaoViewModel<FaturaViewModel>>(200)] | ||
[ProducesResponseType<ErrorResponse>(400)] | ||
public async Task<IActionResult> Paginacao(PaginacaoParcelaDto paginacaoFaturaAReceberDto) | ||
{ | ||
var paginacaoViewModel = await _parcelaService.PaginacaoAsync(paginacaoFaturaAReceberDto); | ||
return Ok(paginacaoViewModel); | ||
} | ||
|
||
[HttpGet("pedido")] | ||
[ProducesResponseType<IList<FaturaViewModel>>(200)] | ||
[ProducesResponseType<ErrorResponse>(400)] | ||
public async Task<IActionResult> ByPedido([FromQuery] Guid pedidoId, [FromQuery] StatusParcelaEnum statusFatura) | ||
{ | ||
var faturas = await _parcelaService.GetByPedidoIdAsync(pedidoId, statusFatura); | ||
return Ok(faturas); | ||
} | ||
|
||
[HttpGet("get-by-id")] | ||
[ProducesResponseType<FaturaViewModel>(200)] | ||
[ProducesResponseType<ErrorResponse>(400)] | ||
public async Task<IActionResult> GetById([FromQuery] Guid id) | ||
{ | ||
var fatura = await _parcelaService.GetByIdAsync(id); | ||
return Ok(fatura); | ||
} | ||
|
||
[HttpPut("pagar")] | ||
[ProducesResponseType<FaturaViewModel>(200)] | ||
[ProducesResponseType<ErrorResponse>(400)] | ||
public async Task<IActionResult> Pagar(PagarParcelaDto pagarFaturaAReceberDto) | ||
{ | ||
var fatura = await _parcelaService.PagarAsync(pagarFaturaAReceberDto); | ||
return Ok(fatura); | ||
} | ||
|
||
[HttpPut("edit")] | ||
[ProducesResponseType<FaturaViewModel>(200)] | ||
[ProducesResponseType<ErrorResponse>(400)] | ||
public async Task<IActionResult> Edit(FaturaEdit faturaAReceberEdit) | ||
{ | ||
var fatura = await _parcelaService.EditAsync(faturaAReceberEdit); | ||
return Ok(fatura); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using OpenAdm.Domain.Enuns; | ||
using OpenAdm.Domain.Exceptions; | ||
|
||
namespace OpenAdm.Application.Dtos.FaturasDtos; | ||
|
||
public class FaturaCriarAdmDto | ||
{ | ||
public Guid UsuarioId { get; set; } | ||
public Guid? PedidoId { get; set; } | ||
public TipoFaturaEnum Tipo { get; set; } | ||
public IList<ParcelaCriarAdmDto> Parcelas { get; set; } = []; | ||
|
||
public void Validar() | ||
{ | ||
if (Parcelas.Count == 0) | ||
{ | ||
throw new ExceptionApi("Informe as parcelas!"); | ||
} | ||
|
||
var temParcelaZerada = Parcelas.Any(x => x.Valor == 0); | ||
if (temParcelaZerada) | ||
{ | ||
throw new ExceptionApi("Não é possível informar parcelas com o valor zero!"); | ||
} | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
OpenAdm.Application/Dtos/FaturasDtos/ParcelaCriarAdmDto.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using OpenAdm.Domain.Enuns; | ||
|
||
namespace OpenAdm.Application.Dtos.FaturasDtos; | ||
|
||
public class ParcelaCriarAdmDto | ||
{ | ||
public DateTime DataDeVencimento { get; set; } | ||
public int NumeroDaFatura { get; set; } | ||
public MeioDePagamentoEnum? MeioDePagamento { get; set; } | ||
public decimal Valor { get; set; } | ||
public decimal? Desconto { get; set; } | ||
public string? Observacao { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using System.Linq.Expressions; | ||
|
||
namespace OpenAdm.Domain.PaginateDto; | ||
|
||
public abstract class PaginacaoDropDown<T> where T : class | ||
{ | ||
public string? Search { get; set; } | ||
public string OrderBy { get; set; } = "DataDeAtualizacao"; | ||
|
||
public abstract Expression<Func<T, bool>>? Where(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.