Tested on:Dynamics 365 version 9.0
Invoice Frequencies provide a very convenient way of scheduling invoices in Dynamics 365 Project Service Automation. There is, however, very specific logic about how they work on both Time and Material and Fixed Price contract lines. While this post isn't meant to cover the different aspects of Project Contract (I covered Project Contract in a video blog), it's important to define a scenario for using Batch Jobs. In this example I'm using the following combination of Time, Expense and Fee on Time and Material and Fixed Price contract lines:
The reason I've selected this combination is based on the following details:
Analyzing the difference of the operating logic between T&M and FP contract lines reveals the need for Batch Jobs in invoicing. While FP contract lines always require an Invoice Frequency with created Periodic Milestone(s) to create an invoice, the logic of T&M contract lines differs significantly. When T&M contract Lines are used and the "Create Invoice" button is clicked on the Project Contract's ribbon, an invoice is created. This invoice pulls all approved Time and Expense Entries on the invoice despite a set Invoice Frequency, its Invoice Schedule (on T&M lines this is called Invoice Schedule as opposed to FP's Periodic Milestone) or Transaction Cut Off Dates. In other words the only way to make T&M contract lines honor Invoice Frequencies and their Invoice Schedules is by using Batch Jobs.
Batch Jobs are relative easy to set up. An important detail to remember is that the on-demand workflow "ProcessRunner" that actually creates an invoice has a condition If Batch Job:Name contains [Create Invoices]. I tried naming my Batch Job Create Invoice - without the s - and an invoice was never created.
There are a couple of important details to note when setting up Invoice Schedules (T&M lines) and Periodic Milestones (FP lines):
I have submitted and approved Time and Expense entries for various dates. As the photos in this post illustrate I have both a T&M and a FP contract line created with an Invoice Frequency set for 1st of month billing. On the T&M line the Transaction Cut Off Date is 30.11.2017 and the Invoice Run Date is 1.12.2017. This means that approved Time and Expense entries logged up to 29.11 will be included on the invoice that the Batch Job creates. For the FP contract line the first Milestone Date is 1.12.2017 so that specific Milestone will also be included on the invoice.
The following Time and Expense entries have been submitted and approved.
The next task is to run the Batch Job. As I want to run the Batch Job immediately, I'm choosing the on-demand workflow "ProcessRunner". The logic behind it is Process, Sleep, Process, Sleep vs. Sleep, Process, Sleep, Process of "ProcessRunCaller". These are the two workflows which actually create the invoices and ProcessRunner does the actual invoice creation (Microsoft, 2017).
Keep in mind that there is to be only one instance of ProcessRunner / ProcessRunCaller in the system. Multiple processes may result in duplicate invoices. Please see here for more information.
The Milestone status on the T&M line changes to Run Successful after the workflow has run. The FP line was manually set to Ready for invoicing.
The last step is to compare the Active Invoice Line Details with what was submitted and approved. All entries up to 29.11 are correctly on the invoice.
I hope this small guide enables you to take more out of invoicing in Dynamics 365 Project Service Automation. My big thanks goes to the PSA PG at Microsoft for providing additional details on creating Batch Jobs.
Disclaimer: All my blog posts reflect my personal opinions and findings unless otherwise stated.
Edits:July 3rd 2018. Added information about ProcessRunner / ProcessRunCaller with a link to another article.