You need to sign in to do that
Don't have an account?
jasloz
Message Edited by jasloz on 06-29-2008 02:43 AM
Opportunity In Year Value calculation
Problem
We are looking to create a custom formula in the Opportunity Object.
For each opportunity we record the 'Opportunity Start Date' and 'Opportunity End Date'; these dates indicate the term of the opportunity which may be as short as a month or as long as 5 years. We are looking for a formula to calculate (on a prorata basis) the Revenue expected in the Current Fiscal Year.
Fields that are relevent
'Opportunity Start Date' API = Opportunity_Start_Date__c - This is the expected works start date, not necessarily the same as the Close Date.
'Opportunity End Date' API = Opportunity_End_Date__c - This is the expected works end date.
'Amount' API = Amount - This is the order amount.
'In Year Value' API = In_Year_Value__c - This is the value of revenue expected from the opportunity in the current Fiscal Year.
Ideal Solution
The formula should be as simple as
In_Year_Value__c = (Amount / (Opportunity_End_Date__c – Opportunity_Start_Date__c)) * (min(Opportunity_End_Date__c, Current_Fiscal_Year_End) – max(Opportunity_Start_Date__c , Current_Fiscal_Year_Start))
However Salesforce has a number of issues with this formula.
1) Max & Min cannot be used on Dates.
2) There is no ability to use Current_Fiscal_Year_End in the formula
I have not created any custom development at this time but am happy to give anything a go to get this to work as it really is a business critical calculation.
Many thank in advance.
Jason
Message Edited by jasloz on 06-29-2008 02:43 AM
I have managed to get Apex to work out the InYearValue (and NextYearValue) and have created a Trigger to run the code on Insert/Update (this was done on my developer licence).
However when I try to save the code into our live environment (using Eclipse) I get the following message.
‘Average test coverage across all Apex Classes and Triggers is 0%, at least 75% test coverage is required’
Can anyone help me with code for the test coverage?