Esempio n. 1
0
        public void InvoiceLineUpdateTest()
        {
            string expected = @"<?xml version=""1.0"" encoding=""utf-8""?>
<function controlid=""unittest"">
    <update_invoice key=""1234"">
        <updateinvoiceitems>
            <updatelineitem line_num=""1"">
                <memo>hello world</memo>
            </updatelineitem>
        </updateinvoiceitems>
    </update_invoice>
</function>";

            InvoiceUpdate record = new InvoiceUpdate("unittest")
            {
                RecordNo = 1234,
            };

            InvoiceLineUpdate line1 = new InvoiceLineUpdate()
            {
                LineNo = 1,
                Memo   = "hello world"
            };

            record.Lines.Add(line1);

            this.CompareXml(expected, record);
        }
Esempio n. 2
0
        public InvoiceLineUpdate GetInvoiceLineUpdate()
        {
            var result = new InvoiceLineUpdate();

            result.InvoiceLineId = InvoiceLineView.InvoiceLineId;
            result.LineTotal     = InvoiceLineView.LineTotal;
            result.Notes         = InvoiceLineView.Notes;
            result.Product       = InvoiceLineView.Product;
            result.ProductCode   = InvoiceLineView.ProductCode;
            result.Quantity      = InvoiceLineView.Quantity;
            result.SubTotal      = InvoiceLineView.SubTotal;
            result.TaxExempt     = InvoiceLineView.TaxExempt;
            result.TaxTotal      = InvoiceLineView.TaxTotal;
            result.UnitCost      = InvoiceLineView.UnitCost;
            return(result);
        }
Esempio n. 3
0
// Update Transaction Code
        public async Task <InvoiceLineView> Update(InvoiceLineUpdate update)
        {
            try
            {
                using (var db = new data.InvoiceContext())
                {
                    var result = await Update(db, update);

                    await db.SaveChangesAsync();

                    return((InvoiceLineView)result);
                }
            }
            catch (Exception e)
            {
                LogFactory.GetLogger().Log(LogLevel.Error, e);
                return(null);
            }
        }
Esempio n. 4
0
        public async Task <InvoiceLineView> InvoiceLineUpdate(InvoiceLineUpdate update)
        {
            try
            {
                string json = "";

                var client = new HttpClient();

                using (var ms = new MemoryStream())
                {
                    var serializer = new DataContractJsonSerializer(typeof(InvoiceLineUpdate), new DataContractJsonSerializerSettings()
                    {
                        DateTimeFormat = new DateTimeFormat("yyyy-MM-dd'T'HH:mm:ss")
                    });
                    serializer.WriteObject(ms, update);
                    ms.Position = 0;
                    StreamReader sr = new StreamReader(ms);
                    json = sr.ReadToEnd();
                }

                var stream = await client.PutAsync($"http://localhost:44443/api/invoiceLine/{update.InvoiceLineId}", new StringContent(json, Encoding.UTF8, "application/json"));

                using (var ms = new MemoryStream())
                {
                    var serializer = new DataContractJsonSerializer(typeof(InvoiceLineView));
                    await stream.Content.CopyToAsync(ms);

                    ms.Position = 0;
                    var view = serializer.ReadObject(ms) as InvoiceLineView;
                    return(view);
                }
            }
            catch (Exception e)
            {
                LogFactory.GetLogger().Log(LogLevel.Error, e);
                return(null);
            }
        }
Esempio n. 5
0
        public async Task <data.InvoiceLine> Update(data.InvoiceContext db, InvoiceLineUpdate update)
        {
            try
            {
                var invoiceLineToUpdate = await db.InvoiceLines.FirstOrDefaultAsync(w => w.InvoiceLineId == update.InvoiceLineId);

                invoiceLineToUpdate.InvoiceLineId = update.InvoiceLineId;
                invoiceLineToUpdate.LineTotal     = update.LineTotal;
                invoiceLineToUpdate.Notes         = update.Notes;
                invoiceLineToUpdate.Product       = update.Product;
                invoiceLineToUpdate.ProductCode   = update.ProductCode;
                invoiceLineToUpdate.Quantity      = update.Quantity;
                invoiceLineToUpdate.SubTotal      = update.SubTotal;
                invoiceLineToUpdate.TaxExempt     = update.TaxExempt;
                invoiceLineToUpdate.TaxTotal      = update.TaxTotal;
                invoiceLineToUpdate.UnitCost      = update.UnitCost;
                return(invoiceLineToUpdate);
            }
            catch (Exception e)
            {
                LogFactory.GetLogger().Log(LogLevel.Error, e);
                return(null);
            }
        }
Esempio n. 6
0
        public void GetAllXmlTest()
        {
            string expected = @"<?xml version=""1.0"" encoding=""utf-8""?>
<function controlid=""unittest"">
    <update_invoice key=""20394"" externalkey=""true"">
        <customerid>CUSTOMER1</customerid>
        <datecreated>
            <year>2015</year>
            <month>06</month>
            <day>30</day>
        </datecreated>
        <dateposted>
            <year>2015</year>
            <month>06</month>
            <day>30</day>
        </dateposted>
        <datedue>
            <year>2020</year>
            <month>09</month>
            <day>24</day>
        </datedue>
        <termname>N30</termname>
        <action>Submit</action>
        <invoiceno>234</invoiceno>
        <ponumber>234235</ponumber>
        <description>Some description</description>
        <payto>
            <contactname>28952</contactname>
        </payto>
        <returnto>
            <contactname>289533</contactname>
        </returnto>
        <currency>USD</currency>
        <exchratedate>
            <year>2015</year>
            <month>06</month>
            <day>30</day>
        </exchratedate>
        <exchratetype>Intacct Daily Rate</exchratetype>
        <supdocid>6942</supdocid>
        <customfields>
            <customfield>
                <customfieldname>customfield1</customfieldname>
                <customfieldvalue>customvalue1</customfieldvalue>
            </customfield>
        </customfields>
        <updateinvoiceitems>
            <updatelineitem line_num=""1"">
                <amount>1000</amount>
            </updatelineitem>
            <lineitem>
                <glaccountno />
                <amount>76343.43</amount>
            </lineitem>
        </updateinvoiceitems>
    </update_invoice>
</function>";

            InvoiceUpdate record = new InvoiceUpdate("unittest")
            {
                RecordNo            = 1234,
                CustomerId          = "CUSTOMER1",
                TransactionDate     = new DateTime(2015, 06, 30),
                GlPostingDate       = new DateTime(2015, 06, 30),
                DueDate             = new DateTime(2020, 09, 24),
                PaymentTerm         = "N30",
                Action              = "Submit",
                InvoiceNumber       = "234",
                ReferenceNumber     = "234235",
                Description         = "Some description",
                ExternalId          = "20394",
                BillToContactName   = "28952",
                ShipToContactName   = "289533",
                TransactionCurrency = "USD",
                ExchangeRateDate    = new DateTime(2015, 06, 30),
                ExchangeRateType    = "Intacct Daily Rate",
                AttachmentsId       = "6942",
                CustomFields        = new Dictionary <string, dynamic>
                {
                    { "customfield1", "customvalue1" }
                },
            };

            InvoiceLineUpdate line1 = new InvoiceLineUpdate
            {
                LineNo            = 1,
                TransactionAmount = 1000
            };

            record.Lines.Add(line1);

            InvoiceLineCreate line2 = new InvoiceLineCreate
            {
                TransactionAmount = 76343.43M
            };

            record.Lines.Add(line2);

            this.CompareXml(expected, record);
        }