private void addItem(ItemFactura item) { IORInvoiceLineAdd invoiceLineAdd = invoiceAdd.ORInvoiceLineAddList.Append(); invoiceLineAdd.InvoiceLineAdd.ItemRef.ListID.SetValue(item.ItemQB.QBId); invoiceLineAdd.InvoiceLineAdd.Quantity.SetValue(int.Parse(item.CantidadEnPieza)); invoiceLineAdd.InvoiceLineAdd.ORRatePriceLevel.Rate.SetValue(Math.Round(item.PrecioUnitario)); invoiceLineAdd.InvoiceLineAdd.Amount.SetValue(Math.Round(item.Importe, 2)); }
private void BuildInvoiceAddRq(IMsgSetRequest requestMsgSet) { IInvoiceAdd invoiceAddRq = requestMsgSet.AppendInvoiceAddRq(); invoiceAddRq.CustomerRef.FullName.SetValue("City"); invoiceAddRq.Other.SetValue("12345"); invoiceAddRq.TxnDate.SetValue(DateTime.Now); IORInvoiceLineAdd oRInvoiceLineAddList = invoiceAddRq.ORInvoiceLineAddList.Append(); string orInvoiceListElementType = "InvoiceLineAdd"; if (orInvoiceListElementType == "InvoiceLineAdd") { // oRInvoiceLineAddList.InvoiceLineAdd.ItemRef.FullName.SetValue("Storage"); oRInvoiceLineAddList.InvoiceLineAdd.Desc.SetValue("January Storage"); // oRInvoiceLineAddList.InvoiceLineAdd.Quantity.SetValue(2); // oRInvoiceLineAddList.InvoiceLineAdd.Amount.SetValue(9.99); // oRInvoiceLineAddList.InvoiceLineAdd.UnitOfMeasure.SetValue("each"); // oRInvoiceLineAddList.InvoiceLineAdd.ORRatePriceLevel.Rate.SetValue(9.99); } // Add blank line var invLine3 = invoiceAddRq.ORInvoiceLineAddList.Append(); var line3 = invLine3.InvoiceLineAdd; line3.Desc.SetEmpty(); IORInvoiceLineAdd oRInvoiceLineAddList2 = invoiceAddRq.ORInvoiceLineAddList.Append(); var invoiceLineAdd2 = oRInvoiceLineAddList2.InvoiceLineAdd; if (orInvoiceListElementType == "InvoiceLineAdd") { invoiceLineAdd2.ItemRef.FullName.SetValue("Storage"); invoiceLineAdd2.Desc.SetValue("Test Transaction Item"); invoiceLineAdd2.Quantity.SetValue(2); // oRInvoiceLineAddList.InvoiceLineAdd.Amount.SetValue(9.99); // oRInvoiceLineAddList.InvoiceLineAdd.UnitOfMeasure.SetValue("each"); invoiceLineAdd2.ORRatePriceLevel.Rate.SetValue(9.99); } //invoiceAddRq.IncludeRetElementList.Add("ab"); Console.WriteLine(requestMsgSet.ToXMLString()); }
public string createInvoice(Invoice invoice) { requestMsgSet.ClearRequests(); IInvoiceAdd InvoiceAddRq = requestMsgSet.AppendInvoiceAddRq(); InvoiceAddRq.CustomerRef.FullName.SetValue(invoice.CustomerName); if (invoice.ClassRef != null) { InvoiceAddRq.ClassRef.FullName.SetValue(invoice.ClassRef); } if (invoice.BillAddress1 != null) { InvoiceAddRq.BillAddress.Addr1.SetValue(invoice.BillAddress1); } if (invoice.City != null) { InvoiceAddRq.BillAddress.City.SetValue(invoice.City); } if (invoice.State != null) { InvoiceAddRq.BillAddress.State.SetValue(invoice.State); } if (invoice.State != null) { InvoiceAddRq.BillAddress.PostalCode.SetValue(invoice.PostalCode); } if (invoice.Country != null) { InvoiceAddRq.BillAddress.Country.SetValue(invoice.Country); } if (invoice.ShipAddress != null) { InvoiceAddRq.ShipAddress.Addr1.SetValue(invoice.ShipAddress); } if (invoice.Ship_City != null) { InvoiceAddRq.ShipAddress.City.SetValue(invoice.Ship_City); } if (invoice.Ship_State != null) { InvoiceAddRq.ShipAddress.State.SetValue(invoice.Ship_State); } if (invoice.Ship_PostalCode != null) { InvoiceAddRq.ShipAddress.PostalCode.SetValue(invoice.PostalCode); } if (invoice.Ship_Country != null) { InvoiceAddRq.ShipAddress.Country.SetValue(invoice.Country); } if (invoice.DueDate >= DateTime.Now) { InvoiceAddRq.DueDate.SetValue(invoice.DueDate); } if (invoice.ShipDate >= DateTime.Now) { InvoiceAddRq.ShipDate.SetValue(invoice.ShipDate); } InvoiceAddRq.Memo.SetValue(invoice.Memo); if (invoice.CustomerMsg != "") { InvoiceAddRq.CustomerMsgRef.FullName.SetValue(invoice.CustomerMsg); } if (invoice.Terms != "") { InvoiceAddRq.TermsRef.FullName.SetValue(invoice.Terms); } InvoiceAddRq.IsToBePrinted.SetValue(invoice.isPrinted); //istobeemail is supported in qbxml version 6.0 and greater if (Manager.MjrVersion >= 6) { InvoiceAddRq.IsToBeEmailed.SetValue(invoice.IsEmail); } if (invoice.CustomerTaxCode != null && invoice.CustomerTaxCode != "") { InvoiceAddRq.CustomerSalesTaxCodeRef.FullName.SetValue(invoice.CustomerTaxCode); } // if (invoice.TxnNumber != null && invoice.TxnNumber != "") // InvoiceAddRq.ItemSalesTaxRef.FullName.SetValue(invoice.TxnNumber); foreach (InvoiceLineItem item in invoice.lineitem) { IORInvoiceLineAdd ORInvoiceLineAddListElement1 = InvoiceAddRq.ORInvoiceLineAddList.Append(); ORInvoiceLineAddListElement1.InvoiceLineAdd.ItemRef.FullName.SetValue(item.Item); ORInvoiceLineAddListElement1.InvoiceLineAdd.Desc.SetValue(item.Desc); ORInvoiceLineAddListElement1.InvoiceLineAdd.Quantity.SetValue(item.Quantity); if (item.ClassRef != null) { ORInvoiceLineAddListElement1.InvoiceLineAdd.ClassRef.FullName.SetValue(item.ClassRef); } ORInvoiceLineAddListElement1.InvoiceLineAdd.Amount.SetValue(item.Amount); if (item.SalesTaxCodeRef != null) { ORInvoiceLineAddListElement1.InvoiceLineAdd.SalesTaxCodeRef.FullName.SetValue(item.SalesTaxCodeRef); } } //Send the request and get the response from QuickBooks IMsgSetResponse responseMsgSet = sessionManager.DoRequests(requestMsgSet); return(WalkInvoiceAddRs(responseMsgSet)); }