Example #1
0
        public void GetXmlTest()
        {
            string expected = @"<?xml version=""1.0"" encoding=""utf-8""?>
<function controlid=""unittest"">
    <create>
        <GLBATCH>
            <JOURNAL />
            <BATCH_DATE />
            <BATCH_TITLE />
            <ENTRIES>
                <GLENTRY>
                    <ACCOUNTNO />
                    <TR_TYPE>1</TR_TYPE>
                    <TRX_AMOUNT />
                </GLENTRY>
            </ENTRIES>
        </GLBATCH>
    </create>
</function>";

            StatisticalJournalEntryCreate record = new StatisticalJournalEntryCreate("unittest");

            StatisticalJournalEntryLineCreate line1 = new StatisticalJournalEntryLineCreate();

            record.Lines.Add(line1);

            this.CompareXml(expected, record);
        }
        /// <summary>
        /// Sends a Hours Journal to the Intacct STATISTIC System
        /// </summary>
        /// <param name="client"></param>
        /// <param name="Org"></param>
        /// <param name="lines"></param>
        /// <param name="PostingDate"></param>
        /// <param name="ReferenceNumber"></param>
        /// <param name="JournalSymbol"></param>
        /// <param name="Description"></param>
        /// <param name="HistoryComment"></param>
        /// <param name="AsDraft"></param>
        /// <returns></returns>
        private async Task SendStatHoursJournalCmd(OnlineClient client, int Org, IEnumerable <IntacctStatHours> lines, DateTime PostingDate, string ReferenceNumber, string JournalSymbol, string Description, string HistoryComment, bool AsDraft)
        {
            StatisticalJournalEntryCreate create = new StatisticalJournalEntryCreate();

            create.JournalSymbol   = JournalSymbol;
            create.ReferenceNumber = ReferenceNumber;
            create.PostingDate     = PostingDate;
            create.Description     = Description;
            create.HistoryComment  = HistoryComment;
            if (AsDraft)
            {
                create.CustomFields.Add("STATE", "Draft");
            }
            foreach (var item in lines)
            {
                StatisticalJournalEntryLineCreate line = new StatisticalJournalEntryLineCreate
                {
                    StatAccountNumber = item.Account,
                    Amount            = decimal.Parse(item.Hours.ToString("F2")),
                    Memo = $"Part of Practice Engine Batch #{item.BatchID}"
                };
                if (!String.IsNullOrWhiteSpace(item.EmployeeID))
                {
                    line.EmployeeId = item.EmployeeID;
                }
                if (!String.IsNullOrWhiteSpace(item.ProjectID))
                {
                    line.ProjectId = item.ProjectID;
                }
                if (!String.IsNullOrWhiteSpace(item.IntacctCustomerID))
                {
                    line.CustomerId = item.IntacctCustomerID;
                }
                if (!String.IsNullOrWhiteSpace(item.IntacctDepartment))
                {
                    line.DepartmentId = item.IntacctDepartment;
                }
                if (!String.IsNullOrWhiteSpace(item.IntacctLocation))
                {
                    line.LocationId = item.IntacctLocation;
                }
                create.Lines.Add(line);
            }
            OnlineResponse onlineResponse = await client.Execute(create);

            foreach (var result in onlineResponse.Results)
            {
                result.EnsureStatusSuccess();
            }
        }
Example #3
0
        public void GetAllXmlTest()
        {
            string expected = @"<?xml version=""1.0"" encoding=""utf-8""?>
<function controlid=""unittest"">
    <create>
        <GLBATCH>
            <JOURNAL>SJ</JOURNAL>
            <BATCH_DATE>06/30/2016</BATCH_DATE>
            <REVERSEDATE>07/01/2016</REVERSEDATE>
            <BATCH_TITLE>My desc</BATCH_TITLE>
            <HISTORY_COMMENT>comment!</HISTORY_COMMENT>
            <REFERENCENO>123</REFERENCENO>
            <SUPDOCID>AT001</SUPDOCID>
            <STATE>Posted</STATE>
            <CUSTOMFIELD01>test01</CUSTOMFIELD01>
            <ENTRIES>
                <GLENTRY>
                    <ACCOUNTNO />
                    <TR_TYPE>1</TR_TYPE>
                    <TRX_AMOUNT />
                </GLENTRY>
            </ENTRIES>
        </GLBATCH>
    </create>
</function>";

            StatisticalJournalEntryCreate record = new StatisticalJournalEntryCreate("unittest")
            {
                JournalSymbol   = "SJ",
                PostingDate     = new DateTime(2016, 06, 30),
                ReverseDate     = new DateTime(2016, 07, 01),
                Description     = "My desc",
                HistoryComment  = "comment!",
                ReferenceNumber = "123",
                AttachmentsId   = "AT001",
                Action          = "Posted",
                CustomFields    = new Dictionary <string, dynamic>
                {
                    { "CUSTOMFIELD01", "test01" }
                },
            };

            StatisticalJournalEntryLineCreate line1 = new StatisticalJournalEntryLineCreate();

            record.Lines.Add(line1);

            this.CompareXml(expected, record);
        }
        public void GetXmlTest()
        {
            string expected = @"<?xml version=""1.0"" encoding=""utf-8""?>
<function controlid=""unittest"">
    <create>
        <GLBATCH>
            <JOURNAL />
            <BATCH_DATE />
            <BATCH_TITLE />
            <ENTRIES>
                <GLENTRY>
                    <ACCOUNTNO />
                    <TR_TYPE>1</TR_TYPE>
                    <TRX_AMOUNT />
                </GLENTRY>
            </ENTRIES>
        </GLBATCH>
    </create>
</function>";

            Stream            stream      = new MemoryStream();
            XmlWriterSettings xmlSettings = new XmlWriterSettings();

            xmlSettings.Encoding    = Encoding.UTF8;
            xmlSettings.Indent      = true;
            xmlSettings.IndentChars = "    ";

            IaXmlWriter xml = new IaXmlWriter(stream, xmlSettings);

            StatisticalJournalEntryCreate record = new StatisticalJournalEntryCreate("unittest");

            StatisticalJournalEntryLineCreate line1 = new StatisticalJournalEntryLineCreate();

            record.Lines.Add(line1);

            record.WriteXml(ref xml);

            xml.Flush();
            stream.Position = 0;
            StreamReader reader = new StreamReader(stream);

            Diff xmlDiff = DiffBuilder.Compare(expected).WithTest(reader.ReadToEnd())
                           .WithDifferenceEvaluator(DifferenceEvaluators.Default)
                           .Build();

            Assert.IsFalse(xmlDiff.HasDifferences(), xmlDiff.ToString());
        }
        public void GetAllXmlTest()
        {
            string expected = @"<?xml version=""1.0"" encoding=""utf-8""?>
<function controlid=""unittest"">
    <create>
        <GLBATCH>
            <JOURNAL>SJ</JOURNAL>
            <BATCH_DATE>06/30/2016</BATCH_DATE>
            <REVERSEDATE>07/01/2016</REVERSEDATE>
            <BATCH_TITLE>My desc</BATCH_TITLE>
            <HISTORY_COMMENT>comment!</HISTORY_COMMENT>
            <REFERENCENO>123</REFERENCENO>
            <SUPDOCID>AT001</SUPDOCID>
            <STATE>Posted</STATE>
            <CUSTOMFIELD01>test01</CUSTOMFIELD01>
            <ENTRIES>
                <GLENTRY>
                    <ACCOUNTNO />
                    <TR_TYPE>1</TR_TYPE>
                    <TRX_AMOUNT />
                </GLENTRY>
            </ENTRIES>
        </GLBATCH>
    </create>
</function>";

            Stream            stream      = new MemoryStream();
            XmlWriterSettings xmlSettings = new XmlWriterSettings();

            xmlSettings.Encoding    = Encoding.UTF8;
            xmlSettings.Indent      = true;
            xmlSettings.IndentChars = "    ";

            IaXmlWriter xml = new IaXmlWriter(stream, xmlSettings);

            StatisticalJournalEntryCreate record = new StatisticalJournalEntryCreate("unittest")
            {
                JournalSymbol   = "SJ",
                PostingDate     = new DateTime(2016, 06, 30),
                ReverseDate     = new DateTime(2016, 07, 01),
                Description     = "My desc",
                HistoryComment  = "comment!",
                ReferenceNumber = "123",
                AttachmentsId   = "AT001",
                Action          = "Posted",
                CustomFields    = new Dictionary <string, dynamic>
                {
                    { "CUSTOMFIELD01", "test01" }
                },
            };

            StatisticalJournalEntryLineCreate line1 = new StatisticalJournalEntryLineCreate();

            record.Lines.Add(line1);

            record.WriteXml(ref xml);

            xml.Flush();
            stream.Position = 0;
            StreamReader reader = new StreamReader(stream);

            Diff xmlDiff = DiffBuilder.Compare(expected).WithTest(reader.ReadToEnd())
                           .WithDifferenceEvaluator(DifferenceEvaluators.Default)
                           .Build();

            Assert.IsFalse(xmlDiff.HasDifferences(), xmlDiff.ToString());
        }