Job Cost Entry file watcher  Topic is solved

Discussions relating to Jiwa 7 plugin development, and the Jiwa 7 API.

Re: Job Cost Entry file watcher

Postby neil.interactit » Thu Jan 14, 2021 3:38 pm

I jumped the gun.

Certainly progress - I now have a job cost entry page being populated - but it isn't picking up the inventory items yet.
neil.interactit
Kohai
Kohai
 
Posts: 232
Joined: Wed Dec 03, 2014 2:36 pm
Topics Solved: 6

Re: Job Cost Entry file watcher

Postby neil.interactit » Thu Jan 14, 2021 4:32 pm

Hi Scott,

I'm getting much closer ... but I'm really stumbling around with trial/error approach. Here's where I'm at:

Code: Select all
    var jobCostEntry = manager.BusinessLogicFactory.CreateBusinessLogic<CostEntry>(null);
    jobCostEntry.NewRecord(CostEntry.ItemType.Material);
    jobCostEntry.Reference = "TEST Toner issued";
    foreach (var csvLine in csvLines)
    {
        var line = new Line(manager);
        var job = manager.BusinessLogicFactory.CreateBusinessLogic<Job>(null);
        job.ReadRecord(Job.ReadModes.FirstRecord, FilterString: "OrderNo = '" + csvLine.OrderNo + "'");
        line.Stage.ReadRecordFromFullJobNo(job.JobNumber + "-010-B");

        jobCostEntry.AddItem(ref line);

        line.NonInventoryItem = false;
        var inventory = manager.EntityFactory.CreateEntity<Inventory>();
        inventory.ReadRecordFromPartNo(csvLine.PartNo);
        line.ComponentNo = inventory.PartNo;
        line.ComponentID = inventory.InventoryID;
        line.ReCalculate(0); // 0 - 5 don't know the Enum descriptions

        line.Qty = csvLine.Quantity;
    }
    jobCostEntry.Save();

So this now produces job cost entry lines with the Stage, (inventory) Item, and Required Qty set.

The remaining issues are: (1) I can't work out how to programatically set Line Type to Inventory, and (2) all the $$ values (Unit Cost, Total Charge, etc) are 0 ... I tried line.ReCalculate(0) above without effect and am unsure of what int value (0 - 5) to use as I can't see the Enum descriptions.

Can you set me straight?

Cheers,
Neil
neil.interactit
Kohai
Kohai
 
Posts: 232
Joined: Wed Dec 03, 2014 2:36 pm
Topics Solved: 6

Re: Job Cost Entry file watcher  Topic is solved

Postby Scott.Pearce » Fri Jan 15, 2021 8:53 am

Job Costing is a bit of an ugly duckling, hence why you are having such trouble. Try this and let me know if it helps.

After the line:

Code: Select all
jobCostEntry.AddItem(ref line);


insert the code:

Code: Select all
line.ItemType = JiwaJobCosting.CostEntry.CostEntry.ItemType.Material; // 0


This should solve both your noted issues.

EDIT: Oh, and I think you can remove the line.Recalculate(0) line.
Scott Pearce
Senior Analyst/Programmer
Jiwa Financials
User avatar
Scott.Pearce
Senpai
Senpai
 
Posts: 765
Joined: Tue Feb 12, 2008 11:27 am
Location: New South Wales, Australia
Topics Solved: 230

Re: Job Cost Entry file watcher

Postby neil.interactit » Fri Jan 15, 2021 10:13 am

That seems to have fixed it!

Many thanks Scott (and Stuart).

I will refine against the remaining requirements, then post up the final working code here, in case it helps others.

Thanks again,
Neil
neil.interactit
Kohai
Kohai
 
Posts: 232
Joined: Wed Dec 03, 2014 2:36 pm
Topics Solved: 6

Re: Job Cost Entry file watcher

Postby neil.interactit » Fri Jan 15, 2021 10:47 am

In case it helps others, here's the final working code snippet ...

Code: Select all
    var jobCostEntry = manager.BusinessLogicFactory.CreateBusinessLogic<CostEntry>(null);
    jobCostEntry.NewRecord(CostEntry.ItemType.Material);
    jobCostEntry.Reference = "TEST Toner issued";
    foreach (var csvLine in csvLines)
    {
        var line = new Line(manager);
        var job = manager.BusinessLogicFactory.CreateBusinessLogic<Job>(null);
        job.ReadRecord(Job.ReadModes.FirstRecord, FilterString: "OrderNo = '" + csvLine.OrderNo + "'");
        line.Stage.ReadRecordFromFullJobNo(job.JobNumber + "-010-B");

        jobCostEntry.AddItem(ref line);
        line.ItemType = JiwaJobCosting.CostEntry.CostEntry.ItemType.Material; // 0
        line.NonInventoryItem = false;
        var inventory = manager.EntityFactory.CreateEntity<Inventory>();
        inventory.ReadRecordFromPartNo(csvLine.PartNo);
        line.ComponentNo = inventory.PartNo;
        line.ComponentID = inventory.InventoryID;

        line.Qty = csvLine.Quantity;
    }
    jobCostEntry.Save();

Many thanks again guys.
neil.interactit
Kohai
Kohai
 
Posts: 232
Joined: Wed Dec 03, 2014 2:36 pm
Topics Solved: 6

Previous

Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 4 guests