accounting: better strategy for grouping reference of internal invoices

Make sure we don't set grouping reference on lines that have a valid
group only for source (or destination) but not for the other side.
Status Job ID Name Coverage
  External
passed ERP5.CodingStyleTest-Master

passed ERP5.CodingStyleTest-TestRunner2

02:14:52

failed ERP5.UnitTest-Master

failed ERP5.UnitTest-Master.Medusa

failed ERP5.UnitTest-TestRunner2

03:49:02

passed ERP5.CodingStyleTest-TestRunner2

01:46:25

failed ERP5.UnitTest-TestRunner2

02:57:01