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> <GLENTRY> <ACCOUNTNO /> <TR_TYPE>1</TR_TYPE> <TRX_AMOUNT /> </GLENTRY> </ENTRIES> </GLBATCH> </create> </function>"; JournalEntryCreate record = new JournalEntryCreate("unittest"); JournalEntryLineCreate line1 = new JournalEntryLineCreate(); JournalEntryLineCreate line2 = new JournalEntryLineCreate(); record.Lines.Add(line1); record.Lines.Add(line2); this.CompareXml(expected, record); }
public void CreditAmountTest() { string expected = @"<?xml version=""1.0"" encoding=""utf-8""?> <GLENTRY> <ACCOUNTNO /> <TR_TYPE>-1</TR_TYPE> <TRX_AMOUNT>400.23</TRX_AMOUNT> </GLENTRY>"; Stream stream = new MemoryStream(); XmlWriterSettings xmlSettings = new XmlWriterSettings(); xmlSettings.Encoding = Encoding.UTF8; xmlSettings.Indent = true; xmlSettings.IndentChars = " "; IaXmlWriter xml = new IaXmlWriter(stream, xmlSettings); JournalEntryLineCreate record = new JournalEntryLineCreate(); record.TransactionAmount = -400.23M; 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 CustomAllocationTest() { string expected = @"<?xml version=""1.0"" encoding=""utf-8""?> <GLENTRY> <ACCOUNTNO>1010</ACCOUNTNO> <TR_TYPE>1</TR_TYPE> <TRX_AMOUNT>1000.00</TRX_AMOUNT> <ALLOCATION>Custom</ALLOCATION> <SPLIT> <AMOUNT>600.00</AMOUNT> </SPLIT> <SPLIT> <AMOUNT>400.00</AMOUNT> </SPLIT> </GLENTRY>"; Stream stream = new MemoryStream(); XmlWriterSettings xmlSettings = new XmlWriterSettings(); xmlSettings.Encoding = Encoding.UTF8; xmlSettings.Indent = true; xmlSettings.IndentChars = " "; IaXmlWriter xml = new IaXmlWriter(stream, xmlSettings); JournalEntryLineCreate record = new JournalEntryLineCreate() { GlAccountNumber = "1010", TransactionAmount = 1000.00M, AllocationId = "Custom", }; CustomAllocationSplit split1 = new CustomAllocationSplit() { Amount = 600.00M, }; CustomAllocationSplit split2 = new CustomAllocationSplit() { Amount = 400.00M, }; record.CustomAllocationSplits.Add(split1); record.CustomAllocationSplits.Add(split2); 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>GJ</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> <BASELOCATION_NO>100</BASELOCATION_NO> <SUPDOCID>AT001</SUPDOCID> <STATE>Posted</STATE> <CUSTOMFIELD01>test01</CUSTOMFIELD01> <ENTRIES> <GLENTRY> <ACCOUNTNO /> <TR_TYPE>1</TR_TYPE> <TRX_AMOUNT /> </GLENTRY> <GLENTRY> <ACCOUNTNO /> <TR_TYPE>1</TR_TYPE> <TRX_AMOUNT /> </GLENTRY> </ENTRIES> </GLBATCH> </create> </function>"; JournalEntryCreate record = new JournalEntryCreate("unittest") { JournalSymbol = "GJ", PostingDate = new DateTime(2016, 06, 30), ReverseDate = new DateTime(2016, 07, 01), Description = "My desc", HistoryComment = "comment!", ReferenceNumber = "123", AttachmentsId = "AT001", Action = "Posted", SourceEntityId = "100", CustomFields = new Dictionary <string, dynamic> { { "CUSTOMFIELD01", "test01" } }, }; JournalEntryLineCreate line1 = new JournalEntryLineCreate(); JournalEntryLineCreate line2 = new JournalEntryLineCreate(); record.Lines.Add(line1); record.Lines.Add(line2); this.CompareXml(expected, record); }
public void GetAllXmlTest() { string expected = @"<?xml version=""1.0"" encoding=""utf-8""?> <GLENTRY> <DOCUMENT>212</DOCUMENT> <ACCOUNTNO>1010</ACCOUNTNO> <TR_TYPE>1</TR_TYPE> <TRX_AMOUNT>1456.54</TRX_AMOUNT> <CURRENCY>USD</CURRENCY> <EXCH_RATE_DATE>06/30/2016</EXCH_RATE_DATE> <EXCH_RATE_TYPE_ID>Intacct Daily Rate</EXCH_RATE_TYPE_ID> <LOCATION>100</LOCATION> <DEPARTMENT>ADM</DEPARTMENT> <PROJECTID>P100</PROJECTID> <TASKID>T123</TASKID> <CUSTOMERID>C100</CUSTOMERID> <VENDORID>V100</VENDORID> <EMPLOYEEID>E100</EMPLOYEEID> <ITEMID>I100</ITEMID> <CLASSID>C200</CLASSID> <CONTRACTID>C300</CONTRACTID> <WAREHOUSEID>W100</WAREHOUSEID> <DESCRIPTION>my memo</DESCRIPTION> <CUSTOM01>123</CUSTOM01> </GLENTRY>"; JournalEntryLineCreate record = new JournalEntryLineCreate() { DocumentNumber = "212", GlAccountNumber = "1010", TransactionAmount = 1456.54M, TransactionCurrency = "USD", ExchangeRateDate = new DateTime(2016, 06, 30), ExchangeRateType = "Intacct Daily Rate", Memo = "my memo", LocationId = "100", DepartmentId = "ADM", ProjectId = "P100", TaskId = "T123", CustomerId = "C100", VendorId = "V100", EmployeeId = "E100", ItemId = "I100", ClassId = "C200", ContractId = "C300", WarehouseId = "W100", CustomFields = new Dictionary <string, dynamic> { { "CUSTOM01", "123" } } }; 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> <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); JournalEntryCreate record = new JournalEntryCreate("unittest"); JournalEntryLineCreate line1 = new JournalEntryLineCreate(); JournalEntryLineCreate line2 = new JournalEntryLineCreate(); record.Lines.Add(line1); record.Lines.Add(line2); 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 GetXmlTest() { string expected = @"<?xml version=""1.0"" encoding=""utf-8""?> <GLENTRY> <ACCOUNTNO /> <TR_TYPE>1</TR_TYPE> <TRX_AMOUNT /> </GLENTRY>"; JournalEntryLineCreate record = new JournalEntryLineCreate(); this.CompareXml(expected, record); }
/// <summary> /// Sends a Journal to the Intacct GL 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 SendJournalCmd(OnlineClient client, int Org, IEnumerable <JournalExtract> lines, DateTime PostingDate, string ReferenceNumber, string JournalSymbol, string Description, string HistoryComment, bool AsDraft) { JournalEntryCreate create = new JournalEntryCreate(); 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) { JournalEntryLineCreate line = new JournalEntryLineCreate { GlAccountNumber = item.AccountCode, TransactionAmount = decimal.Parse(item.NomAmount.ToString("F2")), Memo = String.IsNullOrWhiteSpace(item.NomTransRef) ? item.NomNarrative : item.NomNarrative + " (" + item.NomTransRef + ")" }; if (!String.IsNullOrWhiteSpace(item.IntacctCustomerID)) { line.CustomerId = item.IntacctCustomerID; } if (!String.IsNullOrWhiteSpace(item.IntacctEmployeeID)) { line.EmployeeId = item.IntacctEmployeeID; } if (!String.IsNullOrWhiteSpace(item.IntacctProjectID)) { line.ProjectId = item.IntacctProjectID; } 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(); } }
public void CreditAmountTest() { string expected = @"<?xml version=""1.0"" encoding=""utf-8""?> <GLENTRY> <ACCOUNTNO /> <TR_TYPE>-1</TR_TYPE> <TRX_AMOUNT>400.23</TRX_AMOUNT> </GLENTRY>"; JournalEntryLineCreate record = new JournalEntryLineCreate { TransactionAmount = -400.23M }; this.CompareXml(expected, record); }
public void AllocationTest() { string expected = @"<?xml version=""1.0"" encoding=""utf-8""?> <GLENTRY> <ACCOUNTNO>1010</ACCOUNTNO> <TR_TYPE>1</TR_TYPE> <TRX_AMOUNT>1456.54</TRX_AMOUNT> <ALLOCATION>60-40</ALLOCATION> </GLENTRY>"; JournalEntryLineCreate record = new JournalEntryLineCreate() { GlAccountNumber = "1010", TransactionAmount = 1456.54M, AllocationId = "60-40", }; this.CompareXml(expected, record); }
public void CustomAllocationTest() { string expected = @"<?xml version=""1.0"" encoding=""utf-8""?> <GLENTRY> <ACCOUNTNO>1010</ACCOUNTNO> <TR_TYPE>1</TR_TYPE> <TRX_AMOUNT>1000.00</TRX_AMOUNT> <ALLOCATION>Custom</ALLOCATION> <SPLIT> <AMOUNT>600.00</AMOUNT> </SPLIT> <SPLIT> <AMOUNT>400.00</AMOUNT> </SPLIT> </GLENTRY>"; JournalEntryLineCreate record = new JournalEntryLineCreate() { GlAccountNumber = "1010", TransactionAmount = 1000.00M, AllocationId = "Custom", }; CustomAllocationSplit split1 = new CustomAllocationSplit() { Amount = 600.00M, }; CustomAllocationSplit split2 = new CustomAllocationSplit() { Amount = 400.00M, }; record.CustomAllocationSplits.Add(split1); record.CustomAllocationSplits.Add(split2); this.CompareXml(expected, record); }
public void GetAllXmlTest() { string expected = @"<?xml version=""1.0"" encoding=""utf-8""?> <GLENTRY> <DOCUMENT>212</DOCUMENT> <ACCOUNTNO>1010</ACCOUNTNO> <TR_TYPE>1</TR_TYPE> <TRX_AMOUNT>1456.54</TRX_AMOUNT> <CURRENCY>USD</CURRENCY> <EXCH_RATE_DATE>06/30/2016</EXCH_RATE_DATE> <EXCH_RATE_TYPE_ID>Intacct Daily Rate</EXCH_RATE_TYPE_ID> <LOCATION>100</LOCATION> <DEPARTMENT>ADM</DEPARTMENT> <PROJECTID>P100</PROJECTID> <CUSTOMERID>C100</CUSTOMERID> <VENDORID>V100</VENDORID> <EMPLOYEEID>E100</EMPLOYEEID> <ITEMID>I100</ITEMID> <CLASSID>C200</CLASSID> <CONTRACTID>C300</CONTRACTID> <WAREHOUSEID>W100</WAREHOUSEID> <DESCRIPTION>my memo</DESCRIPTION> <CUSTOM01>123</CUSTOM01> </GLENTRY>"; Stream stream = new MemoryStream(); XmlWriterSettings xmlSettings = new XmlWriterSettings(); xmlSettings.Encoding = Encoding.UTF8; xmlSettings.Indent = true; xmlSettings.IndentChars = " "; IaXmlWriter xml = new IaXmlWriter(stream, xmlSettings); JournalEntryLineCreate record = new JournalEntryLineCreate() { DocumentNumber = "212", GlAccountNumber = "1010", TransactionAmount = 1456.54M, TransactionCurrency = "USD", ExchangeRateDate = new DateTime(2016, 06, 30), ExchangeRateType = "Intacct Daily Rate", Memo = "my memo", LocationId = "100", DepartmentId = "ADM", ProjectId = "P100", CustomerId = "C100", VendorId = "V100", EmployeeId = "E100", ItemId = "I100", ClassId = "C200", ContractId = "C300", WarehouseId = "W100", CustomFields = new Dictionary <string, dynamic> { { "CUSTOM01", "123" } } }; 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>GJ</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> <BASELOCATION_NO>100</BASELOCATION_NO> <SUPDOCID>AT001</SUPDOCID> <STATE>Posted</STATE> <CUSTOMFIELD01>test01</CUSTOMFIELD01> <ENTRIES> <GLENTRY> <ACCOUNTNO /> <TR_TYPE>1</TR_TYPE> <TRX_AMOUNT /> </GLENTRY> <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); JournalEntryCreate record = new JournalEntryCreate("unittest") { JournalSymbol = "GJ", PostingDate = new DateTime(2016, 06, 30), ReverseDate = new DateTime(2016, 07, 01), Description = "My desc", HistoryComment = "comment!", ReferenceNumber = "123", AttachmentsId = "AT001", Action = "Posted", SourceEntityId = "100", CustomFields = new Dictionary <string, dynamic> { { "CUSTOMFIELD01", "test01" } }, }; JournalEntryLineCreate line1 = new JournalEntryLineCreate(); JournalEntryLineCreate line2 = new JournalEntryLineCreate(); record.Lines.Add(line1); record.Lines.Add(line2); 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()); }