Exemplo n.º 1
0
        public override void Handle(Post post)
        {
            bool copyXactDetails = false;

            if (LastXact != post.Xact)
            {
                Temps.CopyXact(post.Xact);
                LastXact        = post.Xact;
                copyXactDetails = true;
            }
            Xact xact = Temps.LastXact;

            xact.Code = null;

            if (copyXactDetails)
            {
                xact.CopyDetails(post.Xact);

                string buf = String.Format("{0}{1}{0}", post.Xact.Payee, IntegerGen.Value());

                xact.Payee = SHA1.GetHash(buf);
                xact.Note  = null;
            }
            else
            {
                xact.Journal = post.Xact.Journal;
            }

            IList <string> accountNames = new List <string>();

            for (Account acct = post.Account; acct != null; acct = acct.Parent)
            {
                string buf = String.Format("{0}{1}{2}", IntegerGen.Value(), acct, acct.FullName);

                accountNames.Add(SHA1.GetHash(buf));
            }

            Account newAccount = FiltersCommon.CreateTempAccountFromPath(accountNames, Temps, xact.Journal.Master);
            Post    temp       = Temps.CopyPost(post, xact, newAccount);

            temp.Note   = null;
            temp.Flags |= SupportsFlagsEnum.POST_ANONYMIZED;

            RenderCommodity(temp.Amount);
            if (temp.Amount.HasAnnotation)
            {
                temp.Amount.Annotation.Tag = null;
                if (temp.Amount.Annotation.Price != null)
                {
                    RenderCommodity(temp.Amount.Annotation.Price);
                }
            }

            if (temp.Cost != null)
            {
                RenderCommodity(temp.Cost);
            }
            if (temp.AssignedAmount != null)
            {
                RenderCommodity(temp.AssignedAmount);
            }

            base.Handle(temp);
        }