fix: formateo y eliminar estado invalido cancelled
This commit is contained in:
parent
c1c7d4bb37
commit
9e888ee985
|
|
@ -18,7 +18,7 @@ public class ClientsController(ClientService clientService) : ControllerBase
|
||||||
[ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status500InternalServerError)]
|
[ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status500InternalServerError)]
|
||||||
public async Task<ActionResult<List<ClientDto>>> GetClientes(
|
public async Task<ActionResult<List<ClientDto>>> GetClientes(
|
||||||
[FromQuery] int limit = 50,
|
[FromQuery] int limit = 50,
|
||||||
[FromQuery] [Range(1, int.MaxValue)] int page = 1)
|
[FromQuery][Range(1, int.MaxValue)] int page = 1)
|
||||||
{
|
{
|
||||||
var clients = await clientService.GetClientsAsync(limit, page);
|
var clients = await clientService.GetClientsAsync(limit, page);
|
||||||
return Ok(clients);
|
return Ok(clients);
|
||||||
|
|
|
||||||
|
|
@ -18,9 +18,9 @@ public class InvoicesController(InvoiceService invoiceService) : ControllerBase
|
||||||
[ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status500InternalServerError)]
|
[ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status500InternalServerError)]
|
||||||
public async Task<ActionResult<List<InvoiceDto>>> GetInvoices(
|
public async Task<ActionResult<List<InvoiceDto>>> GetInvoices(
|
||||||
[FromQuery] int limit = 50,
|
[FromQuery] int limit = 50,
|
||||||
[FromQuery] [Range(1, int.MaxValue)] int page = 1,
|
[FromQuery][Range(1, int.MaxValue)] int page = 1,
|
||||||
[FromQuery] string? status = null,
|
[FromQuery] string? status = null,
|
||||||
[FromQuery] [StringLength(100)] string? search = null)
|
[FromQuery][StringLength(100)] string? search = null)
|
||||||
{
|
{
|
||||||
var invoices = await invoiceService.GetInvoicesAsync(limit, page, status, search);
|
var invoices = await invoiceService.GetInvoicesAsync(limit, page, status, search);
|
||||||
return Ok(invoices);
|
return Ok(invoices);
|
||||||
|
|
@ -43,7 +43,7 @@ public class InvoicesController(InvoiceService invoiceService) : ControllerBase
|
||||||
[ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status500InternalServerError)]
|
[ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status500InternalServerError)]
|
||||||
public async Task<ActionResult<int>> CreateInvoice([FromBody] CreateInvoiceDto createInvoiceDto)
|
public async Task<ActionResult<int>> CreateInvoice([FromBody] CreateInvoiceDto createInvoiceDto)
|
||||||
{
|
{
|
||||||
var invoiceId= await invoiceService.CreateInvoiceAsync(createInvoiceDto);
|
var invoiceId = await invoiceService.CreateInvoiceAsync(createInvoiceDto);
|
||||||
return CreatedAtAction(nameof(GetInvoice), new { id = invoiceId }, invoiceId);
|
return CreatedAtAction(nameof(GetInvoice), new { id = invoiceId }, invoiceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,10 +6,10 @@ public class CreateTokenDto
|
||||||
{
|
{
|
||||||
[Required]
|
[Required]
|
||||||
[StringLength(100)]
|
[StringLength(100)]
|
||||||
public string Username{get;set;}="";
|
public string Username { get; set; } = "";
|
||||||
[Required]
|
[Required]
|
||||||
[StringLength(255)]
|
[StringLength(255)]
|
||||||
public string Password{get;set;}="";
|
public string Password { get; set; } = "";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -93,7 +93,6 @@ public static class InvoiceMapper
|
||||||
"0" => "draft",
|
"0" => "draft",
|
||||||
"1" => "unpaid",
|
"1" => "unpaid",
|
||||||
"2" => "paid",
|
"2" => "paid",
|
||||||
"3" => "cancelled",
|
|
||||||
_ => "unknown"
|
_ => "unknown"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
@ -105,8 +104,7 @@ public static class InvoiceMapper
|
||||||
"draft" => "0",
|
"draft" => "0",
|
||||||
"unpaid" => "1",
|
"unpaid" => "1",
|
||||||
"paid" => "2",
|
"paid" => "2",
|
||||||
"cancelled" => "3",
|
_ => throw new BadRequestException($"Estado inválido: {status}. Valores válidos: draft, unpaid, paid")
|
||||||
_ => throw new BadRequestException($"Estado inválido: {status}. Valores válidos: draft, unpaid, paid, cancelled")
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -33,7 +33,7 @@ public class InvoiceService(IDolibarrApiClient apiClient)
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(search))
|
if (!string.IsNullOrWhiteSpace(search))
|
||||||
{
|
{
|
||||||
search=search.Trim().ToUpperInvariant();
|
search = search.Trim().ToUpperInvariant();
|
||||||
var filter = $"(t.ref:like:'%{search}%')";
|
var filter = $"(t.ref:like:'%{search}%')";
|
||||||
endpoint += $"&sqlfilters={Uri.EscapeDataString(filter)}";
|
endpoint += $"&sqlfilters={Uri.EscapeDataString(filter)}";
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue