Buenas a todos gracias por su apoyo de antemano: tengo este Json
"items": [
{
"sku": "YR-001",
"quantity": 10,
"description": "Descripcion del Producto",
"price": 2000,
"discount_rate": 10,
"taxes": [
{
"tax_category": "IVA",
"tax_rate": 19
}
],
"retentions": [
{
"tax_category": "RET_FUENTE",
"tax_rate": 1
}
]
estoy tratando de "embeber" las listas: taxes y retention dentro de la lista items. Uso datatable para recoger la información, de esta manera:
Dim DTL As DataTable = CapaDatos.Metodosfacturas.ItemsJsonDI(TxtTipo.Text, TxtCodigo.Text)
If DTL IsNot Nothing AndAlso DTL.Rows.Count Then
Dim DR1 As DataRow = DTL.Rows(0)
Dim TASA As String = DR1("TASIMP")
listaTaxes.Add(New Tax("IVA", TASA))
For Each DR2 As DataRow In DTL.Rows
listaItems.Add(New Item(DR2("SKU"), DR2("quantity"), DR2("description"), DR2("price"), DR2("discount_rate"), listaTaxes, ListaRetenciones))
Next
End If
El tema que me sucede es que solo me toma el IVA del primer item no necesariamente el que le corresponde al item es decir si el primer item tiene tax_rate de 19 todos los demas items que tenga el documento toman ese mismo valor. Agradezco su ayuda.Pongo aqui el metedo del dataTable.
Public Shared Function ItemsJsonDI(Tipo As String, Codigo As Integer) As DataTable
Try
Using CN As New OleDbConnection(My.Settings.Conexion)
Dim SQL As String = String.Format("SELECT TIPLFA,CODLFA,POSLFA,ARTLFA AS sku,Round(CANLFA,2) AS quantity,DESLFA AS Description,PRELFA as price,DT1LFA AS discount_rate, F_IVA.TASIMP FROM F_LFA INNER JOIN F_IVA ON F_LFA.IVALFA = F_IVA.CODGRU
WHERE TIPLFA=""{0}"" AND CODLFA={1} ORDER BY POSLFA;", Tipo, Codigo)
Using DA As New OleDbDataAdapter(SQL, CN)
Using DT As New DataTable
DA.Fill(DT)
Return DT
End Using
End Using
End Using
Catch ex As Exception
MsgBox("Err.ItemsJsonDI No.: " & Err.Number & " - " & Err.Description, MsgBoxStyle.Critical, "Err.")
Return Nothing
End Try
End Function