Dynamics 365 Business Central

Coding, Extensions, Ideas

Business Central Projects (Jobs) to Purchase

https://youtu.be/iZ5Aba1MVyw

This is a long post because I want to cover the requirement history and how I try to cover the lack of functionality. I´m going to include some code and the github link.

In one of our implementation projects, we are using Jobs/Projects (this blog was written before BC 2024 Wave 1 release) and the customer asks to create purchase orders from job planning lines.

BC doesn’t do that.

So I did a little research and found these:

2018!! And still marked as under review

2022 2023 asking for votes

2023 declined

in 2021 Microsoft gave something like an “answer” and receive 3 very solid replies

If you check those replies, you can see the Deseree Krumm reply, she touches the most important point:

If you receive your items, those items are “consumed” in the project line and never “pass” in the location, but, if you have a receive/ship process, you dont have a item cost applied in the project until you post your invoice.

Another point that wasnt covered by Business Central, if you use service type items, those items doesnt appears in the order planning or requisition worksheet.

Why this is important? well, you can sell services, so you can add services to project plan lines, and those services can be covered for an external vendor (subcontracting) with their own resources and you cant purchase resources, so you create a service item to purchase/sales and the BC planning system doesn´t care about that or the G/L Accounts for project related expenses.

So, how can we have a solution for these scenarios?

Let’s start checking the Job Planning Lines (JPL)

I added a new field to put the vendor code and a boolean to create the purhcase order only if the vendor is defined because you need a vendor, In the code I put some validations and pull info from item and vendor card.

I mark the bool field if the vendor is defined but… onnly if the line is item, also, if its item, I look for the defined vendor in the item card or the item vendor table, an d yes, I added dimension filed in JPL and look for the item defined dimensions.

also, some code to get the vendor defined location code for the item, if the vendor doesn’t have a defined location, you can set up one in the general setup .

Wuth this, you can put in the lines items, G/L accounts and text and transfer those line types to purchase orders.

Let’s analyze the first part of the codeunit:

In this first procedure, I took the lines and pit the different vendors in a temp table, i can use a query but I prefer this method to try to mimic a SQL Coalesce to delete duplicates. Once I have a set of unique vendors, I started to create the documents with two procedures.

For headers, I look for the project dimensions and create the header setting vendor, those dimensions, dates, and 2 new fields for project “link” .

Now, the lines:

The last line after the insert isa mark procedure that writes the PO number in the line to inform the user with which order is the JPL linked

Let´s check the PO´s

Header

Lines

Now, we can know how many PO’s related to projects are created in the system and how many released PO’s, receipts, invoices, etc.

if we open the Job Planing Lines page we got the whole enchilada

But, what happens if the item is an assembly or production item?

well, we need to modify the previous code checking first in the replenishment system fir the item

ok, the initial code for the Create Purchase Order action is focused on those lines where the “CreatePurchOrd” Boolean was set to true

So, following that idea, I need to create a new action called, CreateAssyOrder

and another called CreateProdOrder

Not all companies use assemblies and less companies use production module, so we can leave booleans in the setup page to show/no show those actions in the page

And add some code to show/hide those actions

Another thing was, how many items did we have in the warehouse? of you use the standard JPL, you dont have an easy access tothat info, so, why we dont create a new factbox page and link that page to the JPL??

The Project Manager Role center was modified to add some actions to the standard application

Job to Purchase Setup

Here you can select if you want to create purchase orders, quotes or send the lines to the requisition worksheet.

In the actual code, the only functional option is the create purchase order process, you need to add the other options code.

For the purchase process, the vendor definition is important at some level, why? Because you need to define in the order planning or the requisition worksheet that value to allow Business Central to create the purchase orders.

In this extension, I added the Vendor No field and bring the item card information (or related Item Vendor table value). I added the data because you can be a project manager or planner and you don’t need to be worried about which vendor you need to use. In the next image, you can see a few more fields, those fields can help to make different actions based on the item replenishment type (purchase, assembly, or production order) and dimensions for job/project planning lines.

I also added some data to the rolecenter to get information about which and how many orders are created based in the job/project demands.

Let’s see how this extension works and put some ideas for the future.

First, I defined a Default location, this can be used for those job/project planning lines with location code undefined.

Projects

Now we need to create a new project and start to add some task lines.

Now, lets go to the project planning lines.

Remember, we can modify our item to assign a vendor number.

Or we can add information in the purchase, related vendors.

For this example, I’m going to add one vendor in the related table.

And now, we add the item to the project lines.

As you can see in the image, we pull the vendor no. and the create purchase order Boolean, if the item has dimension, we pull that information to these lines.

If we run the standard process, we can run the order planning worksheet to calculate the job demand and create our purchase orders.

Now, if we look for the Supply For field.

And click the make orders action to create your next step.

In this page, you can send this information to a requisition worksheet or make your purchase orders.

So, why we need a purchase from jobs extension?

Well, I showed a standard inventory item but, what happens if we use a service item? remember, the order planning doesn’t consider that kind of items, or G/L Accounts.

Another reason, you don’t want to make so many steps and open a lot of pages and click in many actions, you just want to make a purchase order from your project planning lines.

So, lets see how this works for items, service items and expenses (G/L Accounts).

Project to Purchase

We create a new service item.

And then, we add the new item to the planning lines with a G/L Account and texts.

Just for fun, lets run the order planning page and we get the same result as the other scenario.

Let’s check with the Requisition Worksheet.

And we don’t get any warning or line.

So, lets go to the project planning lines and click in the Create Purchase Orders action.

What’s happened now?

Well, if you check the next code, first we need to check how many different vendors are defined in the planning lines and create a purchase order for each vendor.

Then we add the different lines for each order

If you catch the idea, I create a purchase line for G/L Accounts, Items (service or inventory) and blank lines for notes,

Let’s see the orders.

The first order was created with this information.

The second order was created for vendor 40000.

And the third order.

With the last columns, we can track which is the origin project, task, and planning line.

Also, please note that I don’t put the Job/Project No or Task no in the item purchase lines to avoid the automatic consumption.

But in the G/L Account line I put the job/project related information.

So, when you post this kind of stuff, the expense will be applied against the project instantly.

Ideas and future scenarios

Now, what about the assembly or productions items?

Well, we need to detect that kind of items when you select your item s in the planning lines, so I added two Boolean fields to mark them with a subscription event.

We can see these fields in the planning lines.

And with this, we can call assembly or production orders.

For the assembly items, the next code is designed to create the assembly orders filling some special fields to keep control about the source project for the assembly order.

For the assembly items, the next code is designed to create the Production orders filling some special fields to keep control about the source project for the Production order.

Leave a Reply