use of com.axelor.apps.base.db.AdjustHistory in project axelor-open-suite by axelor.
the class AdjustHistoryService method setEndDate.
@Transactional
public void setEndDate(Period period) {
AdjustHistory adjustHistory = adjustHistoryRepo.all().filter("self.period.id = ? AND self.endDate IS NULL", period.getId()).fetchOne();
adjustHistory.setEndDate(LocalDateTime.now());
adjustHistoryRepo.save(adjustHistory);
}
use of com.axelor.apps.base.db.AdjustHistory in project axelor-open-suite by axelor.
the class AdjustHistoryService method setEndDate.
@Transactional
public AdjustHistory setEndDate(Year year) {
AdjustHistory adjustHistory = adjustHistoryRepo.all().filter("self.fiscalYear.id = ? AND self.endDate IS NULL", year.getId()).fetchOne();
adjustHistory.setEndDate(LocalDateTime.now());
adjustHistoryRepo.save(adjustHistory);
return adjustHistory;
}
use of com.axelor.apps.base.db.AdjustHistory in project axelor-open-suite by axelor.
the class AdjustHistoryService method setStartDate.
@Transactional
public void setStartDate(Period period) {
AdjustHistory adjustHistory = new AdjustHistory();
adjustHistory.setPeriod(period);
adjustHistory.setStartDate(LocalDateTime.now());
adjustHistoryRepo.save(adjustHistory);
}
use of com.axelor.apps.base.db.AdjustHistory in project axelor-open-suite by axelor.
the class AdjustHistoryService method setStartDate.
@Transactional
public void setStartDate(Year year) {
AdjustHistory adjustHistory = new AdjustHistory();
adjustHistory.setFiscalYear(year);
adjustHistory.setStartDate(LocalDateTime.now());
adjustHistoryRepo.save(adjustHistory);
}
use of com.axelor.apps.base.db.AdjustHistory in project axelor-open-suite by axelor.
the class YearServiceAccountImpl method closeYearProcess.
/**
* Procédure permettant de cloturer un exercice comptable
*
* @param year Un exercice comptable
* @throws AxelorException
*/
public void closeYearProcess(Year year) throws AxelorException {
year = yearRepository.find(year.getId());
for (Period period : year.getPeriodList()) {
if (period.getStatusSelect() == PeriodRepository.STATUS_ADJUSTING) {
adjustHistoryService.setEndDate(period);
}
period.setStatusSelect(PeriodRepository.STATUS_CLOSED);
period.setClosureDateTime(LocalDateTime.now());
}
Company company = year.getCompany();
if (company == null) {
throw new AxelorException(year, TraceBackRepository.CATEGORY_CONFIGURATION_ERROR, I18n.get(IExceptionMessage.YEAR_1), I18n.get(com.axelor.apps.base.exceptions.IExceptionMessage.EXCEPTION), year.getName());
}
Query q;
if (year.getStatusSelect() == YearRepository.STATUS_ADJUSTING) {
AdjustHistory adjustHistory = adjustHistoryService.setEndDate(year);
q = JPA.em().createQuery("select DISTINCT(self.partner) FROM MoveLine as self WHERE self.move.ignoreInAccountingOk = false AND self.move.period.year = ?1 " + "AND self.move.statusSelect = ?2 AND self.move.adjustingMove = true AND self.date >= ?3 AND self.date <= ?4 AND self.move.company = ?5");
q.setParameter(1, year);
q.setParameter(2, MoveRepository.STATUS_VALIDATED);
q.setParameter(3, adjustHistory.getStartDate().toLocalDate());
q.setParameter(4, adjustHistory.getEndDate().toLocalDate());
} else {
q = JPA.em().createQuery("select DISTINCT(self.partner) FROM MoveLine as self WHERE self.move.ignoreInAccountingOk = false AND self.move.period.year = ?1 " + "AND self.move.statusSelect = ?2 AND self.date >= ?3 AND self.date <= ?4 AND self.move.company = ?5");
q.setParameter(1, year);
q.setParameter(2, MoveRepository.STATUS_VALIDATED);
q.setParameter(3, year.getFromDate());
q.setParameter(4, year.getToDate());
}
q.setParameter(5, year.getCompany());
@SuppressWarnings("unchecked") List<Partner> partnerList = q.getResultList();
List<? extends Partner> partnerListAll = partnerRepository.all().fetch();
log.debug("Nombre total de tiers : {}", partnerListAll.size());
log.debug("Nombre de tiers récupéré : {}", partnerList.size());
for (Partner partner : partnerList) {
partner = partnerRepository.find(partner.getId());
year = yearRepository.find(year.getId());
log.debug("Tiers en cours de traitement : {}", partner.getName());
for (AccountingSituation accountingSituation : partner.getAccountingSituationList()) {
if (accountingSituation.getCompany().equals(year.getCompany())) {
log.debug("On ajoute une ligne à la Situation comptable trouvée");
BigDecimal reportedBalanceAmount = this.computeReportedBalance(year.getFromDate(), year.getToDate(), partner, year);
this.createReportedBalanceLine(accountingSituation, reportedBalanceAmount, year);
break;
}
}
JPA.clear();
}
year = yearRepository.find(year.getId());
closeYear(year);
}
Aggregations