fix: arreglo bug porque dolibarr devuelve el status en numero y lo pide como parametro como palabra.
This commit is contained in:
parent
b937c64e39
commit
5081d71f69
|
|
@ -27,11 +27,14 @@ public class DolibarrApiClient
|
||||||
int page = 1,
|
int page = 1,
|
||||||
string? status = null)
|
string? status = null)
|
||||||
{
|
{
|
||||||
var endpoint = $"invoices?limit={limit}&page={page-1}";
|
// empieza por 1 para el frontend
|
||||||
|
var endpoint = $"invoices?limit={limit}&page={page - 1}";
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(status))
|
if (!string.IsNullOrEmpty(status))
|
||||||
|
{
|
||||||
endpoint += $"&status={status}";
|
endpoint += $"&status={status}";
|
||||||
|
}
|
||||||
|
|
||||||
var dataList = await GetListAsync<InvoiceResponse>(endpoint);
|
var dataList = await GetListAsync<InvoiceResponse>(endpoint);
|
||||||
return dataList.Select(MapToInvoiceDto).ToList();
|
return dataList.Select(MapToInvoiceDto).ToList();
|
||||||
}
|
}
|
||||||
|
|
@ -63,11 +66,21 @@ public class DolibarrApiClient
|
||||||
? Math.Round(remain, 2)
|
? Math.Round(remain, 2)
|
||||||
: null,
|
: null,
|
||||||
|
|
||||||
Status = invoiceResponse.statut ?? "unknown"
|
Status = ConvertStatusToWord(invoiceResponse.statut)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static string ConvertStatusToWord(string? statusNumber)
|
||||||
|
{
|
||||||
|
return statusNumber switch
|
||||||
|
{
|
||||||
|
"0" => "draft",
|
||||||
|
"1" => "unpaid",
|
||||||
|
"2" => "paid",
|
||||||
|
"3" => "cancelled",
|
||||||
|
_ => "unknown"
|
||||||
|
};
|
||||||
|
}
|
||||||
// ===== MÉTODOS GENÉRICOS =====
|
// ===== MÉTODOS GENÉRICOS =====
|
||||||
private async Task<T> GetAsync<T>(string endpoint) where T : class
|
private async Task<T> GetAsync<T>(string endpoint) where T : class
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue