(a) In determining the tax of a shareholder for the shareholder's taxable year in which the taxable year of the Alabama S corporation ends, or for the final taxable year of a shareholder who dies or of a trust or estate that terminates before the end of the corporation's taxable year, there shall be taken into account the shareholder's pro rata share of the corporation's:
(1) Items of income, including tax-exempt income, loss, deduction, or credit the separate treatment of which could affect the liability for tax of any shareholder, including charitable contributions, and
(2) Nonseparately computed income or loss. The term "nonseparately computed income or loss" means gross income minus the deductions allowed to the corporation under this article, determined by excluding all items described in subdivision (1) of this subsection.
(b) The character of any item included in a shareholder's pro rata share under subsection (a) of this section shall be determined as if the item were realized directly from the source from which realized by the corporation, or incurred in the same manner as incurred by the corporation.
(c) In any case where it is necessary to determine the gross income of a shareholder for purposes of this article, such gross income shall include the shareholder's pro rata share of the gross income of the corporation.
(d) The following special rules for losses and deductions shall apply:
(1) The aggregate amount of losses and deductions taken into account by a shareholder under subsection (a) of this section for any taxable year shall not exceed the sum of:
a. The adjusted basis of the shareholder's stock in the Alabama S corporation as determined with regard to subsections (a) and (b)(1) of Section 40-18-164 for the taxable year, and
b. The shareholder's adjusted basis of any indebtedness of the Alabama S corporation to the shareholder as determined without regard to any adjustment under subsection (c)(2) of Section 40-18-164 for the taxable year.
(2) Any loss or deduction which is disallowed for any taxable year by reason of subdivision (1) of this subsection shall be treated as incurred by the corporation in the succeeding taxable year with respect to that shareholder.
(3) The carryover of disallowed losses and deductions to the post-termination transition period shall be determined as follows:
a. If for the last taxable year of a corporation for which it was an Alabama S corporation, a loss or deduction was disallowed by reason of subdivision (1) of this subsection, the loss or deduction shall be treated as incurred by the shareholder on the last day of any post-termination transition period.
b. The aggregate amount of losses and deductions taken into account by a shareholder under paragraph a of this subdivision shall not exceed the adjusted basis of the shareholder's stock in the corporation as determined at the close of the last day of the post-termination transition period and without regard to this paragraph.
c. The shareholder's basis in the stock of the corporation shall be reduced by the amount allowed as a deduction by reason of this subdivision.
(e) If any Alabama income tax is imposed under Section 40-18-174 for any taxable year on an Alabama S corporation, for purposes of subsection (a), the amount of each recognized built-in gain, within the meaning of Section 40-18-174, for the taxable year shall be reduced by its proportionate share of the tax.
(f) If any tax is imposed under Section 40-18-175 for any taxable year on an Alabama S corporation, for purposes of subsection (a), each item of passive investment income shall be reduced by an amount which bears the same ratio to the amount of such tax as the amount of the item bears to the total passive investment income for the taxable year.