I have a field called: Payment terms ( holds values as: 30, 60, Net 30, Net 60..) which defines that payment due date of an oppty.
Payment due date is a Date field, with default value of: Today().
I have a workflow rule and field update that will update the payment due date upon selection on the payment terms field:
CASE( Payment_Terms__c ,
"Net" ,DATE(YEAR(TODAY()),MONTH(TODAY()),CASE( MONTH(TODAY())+1,1, 31, 2, IF( MOD( YEAR(TODAY()), 4) = 0, 29, 28), 3, 31, 4, 30, 5, 1, 6, 30, 7, 31, 8, 31, 9, 30, 10, 31, 11, 30, 12, 31, 0)),
"Net 30" ,DATE(YEAR(TODAY()),MONTH(TODAY())+1,CASE( MONTH(TODAY())+1,1, 31, 2, IF( MOD( YEAR(TODAY()), 4) = 0, 29, 28), 3, 31, 4, 30, 5, 1, 6, 30, 7, 31, 8, 31, 9, 30, 10, 31, 11, 30, 12, 31, 0)),
"Net 60" ,DATE(YEAR(TODAY()),MONTH(TODAY())+2,CASE( MONTH(TODAY())+2,1, 31, 2, IF( MOD( YEAR(TODAY()), 4) = 0, 29, 28), 3, 31, 4, 30, 5, 1, 6, 30, 7, 31, 8, 31, 9, 30, 10, 31, 11, 30, 12, 31, 0)),
"Net 90" ,DATE(YEAR(TODAY()),MONTH(TODAY())+3,CASE( MONTH(TODAY())+3,1, 31, 2, IF( MOD( YEAR(TODAY()), 4) = 0, 29, 28), 3, 31, 4, 30, 5, 1, 6, 30, 7, 31, 8, 31, 9, 30, 10, 31, 11, 30, 12, 31, 0)),
"Net 120",DATE(YEAR(TODAY()),MONTH(TODAY())+4,CASE( MONTH(TODAY())+4,1, 31, 2, IF( MOD( YEAR(TODAY()), 4) = 0, 29, 28), 3, 31, 4, 30, 5, 1, 6, 30, 7, 31, 8, 31, 9, 30, 10, 31, 11, 30, 12, 31, 0)),
"30" ,TODAY()+30,
"60" ,TODAY()+60,
"90" ,TODAY()+90,
TODAY())
The problem I face now, is that once the date is in Next year e.g: October with payment terms of Net 90 - needs to be January first 2014.
Trying the line:
"Net 120", DATE(YEAR(TODAY()),MONTH(TODAY())+4,CASE( MONTH(TODAY())+4,1, 31, 2, IF( MOD( YEAR(TODAY()), 4) = 0, 29, 28), 3, 31, 4, 30, 5, 31, 6, 30, 7, 31, 8, 31, 9, 30, 10, 31, 11, 30, 12, 31, 0)),
gives me an error:
A workflow or approval field update caused an error when saving this record. Contact your administrator to resolve it. Payment Due Date: value not of required type: common.formula.FormulaEvaluationException: Month or Day out of range in DATE() function
I am sure I need to overcome the rolling year issue, not sure how to do that.
TODAY() + 120
for "Net 120"? My understanding is that "Net X" means "balance due X days from invoice date".