public PostCommoditiesIterator(Journal journal) { Posts = new XactPostsIterator(); XactTemps = new List <Xact>(); Temps = new Temporaries(); Reset(journal); }
public SubtotalPosts(PostHandler handler, Expr amountExpr, string dateFormat = null) : base(handler) { AmountExpr = amountExpr; DateFormat = dateFormat; ComponentPosts = new List <Post>(); Temps = new Temporaries(); Values = new SortedDictionary <string, AcctValue>(); }
public TransferDetails(PostHandler handler, TransferDetailsElementEnum whichElement, Account master, Expr expr, Scope scope) : base(handler) { Master = master; Expr = expr; Scope = scope; WhichElement = whichElement; Temps = new Temporaries(); }
public DisplayFilterPosts(PostHandler handler, Report report, bool showRounding) : base(handler) { Report = report; DisplayAmountExpr = report.DisplayAmountHandler.Expr; DisplayTotalExpr = report.DisplayTotalHandler.Expr; ShowRounding = showRounding; Temps = new Temporaries(); CreateAccounts(); }
public void Temporaries_CreateAccount_CreatesTempAccount() { var temps = new Temporaries(); var tempAccount = temps.CreateAccount("temp-account"); Assert.True(tempAccount.IsTempAccount); Assert.Equal("temp-account", tempAccount.Name); Assert.Equal(temps.LastAccount, tempAccount); }
public HLTemporary CreateTemporary(HLType pType) { HLTemporary temporary = new HLTemporary(); temporary.Name = "temp_" + Temporaries.Count; //temporary.Container = this; temporary.Type = pType; Temporaries.Add(temporary); return(temporary); }
public CollapsePosts(PostHandler handler, Report report, Expr amountExpr, Predicate displayPredicate, Predicate onlyPredicate, bool onlyCollapseIfZero = false) : base(handler) { AmountExpr = amountExpr; DisplayPredicate = displayPredicate; OnlyPredicate = onlyPredicate ?? Predicate.EmptyPredicate; OnlyCollapseIfZero = onlyCollapseIfZero; Report = report; Temps = new Temporaries(); ComponentPosts = new List <Post>(); CreateAccounts(); }
public InjectPosts(PostHandler handler, string tagList, Account master) : base(handler) { TagsList = new List <Tuple <string, Account, ISet <Xact> > >(); Temps = new Temporaries(); foreach (string q in tagList.Split(',').Select(s => s.Trim())) { string[] accountNames = q.Split(':'); Account account = FiltersCommon.CreateTempAccountFromPath(accountNames, Temps, master); account.IsGeneratedAccount = true; TagsList.Add(new Tuple <string, Account, ISet <Xact> >(q, account, new HashSet <Xact>())); } }
public static async Task AddTemporary(string videoid) { if (!Temporaries.Any(x => x.VideoId == videoid)) { Temporaries.Add(new TNicoTemporary(videoid, DateTime.Now.Ticks)); using (var control = await DbUtil.GetControl()) { await control.BeginTransaction(); await control.MergeNicoTemporary(videoid, DateTime.Now); await control.Commit(); } } }
public void Temporaries_CopyPost_ClonesOriginalPost() { var temps = new Temporaries(); var xact = new Xact(); var origin = new Post() { Account = new Account() }; var tempPost = temps.CopyPost(origin, xact); // CopyPost adds ITEM_TEMP flag Assert.False(origin.Flags.HasFlag(SupportsFlagsEnum.ITEM_TEMP)); Assert.True(tempPost.Flags.HasFlag(SupportsFlagsEnum.ITEM_TEMP)); Assert.Equal(temps.LastPost, tempPost); Assert.NotEqual(temps.LastPost, origin); }
public static async Task DeleteTemporary(string videoid) { if (Temporaries.Any(x => x.VideoId == videoid)) { Temporaries.Remove(Temporaries.First(x => x.VideoId == videoid)); using (var control = await DbUtil.GetControl()) { await control.BeginTransaction(); await control.DeleteNicoTemporary(videoid); await control.Commit(); } await AddHistory(videoid); } }
public ChangedValuePost(PostHandler handler, Report report, bool forAccountsReports, bool showUnrealized, DisplayFilterPosts displayFilter) : base(handler) { Report = report; TotalExpr = report.RevaluedTotalHandler.Handled ? report.RevaluedTotalHandler.Expr : report.DisplayTotalHandler.Expr; DisplayTotalExpr = report.DisplayTotalHandler.Expr; ChangedValuesOnly = report.RevaluedOnlyHandler.Handled; HistoricalPricesOnly = report.HistoricalHandler.Handled; ForAccountsReports = forAccountsReports; ShowUnrealized = showUnrealized; DisplayFilter = displayFilter; Temps = new Temporaries(); string gainsEquityAccountName; if (report.UnrealizedGainsHandler.Handled) { gainsEquityAccountName = report.UnrealizedGainsHandler.Str(); } else { gainsEquityAccountName = "Equity:Unrealized Gains"; } GainsEquityAccount = report.Session.Journal.Master.FindAccount(gainsEquityAccountName); GainsEquityAccount.IsGeneratedAccount = true; string lossesEquityAccountName; if (report.UnrealizedLossesHandler.Handled) { lossesEquityAccountName = report.UnrealizedLossesHandler.Str(); } else { lossesEquityAccountName = "Equity:Unrealized Losses"; } LossesEquityAccount = report.Session.Journal.Master.FindAccount(lossesEquityAccountName); LossesEquityAccount.IsGeneratedAccount = true; CreateAccounts(); }
public void Temporaries_Dispose_ClearsTemporaries() { var temps = new Temporaries(); var xact = new Xact(); var origin = new Post() { Account = new Account() }; temps.CreateAccount("temp-account1"); temps.CreateAccount("temp-account2"); temps.CopyPost(origin, xact); Assert.NotNull(temps.LastAccount); Assert.NotNull(temps.LastPost); temps.Dispose(); Assert.Null(temps.LastAccount); Assert.Null(temps.LastPost); temps.Dispose(); // Note - Dispose is tolerant to multiple calls }
/// <summary> /// Ported from handle_value /// </summary> public static void HandleValue(Value value, Account account, Xact xact, Temporaries temps, PostHandler handler, Date date = default(Date), bool actDateP = true, Value total = null, bool directAmount = false, bool markVisited = false, bool bidirLink = true) { Post post = temps.CreatePost(xact, account, bidirLink); post.Flags |= SupportsFlagsEnum.ITEM_GENERATED; // If the account for this post is all virtual, then report the post as // such. This allows subtotal reports to show "(Account)" for accounts // that contain only virtual posts. if (account != null && account.HasXData && account.XData.AutoVirtualize) { if (!account.XData.HasNonVirtuals) { post.Flags |= SupportsFlagsEnum.POST_VIRTUAL; if (!account.XData.HasUnbVirtuals) { post.Flags |= SupportsFlagsEnum.POST_MUST_BALANCE; } } } PostXData xdata = post.XData; if (date.IsValid()) { if (actDateP) { xdata.Date = date; } else { xdata.ValueDate = date; } } Value temp = Value.Clone(value); switch (value.Type) { case ValueTypeEnum.Boolean: case ValueTypeEnum.Integer: temp.InPlaceCast(ValueTypeEnum.Amount); post.Amount = temp.AsAmount; break; case ValueTypeEnum.Amount: post.Amount = temp.AsAmount; break; case ValueTypeEnum.Balance: case ValueTypeEnum.Sequence: xdata.CompoundValue = temp; xdata.Compound = true; break; default: throw new InvalidOperationException(); } if (!Value.IsNullOrEmpty(total)) { xdata.Total = total; } if (directAmount) { xdata.DirectAmt = true; } Logger.Current.Debug("filters.changed_value.rounding", () => String.Format("post.amount = {0}", post.Amount)); handler.Handle(post); if (markVisited) { post.XData.Visited = true; post.Account.XData.Visited = true; } }
public static Account CreateTempAccountFromPath(IEnumerable <string> accountNames, Temporaries temps, Account master) { Account newAccount = null; foreach (string name in accountNames) { if (newAccount != null) { newAccount = newAccount.FindAccount(name); } else { newAccount = master.FindAccount(name, false); if (newAccount == null) { newAccount = temps.CreateAccount(name, master); } } } if (newAccount == null) { throw new InvalidOperationException("newAccount"); } return(newAccount); }
public GeneratePosts(PostHandler handler) : base(handler) { PendingPosts = new List <PendingPostsPair>(); Temps = new Temporaries(); }