BrightSide Workbench Full Report + Source Code
org.turro.financials.model.register.RegisterWrapper Class Reference
Collaboration diagram for org.turro.financials.model.register.RegisterWrapper:

Public Member Functions

 RegisterWrapper (Register register)
 
 RegisterWrapper (Register register, boolean generate)
 
Register getRegister ()
 
EntrySet getEntries ()
 
String getBookString ()
 
Register save ()
 
boolean delete ()
 
boolean checkSave ()
 

Static Public Member Functions

static Register prepareBookRegister (Register register)
 

Protected Attributes

Register register
 

Detailed Description

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

Definition at line 36 of file RegisterWrapper.java.

Constructor & Destructor Documentation

◆ RegisterWrapper() [1/2]

org.turro.financials.model.register.RegisterWrapper.RegisterWrapper ( Register  register)

Definition at line 42 of file RegisterWrapper.java.

42  {
43  this(register, true);
44  }

◆ RegisterWrapper() [2/2]

org.turro.financials.model.register.RegisterWrapper.RegisterWrapper ( Register  register,
boolean  generate 
)

Definition at line 46 of file RegisterWrapper.java.

46  {
47  this.register = register;
48  this.generate = generate;
49  bookDefs = new HashSet<Long>();
50  generateEntries();
51  }

Member Function Documentation

◆ checkSave()

boolean org.turro.financials.model.register.RegisterWrapper.checkSave ( )

Definition at line 196 of file RegisterWrapper.java.

196  {
197  return CompanyWrapper.isValidDate(register.getRegisterDate(), register.isClosing() && register.isExclude());
198  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ delete()

boolean org.turro.financials.model.register.RegisterWrapper.delete ( )

Definition at line 163 of file RegisterWrapper.java.

163  {
164  if(register.getDocument() == null) {
165  SystemLogger.getInstance().doLog(SystemLogType.LOG_INFO, register, "deleted", new XMLSerializer(register).data());
166  new FinancialsPU().deleteObject(register);
167  return true;
168  }
169  return false;
170  }
void deleteObject(Object obj)
Definition: Dao.java:162
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getBookString()

String org.turro.financials.model.register.RegisterWrapper.getBookString ( )

Definition at line 107 of file RegisterWrapper.java.

107  {
108  Iterator<BookRegister> itbr = register.getBookRegisters().iterator();
109  // Clear temporary assigned books
110  while(itbr.hasNext()) {
111  BookRegister br = itbr.next();
112  boolean found = false;
113  for(Long idBd : bookDefs) {
114  if(br.getBookDefinition().getId() == idBd) {
115  found = true;
116  break;
117  }
118  }
119  if(!found && br.getId() == 0) {
120  itbr.remove();
121  }
122  }
123  // Generate new books
124  StringBuilder sb = new StringBuilder();
125  for(Long idBd : bookDefs) {
126  boolean found = false;
127  for(BookRegister br : register.getBookRegisters()) {
128  if(br.getBookDefinition().getId() == idBd) {
129  if(sb.length() > 0) {
130  sb.append(" | ");
131  }
132  sb.append(br.getBookDefinition().getDescription());
133  sb.append(" [" + (br.getBookOrder() == 0 ? "<auto>" : br.getBookOrder()) +"]");
134  found = true;
135  break;
136  }
137  }
138  if(!found) {
139  BookDefinition bd = new FinancialsPU().find(BookDefinition.class, idBd);
140  if(bd != null) {
141  BookRegister br = new BookRegister();
142  br.setRegister(register);
143  br.setBookDefinition(bd);
144  register.getBookRegisters().add(br);
145  if(sb.length() > 0) {
146  sb.append(" | ");
147  }
148  sb.append(bd.getDescription());
149  sb.append(" [<auto>]");
150  }
151  }
152  }
153  return sb.toString();
154  }
void setBookDefinition(BookDefinition bookDefinition)
Here is the call graph for this function:

◆ getEntries()

EntrySet org.turro.financials.model.register.RegisterWrapper.getEntries ( )

Definition at line 57 of file RegisterWrapper.java.

57  {
58  return generateEntries();
59  }
Here is the caller graph for this function:

◆ getRegister()

Register org.turro.financials.model.register.RegisterWrapper.getRegister ( )

Definition at line 53 of file RegisterWrapper.java.

53  {
54  return register;
55  }
Here is the caller graph for this function:

◆ prepareBookRegister()

static Register org.turro.financials.model.register.RegisterWrapper.prepareBookRegister ( Register  register)
static

Definition at line 172 of file RegisterWrapper.java.

172  {
173  Dao dao = new FinancialsPU();
174  Set<Long> bookDefs = new HashSet<Long>();
175  for(RegisterEntry re : register.getRegisterEntries()) {
176  if(re.getDebit() != 0 || re.getCredit() != 0) {
177  MajorAccount ma = re.getAccount().getParent();
178  if(ma != null) {
180  if(bf != null) {
181  bookDefs.add(bf.getId());
182  }
183  }
184  }
185  }
186  for(Long bookDef : bookDefs) {
187  BookRegister br = new BookRegister();
188  br.setRegister(register);
189  br.setBookDefinition(dao.find(BookDefinition.class, bookDef));
190  register.getBookRegisters().add(br);
191  }
192  register.prepareSave();
193  return register;
194  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ save()

Register org.turro.financials.model.register.RegisterWrapper.save ( )

Definition at line 156 of file RegisterWrapper.java.

156  {
157  register.prepareSave();
158  register = new FinancialsPU().saveObject(register);
159  SystemLogger.getInstance().doLog(SystemLogType.LOG_INFO, register, "saved", new XMLSerializer(register).data());
160  return register;
161  }
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ register

Register org.turro.financials.model.register.RegisterWrapper.register
protected

Definition at line 38 of file RegisterWrapper.java.


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