Search in sources :

Example 6 with AccountingReport

use of com.axelor.apps.account.db.AccountingReport in project axelor-open-suite by axelor.

the class AccountingReportController method setBankDetailsDomain.

public void setBankDetailsDomain(ActionRequest request, ActionResponse response) {
    try {
        AccountingReport accountingReport = request.getContext().asType(AccountingReport.class);
        String domain = Beans.get(AccountingReportBankPaymentService.class).createDomainForBankDetails(accountingReport);
        // if nothing was found for the domain, we set it at a default value.
        if (domain.equals("")) {
            response.setAttr("bankDetailsSet", "domain", "self.id IN (0)");
        } else {
            response.setAttr("bankDetailsSet", "domain", domain);
        }
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : AccountingReportBankPaymentService(com.axelor.apps.bankpayment.service.AccountingReportBankPaymentService) AccountingReport(com.axelor.apps.account.db.AccountingReport)

Example 7 with AccountingReport

use of com.axelor.apps.account.db.AccountingReport in project axelor-open-suite by axelor.

the class AccountingReportController method searchMoveLine.

/**
 * @param request
 * @param response
 */
public void searchMoveLine(ActionRequest request, ActionResponse response) {
    AccountingReport accountingReport = request.getContext().asType(AccountingReport.class);
    AccountingReportService accountingReportService = Beans.get(AccountingReportService.class);
    try {
        accountingReport = Beans.get(AccountingReportRepository.class).find(accountingReport.getId());
        String query = accountingReportService.getMoveLineList(accountingReport);
        BigDecimal debitBalance = accountingReportService.getDebitBalance();
        BigDecimal creditBalance = accountingReportService.getCreditBalance();
        response.setValue("totalDebit", debitBalance);
        response.setValue("totalCredit", creditBalance);
        response.setValue("balance", debitBalance.subtract(creditBalance));
        ActionViewBuilder actionViewBuilder = ActionView.define(I18n.get(IExceptionMessage.ACCOUNTING_REPORT_3));
        actionViewBuilder.model(MoveLine.class.getName());
        actionViewBuilder.add("grid", "move-line-grid");
        actionViewBuilder.add("form", "move-line-form");
        actionViewBuilder.param("search-filters", "move-line-filters");
        actionViewBuilder.domain(query);
        response.setView(actionViewBuilder.map());
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : AccountingReport(com.axelor.apps.account.db.AccountingReport) MoveLine(com.axelor.apps.account.db.MoveLine) AccountingReportService(com.axelor.apps.account.service.AccountingReportService) BigDecimal(java.math.BigDecimal) ActionViewBuilder(com.axelor.meta.schema.actions.ActionView.ActionViewBuilder)

Example 8 with AccountingReport

use of com.axelor.apps.account.db.AccountingReport in project axelor-open-suite by axelor.

the class AccountingReportManagementRepository method copy.

@Override
public AccountingReport copy(AccountingReport entity, boolean deep) {
    AccountingReport copy = super.copy(entity, deep);
    copy.setRef(null);
    copy.setStatusSelect(this.STATUS_DRAFT);
    copy.setPublicationDateTime(null);
    copy.setTotalDebit(BigDecimal.ZERO);
    copy.setTotalCredit(BigDecimal.ZERO);
    copy.setBalance(BigDecimal.ZERO);
    return copy;
}
Also used : AccountingReport(com.axelor.apps.account.db.AccountingReport)

Example 9 with AccountingReport

use of com.axelor.apps.account.db.AccountingReport in project axelor-open-suite by axelor.

the class MoveLineExportServiceImpl method createAccountingReport.

@Transactional(rollbackOn = { Exception.class })
public AccountingReport createAccountingReport(Company company, int exportTypeSelect, LocalDate startDate, LocalDate endDate) throws AxelorException {
    AccountingReport accountingReport = new AccountingReport();
    accountingReport.setCompany(company);
    accountingReport.getReportType().setTypeSelect(exportTypeSelect);
    accountingReport.setDateFrom(startDate);
    accountingReport.setDateTo(endDate);
    accountingReport.setStatusSelect(AccountingReportRepository.STATUS_DRAFT);
    accountingReport.setDate(appAccountService.getTodayDateTime().toLocalDate());
    accountingReport.setRef(accountingReportService.getSequence(accountingReport));
    accountingReportService.buildQuery(accountingReport);
    BigDecimal debitBalance = accountingReportService.getDebitBalance();
    BigDecimal creditBalance = accountingReportService.getCreditBalance();
    accountingReport.setTotalDebit(debitBalance);
    accountingReport.setTotalCredit(creditBalance);
    accountingReport.setBalance(debitBalance.subtract(creditBalance));
    accountingReportRepo.save(accountingReport);
    return accountingReport;
}
Also used : AccountingReport(com.axelor.apps.account.db.AccountingReport) BigDecimal(java.math.BigDecimal) Transactional(com.google.inject.persist.Transactional)

Example 10 with AccountingReport

use of com.axelor.apps.account.db.AccountingReport in project axelor-open-suite by axelor.

the class BatchMoveLineExport method process.

@Override
protected void process() {
    if (!end) {
        try {
            Company company = batch.getAccountingBatch().getCompany();
            LocalDate startDate = batch.getAccountingBatch().getStartDate();
            LocalDate endDate = batch.getAccountingBatch().getEndDate();
            int exportTypeSelect = batch.getAccountingBatch().getMoveLineExportTypeSelect();
            AccountingReport accountingReport = moveLineExportService.createAccountingReport(company, exportTypeSelect, startDate, endDate);
            moveLineExportService.exportMoveLine(accountingReport);
            JPA.clear();
            accountingReport = accountingReportRepository.find(accountingReport.getId());
            moveLineDone = moveLineRepo.all().filter("self.move.accountingReport = ?1", accountingReport).count();
            moveDone = moveRepo.all().filter("self.accountingReport = ?1", accountingReport).count();
            debit = accountingReport.getTotalDebit();
            credit = accountingReport.getTotalCredit();
            balance = accountingReport.getBalance();
            updateAccountingReport(accountingReport);
        } catch (AxelorException e) {
            TraceBackService.trace(new AxelorException(e, e.getCategory(), String.format("%s", e)), ExceptionOriginRepository.MOVE_LINE_EXPORT_ORIGIN, batch.getId());
            incrementAnomaly();
        } catch (Exception e) {
            TraceBackService.trace(new Exception(String.format("%s", e), e), ExceptionOriginRepository.MOVE_LINE_EXPORT_ORIGIN, batch.getId());
            incrementAnomaly();
            log.error("Bug(Anomalie) généré(e) pour le batch {}", batch.getId());
        }
    }
}
Also used : AxelorException(com.axelor.exception.AxelorException) Company(com.axelor.apps.base.db.Company) AccountingReport(com.axelor.apps.account.db.AccountingReport) LocalDate(java.time.LocalDate) AxelorException(com.axelor.exception.AxelorException)

Aggregations

AccountingReport (com.axelor.apps.account.db.AccountingReport)10 AccountingReportService (com.axelor.apps.account.service.AccountingReportService)4 MoveLineExportService (com.axelor.apps.account.service.MoveLineExportService)2 ActionViewBuilder (com.axelor.meta.schema.actions.ActionView.ActionViewBuilder)2 BigDecimal (java.math.BigDecimal)2 Account (com.axelor.apps.account.db.Account)1 JournalType (com.axelor.apps.account.db.JournalType)1 Move (com.axelor.apps.account.db.Move)1 MoveLine (com.axelor.apps.account.db.MoveLine)1 AccountingReportBankPaymentService (com.axelor.apps.bankpayment.service.AccountingReportBankPaymentService)1 App (com.axelor.apps.base.db.App)1 Company (com.axelor.apps.base.db.Company)1 AxelorException (com.axelor.exception.AxelorException)1 MetaFile (com.axelor.meta.db.MetaFile)1 Transactional (com.google.inject.persist.Transactional)1 LocalDate (java.time.LocalDate)1