The magnetic flux needs to be included as a function of position to get the total flux and thereby the total inductance. The simplest solution for the B field for a finite length solenoid (it turns out to be exact), is to use a result from the "pole method" of magnetostatics. The B (M.K.S. units) inside the solenoid will be equal to ## B_z= n*\mu_o*I ## plus a subtractive correction term of the B from poles of surface magnetic charge density ## \sigma_m=n*\mu_o*I ## with a "+" pole on the right and a "-" pole on the left. The magnetic surface charge density in this mathematical solution is considered to be uniform over the opening of the solenoid. I don't have a "link" for you, but I do think you could possibly find this solution in one of the older and more advanced E&M texts. One result you get from the above is that the B field at the openings of any finite length solenoid is exactly half of the value that it takes on for one of infinite length.