One other suggestion. There’s also an overload on the InvoiceList to fetch by date range. If you use that you’ll retrieve less data. Right now you’re fetching all of the data and then filtering it.
Dim invoices As InvoiceList =
InvoiceList.GetInvoiceList(scaffoldList, InvoiceSyncStatus.All, InvoiceExportStatus.All, Guid.Empty)
I don’t see where I can pass a date. Can you please advise how to overload InvoiceList?
Woops, that one is on the shipment that I was thinking of. Sorry about that.
Another thing you could do, which might make sense anyways since you’re exporting the invoices, is to set the ‘Exported’ status after you export it. There’s a filter for the export status and you can fetch by ‘NotExported’, which will cut down on your list size quite a bit. Of course, after you export an invoice set its status to ‘Exported’.
Needing more assistance:
I am trying to extract the Work Order Number for a Purchase Order Number from the invoice, but I cannot figure out why its not coming over, even though its entered and visible in Quantify. What am I doing wrong? Can you suggest alternative code?
Dim inv As Invoice = Invoice.GetInvoice(invoiceitem.InvoiceID, False) gid_InvoiceID = invoiceitem.InvoiceID If inv.InvoiceUpToDate = dt_Invoice_Date.ToString("MM/dd/yyyy") Then str_Invoice_Number = inv.InvoiceNumber dt_Invoice_Date = inv.InvoiceUpToDate str_Order_Number = inv.Order.Number ' PROBLEM HERE str_Work_Order_Number = IIf(inv.WorkOrderNumber = "", "None", inv.WorkOrderNumber) End If
Your post suggests that you are not obtaining the Work Order Number for invoices that have them. The IIf statement should return Invoice inv’s WorkOrderNumber or the string “None” as you intend.
I suggest that you set a break point on the IIf statement to verify that the If condition is being met. Then check the value of inv.WorkOrderNumber, single step the IIf statement and verify the value assigned to str_Work_Order_Number.
So, basically debug to a code line that seems to fail.
Good luck with your project.
I was able to extract the Work Order from the Tag Equipment details instead of the Invoice Header. I guess my lack of understanding of the API led me down the wrong path.
How is that API guide coming?
Okay, here’s another question regarding Invoice extraction…
I am using the code below to connect to the invoices…
Dim invoices As InvoiceList = InvoiceList.GetInvoiceList(scaffoldList, InvoiceSyncStatus.All, InvoiceExportStatus.All, Guid.Empty) For Each invoiceitem As InvoiceListItem In invoices Dim inv As Invoice = Invoice.GetInvoice(invoiceitem.InvoiceID, False) gid_InvoiceID = invoiceitem.InvoiceID If inv.InvoiceUpToDate = dt_Invoice_Date.ToString("MM/dd/yyyy") Then End If
What this does is loops each and every invoice ever created for a Job and then check the Invoice Date to see if its relevant to the actions I am performing.
As more invoices are created, the time for it to cycle the loops is adding considerable time to the procedure.
So, I am wondering…
a) Is there was way to fetch the Quantify Invoices, but sort by the Invoice Date? This way, I can check the Quantify Invoice Date and cancel the routine once the Quantify Invoice Date does not match my desired Invoice Date, or
b) Just connect to the Quantify Invoice Collection passing my desired Invoice Date, thus, excluding all unrelated Quantify Invoices?
If you’re doing some sort of processing and then don’t need to view the invoice that you’ve processed again, you can use the ExportStatus. Once an invoice has been processed, set it to ‘NotExported’.
' Set status to Exported Dim inv As Invoice = Invoice.GetInvoice(invoiceID, False) inv.InvoiceExportStatus = InvoiceExportStatus.Exported
There’s a parameter in the GetInvoiceList to only load invoices by status, which you can use.
' Only load non-exported invoices Dim invList As InvoiceList = InvoiceList.GetInvoiceList(InvoiceExportStatus.NotExported)
Sounds like a valid option… if only I would have paid attention in March 21 when this was suggested originally on this same thread… sorry for that, I totally missed the post. I will attempt this which should substantially save time.
Thank you for your assistance.
No problem at all. It’s coding, always too much to remember.
Hello - I’ll tag onto this conversation since these questions are related. I am trying to get the accounting item type that is defined in the global options for Billing for InvoiceRentProducts. Is that possible or am I forced to use the product category accounts?
Hello IFrisch. Yes, you can easily get the accounting type with this line of code.
// Get accounting item type AccountingItemType item = AccountingItemType.GetAccountingItemType(BillingTransactionType.RentalCharge);
Hi,AvontusDev. Thank you. Here is what I am looking for. If I have an InvoiceList, with InvoiceListItems, and i am sorting through the InvoiceRentalProducts for each InvoiceListItem, how do I get the AccountingItemType associated with each of the rental products on the invoice?
Hello. IFrosch. By definition, everything in InvoiceRentProducts is a rental charge. In the InvoiceUnitPrices you’ll see the other charges.
I understand - how do i get the value of the accounting item type for these rental charges without hard coding it from the global constants?
Hello iFrosch. I don’t think you need to hardcode anything. The items in the InvoiceRentProductCollection are all BillingTransactionType.RentalCharge.
Maybe I’m not understanding your question? Can you start a new thread with your question? The original topic here is about scaffold tag invoicing details.