Hi everybody,
I have a windows service that creates customers in Quantify works great, now I need it to retrieve new invoices.
At this stage I am just trying to get the lines items from an invoice,
I can get the customer, dates, invoice number etc using
InvoiceList invoices = InvoiceList.GetInvoiceList(InvoiceExportStatus.All);
and then iterating over it using
foreach (InvoiceListItem inv in invoices)
But it doesn’t work as I thought it would. I thought I could access the invoice lines from here, but can’t figure it out.
Summary: I’m trying to get the detail from an invoice in particular each line item and the line item detail (part, quantity total etc) .
Can someone put me in the right direction?
Thanks MJ.
Hi, MarkJoyce.
You may use the same method below that the report uses to fetch the details.
var invoice = Invoice.GetInvoiceChildForPrinting(Invoice-ID, false)
Further, the child collection, InvoiceRentProducts may be iterated though to fetch PartNumber, ReportShipmentNumber, ReportTotalRent etc.
Thanks for posting!
Thank you so much! Working.
Ok so next proplem I face is Non-Hire-Items / Additional charges in the invoice lines.
Which seems to correlate with Additional charges further down the invoice
Not sure how to relate this back to the current invoice im querying; and to be clear this is another line of the invoice in need, but doesnt seem to be present in → Invoice.GetInvoiceChildForPrinting.
Thanks
Ok, I think I figured it out,
I was trying for example to get these non rent products from an Invoice.
Product charges and Non-Hire items.
I was able to use the Parent invoice as below (my discovery code)
NOTE: invoiceNumber is a variable I am entering via a console read line.
InvoiceList invoices = InvoiceList.GetInvoiceList(InvoiceExportStatus.All);
foreach (InvoiceListItem inv in invoices)
{
if (inv.InvoiceNumber == invoiceNumber)
{
Console.WriteLine(“INVOICE - PARENT”);
Console.WriteLine($“Invoice Number = {inv.InvoiceNumber}, \nInvoiceDate = {inv.InvoiceDate}\n InvoiceID = {inv.InvoiceID}\n CustomerName = {inv.CustomerName}\n\n”);
var invy = Invoice.GetInvoice(inv.InvoiceNumber, false);
var x = invy.InvoiceProductCharges;
foreach (InvoiceProductCharge charge in x)
{
Console.WriteLine($“Charge Description = {charge.Description},\n Charge ID = {charge.InvoiceProductChargeID},\n Charge Quantity = {charge.Quantity},\n Charge Total = {charge.Total}”);
}
Console.WriteLine(“\n\n”);
var a = invy.InvoiceUnitPrices;
foreach (InvoiceUnitPrice unitPrice in a)
{
Console.WriteLine($“Unit Price Description = {unitPrice.Description},\n Unit Price ID = {unitPrice.InvoiceUnitPriceID},\n Item Type Name = {unitPrice.ItemTypeName},\n Unit Price JobCost Total = {unitPrice.UnitPriceJobCostTotal},\n Unit Price Total = {unitPrice.UnitPriceTotal}”);
}
var z = invy.InvoiceRentProducts;
Console.WriteLine(“\n\n”);
foreach (InvoiceRentProduct product in z)
{
Console.WriteLine($“Product Description = {product.Description},\n Product ID = {product.InvoiceRentProductID},\n Product Quantity = {product.Quantity},\n Product Total = {product.TotalRent}”);
}
Console.WriteLine(“\n\n\n\n\n”);
Console.WriteLine(“press enter to continue”);
Console.ReadLine();
I’m able to get what I need from Invoices, Might not need the
var invoice = Invoice.GetInvoiceChildForPrinting(inv.InvoiceID, false);
As mentioned before.
I think I’m getting the hang of this.
MJ