public void GetXmlTest()
        {
            string expected = @"<?xml version=""1.0"" encoding=""utf-8""?>
<function controlid=""unittest"">
    <update_sotransaction key=""Sales Order-SO0001"" />
</function>";

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

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

            IaXmlWriter xml = new IaXmlWriter(stream, xmlSettings);

            OrderEntryTransactionUpdate record = new OrderEntryTransactionUpdate("unittest")
            {
                TransactionId = "Sales Order-SO0001",
            };

            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());
        }
示例#2
0
        public void SubtotalEntryTest()
        {
            string expected = @"<?xml version=""1.0"" encoding=""utf-8""?>
<function controlid=""unittest"">
    <update_sotransaction key=""Sales Order-SO0001"">
        <updatesotransitems>
            <updatesotransitem line_num=""1"">
                <itemid>02354032</itemid>
                <quantity>12</quantity>
            </updatesotransitem>
            <sotransitem>
                <itemid>02354032</itemid>
                <quantity>1200</quantity>
            </sotransitem>
        </updatesotransitems>
        <updatesubtotals>
            <updatesubtotal>
                <description>Subtotal Description</description>
                <total>1200</total>
            </updatesubtotal>
        </updatesubtotals>
    </update_sotransaction>
</function>";

            OrderEntryTransactionUpdate record = new OrderEntryTransactionUpdate("unittest")
            {
                TransactionId = "Sales Order-SO0001",
            };

            OrderEntryTransactionLineUpdate line1 = new OrderEntryTransactionLineUpdate()
            {
                LineNo   = 1,
                ItemId   = "02354032",
                Quantity = 12,
            };

            record.Lines.Add(line1);

            OrderEntryTransactionLineCreate line2 = new OrderEntryTransactionLineCreate()
            {
                ItemId   = "02354032",
                Quantity = 1200,
            };

            record.Lines.Add(line2);

            TransactionSubtotalUpdate subtotal1 = new TransactionSubtotalUpdate()
            {
                Description = "Subtotal Description",
                Total       = 1200,
            };

            record.Subtotals.Add(subtotal1);

            this.CompareXml(expected, record);
        }
示例#3
0
        public void GetXmlTest()
        {
            string expected = @"<?xml version=""1.0"" encoding=""utf-8""?>
<function controlid=""unittest"">
    <update_sotransaction key=""Sales Order-SO0001"" />
</function>";

            OrderEntryTransactionUpdate record = new OrderEntryTransactionUpdate("unittest")
            {
                TransactionId = "Sales Order-SO0001",
            };

            this.CompareXml(expected, record);
        }
        public static bool UpdateInvoice(string doucmentId, string attachmentsId, string invoiceNum, System.Xml.Linq.XElement invoiceLineItem)
        {
            var lineNo   = Convert.ToInt32(invoiceLineItem?.Element("LINE_NUM")?.Value ?? "1");
            var memo     = invoiceLineItem?.Element("MEMO")?.Value ?? string.Empty;
            var itemid   = invoiceLineItem?.Element("ITEMID")?.Value ?? string.Empty;
            var quantity = Convert.ToInt32(invoiceLineItem?.Element("QUANTITY")?.Value ?? "1");

            try
            {
                var updateInvoice = new OrderEntryTransactionUpdate
                {
                    TransactionId = doucmentId,
                    AttachmentsId = attachmentsId,
                    Lines         =
                        new List <AbstractOrderEntryTransactionLine>
                    {
                        new OrderEntryTransactionLineUpdate {
                            LineNo = lineNo, Memo = memo, ItemId = itemid, Quantity = quantity
                        }
                    }                             //A line Item update is required to call this function. Dumb...
                };
                var task = Client.Execute(updateInvoice);
                task.Wait();

                var response = task.Result;
                var result   = response.Results[0];
                if (result is null || result.Status != "success")
                {
                    ErrorLogger.LogError(invoiceNum, "Dailed to update Invoice.");
                    return(false);
                }
            }
            catch (Exception e)
            {
                ErrorLogger.LogError(invoiceNum, $"Updating Invoice #{invoiceNum} Errored: {e.Message}");
                return(false);
            }

            return(true);
        }
示例#5
0
        public void GetAllXmlTest()
        {
            string expected = @"<?xml version=""1.0"" encoding=""utf-8""?>
<function controlid=""unittest"">
    <update_sotransaction key=""Sales Order-SO0001"">
        <datecreated>
            <year>2015</year>
            <month>06</month>
            <day>30</day>
        </datecreated>
        <dateposted>
            <year>2015</year>
            <month>06</month>
            <day>30</day>
        </dateposted>
        <referenceno>234235</referenceno>
        <termname>N30</termname>
        <datedue>
            <year>2020</year>
            <month>09</month>
            <day>24</day>
        </datedue>
        <origdocdate>
            <year>2015</year>
            <month>06</month>
            <day>15</day>
        </origdocdate>
        <message>Submit</message>
        <shippingmethod>USPS</shippingmethod>
        <shipto>
            <contactname>28952</contactname>
        </shipto>
        <billto>
            <contactname>289533</contactname>
        </billto>
        <supdocid>6942</supdocid>
        <basecurr>USD</basecurr>
        <currency>USD</currency>
        <exchratedate>
            <year>2015</year>
            <month>06</month>
            <day>30</day>
        </exchratedate>
        <exchratetype>Intacct Daily Rate</exchratetype>
        <vsoepricelist>VSOEPricing</vsoepricelist>
        <customfields>
            <customfield>
                <customfieldname>customfield1</customfieldname>
                <customfieldvalue>customvalue1</customfieldvalue>
            </customfield>
        </customfields>
        <state>Pending</state>
        <projectid>P2904</projectid>
    </update_sotransaction>
</function>";

            OrderEntryTransactionUpdate record = new OrderEntryTransactionUpdate("unittest")
            {
                TransactionId        = "Sales Order-SO0001",
                TransactionDate      = new DateTime(2015, 06, 30),
                GlPostingDate        = new DateTime(2015, 06, 30),
                OriginalDocumentDate = new DateTime(2015, 06, 15),
                ReferenceNumber      = "234235",
                PaymentTerm          = "N30",
                DueDate             = new DateTime(2020, 09, 24),
                Message             = "Submit",
                ShippingMethod      = "USPS",
                ShipToContactName   = "28952",
                BillToContactName   = "289533",
                AttachmentsId       = "6942",
                BaseCurrency        = "USD",
                TransactionCurrency = "USD",
                ExchangeRateDate    = new DateTime(2015, 06, 30),
                ExchangeRateType    = "Intacct Daily Rate",
                VsoePriceList       = "VSOEPricing",
                State        = "Pending",
                ProjectId    = "P2904",
                CustomFields = new Dictionary <string, dynamic>
                {
                    { "customfield1", "customvalue1" }
                }
            };

            this.CompareXml(expected, record);
        }
        public void SubtotalEntryTest()
        {
            string expected = @"<?xml version=""1.0"" encoding=""utf-8""?>
<function controlid=""unittest"">
    <update_sotransaction key=""Sales Order-SO0001"">
        <updatesotransitems>
            <updatesotransitem line_num=""1"">
                <itemid>02354032</itemid>
                <quantity>12</quantity>
            </updatesotransitem>
            <sotransitem>
                <itemid>02354032</itemid>
                <quantity>1200</quantity>
            </sotransitem>
        </updatesotransitems>
        <updatesubtotals>
            <updatesubtotal>
                <description>Subtotal Description</description>
                <total>1200</total>
            </updatesubtotal>
        </updatesubtotals>
    </update_sotransaction>
</function>";

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

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

            IaXmlWriter xml = new IaXmlWriter(stream, xmlSettings);

            OrderEntryTransactionUpdate record = new OrderEntryTransactionUpdate("unittest")
            {
                TransactionId = "Sales Order-SO0001",
            };

            OrderEntryTransactionLineUpdate line1 = new OrderEntryTransactionLineUpdate()
            {
                LineNo   = 1,
                ItemId   = "02354032",
                Quantity = 12,
            };

            record.Lines.Add(line1);

            OrderEntryTransactionLineCreate line2 = new OrderEntryTransactionLineCreate()
            {
                ItemId   = "02354032",
                Quantity = 1200,
            };

            record.Lines.Add(line2);

            TransactionSubtotalUpdate subtotal1 = new TransactionSubtotalUpdate()
            {
                Description = "Subtotal Description",
                Total       = 1200,
            };

            record.Subtotals.Add(subtotal1);

            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"">
    <update_sotransaction key=""Sales Order-SO0001"">
        <datecreated>
            <year>2015</year>
            <month>06</month>
            <day>30</day>
        </datecreated>
        <dateposted>
            <year>2015</year>
            <month>06</month>
            <day>30</day>
        </dateposted>
        <referenceno>234235</referenceno>
        <termname>N30</termname>
        <datedue>
            <year>2020</year>
            <month>09</month>
            <day>24</day>
        </datedue>
        <origdocdate>
            <year>2015</year>
            <month>06</month>
            <day>15</day>
        </origdocdate>
        <message>Submit</message>
        <shippingmethod>USPS</shippingmethod>
        <shipto>
            <contactname>28952</contactname>
        </shipto>
        <billto>
            <contactname>289533</contactname>
        </billto>
        <supdocid>6942</supdocid>
        <basecurr>USD</basecurr>
        <currency>USD</currency>
        <exchratedate>
            <year>2015</year>
            <month>06</month>
            <day>30</day>
        </exchratedate>
        <exchratetype>Intacct Daily Rate</exchratetype>
        <vsoepricelist>VSOEPricing</vsoepricelist>
        <customfields>
            <customfield>
                <customfieldname>customfield1</customfieldname>
                <customfieldvalue>customvalue1</customfieldvalue>
            </customfield>
        </customfields>
        <state>Pending</state>
        <projectid>P2904</projectid>
    </update_sotransaction>
</function>";

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

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

            IaXmlWriter xml = new IaXmlWriter(stream, xmlSettings);

            OrderEntryTransactionUpdate record = new OrderEntryTransactionUpdate("unittest")
            {
                TransactionId        = "Sales Order-SO0001",
                TransactionDate      = new DateTime(2015, 06, 30),
                GlPostingDate        = new DateTime(2015, 06, 30),
                OriginalDocumentDate = new DateTime(2015, 06, 15),
                ReferenceNumber      = "234235",
                PaymentTerm          = "N30",
                DueDate             = new DateTime(2020, 09, 24),
                Message             = "Submit",
                ShippingMethod      = "USPS",
                ShipToContactName   = "28952",
                BillToContactName   = "289533",
                AttachmentsId       = "6942",
                BaseCurrency        = "USD",
                TransactionCurrency = "USD",
                ExchangeRateDate    = new DateTime(2015, 06, 30),
                ExchangeRateType    = "Intacct Daily Rate",
                VsoePriceList       = "VSOEPricing",
                State        = "Pending",
                ProjectId    = "P2904",
                CustomFields = new Dictionary <string, dynamic>
                {
                    { "customfield1", "customvalue1" }
                }
            };

            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());
        }