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

Public Member Functions

 DocumentWrapper (Document entity)
 
Set< RegisterWrappergetRegisters ()
 
void setPriorSavingValues (List< DocumentLine > lines, List< DocumentRelation > descendants)
 
Document save ()
 
Document save (List< DocumentLine > lines, List< DocumentRelation > descendants)
 
boolean delete ()
 
List< DocumentgetRelatedAncestor (DocumentDefinition documentDefinition)
 
List< DocumentgetRelatedDescendant (DocumentDefinition documentDefinition)
 
double getAdvance ()
 
- 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)
 
ID getId ()
 
List< String > getMessages ()
 
boolean canDelete ()
 
boolean canSave ()
 
boolean equals (Object obj)
 
int hashCode ()
 

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

- 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 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

◆ DocumentWrapper()

org.turro.financials.model.document.DocumentWrapper.DocumentWrapper ( Document  entity)

Reimplemented in org.turro.financials.document.logic.DocumentWrapper.

Definition at line 39 of file bsfinancials-core/src/main/java/org/turro/financials/model/document/DocumentWrapper.java.

39  {
40  super(entity);
41  for(Register r : entity.getRegisters()) {
42  entity.setRegularizeVAT(r.isRegularizeVAT());
43  entity.setRegularizeIRPF(r.isRegularizeIRPF());
44  }
45  }
Here is the caller graph for this function:

Member Function Documentation

◆ createDao()

Dao org.turro.financials.model.document.DocumentWrapper.createDao ( )
protected

◆ delete()

boolean org.turro.financials.model.document.DocumentWrapper.delete ( )

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

Definition at line 178 of file bsfinancials-core/src/main/java/org/turro/financials/model/document/DocumentWrapper.java.

178  {
179  // Check if possible and notify
181  "delete from DocumentRelation " +
182  "where ancestor = ? " +
183  "or descendant = ?",
184  new Object[] { entity, entity });
185  entity.getAncestors().clear();
186  entity.getDescendants().clear();
187  return super.delete();
188  }
int executeUpdate(String query)
Definition: Dao.java:463
Here is the call graph for this function:

◆ getAdvance()

double org.turro.financials.model.document.DocumentWrapper.getAdvance ( )

◆ getRegisters()

Set<RegisterWrapper> org.turro.financials.model.document.DocumentWrapper.getRegisters ( )

Definition at line 52 of file bsfinancials-core/src/main/java/org/turro/financials/model/document/DocumentWrapper.java.

52  {
53  Set<RegisterWrapper> s = new HashSet<RegisterWrapper>();
54  for(RegisterView rv : ViewWrapper.getViews()) {
55  boolean done = false;
56  for(Register r : entity.getRegisters()) {
57  if(r.getView().getId() == rv.getId()) {
58  r.setRegisterDate(entity.getReceiptDate());
59  s.add(new RegisterWrapper(r));
60  done = true;
61  break;
62  }
63  }
64  if(!done) {
65  Register r = new Register();
66  r.setView(rv);
67  r.setRegisterDate(entity.getReceiptDate());
69  entity.getRegisters().add(r);
70  s.add(new RegisterWrapper(r));
71  }
72  }
73  return s;
74  }
void setView(RegisterView view)
Definition: Register.java:163
void setDocument(Document document)
Definition: Register.java:95
void setRegisterDate(Date registerDate)
Definition: Register.java:127
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getRelatedAncestor()

List<Document> org.turro.financials.model.document.DocumentWrapper.getRelatedAncestor ( DocumentDefinition  documentDefinition)

Definition at line 195 of file bsfinancials-core/src/main/java/org/turro/financials/model/document/DocumentWrapper.java.

195  {
196  return getDao().getResultList(
197  "select doc from Document as doc " +
198  "where doc.descendants is empty " +
199  "and doc.documentDefinition = ? " +
200  "and doc.contract = ?",
201  new Object[] { documentDefinition, entity.getContract() });
202  }
Here is the call graph for this function:

◆ getRelatedDescendant()

List<Document> org.turro.financials.model.document.DocumentWrapper.getRelatedDescendant ( DocumentDefinition  documentDefinition)

Definition at line 204 of file bsfinancials-core/src/main/java/org/turro/financials/model/document/DocumentWrapper.java.

204  {
205  return getDao().getResultList(
206  "select doc from Document as doc " +
207  "where doc.ancestors is empty " +
208  "and doc.documentDefinition = ? " +
209  "and doc.contract = ?",
210  new Object[] { documentDefinition, entity.getContract() });
211  }
Here is the call graph for this function:

◆ save() [1/2]

Document org.turro.financials.model.document.DocumentWrapper.save ( )

◆ save() [2/2]

Document org.turro.financials.model.document.DocumentWrapper.save ( List< DocumentLine lines,
List< DocumentRelation descendants 
)

Definition at line 86 of file bsfinancials-core/src/main/java/org/turro/financials/model/document/DocumentWrapper.java.

86  {
87  /*
88  * Save documents and assign ancestor and descendant,
89  * then save relations.
90  */
91  if(descendants != null) {
92  DocumentWrapper dw;
93  for(DocumentRelation dr : descendants) {
94  if(!dr.isEmpty()) {
95  if(!dr.getDescendant().isEmpty()) {
96  dr.getDescendant().setForcedView(entity.getForcedView());
97  if(dr.getDescendant().getId() == 0) {
98  if(entity.isDraft()) {
99  dr.getDescendant().setDraft(true);
100  }
101  } else {
102  if(!entity.isDraft()) {
103  dr.getDescendant().setDraft(false);
104  }
105  }
106  for(DocumentLine l : dr.getDescendant().getDocumentLines()) {
107  if(!l.isEmpty() && l.getStore() != null) {
108  UsualUsages.addUsage(entity.getUsualPath() + "df:" + l.getDocument().getDocumentDefinition().getId());
109  UsualUsages.addUsage(dr.getDescendant().getUsualPath() + "st:" + l.getStore().getId());
110  UsualUsages.addUsage(dr.getDescendant().getUsualPath() + "cp:" + l.getConcept());
111  }
112  }
113  dw = new DocumentWrapper(dr.getDescendant());
114  dr.setDescendant(dw.save(null, null));
115  }
116  }
117  }
118  }
119  if(lines != null) {
120  entity.assignTableOrder(lines);
121  for(DocumentLine l : lines) {
122  if(!l.isEmpty() && l.getStore() != null) {
123  UsualUsages.addUsage(entity.getUsualPath() + "st:" + l.getStore().getId());
124  UsualUsages.addUsage(entity.getUsualPath() + "cp:" + l.getConcept());
125  }
126  }
127  }
128  entity.clearEmpties();
129  if(entity.isDraft()) {
130  entity.getRegisters().clear();
131  } else {
132  getRegisters();
133  Iterator<Register> ir = entity.getRegisters().iterator();
134  while(ir.hasNext()) {
135  Register r = ir.next();
136  r.removeEmpties();
137  r.setRegisterDate(entity.getReceiptDate());
138  if(r.isEmpty()) {
139  r.setDocument(null);
140  ir.remove();
141  } else if(entity.getForcedView() != null) {
142  if(r.getView().getId() != entity.getForcedView().getId()) {
143  r.setView(entity.getForcedView());
144  r.setIdRegister(0);
145  }
146  }
147  }
148  }
149 
150  /* Save relations for future saving */
151  ArrayList<DocumentRelation> relancestors = new ArrayList<DocumentRelation>(entity.getAncestors());
152  ArrayList<DocumentRelation> reldescendants = new ArrayList<DocumentRelation>(entity.getDescendants());
153  entity.getAncestors().clear();
154  entity.getDescendants().clear();
155 
156  entity.prepareSave();
157  super.save();
158 
159  /* Save relations from editing entity */
160  if(lines != null) {
161  for(DocumentRelation dr : relancestors) {
162  if(!dr.isEmpty()) {
163  dr.setDescendant(entity);
164  getDao().saveObject(dr);
165  }
166  }
167  for(DocumentRelation dr : reldescendants) {
168  if(!dr.isEmpty() && dr.getDescendant().getId() != 0) {
169  dr.setAncestor(entity);
170  getDao().saveObject(dr);
171  }
172  }
173  }
174  return entity;
175  }
void setIdRegister(long idRegister)
Definition: Register.java:119
Here is the call graph for this function:

◆ setPriorSavingValues()

void org.turro.financials.model.document.DocumentWrapper.setPriorSavingValues ( List< DocumentLine lines,
List< DocumentRelation descendants 
)

Definition at line 76 of file bsfinancials-core/src/main/java/org/turro/financials/model/document/DocumentWrapper.java.

76  {
77  this.lines = lines;
78  this.descendants = descendants;
79  }
Here is the caller graph for this function:

◆ shouldLog()

boolean org.turro.financials.model.document.DocumentWrapper.shouldLog ( )
protected

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