| 1 package sellwin.domain; 2 3 import java.util.*; 4 import java.io.*; 5 import java.text.*; 6 import javax.swing.text.*; 7 8 12 13 18 public class Forecast implements Serializable { 19 private long pk; 20 private long oppPK; 21 private String name; 22 private Date closeDate; 23 private Boolean submitted; 24 private Date submittedDate; 25 private String submittedBy; 26 private Integer revenue; 27 private Integer profit; 28 private Double margin; 29 private String scenario; 30 private Integer amountJan; 31 private Integer amountFeb; 32 private Integer amountMar; 33 private Integer Q1; 34 private Integer amountApr; 35 private Integer amountMay; 36 private Integer amountJun; 37 private Integer Q2; 38 private Integer amountJul; 39 private Integer amountAug; 40 private Integer amountSep; 41 private Integer Q3; 42 private Integer amountOct; 43 private Integer amountNov; 44 private Integer amountDec; 45 private Integer Q4; 46 private String modifiedBy; 47 private Date modifiedDate; 48 private boolean addedLocally=false; 49 private boolean updatedLocally=false; 50 51 public static final String SCEN_BEST_CASE = "Best Case"; 52 public static final String SCEN_MOST_LIKELY_CASE = "Most Likely"; 53 public static final String SCEN_WORST_CASE = "Worst Case"; 54 55 public static final double BEST_CASE_FACTOR = 1.0; 56 public static final double MOST_LIKELY_FACTOR = 0.75; 57 public static final double WORST_CASE_FACTOR = 0.50; 58 59 public static final String [] SCENARIOS = { 60 SCEN_BEST_CASE, SCEN_MOST_LIKELY_CASE, SCEN_WORST_CASE 61 }; 62 63 public final static int PERIOD_ALL = 0; 64 public final static int PERIOD_Q1 = 1; 65 public final static int PERIOD_Q2 = 2; 66 public final static int PERIOD_Q3 = 3; 67 public final static int PERIOD_Q4 = 4; 68 69 public final static String [] PERIODS = new String [5]; 70 71 static { 72 PERIODS[PERIOD_ALL] = "All Quarters"; 73 PERIODS[PERIOD_Q1] = "Q1 - Current Year (Jan-Mar)"; 74 PERIODS[PERIOD_Q2] = "Q2 - Current Year (Apr-Jun)"; 75 PERIODS[PERIOD_Q3] = "Q3 - Current Year (Jul-Sep)"; 76 PERIODS[PERIOD_Q4] = "Q4 - Current Year (Oct-Dec)"; 77 } 78 79 80 public Forecast() { 81 submitted=new Boolean (false); 82 closeDate = new Date(); 83 submittedDate = new Date(); 84 submittedBy = "SYSTEM"; 85 revenue = new Integer (0); 86 profit = new Integer (0); 87 margin = new Double (0.00); 88 scenario = SCEN_BEST_CASE; 89 amountJan = new Integer (0); 90 amountFeb = new Integer (0); 91 amountMar = new Integer (0); 92 amountApr = new Integer (0); 93 amountMay = new Integer (0); 94 amountJun = new Integer (0); 95 amountJul = new Integer (0); 96 amountAug = new Integer (0); 97 amountSep = new Integer (0); 98 amountOct = new Integer (0); 99 amountNov = new Integer (0); 100 amountDec = new Integer (0); 101 Q1 = new Integer (0); 102 Q2 = new Integer (0); 103 Q3 = new Integer (0); 104 Q4 = new Integer (0); 105 modifiedBy="SYSTEM"; 106 modifiedDate = new Date(); 107 } 108 109 public final void setPK(long pk) { this.pk = pk; } 110 public final long getPK() { return pk; } 111 112 public final void setOppKey(long pk) { this.oppPK = pk; } 113 public final long getOppKey() { return oppPK; } 114 115 public final void setName(String n) { name = n;} 116 public final String getName() { return name; } 117 118 public final void setCloseDate(Date t) { closeDate = t; } 119 public final Date getCloseDate() { return closeDate; } 120 121 public final void setSubmitted(Boolean t) { submitted = t; } 122 public final Boolean getSubmitted() { return submitted; } 123 124 public final void setSubmittedDate(Date t) { submittedDate = t; } 125 public final Date getSubmittedDate() { return submittedDate; } 126 127 public final void setSubmittedBy(String t) { submittedBy = t; } 128 public final String getSubmittedBy() { return submittedBy; } 129 130 public final void setRevenue(Integer d) { revenue=d; } 131 public final Integer getRevenue() { return revenue; } 132 133 public final void setProfit(Integer d) { profit = d; } 134 public final Integer getProfit() { return profit; } 135 136 public final void setMargin(Double d) { 137 margin = d; 138 calcProfit(); 139 } 140 public final Double getMargin() { return margin; } 141 142 public final void setScenario(String s) { scenario = s; } 143 public final String getScenario() { return scenario; } 144 145 public final void setModifiedBy(String s) { modifiedBy = s; } 146 public final String getModifiedBy() { return modifiedBy; } 147 148 public final void setModifiedDate(Date s) { modifiedDate = s; } 149 public final Date getModifiedDate() { return modifiedDate; } 150 151 152 public final void setAmountJan(Integer i) { 153 amountJan = i; 154 calcQ1(); 155 } 156 public final void setAmountFeb(Integer i) { 157 amountFeb = i; 158 calcQ1(); 159 } 160 public final void setAmountMar(Integer i) { 161 amountMar = i; 162 calcQ1(); 163 } 164 public final void setAmountApr(Integer i) { 165 amountApr = i; 166 calcQ2(); 167 } 168 public final void setAmountMay(Integer i) { 169 amountMay = i; 170 calcQ2(); 171 } 172 public final void setAmountJun(Integer i) { 173 amountJun = i; 174 calcQ2(); 175 } 176 public final void setAmountJul(Integer i) { 177 amountJul = i; 178 calcQ3(); 179 } 180 public final void setAmountAug(Integer i) { 181 amountAug = i; 182 calcQ3(); 183 } 184 public final void setAmountSep(Integer i) { 185 amountSep = i; 186 calcQ3(); 187 } 188 public final void setAmountOct(Integer i) { 189 amountOct = i; 190 calcQ4(); 191 } 192 public final void setAmountNov(Integer i) { 193 amountNov = i; 194 calcQ4(); 195 } 196 public final void setAmountDec(Integer i) { 197 amountDec = i; 198 calcQ4(); 199 } 200 201 public final void setQ1(Integer i) { Q1 = i; } 202 public final void setQ2(Integer i) { Q2 = i; } 203 public final void setQ3(Integer i) { Q3 = i; } 204 public final void setQ4(Integer i) { Q4 = i; } 205 206 public final Integer getAmountJan() { return amountJan; } 207 public final Integer getAmountFeb() { return amountFeb; } 208 public final Integer getAmountMar() { return amountMar; } 209 public final Integer getAmountApr() { return amountApr; } 210 public final Integer getAmountMay() { return amountMay; } 211 public final Integer getAmountJun() { return amountJun; } 212 public final Integer getAmountJul() { return amountJul; } 213 public final Integer getAmountAug() { return amountAug; } 214 public final Integer getAmountSep() { return amountSep; } 215 public final Integer getAmountOct() { return amountOct; } 216 public final Integer getAmountNov() { return amountNov; } 217 public final Integer getAmountDec() { return amountDec; } 218 219 public final Integer getQ1() { return Q1; } 220 public final Integer getQ2() { return Q2; } 221 public final Integer getQ3() { return Q3; } 222 public final Integer getQ4() { return Q4; } 223 224 public final void setAddedLocally(boolean b) { addedLocally=b; } 225 public final void setUpdatedLocally(boolean b) { updatedLocally=b; } 226 public final boolean getAddedLocally() { return addedLocally; } 227 public final boolean getUpdatedLocally() { return updatedLocally; } 228 229 230 public final Forecast copy() { 231 Forecast copy = new Forecast(); 232 if (name != null) 233 copy.name = new String (name); 234 if (closeDate != null) 235 copy.closeDate = new Date( closeDate.getTime()); 236 copy.revenue= new Integer (revenue.intValue()); 237 copy.submitted = new Boolean (submitted.booleanValue()); 238 copy.profit = new Integer (profit.intValue()); 239 copy.margin = new Double (margin.doubleValue()); 240 copy.submittedDate = new Date(submittedDate.getTime()); 241 copy.submittedBy = new String (submittedBy); 242 copy.modifiedDate = new Date(modifiedDate.getTime()); 243 copy.modifiedBy = new String (modifiedBy); 244 if (scenario != null) 245 copy.scenario = new String ( scenario); 246 247 copy.amountJan = new Integer (amountJan.intValue()); 248 copy.amountFeb = new Integer (amountFeb.intValue()); 249 copy.amountMar = new Integer (amountMar.intValue()); 250 copy.amountApr = new Integer (amountApr.intValue()); 251 copy.amountMay = new Integer (amountMay.intValue()); 252 copy.amountJun = new Integer (amountJun.intValue()); 253 copy.amountJul = new Integer (amountJul.intValue()); 254 copy.amountAug = new Integer (amountAug.intValue()); 255 copy.amountSep = new Integer (amountSep.intValue()); 256 copy.amountOct = new Integer (amountOct.intValue()); 257 copy.amountNov = new Integer (amountNov.intValue()); 258 copy.amountDec = new Integer (amountDec.intValue()); 259 copy.Q1 = new Integer (Q1.intValue()); 260 copy.Q2 = new Integer (Q2.intValue()); 261 copy.Q3 = new Integer (Q3.intValue()); 262 copy.Q4 = new Integer (Q4.intValue()); 263 264 return copy; 265 266 } 267 268 public final void factorChange() { 269 calcQ1(); 270 calcQ2(); 271 calcQ3(); 272 calcQ4(); 273 } 274 275 public final void calcQ1() { 276 int val = 277 getAmountJan().intValue() + 278 getAmountFeb().intValue() + 279 getAmountMar().intValue(); 280 Double temp = new Double (val * getFactor()); 281 setQ1(new Integer (temp.intValue())); 282 calcAll(); 283 } 284 285 public final void calcQ2() { 286 int val = 287 getAmountApr().intValue() + 288 getAmountMay().intValue() + 289 getAmountJun().intValue(); 290 Double temp = new Double (val * getFactor()); 291 setQ2(new Integer (temp.intValue())); 292 calcAll(); 293 } 294 public final void calcQ3() { 295 int val = 296 getAmountJul().intValue() + 297 getAmountAug().intValue() + 298 getAmountSep().intValue(); 299 300 Double temp = new Double (val * getFactor()); 301 setQ3(new Integer (temp.intValue())); 302 calcAll(); 303 } 304 public final void calcQ4() { 305 int val = 306 getAmountOct().intValue() + 307 getAmountNov().intValue() + 308 getAmountDec().intValue(); 309 310 Double temp = new Double (val * getFactor()); 311 setQ4(new Integer (temp.intValue())); 312 calcAll(); 313 } 314 public final void calcAll() { 315 int val = 316 getQ1().intValue() + 317 getQ2().intValue() + 318 getQ3().intValue() + 319 getQ4().intValue(); 320 321 setRevenue(new Integer (val)); 322 323 calcProfit(); 324 } 325 326 public final void calcProfit() { 327 int rev = getRevenue().intValue(); 328 double marg = getMargin().doubleValue(); 329 Double temp = new Double (rev * marg); 330 331 setProfit( new Integer (temp.intValue())); 332 } 333 334 335 public final double getFactor() { 336 if (scenario.equals(SCEN_BEST_CASE)) 337 return BEST_CASE_FACTOR; 338 if (scenario.equals(SCEN_MOST_LIKELY_CASE)) 339 return MOST_LIKELY_FACTOR; 340 if (scenario.equals(SCEN_WORST_CASE)) 341 return WORST_CASE_FACTOR; 342 343 Exception e = new Exception (); 344 e.printStackTrace(); 345 System.exit(0); 346 347 return BEST_CASE_FACTOR; 348 } 349 350 public final void print() { 351 System.out.println("<<Forecast>>"); 352 System.out.println("pk=["+getPK()+"]"); 353 System.out.println("Name=["+getName()+"]"); 354 System.out.println("Close Date="+getCloseDate()); 355 System.out.println("Revenue="+getRevenue()); 356 System.out.println("Profit="+getProfit()); 357 System.out.println("Margin="+getMargin()); 358 System.out.println("Scenario=["+getScenario()+"]"); 359 System.out.println("Submitted="+getSubmitted()); 360 System.out.println("Submit Date="+ getSubmittedDate()); 361 System.out.println("SubmittedBy="+ getSubmittedBy()); 362 System.out.println("Jan="+getAmountJan() + " Feb="+getAmountFeb()); 363 System.out.println("Mar="+getAmountMar() + " Apr="+getAmountApr()); 364 System.out.println("May="+getAmountMay() + " Jun="+getAmountJun()); 365 System.out.println("Jul="+getAmountJul() + " Aug="+getAmountAug()); 366 System.out.println("Sep="+getAmountSep() + " Oct="+getAmountOct()); 367 System.out.println("Nov="+getAmountNov() + " Dec="+getAmountDec()); 368 System.out.println("Q1="+getQ1()+" Q2="+getQ2()+" Q3="+getQ3() +" Q4="+getQ4()); 369 System.out.println("ModifiedBy="+ getModifiedBy()); 370 System.out.println("ModifiedDate="+ getModifiedDate()); 371 } 372 } 373 | Popular Tags |