private void CreatePriceXact(DateTime date, Amount price, IDictionary <string, Xact> xactsByCommodity, Journal journal, Account account) { Xact xact; string symbol = price.Commodity.Symbol; if (!xactsByCommodity.TryGetValue(symbol, out xact)) { xact = Temps.CreateXact(); XactTemps.Add(xact); xact.Payee = symbol; xact.Date = (Date)date.Date; xactsByCommodity.Add(symbol, xact); xact.Journal = journal; } bool postAlreadyExists = false; foreach (Post post in xact.Posts) { if (post.Date == date && post.Amount == price) { postAlreadyExists = true; break; } } if (!postAlreadyExists) { Post temp = Temps.CreatePost(xact, account); temp.Date = (Date)date.Date; temp.Amount = price; temp.XData.Datetime = date; } }
public Xact CreateXact() { if (XactTemps == null) { XactTemps = new List <Xact>(); } Xact temp = new Xact(); temp.Flags |= SupportsFlagsEnum.ITEM_TEMP; XactTemps.Add(temp); return(temp); }
public Xact CopyXact(Xact origin) { if (XactTemps == null) { XactTemps = new List <Xact>(); } XactTemps.Add(origin); Xact temp = new Xact(origin); temp.Flags |= SupportsFlagsEnum.ITEM_TEMP; return(temp); }
public void Clear() { if (PostTemps != null) { foreach (Post post in PostTemps) { if (!post.Xact.Flags.HasFlag(SupportsFlagsEnum.ITEM_TEMP)) { post.Xact.RemovePost(post); } if (post.Account != null && !post.Account.IsTempAccount) { post.Account.RemovePost(post); } } PostTemps.Clear(); } if (XactTemps != null) { XactTemps.Clear(); } if (AcctTemps != null) { foreach (Account acct in AcctTemps) { if (acct.Parent != null && !acct.Parent.IsTempAccount) { acct.Parent.RemoveAccount(acct); } } AcctTemps.Clear(); } }