There is imposed a tax on the taxable income of an "S" corporation that has:
(1) elected S corporation status pursuant to section 1362 of the Internal Revenue Code of 1986, as amended through December 31, 1986, before January 1, 1987;
(2) a net capital gain for the taxable year (i) in excess of $25,000 and (ii) exceeding 50 percent of the corporation's federal taxable income for the taxable year; and
(3) federal taxable income for the taxable year exceeding $25,000.
The tax is imposed at the rate prescribed by section 290.06, subdivision 1. For purposes of this section, "federal taxable income" means federal taxable income determined under section 1374(4)(d) of the Internal Revenue Code. This section does not apply to an S corporation which has had an election under section 1362 of the Internal Revenue Code of 1954, in effect for the three immediately preceding taxable years. This section does not apply to an S corporation that has been in existence for less than four taxable years and has had an election in effect under section 1362 of the Internal Revenue Code of 1954 for each of the corporation's taxable years. For purposes of this section, an S corporation and any predecessor corporation are treated as one corporation.
For purposes of this section, taxable income means the lesser of:
(1) the amount of the net capital gain of the S corporation for the taxable year, as determined under sections 1222 and 1374 of the Internal Revenue Code, and subject to the modifications provided in section 290.0135, in excess of $25,000 that is allocable to this state under section 290.17, 290.191, or 290.20; or