public void TestInvoiceFieldsPush() { InboundInvoice theInvoiceToPush = new InboundInvoice(); theInvoiceToPush.LeadID = 970452; theInvoiceToPush.MatterID = 1062816; theInvoiceToPush.LeadTypeID = 261; theInvoiceToPush.InvoiceType = "Test invoice type"; theInvoiceToPush.InvoiceDate = DateTime.Now; theInvoiceToPush.ProvidersInvoiceNumber = 12345; //.fields theInvoiceToPush.LineItem1Cost = "200.00"; theInvoiceToPush.LineItem1Desc = "THIS IS A TEST FROM XERO APP"; theInvoiceToPush.LineItem1Qty = "1"; theInvoiceToPush.LineItem2Cost = "200.00"; theInvoiceToPush.LineItem2Desc = "THIS IS A TEST FROM XERO APP"; theInvoiceToPush.LineItem2Qty = "1"; theInvoiceToPush.LineItem3Cost = "200.00"; theInvoiceToPush.LineItem3Desc = "THIS IS A TEST FROM XERO APP"; theInvoiceToPush.LineItem3Qty = "1"; theInvoiceToPush.LineItem4Cost = "200.00"; theInvoiceToPush.LineItem4Desc = "THIS IS A TEST FROM XERO APP"; theInvoiceToPush.LineItem4Qty = "1"; theInvoiceToPush.InvoiceTotalCost = 400; theInvoiceToPush.InvoiceVATAmount = 40; theInvoiceToPush.InvoiceSubtotal = 400; theInvoiceToPush.ApplyInvoiceToAquarium(); }
/// <summary> /// takes a Xero Invoice, returns a Aquarium Invoice /// </summary> /// <param name="?"></param> public InboundInvoice(XeroApi.Model.Invoice theInboundXeroInvoice) { InboundInvoice theAquariumInvoiceToReturn = new InboundInvoice(); InvoicePDF = null; this.XeroInvoiceID_GUID = theInboundXeroInvoice.InvoiceID; //THESE FIELDS CAN ONLY BE GRABBED IF THE REFERENCE HAS BEEN PROPERLY RESOLVED if (theInboundXeroInvoice.InvoiceNumber.Contains('-')) { this.LeadID = InboundInvoice.GetLeadIDFromXeroInvoiceReferenceField(theInboundXeroInvoice);//from reference in Invoice this.MatterID = XeroHelper.GetMatterIDByLeadID(this.LeadID); this.LeadTypeID = XeroHelper.Aquarium_GetLeadTypeIDFromLeadID(LeadID); this.ProvidersInvoiceNumber = InboundInvoice.GetProviderInvoiceNumberFromXeroInvoiceNumberField(theInboundXeroInvoice); } this.InvoiceSubtotal = (decimal)theInboundXeroInvoice.SubTotal; this.InvoiceVATAmount = (decimal)theInboundXeroInvoice.TotalTax; this.InvoiceTotalCost = (decimal)theInboundXeroInvoice.Total; this.InvoiceDate = (DateTime)theInboundXeroInvoice.Date; if (theInboundXeroInvoice.LineItems.Count > 0) { if (theInboundXeroInvoice.LineItems.Count >= 1) { this.LineItem1Cost = XeroHelper.ReturnStringifStringPassedIsZero(theInboundXeroInvoice.LineItems.ElementAtOrDefault(0).UnitAmount.ToString()); this.LineItem1Desc = XeroHelper.ReturnStringifStringPassedIsZero(theInboundXeroInvoice.LineItems.ElementAtOrDefault(0).Description.ToString()); this.LineItem1Qty = XeroHelper.ReturnStringifStringPassedIsZero(theInboundXeroInvoice.LineItems.ElementAtOrDefault(0).Quantity.ToString()); } if (theInboundXeroInvoice.LineItems.Count >= 2) { this.LineItem2Cost = XeroHelper.ReturnStringifStringPassedIsZero(theInboundXeroInvoice.LineItems.ElementAtOrDefault(1).UnitAmount.ToString()); this.LineItem2Desc = XeroHelper.ReturnStringifStringPassedIsZero(theInboundXeroInvoice.LineItems.ElementAtOrDefault(1).Description.ToString()); this.LineItem2Qty = XeroHelper.ReturnStringifStringPassedIsZero(theInboundXeroInvoice.LineItems.ElementAtOrDefault(1).Quantity.ToString()); } if (theInboundXeroInvoice.LineItems.Count >= 3) { this.LineItem3Cost = XeroHelper.ReturnStringifStringPassedIsZero(theInboundXeroInvoice.LineItems.ElementAtOrDefault(2).UnitAmount.ToString()); this.LineItem3Desc = XeroHelper.ReturnStringifStringPassedIsZero(theInboundXeroInvoice.LineItems.ElementAtOrDefault(2).Description.ToString()); this.LineItem3Qty = XeroHelper.ReturnStringifStringPassedIsZero(theInboundXeroInvoice.LineItems.ElementAtOrDefault(2).Quantity.ToString()); } if (theInboundXeroInvoice.LineItems.Count >= 4) { this.LineItem4Cost = XeroHelper.ReturnStringifStringPassedIsZero(theInboundXeroInvoice.LineItems.ElementAtOrDefault(3).UnitAmount.ToString()); this.LineItem4Desc = XeroHelper.ReturnStringifStringPassedIsZero(theInboundXeroInvoice.LineItems.ElementAtOrDefault(3).Description.ToString()); this.LineItem4Qty = XeroHelper.ReturnStringifStringPassedIsZero(theInboundXeroInvoice.LineItems.ElementAtOrDefault(3).Quantity.ToString()); } } }