For whatever it is worth, here is what the ERISA Outline Book says,
"If a self-employed individual is engaged in more than one trade or business, the earned income of each trade or business is determined separately, according to Treas. Reg. 1.401-10(b)(2). For example, if one business produces earned income of $50,000 and the other business produces a loss of $60,000, the individual does not net the earned income of the two businesses. The $50,000 of earned income from the first business may be used to support a qualified plan contribution ...
"IRS apparently agrees with interpretation ...
"Note that some commentators take the position that a net loss must be offset against the net gain, so that a self-employed individual has less earned income taken into account under the qualified plan ... we feel that IRC section 401(d) and Treas. Reg. 1.401-10(b)(2) support the conclusion that a net loss should be treated as "zero" compensation, not as negative compensation."
This perspective seems to be contrary to the consensus on this forum. I hope someone can chip in and clarify.