From 4f81f099bf974e7d1fb964902a094d3b4273831b Mon Sep 17 00:00:00 2001 From: Serge Bailes Date: Sat, 15 Oct 2022 09:25:26 +1030 Subject: [PATCH] Override calculated VAT via linesubtotals object. --- .../InventoryControl/LineSubtotalTest.cs | 35 +++++ .../OrderEntryTransactionLineSubtotalTest.cs | 125 ++++++++++++++++++ .../InventoryControl/AbstractLineSubtotal.cs | 22 +++ .../InventoryControl/LineSubtotal.cs | 20 +++ .../AbstractOrderEntryTransactionLine.cs | 2 + .../OrderEntryTransactionLineCreate.cs | 10 ++ .../OrderEntryTransactionLineUpdate.cs | 10 ++ .../AbstractPurchasingTransactionLine.cs | 2 + .../PurchasingTransactionLineCreate.cs | 10 ++ .../PurchasingTransactionLineUpdate.cs | 10 ++ 10 files changed, 246 insertions(+) create mode 100644 Intacct.SDK.Tests/Functions/InventoryControl/LineSubtotalTest.cs create mode 100644 Intacct.SDK.Tests/Functions/OrderEntry/OrderEntryTransactionLineSubtotalTest.cs create mode 100644 Intacct.SDK/Functions/InventoryControl/AbstractLineSubtotal.cs create mode 100644 Intacct.SDK/Functions/InventoryControl/LineSubtotal.cs diff --git a/Intacct.SDK.Tests/Functions/InventoryControl/LineSubtotalTest.cs b/Intacct.SDK.Tests/Functions/InventoryControl/LineSubtotalTest.cs new file mode 100644 index 00000000..90423940 --- /dev/null +++ b/Intacct.SDK.Tests/Functions/InventoryControl/LineSubtotalTest.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Text; +using System.Xml; +using Intacct.SDK.Functions.OrderEntry; +using Intacct.SDK.Functions; +using Intacct.SDK.Tests.Xml; +using Intacct.SDK.Xml; +using Xunit; +using Intacct.SDK.Functions.InventoryControl; + +namespace Intacct.SDK.Tests.Functions.InventoryControl +{ + public class LineSubtotalTest : XmlObjectTestHelper + { + [Fact] + public void GetXmlTest() + { + string expected = @" + + GST + 17.5 +"; + + var record = new LineSubtotal() + { + OverrideDetailId = "GST", + Trx_tax = 17.5m + }; + + this.CompareXml(expected, record); + } + } +} diff --git a/Intacct.SDK.Tests/Functions/OrderEntry/OrderEntryTransactionLineSubtotalTest.cs b/Intacct.SDK.Tests/Functions/OrderEntry/OrderEntryTransactionLineSubtotalTest.cs new file mode 100644 index 00000000..3378ba91 --- /dev/null +++ b/Intacct.SDK.Tests/Functions/OrderEntry/OrderEntryTransactionLineSubtotalTest.cs @@ -0,0 +1,125 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Text; +using System.Xml; +using Intacct.SDK.Functions.InventoryControl; +using Intacct.SDK.Functions.OrderEntry; +using Intacct.SDK.Functions; +using Intacct.SDK.Tests.Xml; +using Intacct.SDK.Xml; +using Xunit; + +namespace Intacct.SDK.Tests.Functions.OrderEntry +{ + public class OrderEntryTransactionLineSubtotalTest : XmlObjectTestHelper + { + [Fact] + public void GetAllXmlTest() + { + string expected = @" + + 092304 + 26323 + Item Description + true + 93294 + 2340 + 593 + Test + 10.00 + 32.35 + None + SF + Receiving + Memo + + + customfield1 + customvalue1 + + + template + + 2015 + 06 + 30 + + + 2015 + 07 + 31 + + Quarterly + 235 + 23423434 + 797656 + 90295 + 243609 + 9062 + Complete + 9850 + 3525 + + + GST + 17.5 + + + WET + 4.25 + + +"; + + OrderEntryTransactionLineCreate record = new OrderEntryTransactionLineCreate() + { + BundleNumber = "092304", + ItemId = "26323", + ItemDescription = "Item Description", + Taxable = true, + WarehouseId = "93294", + Quantity = 2340, + Unit = "593", + LineLevelSimpleTaxType = "Test", + DiscountPercent = 10.00M, + Price = 32.35M, + DiscountSurchargeMemo = "None", + Memo = "Memo", + RevRecTemplate = "template", + RevRecStartDate = new DateTime(2015, 06, 30), + RevRecEndDate = new DateTime(2015, 07, 31), + RenewalMacro = "Quarterly", + FulfillmentStatus = "Complete", + TaskNumber = "9850", + BillingTemplate = "3525", + LocationId = "SF", + DepartmentId = "Receiving", + ProjectId = "235", + CustomerId = "23423434", + VendorId = "797656", + EmployeeId = "90295", + ClassId = "243609", + ContractId = "9062", + CustomFields = new Dictionary + { + { "customfield1", "customvalue1" } + } + }; + + record.LineSubtotals.Add(new LineSubtotal() + { + OverrideDetailId = "GST", + Trx_tax = 17.5m + }); + + record.LineSubtotals.Add(new LineSubtotal() + { + OverrideDetailId = "WET", + Trx_tax = 4.25m + }); + + this.CompareXml(expected, record); + } + } +} diff --git a/Intacct.SDK/Functions/InventoryControl/AbstractLineSubtotal.cs b/Intacct.SDK/Functions/InventoryControl/AbstractLineSubtotal.cs new file mode 100644 index 00000000..84e489bb --- /dev/null +++ b/Intacct.SDK/Functions/InventoryControl/AbstractLineSubtotal.cs @@ -0,0 +1,22 @@ +using Intacct.SDK.Xml; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Intacct.SDK.Functions.InventoryControl +{ + public abstract class AbstractLineSubtotal : IXmlObject + { + public string OverrideDetailId; + + public decimal? Trx_tax; + + public abstract void WriteXml(ref IaXmlWriter xml); + + protected AbstractLineSubtotal() + { + } + } +} diff --git a/Intacct.SDK/Functions/InventoryControl/LineSubtotal.cs b/Intacct.SDK/Functions/InventoryControl/LineSubtotal.cs new file mode 100644 index 00000000..d046dc0c --- /dev/null +++ b/Intacct.SDK/Functions/InventoryControl/LineSubtotal.cs @@ -0,0 +1,20 @@ +using Intacct.SDK.Xml; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Intacct.SDK.Functions.InventoryControl +{ + public class LineSubtotal : AbstractLineSubtotal + { + public override void WriteXml(ref IaXmlWriter xml) + { + xml.WriteStartElement("linesubtotal"); + xml.WriteElement("overridedetailid", OverrideDetailId); + xml.WriteElement("trx_tax", Trx_tax); + xml.WriteEndElement(); + } + } +} diff --git a/Intacct.SDK/Functions/OrderEntry/AbstractOrderEntryTransactionLine.cs b/Intacct.SDK/Functions/OrderEntry/AbstractOrderEntryTransactionLine.cs index 64f48bab..0bd169f5 100644 --- a/Intacct.SDK/Functions/OrderEntry/AbstractOrderEntryTransactionLine.cs +++ b/Intacct.SDK/Functions/OrderEntry/AbstractOrderEntryTransactionLine.cs @@ -83,6 +83,8 @@ public abstract class AbstractOrderEntryTransactionLine : IXmlObject public string ContractId; + public List LineSubtotals = new List(); + public Dictionary CustomFields = new Dictionary(); protected AbstractOrderEntryTransactionLine() diff --git a/Intacct.SDK/Functions/OrderEntry/OrderEntryTransactionLineCreate.cs b/Intacct.SDK/Functions/OrderEntry/OrderEntryTransactionLineCreate.cs index 1dd12e1f..0ab9c109 100644 --- a/Intacct.SDK/Functions/OrderEntry/OrderEntryTransactionLineCreate.cs +++ b/Intacct.SDK/Functions/OrderEntry/OrderEntryTransactionLineCreate.cs @@ -57,6 +57,16 @@ public override void WriteXml(ref IaXmlWriter xml) xml.WriteEndElement(); //itemdetails } + if (LineSubtotals.Count > 0) + { + xml.WriteStartElement("linesubtotals"); + foreach (AbstractLineSubtotal subtotal in LineSubtotals) + { + subtotal.WriteXml(ref xml); + } + xml.WriteEndElement(); + } + xml.WriteCustomFieldsExplicit(CustomFields); xml.WriteElement("revrectemplate", RevRecTemplate); diff --git a/Intacct.SDK/Functions/OrderEntry/OrderEntryTransactionLineUpdate.cs b/Intacct.SDK/Functions/OrderEntry/OrderEntryTransactionLineUpdate.cs index 83f40d21..7b485dfe 100644 --- a/Intacct.SDK/Functions/OrderEntry/OrderEntryTransactionLineUpdate.cs +++ b/Intacct.SDK/Functions/OrderEntry/OrderEntryTransactionLineUpdate.cs @@ -72,6 +72,16 @@ public override void WriteXml(ref IaXmlWriter xml) xml.WriteEndElement(); //itemdetails } + if (LineSubtotals.Count > 0) + { + xml.WriteStartElement("linesubtotals"); + foreach (AbstractLineSubtotal subtotal in LineSubtotals) + { + subtotal.WriteXml(ref xml); + } + xml.WriteEndElement(); + } + xml.WriteCustomFieldsExplicit(CustomFields); xml.WriteElement("revrectemplate", RevRecTemplate); diff --git a/Intacct.SDK/Functions/Purchasing/AbstractPurchasingTransactionLine.cs b/Intacct.SDK/Functions/Purchasing/AbstractPurchasingTransactionLine.cs index 177e9863..83b79783 100644 --- a/Intacct.SDK/Functions/Purchasing/AbstractPurchasingTransactionLine.cs +++ b/Intacct.SDK/Functions/Purchasing/AbstractPurchasingTransactionLine.cs @@ -72,6 +72,8 @@ public abstract class AbstractPurchasingTransactionLine : IXmlObject public string ContractId; + public List LineSubtotals = new List(); + public Dictionary CustomFields = new Dictionary(); protected AbstractPurchasingTransactionLine() diff --git a/Intacct.SDK/Functions/Purchasing/PurchasingTransactionLineCreate.cs b/Intacct.SDK/Functions/Purchasing/PurchasingTransactionLineCreate.cs index a1227d9d..c172a7a2 100644 --- a/Intacct.SDK/Functions/Purchasing/PurchasingTransactionLineCreate.cs +++ b/Intacct.SDK/Functions/Purchasing/PurchasingTransactionLineCreate.cs @@ -64,6 +64,16 @@ public override void WriteXml(ref IaXmlWriter xml) xml.WriteEndElement(); //itemdetails } + if (LineSubtotals.Count > 0) + { + xml.WriteStartElement("linesubtotals"); + foreach (AbstractLineSubtotal subtotal in LineSubtotals) + { + subtotal.WriteXml(ref xml); + } + xml.WriteEndElement(); + } + xml.WriteElement("form1099", Form1099); xml.WriteElement("form1099type", Form1099Type); xml.WriteElement("form1099box", Form1099Box); diff --git a/Intacct.SDK/Functions/Purchasing/PurchasingTransactionLineUpdate.cs b/Intacct.SDK/Functions/Purchasing/PurchasingTransactionLineUpdate.cs index 8c3a12a8..585cf274 100644 --- a/Intacct.SDK/Functions/Purchasing/PurchasingTransactionLineUpdate.cs +++ b/Intacct.SDK/Functions/Purchasing/PurchasingTransactionLineUpdate.cs @@ -77,6 +77,16 @@ public override void WriteXml(ref IaXmlWriter xml) xml.WriteEndElement(); //itemdetails } + if (LineSubtotals.Count > 0) + { + xml.WriteStartElement("linesubtotals"); + foreach (AbstractLineSubtotal subtotal in LineSubtotals) + { + subtotal.WriteXml(ref xml); + } + xml.WriteEndElement(); + } + xml.WriteElement("form1099", Form1099); xml.WriteElement("form1099type", Form1099Type); xml.WriteElement("form1099box", Form1099Box);