As I understand from OT kings of Judea, there was always a biological paternal line between the kingship and David. However if Jesus was the son of God and not of Joseph, how was he descended from David? Furthermore why are there two different accounts of who Joseph's father was?
There is no discrepancy.
First, in the genealogy encountered in the Gospel according to Luke (cp. 3:23-38), the very syntax of the Greek text seems to argue against the assertion that Luke is stating that Joseph is the son of Heli.
Consider Num. 36:1 in the LXX. When the translator wished to state that Gil'ad (גִלְעָד) was the son of Makhir (מָכִיר), and Makhir was the son of Menashe (מְנַשֶּׁה), he translated this into Greek as, «Γαλααδ υἱοῦ Μαχιρ υἱοῦ Μανασση». Notice that the Greek word υἱοῦ ("son of") precedes the name of each father. So, it is understood as Gil'ad, the son of Makhir, and Makhir, the son of Menashe. (Formula: A, son of B, [B] son of C).
Another example is Num. 16:1. The idea is that Korach (קֹרַח) is the son of Yitzhar (יִצְהָר), and Yitzhar is the son of Kehat (קְהָת), and Kohat is the son of Levi (לֵוִי). The translator of the LXX expresses this in Greek as, «Κορε υἱὸς Ισσααρ υἱοῦ Κααθ υἱοῦ Λευι». Again, the translator precedes each father by υἱὸς/ υἱοῦ.
The problem is that υἱοῦ does not precede the name of each father in Luke's genealogy. In a genealogy, where there's a series of names, this seems quite the anomaly. Certainly it's not unusual to see υἱὸς absent before, say, a single father in a narrative (cp. Luke 6:15) (however, he includes the definite article τὸν which is shorthand for τὸν υἱὸν). But, for it to be missing before every father in a genealogy, I know of no other examples.
A rule, you say?
When we see one name preceded by another in a genealogy, we tend to think that the preceding name is the son/ daughter of the succeeding name. Hence, when people read the following (Luke 3:24),
they interpret it to mean that Matthat is the son of Levi, and Levi is the son of Melchi, and so forth, all the way until the end of Luke 3:38, which states,
and thus, it is believed that Luke wrote that Adam is the son of God, since Adam precedes God in the genealogy.
However, this rule is not absolutely true. Consider the example of Gen. 36:2.
I ask, "Who is the daughter of Zibeon the Hivite"? Based on the aforementioned rule, you might say, "It is Anah, since Anah precedes Zibeon in the genealogy. Therefore, Anah must be Zibeon's daughter."
Such would be unequivocally wrong, for Anah is a male, not a female, and thus he could not be anyone's daughter (cp. Gen. 36:24). So, the genealogy in Gen. 36:2 is actually stating that Aholibamah is the daughter of Anah (her father), and Aholibamah is also the daughter of Zibeon (Anah's father (cp. Gen. 36:24), and thus, Aholibamah's grandfather).
Therefore, there is no reason to assume, especially in light of the absence of υἱοῦ before each father, that Luke is saying A is the son of B, [B] is the son of C, [C] is the son of D, and so forth. In other words, what reason is there for assuming that Luke is saying that Joseph is the son of Heli, or that Adam is the son of God? I have shown you using the example of Aholibamah that a name simply preceding another name in a genealogy is not evidence of such a rule.
If Joseph is not Heli's son, then who is?
I have demonstrated that it is absolutely normal for the daughter of a man to also be reckoned as the daughter of the same man's father. Naturally, this would also apply to a man's son. For example, Jesus is not only the son of David, but also the son of Abraham (Matt. 1:1), even though neither were Jesus' direct, biological father.
Luke 3:32 states,
Let us consider the notion that Luke intentionally omitted υἱός from each father and only included it after Jesus (Ἰησοῦς) and before Joseph (Ἰωσὴφ). Again, it wasn't normal for it to be omitted before each father in a genealogy. Either it is an anomaly, or Luke intended to do so. My belief is that Luke does not want us to understand Joseph as being the son of Heli, but Jesus as being the son of Heli, and Jesus being the son of:
Matthat, Levi, Melchi, Janna... (Luke 3:24)
...all the way to...
Enos, Seth, and likewise, Jesus is the son of Adam, and Jesus (not Adam) is the son of God. (Luke 3:38)
Is Jesus the son of God? Well, of course. If there's anything that a Christian should believe, it's that.
In fact, if we actually take a step back and read the narrative --- again, taking a step back --- you'll see that it was Luke's very intent to declare Jesus as the son of God.
First, Luke begins his gospel describing the very nativity of our Lord Jesus. And, what does Luke tell us?
So, the angel says that Jesus will be "the Son of the Most High" (υἱὸς ὑψίστου) and "the Son of God" (υἱὸς θεοῦ) because...God the Father is Jesus' actual father. For that reason, John in his gospel refers to Jesus as "the only-begotten Son of God| (ὁ υἱός ὁ μονογενής τοῦ θεοῦ; cp. John 3:16).
Again, Luke commences his very gospel by demonstrating that Jesus is truly and literally the Son of God.
But, he does not stop there.
In chapter 2, Luke describes the birth of the Lord Jesus (Luke 2:7). He writes that "Joseph and his mother marvelled..." (rather than "his father and mother") (Luke 2:33), and he writes that Jesus tells his mother, "...I must be about my Father's business..." (Luke 2:49).
Of course, it was God the Father who declared to Jesus, "You are My beloved Son in whom I am well pleased."
THEN, just one verse later, Luke begins the genealogy. Again, looking at this from the big picture, you see that Luke's very intent was to describe Jesus as being God's son. This is accomplished in the narratives of the nativity, baptism, and finally, the genealogy (chapters 1-3).
Not only does Luke focus on Jesus being God's son, but he also focuses especially on Mary. On the other hand, if you read Matthew's narrative, he focuses especially on Joseph. Hence, we need to understand that Luke's genealogy is of Mary, and that Jesus is the son of God (not Adam). Accordingly, Jesus is Heli's son, because Heli is his grandfather (Mary's father).
This is actually proven by the Jerusalem Talmud which speaks (albeit in a vile and derogatory manner, as can be expected) of a מרים ברת עלי ("Miryam, daughter of Eli") (Masekhet Chaggiga, Daf 11a, Ch. 2, Halakha 2, Gemara).
Here is the commentary of John Lightfoot,
Jesus is descended from David via his mother Mary, who was of the tribe of Yehuda and thus physically descended from David. This fulfills God's promise to David that the fruit of his loins would reign on his throne forever.
Jesus cannot actually inherit the throne from his mother. Tribal status is actually passed paternally. So, how then does Jesus inherit the throne of David? Adoption, in the same way that Christians inherit our throne and reign with Jesus (Rom. 8:15-17).
The Gospel of Luke makes the connection-
Actual biology is, when it comes to sonship, irrelevant.
Indeed, when it came to inheritance and descendance, any named successor could be counted as a child.
Abraham, for example, knew that he would have many descendants, because God had told Him, but did not necessarily believe they would physically descend from his and Sarah's own body, hence Ishmael. (Yes, Christians have different beliefs around that story.)
In effect, Joseph adopted Jesus the way that God adopts us as his sons. For all practical purposes "we are adopted as sons, and if sons then joint heirs with Christ". Indeed to the outside world, Mary looked like an unwed mother, and Joseph like a dad who started having relations too early. On the census that was taken, there is no doubt that Jesus was reckoned as Joseph's son.
The actual genetic heritage is not the important thing. If you are adopted, you are the descendant. Jesus may have been adopted first, but as Christians we are counted as adopted into God's family most.
Romans 15:12 A descendant of Jesse will appear;he will come to rule the Gentiles and they will put their hope in him. I see nothing about gender here, so any progeny from the genetic material of David or his siblings should be suitable.
My general knowledge is that lineage of Jewish persons is through the mother. The mother is undisputed the father could be, eg from a raiding nation.
In tribal cultures of the region the men often died in battles or raids before their offspring reached adult hood, necessarily the adult uncles that were alive and fit became the providers for any dependants. eg: Mohammed(P) the prophet was raised from 8 years old by his Uncle Abu Tahlib. Mohammed Ali Baquir is the son of Uncle Abu Tahlib and was raised from 8 years old by Mohammed the prophet. The two were first cousins. Mohammed(P)'s wife converted to Islam and they raised four daughters, one named Fatima and all four daughters married Caliph. Mohammed Ali was raised as a sibling of Fatima his second cousin. While Mohammed(P) was alive Mohammed Ali married Fatima and they had two sons. You can find this by looking and linking through the Wikipedia,creating your own geneology, subject to verification of what is posted.
Actual Biology is important. Jesus physically was the son of David through his mother Mary. Most bible scholars agree Luke 3 is a relation of Jesus's genealogy through Mary by David's son Nathan as it traces the linage of Jesus different than Matthew 1 (Joesph's genealogy through Solomon).