Search in sources :

Example 1 with AccountConfig

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

the class AccountClearanceService method validateAccountClearance.

@Transactional(rollbackOn = { Exception.class })
public void validateAccountClearance(AccountClearance accountClearance) throws AxelorException {
    Company company = accountClearance.getCompany();
    AccountConfig accountConfig = company.getAccountConfig();
    Tax tax = accountConfig.getStandardRateTax();
    BigDecimal taxRate = taxService.getTaxRate(tax, appBaseService.getTodayDateTime().toLocalDate());
    Account taxAccount = taxAccountService.getAccount(tax, company, false, false);
    Account profitAccount = accountConfig.getProfitAccount();
    Journal journal = accountConfig.getAccountClearanceJournal();
    Set<MoveLine> moveLineList = accountClearance.getMoveLineSet();
    for (MoveLine moveLine : moveLineList) {
        Move move = this.createAccountClearanceMove(moveLine, taxRate, taxAccount, profitAccount, company, journal, accountClearance);
        moveService.getMoveValidateService().validate(move);
    }
    accountClearance.setStatusSelect(AccountClearanceRepository.STATUS_VALIDATED);
    accountClearance.setDateTime(appBaseService.getTodayDateTime());
    accountClearance.setName(sequenceService.getSequenceNumber(SequenceRepository.ACCOUNT_CLEARANCE, company));
    accountClearanceRepo.save(accountClearance);
}
Also used : Account(com.axelor.apps.account.db.Account) Company(com.axelor.apps.base.db.Company) Move(com.axelor.apps.account.db.Move) MoveLine(com.axelor.apps.account.db.MoveLine) Tax(com.axelor.apps.account.db.Tax) Journal(com.axelor.apps.account.db.Journal) BigDecimal(java.math.BigDecimal) AccountConfig(com.axelor.apps.account.db.AccountConfig) Transactional(com.google.inject.persist.Transactional)

Example 2 with AccountConfig

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

the class IrrecoverableService method testCompanyField.

/**
 * Procédure permettant de vérifier les champs d'une société
 *
 * @param company Une société
 * @throws AxelorException
 */
public void testCompanyField(Company company) throws AxelorException {
    AccountConfig accountConfig = accountConfigService.getAccountConfig(company);
    accountConfigService.getIrrecoverableAccount(accountConfig);
    accountConfigService.getIrrecoverableJournal(accountConfig);
    accountConfigService.getIrrecoverableStandardRateTax(accountConfig);
}
Also used : AccountConfig(com.axelor.apps.account.db.AccountConfig)

Example 3 with AccountConfig

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

the class ReimbursementExportService method createReimbursementMove.

/**
 * Methode permettant de créer l'écriture de remboursement
 *
 * @param reimbursement Un objet d'export des prélèvements
 * @throws AxelorException
 */
public void createReimbursementMove(Reimbursement reimbursement, Company company) throws AxelorException {
    reimbursement = reimbursementRepo.find(reimbursement.getId());
    Partner partner = null;
    Move newMove = null;
    boolean first = true;
    AccountConfig accountConfig = company.getAccountConfig();
    if (reimbursement.getMoveLineSet() != null && !reimbursement.getMoveLineSet().isEmpty()) {
        int seq = 1;
        for (MoveLine moveLine : reimbursement.getMoveLineSet()) {
            BigDecimal amountRemaining = moveLine.getAmountRemaining();
            if (amountRemaining.compareTo(BigDecimal.ZERO) > 0) {
                partner = moveLine.getPartner();
                // On passe les lignes d'écriture (trop perçu) à l'état 'remboursé'
                moveLine.setReimbursementStatusSelect(MoveLineRepository.REIMBURSEMENT_STATUS_REIMBURSED);
                if (first) {
                    newMove = moveService.getMoveCreateService().createMove(accountConfig.getReimbursementJournal(), company, null, partner, null, MoveRepository.TECHNICAL_ORIGIN_AUTOMATIC, MoveRepository.FUNCTIONAL_ORIGIN_PAYMENT);
                    first = false;
                }
                // Création d'une ligne au débit
                MoveLine newDebitMoveLine = moveLineService.createMoveLine(newMove, partner, moveLine.getAccount(), amountRemaining, true, appAccountService.getTodayDate(company), seq, reimbursement.getRef(), reimbursement.getDescription());
                newMove.getMoveLineList().add(newDebitMoveLine);
                if (reimbursement.getDescription() != null && !reimbursement.getDescription().isEmpty()) {
                    newDebitMoveLine.setDescription(reimbursement.getDescription());
                }
                seq++;
                // Création de la réconciliation
                Reconcile reconcile = reconcileService.createReconcile(newDebitMoveLine, moveLine, amountRemaining, false);
                if (reconcile != null) {
                    reconcileService.confirmReconcile(reconcile, true);
                }
            }
        }
        // Création de la ligne au crédit
        MoveLine newCreditMoveLine = moveLineService.createMoveLine(newMove, partner, accountConfig.getReimbursementAccount(), reimbursement.getAmountReimbursed(), false, appAccountService.getTodayDate(company), seq, reimbursement.getRef(), reimbursement.getDescription());
        newMove.getMoveLineList().add(newCreditMoveLine);
        if (reimbursement.getDescription() != null && !reimbursement.getDescription().isEmpty()) {
            newCreditMoveLine.setDescription(reimbursement.getDescription());
        }
        moveService.getMoveValidateService().validate(newMove);
        moveRepo.save(newMove);
    }
}
Also used : Move(com.axelor.apps.account.db.Move) MoveLine(com.axelor.apps.account.db.MoveLine) Partner(com.axelor.apps.base.db.Partner) BigDecimal(java.math.BigDecimal) AccountConfig(com.axelor.apps.account.db.AccountConfig) Reconcile(com.axelor.apps.account.db.Reconcile)

Example 4 with AccountConfig

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

the class BankDetailsServiceAccountImpl method getDefaultCompanyBankDetailsFromFactorPartner.

private BankDetails getDefaultCompanyBankDetailsFromFactorPartner(Company company) throws AxelorException {
    AccountConfig accountConfig = Beans.get(AccountConfigService.class).getAccountConfig(company);
    if (accountConfig.getFactorPartner() == null) {
        return null;
    }
    List<BankDetails> bankDetailsList = accountConfig.getFactorPartner().getBankDetailsList();
    return bankDetailsList.stream().filter(bankDetails -> bankDetails.getIsDefault()).findFirst().orElse(null);
}
Also used : BankDetails(com.axelor.apps.base.db.BankDetails) AccountConfigService(com.axelor.apps.account.service.config.AccountConfigService) AccountConfig(com.axelor.apps.account.db.AccountConfig)

Example 5 with AccountConfig

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

the class AccountingReportServiceImpl method isThereTooManyLines.

public boolean isThereTooManyLines(AccountingReport accountingReport) throws AxelorException {
    AccountConfig accountConfig = Beans.get(AccountConfigService.class).getAccountConfig(accountingReport.getCompany());
    Integer lineMinBeforeLongReportGenerationMessageNumber = accountConfig.getLineMinBeforeLongReportGenerationMessageNumber();
    if (lineMinBeforeLongReportGenerationMessageNumber != null && lineMinBeforeLongReportGenerationMessageNumber > 0) {
        if (accountingReport.getReportType() == null) {
            return false;
        }
        Integer typeSelect = accountingReport.getReportType().getTypeSelect();
        long count = 0;
        if (typeSelect > 0 && typeSelect <= AccountingReportRepository.REPORT_GENERAL_LEDGER2) {
            count = Beans.get(MoveLineRepository.class).all().filter(this.getMoveLineList(accountingReport)).count();
        } else if (typeSelect == AccountingReportRepository.REPORT_VAT_STATEMENT_RECEIVED) {
            count = Beans.get(TaxPaymentMoveLineRepository.class).all().filter(this.getTaxPaymentMoveLineList(accountingReport)).count();
        } else if (typeSelect == AccountingReportRepository.REPORT_ACQUISITIONS) {
            count = Beans.get(FixedAssetRepository.class).all().filter(this.getFixedAssetList(accountingReport)).count();
            count += JPA.em().createQuery("Select invoiceLine FROM InvoiceLine invoiceLine LEFT JOIN FixedAsset fixedAsset on fixedAsset.invoiceLine = invoiceLine.id WHERE invoiceLine.fixedAssets = true and fixedAsset.invoiceLine is null ").getResultList().size();
        } else if (typeSelect == AccountingReportRepository.REPORT_GROSS_VALUES_AND_DEPRECIATION) {
            count = Beans.get(FixedAssetRepository.class).all().filter(this.getFixedAssetList(accountingReport)).count();
        } else if (typeSelect == AccountingReportRepository.REPORT_ANALYTIC_BALANCE) {
            count = Beans.get(AnalyticMoveLineRepository.class).all().filter(this.getAnalyticMoveLineList(accountingReport)).count();
        } else {
            return false;
        }
        return count > lineMinBeforeLongReportGenerationMessageNumber;
    } else {
        return false;
    }
}
Also used : FixedAssetRepository(com.axelor.apps.account.db.repo.FixedAssetRepository) TaxPaymentMoveLineRepository(com.axelor.apps.account.db.repo.TaxPaymentMoveLineRepository) AccountConfigService(com.axelor.apps.account.service.config.AccountConfigService) AccountConfig(com.axelor.apps.account.db.AccountConfig)

Aggregations

AccountConfig (com.axelor.apps.account.db.AccountConfig)46 Company (com.axelor.apps.base.db.Company)27 Move (com.axelor.apps.account.db.Move)18 MoveLine (com.axelor.apps.account.db.MoveLine)17 BigDecimal (java.math.BigDecimal)17 Account (com.axelor.apps.account.db.Account)14 Partner (com.axelor.apps.base.db.Partner)14 Transactional (com.google.inject.persist.Transactional)14 Journal (com.axelor.apps.account.db.Journal)9 AccountConfigService (com.axelor.apps.account.service.config.AccountConfigService)9 AxelorException (com.axelor.exception.AxelorException)9 AccountingSituation (com.axelor.apps.account.db.AccountingSituation)7 Reconcile (com.axelor.apps.account.db.Reconcile)7 BankDetails (com.axelor.apps.base.db.BankDetails)6 LocalDate (java.time.LocalDate)6 ArrayList (java.util.ArrayList)6 Invoice (com.axelor.apps.account.db.Invoice)5 PaymentMode (com.axelor.apps.account.db.PaymentMode)5 List (java.util.List)4 AnalyticMoveLine (com.axelor.apps.account.db.AnalyticMoveLine)3