/// <summary> /// Find a split matching the given transaction. /// This is only used during QIF importing to link up transfers. /// </summary> /// <param name="t">The transaction we are importing</param> /// <param name="to"></param> /// <returns></returns> public Transfer FindSplitTransfer(Splits splits, Transaction t, Account to) { foreach (Split s in splits.GetSplits()) { if (s.Amount == -t.Amount && s.Category == t.Category) { if (s.Transfer != null) { if (s.Transfer.Transaction == t) { // already hooked up then! return(s.Transfer); } // another exact same transfer on the same day is already hooked up to a different transaction. // weird, but it happens sometimes when people transfer money to the wrong account then fix it. continue; } // Hook it up then, this Split looks to be the other side of the transfer transaction 't'. return(s.Transfer = new Transfer(0, s.Transaction, s, t)); } } return(null); }