BrightSide Workbench Full Report + Source Code
org.turro.financials.model.contract.ContractWrapper Class Reference
Inheritance diagram for org.turro.financials.model.contract.ContractWrapper:
Collaboration diagram for org.turro.financials.model.contract.ContractWrapper:

Public Member Functions

 ContractWrapper (Contract entity)
 
Collection< DocumentDefinitiongetExpiryDefinitions (DocumentDefinition source)
 
boolean canDelete ()
 
void generateRegisters (DocumentDefinition docDef, int year)
 
Collection< DocumentgetDocuments (DocumentDefinition docDef, int year)
 
double getAdvance (RegisterView view)
 
void addAdvanceIfNeeded (RegisterView view, Collection< Contract > contracts)
 
IDossier getDossier ()
 
- Public Member Functions inherited from org.turro.jpa.entity.DaoEntity< T extends IDaoEntity, ID extends Serializable >
 DaoEntity ()
 
 DaoEntity (Class< T > persistentClass)
 
 DaoEntity (T entity)
 
Dao getDao ()
 
getEntity ()
 
IElephantEntity getIee ()
 
find (ID id)
 
save ()
 
boolean delete ()
 
ID getId ()
 
List< String > getMessages ()
 
boolean canSave ()
 
boolean equals (Object obj)
 
int hashCode ()
 

Static Public Member Functions

static Collection< ContractgetContracts (ContractDefinition contractDefinition)
 
static Collection< ContractgetContracts (Long contractDefinitionId)
 
static void clearActives (Collection< Contract > contracts)
 
static void clearInactives (Collection< Contract > contracts)
 
static boolean isActive (Date now, Contract contract)
 
static Collection< ContractgetContracts (IContact contact)
 
static Collection< DocumentDefinitiongetExpiryDefinitions (ContractDefinition contractDefinition, DocumentDefinition documentDefinition)
 
- Static Public Member Functions inherited from org.turro.jpa.entity.DaoEntity< T extends IDaoEntity, ID extends Serializable >
static Object getEntityId (Object entity)
 
static boolean isNewId (Object id)
 

Protected Member Functions

Dao createDao ()
 
boolean shouldLog ()
 
- Protected Member Functions inherited from org.turro.jpa.entity.DaoEntity< T extends IDaoEntity, ID extends Serializable >
void logEntity (SystemLogType logType, Object entity, String action, String data)
 
String dataEntity (Object entity)
 
void initOperation ()
 
void addMessage (String message)
 

Additional Inherited Members

- Protected Attributes inherited from org.turro.jpa.entity.DaoEntity< T extends IDaoEntity, ID extends Serializable >
entity
 
ID id
 
List< String > messages = new ArrayList<>()
 

Detailed Description

Constructor & Destructor Documentation

◆ ContractWrapper()

org.turro.financials.model.contract.ContractWrapper.ContractWrapper ( Contract  entity)

Member Function Documentation

◆ addAdvanceIfNeeded()

void org.turro.financials.model.contract.ContractWrapper.addAdvanceIfNeeded ( RegisterView  view,
Collection< Contract contracts 
)

Definition at line 127 of file bsfinancials-core/src/main/java/org/turro/financials/model/contract/ContractWrapper.java.

127  {
128  if(getAdvance(view) != 0.0d) {
129  Iterator<Contract> it = contracts.iterator();
130  while(it.hasNext()) {
131  Contract ctc = it.next();
132  if(ctc.getId() == entity.getId()) {
133  return;
134  }
135  }
136  contracts.add(entity);
137  }
138  }
Here is the call graph for this function:

◆ canDelete()

boolean org.turro.financials.model.contract.ContractWrapper.canDelete ( )

Reimplemented from org.turro.jpa.entity.DaoEntity< T extends IDaoEntity, ID extends Serializable >.

Definition at line 62 of file bsfinancials-core/src/main/java/org/turro/financials/model/contract/ContractWrapper.java.

62  {
63  if(!super.canDelete()) return false;
64  Long count = (Long) getDao().getSingleResult(
65  "select count(*) from Document " +
66  "where contract = ?",
67  new Object[] { entity });
68  if(count == 0) {
69  count = (Long) getDao().getSingleResult(
70  "select count(*) from DocumentLine " +
71  "where store = ?",
72  new Object[] { entity });
73  }
74  return count == 0;
75  }
Object getSingleResult(WhereClause wc)
Definition: Dao.java:380
Here is the call graph for this function:

◆ clearActives()

static void org.turro.financials.model.contract.ContractWrapper.clearActives ( Collection< Contract contracts)
static

Definition at line 160 of file bsfinancials-core/src/main/java/org/turro/financials/model/contract/ContractWrapper.java.

160  {
161  Date now = new Date();
162  Iterator<Contract> it = contracts.iterator();
163  while(it.hasNext()) {
164  if(isActive(now, it.next())) {
165  it.remove();
166  }
167  }
168  }
Here is the call graph for this function:

◆ clearInactives()

static void org.turro.financials.model.contract.ContractWrapper.clearInactives ( Collection< Contract contracts)
static

Definition at line 170 of file bsfinancials-core/src/main/java/org/turro/financials/model/contract/ContractWrapper.java.

170  {
171  Date now = new Date();
172  Iterator<Contract> it = contracts.iterator();
173  while(it.hasNext()) {
174  if(!isActive(now, it.next())) {
175  it.remove();
176  }
177  }
178  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ createDao()

Dao org.turro.financials.model.contract.ContractWrapper.createDao ( )
protected

◆ generateRegisters()

void org.turro.financials.model.contract.ContractWrapper.generateRegisters ( DocumentDefinition  docDef,
int  year 
)

Reimplemented in org.turro.financials.contract.logic.ContractWrapper.

Definition at line 82 of file bsfinancials-core/src/main/java/org/turro/financials/model/contract/ContractWrapper.java.

82  {
83  for(Document doc : getDocuments(docDef, year)) {
84  new DocumentWrapper(doc).save(null, null);
85  }
86  }
Here is the call graph for this function:

◆ getAdvance()

double org.turro.financials.model.contract.ContractWrapper.getAdvance ( RegisterView  view)

Definition at line 101 of file bsfinancials-core/src/main/java/org/turro/financials/model/contract/ContractWrapper.java.

101  {
102  String acc = entity.getContractDefinition().getAsCash();
103  if(!Strings.isBlank(acc) && (acc.startsWith("560") ||
104  acc.startsWith("561") || acc.startsWith("565") || acc.startsWith("566"))) {
105  WhereClause wc = new WhereClause();
106  wc.addClause("select sum(re.debit-re.credit) from RegisterEntry as re");
107  wc.addClause("where re.account.id = :idacc");
108  wc.addNamedValue("idacc", AccountFormat.expand(acc + "." + entity.getId()));
109  wc.addClause("and re.register.view = :view");
110  if(view != null) {
111  wc.addNamedValue("view", view);
112  } else {
113  wc.addNamedValue("view", ViewWrapper.getFormalView());
114  }
115  advance = (Double) getDao().getSingleResultOrNull(wc);
116  if("566".equals(entity.getContractDefinition().getAsCash())) {
117  advance = advance != null ? -advance : 0.0d;
118  } else {
119  advance = advance != null ? advance : 0.0d;
120  }
121  return advance;
122  } else {
123  return 0.0d;
124  }
125  }
void addNamedValue(String name, Object value)
Object getSingleResultOrNull(SqlClause sc)
Definition: Dao.java:419
boolean equals(Object obj)
Definition: DaoEntity.java:154
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getContracts() [1/3]

static Collection<Contract> org.turro.financials.model.contract.ContractWrapper.getContracts ( ContractDefinition  contractDefinition)
static

Definition at line 140 of file bsfinancials-core/src/main/java/org/turro/financials/model/contract/ContractWrapper.java.

140  {
141  Dao dao = new FinancialsPU();
142  return dao.getResultList(
143  "select ctc from Contract as ctc " +
144  "where ctc.contractDefinition = ? " +
145  "and ctc.active = TRUE " +
146  "order by ctc.name",
147  new Object[] { contractDefinition });
148  }

◆ getContracts() [2/3]

static Collection<Contract> org.turro.financials.model.contract.ContractWrapper.getContracts ( IContact  contact)
static

Definition at line 209 of file bsfinancials-core/src/main/java/org/turro/financials/model/contract/ContractWrapper.java.

209  {
210  if(contact == null) return null;
211 
212  Dao dao = new FinancialsPU();
213  return dao.getResultList(
214  "select ctc from Contract as ctc " +
215  "left outer join ctc.participants participant " +
216  "where ctc.contractor = ? or (participant.idContact = ? and participant.interventionType = ?) " +
217  "order by ctc.name",
218  new Object[] { contact.getId(), contact.getId(), ContractInterventionType.INT_OPERATOR });
219  }
Here is the call graph for this function:

◆ getContracts() [3/3]

static Collection<Contract> org.turro.financials.model.contract.ContractWrapper.getContracts ( Long  contractDefinitionId)
static

Definition at line 150 of file bsfinancials-core/src/main/java/org/turro/financials/model/contract/ContractWrapper.java.

150  {
151  Dao dao = new FinancialsPU();
152  return dao.getResultList(
153  "select ctc from Contract as ctc " +
154  "where ctc.contractDefinition.id = ? " +
155  "and ctc.active = TRUE " +
156  "order by ctc.name",
157  new Object[] { contractDefinitionId });
158  }

◆ getDocuments()

Collection<Document> org.turro.financials.model.contract.ContractWrapper.getDocuments ( DocumentDefinition  docDef,
int  year 
)

Definition at line 88 of file bsfinancials-core/src/main/java/org/turro/financials/model/contract/ContractWrapper.java.

88  {
89  return getDao().getResultList(
90  "select doc from Document as doc " +
91  "where doc.contract = ? " +
92  "and doc.documentDefinition = ? " +
93  "and year(doc.receiptDate) = ? " +
94  "order by doc.documentDate",
95  new Object[] { entity, docDef, year });
96  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getDossier()

IDossier org.turro.financials.model.contract.ContractWrapper.getDossier ( )

Definition at line 180 of file bsfinancials-core/src/main/java/org/turro/financials/model/contract/ContractWrapper.java.

180  {
181  if(entity.getId() > 0) {
182  IDossier dossier = (IDossier) Plugins.loadImplementation(IDossier.class);//PluginChecker.get("dossier");
183  ICategory cat = dossier.addCategory();
184  cat.setDescription("Financials");
185  cat.setId(9000);
186  cat = dossier.addCategory();
187  cat.setDescription("Contracts");
188  cat.setId(9001);
189  cat.setParentId(9000);
190  cat = dossier.addCategory();
191  cat.setDescription(entity.getContractDefinition().getName());
192  cat.setId(9500 + entity.getContractDefinition().getId());
193  cat.setParentId(9001);
194  dossier.setDescription(entity.getFullDescription());
195  dossier.setIdCategory(cat.getId());
196  dossier.setPath(FinancialsPU.getObjectPath(entity));
197  dossier.setSubject(entity.getIContractor());
198  return dossier;
199  }
200  return null;
201  }
static String getObjectPath(Object object)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getExpiryDefinitions() [1/2]

static Collection<DocumentDefinition> org.turro.financials.model.contract.ContractWrapper.getExpiryDefinitions ( ContractDefinition  contractDefinition,
DocumentDefinition  documentDefinition 
)
static

Definition at line 221 of file bsfinancials-core/src/main/java/org/turro/financials/model/contract/ContractWrapper.java.

221  {
222  ArrayList<DocumentDefinition> list = new ArrayList<DocumentDefinition>();
223  for(DocumentWorkflow dw : contractDefinition.getDocumentWorkflows()) {
224  if(dw.getAncestor().getId() == documentDefinition.getId() && dw.isAllowNewDescendants()) {
225  list.add(dw.getDescendant());
226  }
227  }
228  return list;
229  }
Here is the call graph for this function:

◆ getExpiryDefinitions() [2/2]

Collection<DocumentDefinition> org.turro.financials.model.contract.ContractWrapper.getExpiryDefinitions ( DocumentDefinition  source)

Definition at line 50 of file bsfinancials-core/src/main/java/org/turro/financials/model/contract/ContractWrapper.java.

50  {
51  if(entity == null || source == null) return Collections.EMPTY_LIST;
52  ArrayList<DocumentDefinition> list = new ArrayList<>();
53  for(DocumentWorkflow dw : entity.getContractDefinition().getDocumentWorkflows()) {
54  if(dw.getAncestor().getId() == source.getId() && dw.isAllowNewDescendants()) {
55  list.add(dw.getDescendant());
56  }
57  }
58  return list;
59  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ isActive()

static boolean org.turro.financials.model.contract.ContractWrapper.isActive ( Date  now,
Contract  contract 
)
static

Definition at line 203 of file bsfinancials-core/src/main/java/org/turro/financials/model/contract/ContractWrapper.java.

203  {
204  return contract.isActive() &&
205  (contract.getStartDate() == null || now.after(contract.getStartDate())) &&
206  (contract.getEndDate() == null || now.before(contract.getEndDate()));
207  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ shouldLog()

boolean org.turro.financials.model.contract.ContractWrapper.shouldLog ( )
protected

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