Пример #1
0
        /// <remarks>ported from create_timelog_xact</remarks>
        public static void CreateTimelogXact(TimeXact inEvent, TimeXact outEvent, ParseContext context)
        {
            Xact curr = new Xact()
            {
                Date  = (Date)inEvent.Checkin.Date,
                Code  = outEvent.Desc, // if it wasn't used above
                Payee = inEvent.Desc,
                Pos   = inEvent.Position
            };

            if (!String.IsNullOrEmpty(inEvent.Note))
            {
                curr.AppendNote(inEvent.Note, context.Scope);
            }

            string buf = String.Format("{0}s", (outEvent.Checkin - inEvent.Checkin).TotalSeconds);

            Amount amt = new Amount();

            amt.Parse(ref buf);
            Validator.Verify(() => amt.Valid());

            Post post = new Post(inEvent.Account, amt);

            post.Flags   |= SupportsFlagsEnum.POST_VIRTUAL;
            post.State    = outEvent.Completed ? ItemStateEnum.Cleared : ItemStateEnum.Uncleared;
            post.Pos      = inEvent.Position;
            post.Checkin  = inEvent.Checkin;
            post.Checkout = outEvent.Checkin;
            curr.AddPost(post);
            inEvent.Account.AddPost(post);

            if (!context.Journal.AddXact(curr))
            {
                throw new ParseError(ParseError.ParseError_FailedToRecordOutTimelogTransaction);
            }
        }