BrightSide Workbench Full Report + Source Code
org.turro.crm.zul.sale.ProspectStageWrapper Class Reference
Inheritance diagram for org.turro.crm.zul.sale.ProspectStageWrapper:
Collaboration diagram for org.turro.crm.zul.sale.ProspectStageWrapper:

Public Member Functions

 ProspectStageWrapper (SaleProspect saleProspect, Date now)
 
boolean canChangeTo (ProspectStage newStage)
 

Protected Member Functions

ProspectStage doCheckStatus (Date now)
 
ProspectStage doChangeTo (final ProspectStage newStage)
 

Detailed Description

Author
Lluis TurrĂ³ Cutiller lluis.nosp@m.@tur.nosp@m.ro.or.nosp@m.g

Definition at line 39 of file ProspectStageWrapper.java.

Constructor & Destructor Documentation

◆ ProspectStageWrapper()

org.turro.crm.zul.sale.ProspectStageWrapper.ProspectStageWrapper ( SaleProspect  saleProspect,
Date  now 
)

Definition at line 43 of file ProspectStageWrapper.java.

43  {
44  super(saleProspect.getStage());
45  this.saleProspect = saleProspect;
46  checkStatus(now);
47  }
Here is the call graph for this function:

Member Function Documentation

◆ canChangeTo()

boolean org.turro.crm.zul.sale.ProspectStageWrapper.canChangeTo ( ProspectStage  newStage)

Definition at line 113 of file ProspectStageWrapper.java.

113  {
114  if(ProspectType.TRACING.equals(saleProspect.getType())) return false;
115  if(current.equals(ProspectStage.STARTED)) {
116  return EnumSet.of(
117  ProspectStage.BUDGETED,
118  ProspectStage.NEGOTIATING,
119  ProspectStage.CLOSED_WON,
120  ProspectStage.CLOSED_LOST).contains(newStage);
121  } else if(current.equals(ProspectStage.BUDGETED)) {
122  return EnumSet.of(
123  ProspectStage.NEGOTIATING,
124  ProspectStage.CLOSED_WON,
125  ProspectStage.CLOSED_LOST).contains(newStage);
126  } else if(current.equals(ProspectStage.NEGOTIATING)) {
127  return EnumSet.of(
128  ProspectStage.CLOSED_WON,
129  ProspectStage.CLOSED_LOST).contains(newStage);
130  }
131  return false;
132  }
Here is the call graph for this function:

◆ doChangeTo()

ProspectStage org.turro.crm.zul.sale.ProspectStageWrapper.doChangeTo ( final ProspectStage  newStage)
protected

Definition at line 67 of file ProspectStageWrapper.java.

67  {
68  final ArrayList<SaleAction> saleActions = new ArrayList<SaleAction>();
69  final Dao dao = new CrmPU();
70  boolean shouldSave;
71  for(SaleAction sa : saleProspect.getSaleActions()) {
72  shouldSave = false;
73  TouchPoint tp = sa.getEndingTouchPoint();
74  if(tp == null) {
75 
76  } else if(tp.isPositive()) {
77  if(newStage.equals(ProspectStage.CLOSED_LOST)) {
78  sa.setEndingTouchPoint(null);
79  shouldSave = true;
80  }
81  } else if(!tp.isPositive()) {
82  if(newStage.equals(ProspectStage.CLOSED_WON)) {
83  sa.setEndingTouchPoint(null);
84  shouldSave = true;
85  }
86  }
87  if(EnumSet.of(ProspectStage.CLOSED_WON,
88  ProspectStage.CLOSED_LOST).contains(newStage)) {
89  if(sa.getStatus() == SaleAction.SA_PENDING) {
90  sa.setStatus(SaleAction.SA_CANCELLED);
91  shouldSave = true;
92  }
93  }
94  if(shouldSave) {
95  saleActions.add(sa);
96  }
97  }
98  if(!saleActions.isEmpty()) {
99  Messages.confirmProcess().paragraph().add(I_.get("Affected") + ": ")
100  .add(saleActions.size() + " " + I_.get("Sale actions")).show(() -> {
101  for(SaleAction sa : saleActions) {
102  dao.saveObject(sa);
103  }
104  saleProspect.setStage(newStage);
105  });
106  } else {
107  saleProspect.setStage(newStage);
108  }
109  return saleProspect.getStage();
110  }
void setStage(ProspectStage stage)
Here is the call graph for this function:

◆ doCheckStatus()

ProspectStage org.turro.crm.zul.sale.ProspectStageWrapper.doCheckStatus ( Date  now)
protected

Definition at line 50 of file ProspectStageWrapper.java.

50  {
51  ProspectStage stage = current;
52  for(SaleAction sa : saleProspect.getSaleActions()) {
53  TouchPoint tp = sa.getEndingTouchPoint();
54  if(tp == null) {
55  // nothing
56  } else if(tp.isPositive()) {
57  stage = ProspectStage.CLOSED_WON;
58  } else if(!tp.isPositive()) {
59  stage = ProspectStage.CLOSED_LOST;
60  }
61  }
62  return stage;
63  }
Here is the call graph for this function:

The documentation for this class was generated from the following file: