18 package org.turro.financials.model.business;
20 import java.text.DecimalFormat;
21 import java.text.NumberFormat;
22 import java.util.Currency;
23 import java.util.Date;
24 import java.util.List;
25 import java.util.Locale;
26 import org.amic.util.date.CheckDate;
27 import org.turro.contacts.Contact;
28 import org.turro.elephant.context.Application;
29 import org.turro.financials.db.FinancialsPU;
30 import org.turro.financials.entity.Company;
31 import org.turro.financials.entity.Contract;
32 import org.turro.financials.entity.Department;
33 import org.turro.financials.entity.Document;
34 import org.turro.financials.entity.DocumentLine;
35 import org.turro.financials.entity.Headquarters;
36 import org.turro.financials.entity.Register;
37 import org.turro.financials.entity.Service;
38 import org.turro.financials.model.document.DocumentWrapper;
39 import org.turro.financials.model.register.RegisterWrapper;
40 import org.turro.jpa.Dao;
41 import org.turro.jpa.DaoTransaction;
42 import org.turro.jpa.entity.DaoEntity;
43 import org.turro.jpa.entity.EntityCollections;
44 import org.turro.sql.SqlClause;
45 import org.turro.zkoss.locale.Currencies;
70 _defaultCompany = super.save();
71 return _defaultCompany;
75 public boolean delete() {
120 return (date ==
null || dateClosing ==
null || dateClosing.before(date) ||
126 if(company !=
null) {
137 CheckDate cd =
new CheckDate(date);
138 if(cd.getDay() == 31 && cd.getMonth() == 12) {
177 if(company !=
null) {
179 if(contact !=
null) {
188 if(company !=
null) {
190 if(contact !=
null) {
202 if(line !=
null && line.
getStore() !=
null) {
215 if(line !=
null && line.
getStore() !=
null) {
225 if(line !=
null && line.
getStore() !=
null) {
233 if(line !=
null && line.
getStore() !=
null) {
240 private static Company _defaultCompany;
247 if(reload || _defaultCompany ==
null) {
250 return _defaultCompany;
254 if(year ==
null || year == 0)
return;
266 List<Register> l = transaction.getDao().getResultList(
267 "select r from Register r " +
268 "where year(r.registerDate) = ? " +
270 "order by r.registerDate, r.closing desc",
275 r.setIdRegister(count++);
276 transaction.saveObject(r);
287 "delete from BookRegister br " +
289 " select r from Register r " +
290 " where br.register.id = r.id " +
291 " and year(r.registerDate) = ? " +
297 List<Register> l = dao.getResultList(
298 "select r from Register r " +
299 "where year(r.registerDate) = ? " +
301 "order by r.idRegister",
307 if(!r.getBookRegisters().isEmpty()) {
315 "select service from Service as service " +
316 "where service.id = (select min(id) from Service)");
321 "select ctc from Contract as ctc " +
322 "where ctc.id = (select min(id) from Contract where service is not null)");
327 SqlClause.delete(
"Document")
328 .where().equal(
"year(receiptDate)", year)
331 SqlClause.delete(
"DocumentLine")
332 .where(
"not exists").sub(
333 SqlClause.select(
"*").from(
"Document d")
334 .where(
"d.identifier = document_identifier"))
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"))
346 SqlClause.delete(
"Register")
347 .where().equal(
"year(registerDate)", year)
350 SqlClause.delete(
"RegisterEntry")
351 .where(
"not exists").sub(
352 SqlClause.select(
"*").from(
"Register r")
353 .where(
"r.identifier = register_identifier"))
356 SqlClause.delete(
"BookRegister")
357 .where(
"not exists").sub(
358 SqlClause.select(
"*").from(
"Register r")
359 .where(
"r.identifier = register_identifier"))
static Locale getUsedLocale()
Department getDepartment()
Headquarters getHeadquarters()
static Headquarters getHeadquartersFrom(DocumentLine line)
static void renumRegisters(Integer year, boolean books)
static Service getDefaultService()
static Company getDefaultCompany()
static Company getCompanyFrom(DocumentLine line)
static Contract getDefaultContractService()
static int getEndOfYearClosing()
static Currency getCompanyCurrency()
static boolean isValidDate(Date date)
static Locale getCompanyLocale()
static void removeExercise(Integer year)
static boolean isValidDate(Date date, boolean closing)
static Service getServiceFrom(DocumentLine line)
static void renumBookRegisters(Integer year)
static Department getDepartmentFrom(DocumentLine line)
static Company getDefaultCompany(boolean reload)
static int getEndOfYearClosing(Date date)
static Date getCompanyClosingDate()
static NumberFormat getCurrencyFormatter()
static Register prepareBookRegister(Register register)
int executeUpdate(String query)
Object getSingleResult(WhereClause wc)
static EntityCollections entities(Collection values)
static Currency getDefault()