feat: Creo los DTOS para el POST de facturas , tambien organizo un poco en command y query los DTOS
This commit is contained in:
parent
ab80901280
commit
daded56582
|
|
@ -18,6 +18,7 @@ public class InvoicesController : ControllerBase
|
|||
|
||||
[HttpGet]
|
||||
[ProducesResponseType(typeof(List<InvoiceDto>), StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status500InternalServerError)]
|
||||
public async Task<ActionResult<List<InvoiceDto>>> GetInvoices(
|
||||
[FromQuery] int limit = 50,
|
||||
|
|
@ -30,9 +31,10 @@ public class InvoicesController : ControllerBase
|
|||
|
||||
[HttpGet("{id:int}")]
|
||||
[ProducesResponseType(typeof(InvoiceDetailDto), StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status404NotFound)]
|
||||
[ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status500InternalServerError)]
|
||||
public async Task<ActionResult<InvoiceDetailDto>> GetInvoice(int id)
|
||||
public async Task<ActionResult<InvoiceDetailDto>> GetInvoice([Range(1, int.MaxValue)] int id)
|
||||
{
|
||||
var invoice = await _invoiceService.GetInvoiceAsync(id);
|
||||
return Ok(invoice);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,25 @@
|
|||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace DoliMiddlewareApi.Dtos.command;
|
||||
|
||||
public class CreateInvoiceDto
|
||||
{
|
||||
[Required]
|
||||
public int ClientId { get; set; }
|
||||
|
||||
[Required]
|
||||
public DateTime Date { get; set; }
|
||||
|
||||
public DateTime? ExpireDate { get; set; }
|
||||
|
||||
[StringLength(100)]
|
||||
public string? Reference { get; set; }
|
||||
|
||||
public string? NotePublic { get; set; }
|
||||
public string? NotePrivate { get; set; }
|
||||
|
||||
[Required]
|
||||
[MinLength(1)]
|
||||
public List<CreateInvoiceLineDto> Lines { get; set; } = new();
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace DoliMiddlewareApi.Dtos.command;
|
||||
|
||||
public class CreateInvoiceLineDto
|
||||
{
|
||||
[Required]
|
||||
[StringLength(500)]
|
||||
public string? Description { get; set; }
|
||||
|
||||
[Required]
|
||||
[Range(0.01, double.MaxValue)]
|
||||
public decimal Quantity { get; set; }
|
||||
|
||||
[Required]
|
||||
[Range(0, double.MaxValue)]
|
||||
public decimal UnitPrice { get; set; }
|
||||
|
||||
[Range(0, 100)]
|
||||
public decimal TaxRate { get; set; } = 0;
|
||||
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue