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

Public Member Functions

 CompanyWrapper ()
 
Company save ()
 
boolean delete ()
 
- 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 ()
 

Static Public Member Functions

static boolean isValidDate (Date date)
 
static boolean isValidDate (Date date, boolean closing)
 
static Date getCompanyClosingDate ()
 
static int getEndOfYearClosing ()
 
static int getEndOfYearClosing (Date date)
 
static Currency getCompanyCurrency ()
 
static Locale getCompanyLocale ()
 
static NumberFormat getCurrencyFormatter ()
 
static Company getCompanyFrom (DocumentLine line)
 
static Headquarters getHeadquartersFrom (DocumentLine line)
 
static Department getDepartmentFrom (DocumentLine line)
 
static Service getServiceFrom (DocumentLine line)
 
static Company getDefaultCompany ()
 
static Company getDefaultCompany (boolean reload)
 
static void renumRegisters (Integer year, boolean books)
 
static void renumBookRegisters (Integer year)
 
static Service getDefaultService ()
 
static Contract getDefaultContractService ()
 
static void removeExercise (Integer year)
 
- 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

◆ CompanyWrapper()

org.turro.financials.model.business.CompanyWrapper.CompanyWrapper ( )

Member Function Documentation

◆ createDao()

Dao org.turro.financials.model.business.CompanyWrapper.createDao ( )
protected

◆ delete()

boolean org.turro.financials.model.business.CompanyWrapper.delete ( )

◆ getCompanyClosingDate()

static Date org.turro.financials.model.business.CompanyWrapper.getCompanyClosingDate ( )
static

Definition at line 124 of file bsfinancials-core/src/main/java/org/turro/financials/model/business/CompanyWrapper.java.

124  {
125  Company company = getDefaultCompany();
126  if(company != null) {
127  return company.getClosingDate();
128  }
129  return null;
130  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getCompanyCurrency()

static Currency org.turro.financials.model.business.CompanyWrapper.getCompanyCurrency ( )
static

Definition at line 175 of file bsfinancials-core/src/main/java/org/turro/financials/model/business/CompanyWrapper.java.

175  {
176  Company company = getDefaultCompany();
177  if(company != null) {
178  Contact contact = (Contact) company.getIContact().getContact();
179  if(contact != null) {
180  return contact.getCurrency();
181  }
182  }
183  return Currencies.getDefault();
184  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getCompanyFrom()

static Company org.turro.financials.model.business.CompanyWrapper.getCompanyFrom ( DocumentLine  line)
static

Definition at line 201 of file bsfinancials-core/src/main/java/org/turro/financials/model/business/CompanyWrapper.java.

201  {
202  if(line != null && line.getStore() != null) {
203  Contract store = line.getStore();
204  if(store.getDepartment() != null && store.getDepartment().getHeadquarters() != null) {
205  return store.getDepartment().getHeadquarters().getCompany();
206  }
207  if(store.getService() != null) {
208  return store.getService().getCompany();
209  }
210  }
211  return getDefaultCompany();
212  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getCompanyLocale()

static Locale org.turro.financials.model.business.CompanyWrapper.getCompanyLocale ( )
static

Definition at line 186 of file bsfinancials-core/src/main/java/org/turro/financials/model/business/CompanyWrapper.java.

186  {
187  Company company = getDefaultCompany();
188  if(company != null) {
189  Contact contact = (Contact) company.getIContact().getContact();
190  if(contact != null) {
191  return contact.getLocale();
192  }
193  }
194  return Application.getUsedLocale();
195  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getCurrencyFormatter()

static NumberFormat org.turro.financials.model.business.CompanyWrapper.getCurrencyFormatter ( )
static

Definition at line 197 of file bsfinancials-core/src/main/java/org/turro/financials/model/business/CompanyWrapper.java.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getDefaultCompany() [1/2]

static Company org.turro.financials.model.business.CompanyWrapper.getDefaultCompany ( )
static

Definition at line 242 of file bsfinancials-core/src/main/java/org/turro/financials/model/business/CompanyWrapper.java.

242  {
243  return getDefaultCompany(false);
244  }
Here is the caller graph for this function:

◆ getDefaultCompany() [2/2]

static Company org.turro.financials.model.business.CompanyWrapper.getDefaultCompany ( boolean  reload)
static

Definition at line 246 of file bsfinancials-core/src/main/java/org/turro/financials/model/business/CompanyWrapper.java.

246  {
247  if(reload || _defaultCompany == null) {
248  _defaultCompany = (Company) new FinancialsPU().getSingleResult("select company from Company as company");
249  }
250  return _defaultCompany;
251  }
Here is the call graph for this function:

◆ getDefaultContractService()

static Contract org.turro.financials.model.business.CompanyWrapper.getDefaultContractService ( )
static

Definition at line 319 of file bsfinancials-core/src/main/java/org/turro/financials/model/business/CompanyWrapper.java.

319  {
320  return (Contract) new FinancialsPU().getSingleResult(
321  "select ctc from Contract as ctc " +
322  "where ctc.id = (select min(id) from Contract where service is not null)");
323  }
Here is the call graph for this function:

◆ getDefaultService()

static Service org.turro.financials.model.business.CompanyWrapper.getDefaultService ( )
static

Definition at line 313 of file bsfinancials-core/src/main/java/org/turro/financials/model/business/CompanyWrapper.java.

313  {
314  return (Service) new FinancialsPU().getSingleResult(
315  "select service from Service as service " +
316  "where service.id = (select min(id) from Service)");
317  }
Here is the call graph for this function:

◆ getDepartmentFrom()

static Department org.turro.financials.model.business.CompanyWrapper.getDepartmentFrom ( DocumentLine  line)
static

Definition at line 224 of file bsfinancials-core/src/main/java/org/turro/financials/model/business/CompanyWrapper.java.

224  {
225  if(line != null && line.getStore() != null) {
226  Contract store = line.getStore();
227  return store.getDepartment();
228  }
229  return null;
230  }
Here is the call graph for this function:

◆ getEndOfYearClosing() [1/2]

static int org.turro.financials.model.business.CompanyWrapper.getEndOfYearClosing ( )
static

◆ getEndOfYearClosing() [2/2]

static int org.turro.financials.model.business.CompanyWrapper.getEndOfYearClosing ( Date  date)
static

Definition at line 136 of file bsfinancials-core/src/main/java/org/turro/financials/model/business/CompanyWrapper.java.

136  {
137  CheckDate cd = new CheckDate(date);
138  if(cd.getDay() == 31 && cd.getMonth() == 12) {
139  return cd.getYear();
140  }
141  return 0;
142  }

◆ getHeadquartersFrom()

static Headquarters org.turro.financials.model.business.CompanyWrapper.getHeadquartersFrom ( DocumentLine  line)
static

Definition at line 214 of file bsfinancials-core/src/main/java/org/turro/financials/model/business/CompanyWrapper.java.

214  {
215  if(line != null && line.getStore() != null) {
216  Contract store = line.getStore();
217  if(store.getDepartment() != null) {
218  return store.getDepartment().getHeadquarters();
219  }
220  }
221  return null;
222  }
Here is the call graph for this function:

◆ getServiceFrom()

static Service org.turro.financials.model.business.CompanyWrapper.getServiceFrom ( DocumentLine  line)
static

Definition at line 232 of file bsfinancials-core/src/main/java/org/turro/financials/model/business/CompanyWrapper.java.

232  {
233  if(line != null && line.getStore() != null) {
234  Contract store = line.getStore();
235  return store.getService();
236  }
237  return null;
238  }
Here is the call graph for this function:

◆ isValidDate() [1/2]

static boolean org.turro.financials.model.business.CompanyWrapper.isValidDate ( Date  date)
static

◆ isValidDate() [2/2]

static boolean org.turro.financials.model.business.CompanyWrapper.isValidDate ( Date  date,
boolean  closing 
)
static

Definition at line 118 of file bsfinancials-core/src/main/java/org/turro/financials/model/business/CompanyWrapper.java.

118  {
119  Date dateClosing = getCompanyClosingDate();
120  return (date == null || dateClosing == null || dateClosing.before(date) ||
121  (closing && new CheckDate(date).getYear() == getEndOfYearClosing(dateClosing)));
122  }
Here is the call graph for this function:

◆ removeExercise()

static void org.turro.financials.model.business.CompanyWrapper.removeExercise ( Integer  year)
static

Definition at line 325 of file bsfinancials-core/src/main/java/org/turro/financials/model/business/CompanyWrapper.java.

325  {
326  Dao dao = new FinancialsPU();
327  SqlClause.delete("Document")
328  .where().equal("year(receiptDate)", year)
329  .dao(dao)
330  .execute();
331  SqlClause.delete("DocumentLine")
332  .where("not exists").sub(
333  SqlClause.select("*").from("Document d")
334  .where("d.identifier = document_identifier"))
335  .dao(dao)
336  .executeNative();
337  SqlClause.delete("DocumentRelation")
338  .where("not exists").sub(
339  SqlClause.select("*").from("Document d")
340  .where("d.identifier = ancestor_identifier"))
341  .or("not exists").sub(
342  SqlClause.select("*").from("Document d")
343  .where("d.identifier = descendant_identifier"))
344  .dao(dao)
345  .executeNative();
346  SqlClause.delete("Register")
347  .where().equal("year(registerDate)", year)
348  .dao(dao)
349  .execute();
350  SqlClause.delete("RegisterEntry")
351  .where("not exists").sub(
352  SqlClause.select("*").from("Register r")
353  .where("r.identifier = register_identifier"))
354  .dao(dao)
355  .executeNative();
356  SqlClause.delete("BookRegister")
357  .where("not exists").sub(
358  SqlClause.select("*").from("Register r")
359  .where("r.identifier = register_identifier"))
360  .dao(dao)
361  .executeNative();
362  }

◆ renumBookRegisters()

static void org.turro.financials.model.business.CompanyWrapper.renumBookRegisters ( Integer  year)
static

Definition at line 284 of file bsfinancials-core/src/main/java/org/turro/financials/model/business/CompanyWrapper.java.

284  {
285  Dao dao = new FinancialsPU();
286  dao.executeUpdate(
287  "delete from BookRegister br " +
288  "where exists (" +
289  " select r from Register r " +
290  " where br.register.id = r.id " +
291  " and year(r.registerDate) = ? " +
292  " and r.view = 1 " +
293  ")",
294  new Object[] {
295  year
296  });
297  List<Register> l = dao.getResultList(
298  "select r from Register r " +
299  "where year(r.registerDate) = ? " +
300  "and r.view = 1 " +
301  "order by r.idRegister",
302  new Object[] {
303  year
304  });
305  for(Register r : l) {
306  r = RegisterWrapper.prepareBookRegister(r);
307  if(!r.getBookRegisters().isEmpty()) {
308  dao.saveObject(r);
309  }
310  }
311  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ renumRegisters()

static void org.turro.financials.model.business.CompanyWrapper.renumRegisters ( Integer  year,
boolean  books 
)
static

Definition at line 253 of file bsfinancials-core/src/main/java/org/turro/financials/model/business/CompanyWrapper.java.

253  {
254  if(year == null || year == 0) return;
255 // Dao dao = new FinancialsPU();
256 // List<Register> l = dao.getResultList(
257 // "select r from Register r " +
258 // "where year(r.registerDate) = ? " +
259 // "and r.view = 1 " +
260 // "order by r.registerDate, r.closing desc",
261 // new Object[] {
262 // year
263 // });
264  int count = 1;
265  try(DaoTransaction transaction = new DaoTransaction(new FinancialsPU())) {
266  List<Register> l = transaction.getDao().getResultList(
267  "select r from Register r " +
268  "where year(r.registerDate) = ? " +
269  "and r.view = 1 " +
270  "order by r.registerDate, r.closing desc",
271  new Object[] {
272  year
273  });
274  for(Register r : l) {
275  r.setIdRegister(count++);
276  transaction.saveObject(r);
277  }
278  }
279  if(books) {
280  renumBookRegisters(year);
281  }
282  }
Here is the call graph for this function:

◆ save()

Company org.turro.financials.model.business.CompanyWrapper.save ( )

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

Definition at line 63 of file bsfinancials-core/src/main/java/org/turro/financials/model/business/CompanyWrapper.java.

63  {
64  EntityCollections.entities(entity.getServices()).removeEmpties();
65  EntityCollections.entities(entity.getHeadquarters()).removeEmpties();
66  for(Headquarters hq : entity.getHeadquarters()) {
67  EntityCollections.entities(hq.getDepartments()).removeEmpties();
68  }
69 
70  _defaultCompany = super.save();
71  return _defaultCompany;
72  }
Here is the call graph for this function:

◆ shouldLog()

boolean org.turro.financials.model.business.CompanyWrapper.shouldLog ( )
protected

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