Except as otherwise provided in this section, in the case of a taxpayer who is an individual or an S corporation, no deduction otherwise allowable under this chapter shall be allowed with respect to the use of a dwelling unit which is used by the taxpayer during the taxable year as a residence.
Subsection (a) shall not apply to any deduction allowable to the taxpayer without regard to its connection with his trade or business (or with his income-producing activity).
Subsection (a) shall not apply to any item to the extent such item is allocable to space within the dwelling unit which is used on a regular basis as a storage unit for the inventory or product samples of the taxpayer held for use in the taxpayer’s trade or business of selling products at retail or wholesale, but only if the dwelling unit is the sole fixed location of such trade or business.
Subsection (a) shall not apply to any item which is attributable to the rental of the dwelling unit or portion thereof (determined after the application of subsection (e)).
Subsection (a) shall not apply to any item to the extent that such item is allocable to the use of any portion of the dwelling unit on a regular basis in the taxpayer’s trade or business of providing day care for children, for individuals who have attained age 65, or for individuals who are physically or mentally incapable of caring for themselves.
If a portion of the taxpayer’s dwelling unit used for the purposes described in subparagraph (A) is not used exclusively for those purposes, the amount of the expenses attributable to that portion shall not exceed an amount which bears the same ratio to the total amount of the items allocable to such portion as the number of hours the portion is used for such purposes bears to the number of hours the portion is available for use.
Paragraphs (1) and (3) shall not apply to any item which is attributable to the rental of the dwelling unit (or any portion thereof) by the taxpayer to his employer during any period in which the taxpayer uses the dwelling unit (or portion) in performing services as an employee of the employer.
A taxpayer shall not be treated as using a dwelling unit for personal purposes by reason of a rental arrangement for any period if for such period such dwelling unit is rented, at a fair rental, to any person for use as such person’s principal residence.
Subparagraph (A) shall apply to a rental to a person who has an interest in the dwelling unit only if such rental is pursuant to a shared equity financing agreement.
In the case of a rental pursuant to a shared equity financing agreement, fair rental shall be determined as of the time the agreement is entered into and by taking into account the occupant’s qualified ownership interest.
For purposes of this paragraph, the term “qualified ownership interest” means an undivided interest for more than 50 years in the entire dwelling unit and appurtenant land being acquired in the transaction to which the shared equity financing agreement relates.
For purposes of applying subsection (c)(5) to deductions allocable to a qualified rental period, a taxpayer shall not be considered to have used a dwelling unit for personal purposes for any day during the taxable year which occurs before or after a qualified rental period described in subparagraph (B)(i), or before a qualified rental period described in subparagraph (B)(ii), if with respect to such day such unit constitutes the principal residence (within the meaning of section 121) of the taxpayer.
In any case where a taxpayer who is an individual or an S corporation uses a dwelling unit for personal purposes on any day during the taxable year (whether or not he is treated under this section as using such unit as a residence), the amount deductible under this chapter with respect to expenses attributable to the rental of the unit (or portion thereof) for the taxable year shall not exceed an amount which bears the same relationship to such expenses as the number of days during each year that the unit (or portion thereof) is rented at a fair rental bears to the total number of days during such year that the unit (or portion thereof) is used.
The term “dwelling unit” includes a house, apartment, condominium, mobile home, boat, or similar property, and all structures or other property appurtenant to such dwelling unit.
The term “dwelling unit” does not include that portion of a unit which is used exclusively as a hotel, motel, inn, or similar establishment.
In the case of an S corporation, subparagraphs (A) and (B) of subsection (d)(2) shall be applied by substituting “any shareholder of the S corporation” for “the taxpayer” each place it appears.
Nothing in this section shall be construed to disallow any deduction allowable under section 162(a)(2) (or any deduction which meets the tests of section 162(a)(2) but is allowable under another provision of this title) by reason of the taxpayer’s being away from home in the pursuit of a trade or business (other than the trade or business of renting dwelling units).