Job Costing. Adding Cost Centres and Stages  Topic is solved

Discussions relating to plugin development, and the Jiwa API.

Job Costing. Adding Cost Centres and Stages

Postby DannyC » Wed Jan 25, 2017 10:59 am

Hi,

I want to tweak the Job Costing module so that when a Stage is added under a Cost Centre (by the way - is the only way to add a stage by dragging it over the cost centre?) I want to automatically set the Classification too. In this scenario, the naming of the Stage and Classification are matched so that I can choose the correct classification.

My problem is that I can't find the method under the JobCosting class where the Stage is added.
I can see JobCosting.CostCentres.Added but can't find the syntax to get to Stages.

Can you help?
User avatar
DannyC
Senpai
Senpai
 
Posts: 638
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 30

Re: Job Costing. Adding Cost Centres and Stages  Topic is solved

Postby Mike.Sheen » Mon Jan 30, 2017 11:10 am

Hi Danny,

You just need to add a handler to each Cost Centre's stage collection - do this on when the job is read, and when a cost centre is added:

Code: Select all
Public Sub Setup(ByVal JiwaForm As JiwaApplication.IJiwaForm, ByVal Plugin As JiwaApplication.Plugin.Plugin) Implements JiwaApplication.IJiwaFormPlugin.Setup
   JobCostForm = JiwaForm
   AddHandler JobCostForm.Job.Read, AddressOf JobReadEnd
   AddHandler JobCostForm.Job.CostCentres.Added, AddressOf CostCentreAdded      
End Sub

Private Sub JobReadEnd()
   For Each costCentre As JiwaJobCosting.CostCentre In JobCostForm.Job.CostCentres
      AddHandler costCentre.Stages.Added, AddressOf StageAdded
   Next
End Sub

Private Sub CostCentreAdded(CostCentre As JiwaJobCosting.CostCentre)
   ' Add a handler for the stage added event
   AddHandler CostCentre.Stages.Added, AddressOf StageAdded
End Sub

Private Sub StageAdded(Stage As JiwaJobCosting.Stage)      
   JiwaApplication.Manager.DisplayMessage(JobCostForm, String.Format("Stage '{0}' was added to Cost Centre '{1}'", Stage.Stage.Name, Stage.Stages.CostCentre.CostCentre.Name), System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information, System.Windows.Forms.MessageBoxDefaultButton.Button1)
End Sub


Attached is a sample plugin demonstrating this (in VB.NET which I assumed you would have preferred).
Attachments
Plugin Job Costing Stage Added.xml
Sample Plugin
(33.56 KiB) Downloaded 113 times
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2445
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 757

Re: Job Costing. Adding Cost Centres and Stages

Postby DannyC » Wed Feb 01, 2017 12:08 pm

Thats great Mike.
When looking at the Stages, the classification appears to be Read Only.
Is there a way I can set it on the fly when dragging it over to the left?

And yes - VB .Net is preferred. You know me too well!
User avatar
DannyC
Senpai
Senpai
 
Posts: 638
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 30

Re: Job Costing. Adding Cost Centres and Stages

Postby Mike.Sheen » Thu Feb 02, 2017 5:21 pm

DannyC wrote:When looking at the Stages, the classification appears to be Read Only.
Is there a way I can set it on the fly when dragging it over to the left?


It's read only because it's an object - it's an Entity, so something like:

Code: Select all
Stage.Classification.ReadRecordFromName("Test")


should set the classification for the stage.
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2445
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 757


Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 9 guests