First of all check out the recent update from MS - available on partner source - MicrosoftDynamicsNAV5.0SP1_JobsUpdate.exe.
This is not difficult at all. I’m new to NAV and was the first thing I wrote. We had some modules, obtained through a local MS promotion program, which allowed for sales invoices to be posted with a job number on the lines. The mods didn’t allow an order to have job numbers - so I set to work.
When you create an invoice from a job it inserts lines into the Sales Lines table and into the Job Planning table. There is a numeric field which is the link between the two.
When you create an invoice or an order directly you need to add some logic to insert the Job Planning lines. Its not complex.
The existing logic was only written to handle an invoice generated from a job - not an order and an order can be partially invoiced so you need an extra little logic to update the costs in the job planning table to reflect the updated ‘invoiced quantity’ of the sales line. Its not as difficult as you may think.
The 1001 and 1012 code units contain loads of lines like these:
JobPlanningLine.TESTFIELD(Invoiced,FALSE);
which I had to change to
IF SalesLine.“Document Type” <> SalesLine.“Document Type”::Order THEN
JobPlanningLine.TESTFIELD(Invoiced,FALSE);
In the middle of the 1001 code unitm function PostInvoiceContractLine I’ve added this:
// INTEGRA - IPM - Allow invoicing from Orders with Job No assigned
IF SalesLine.“Document Type” = SalesLine.“Document Type”::Order THEN
BEGIN
// As we gradually invoice an order, increase what has been booked against
// the job inline with the total amount invoiced
//
JobPlanningLine.Quantity := SalesLine.“Qty. to Invoice” + SalesLine.“Quantity Invoiced”;
JobPlanningLine.“Quantity (Base)” := JobPlanningLine.Quantity;
JobPlanningLine.“Unit Price (LCY)” := SalesLine.“Unit Price”;
JobPlanningLine.“Unit Price” := SalesLine.“Unit Price”;
JobPlanningLine.“Total Price” := JobPlanningLine.“Unit Price” * JobPlanningLine.Quantity;
JobPlanningLine.“Total Price (LCY)” := JobPlanningLine.“Unit Price (LCY)” * JobPlanningLine.Quantity;
JobPlanningLine.“Line Amount” := JobPlanningLine.“Unit Price” * JobPlanningLine.Quantity;
JobPlanningLine.“Line Amount (LCY)” := JobPlanningLine.“Unit Price (LCY)” * JobPlanningLine.Quantity;
JobPlanningLine.“Invoiced Amount (LCY)” := JobPlanningLine.“Line Amount”;
JobPlanningLine.“Total Cost (LCY)” := JobPlanningLine.“Unit Price (LCY)” * JobPlanningLine.Quantity;
JobPlanningLine.MODIFY;
END;
// ARGETNI
There are a few more things you need to change but none of it is very difficult once you understand how it works.Sorry I can’t just post a fob but I don’t think I can publish the bits of code from the extension modules we recieved.
I also added a job number to the sales header and added code to just fill that number into each sales line.
Ian