Search in sources :

Example 41 with AccountConfig

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

the class AccountingSituationServiceImpl method getEmployeeAccount.

@Override
public Account getEmployeeAccount(Partner partner, Company company) throws AxelorException {
    Account account = null;
    AccountingSituation accountingSituation = getAccountingSituation(partner, company);
    if (accountingSituation != null) {
        account = accountingSituation.getEmployeeAccount();
    }
    if (account == null) {
        AccountConfig accountConfig = accountConfigService.getAccountConfig(company);
        account = accountConfigService.getEmployeeAccount(accountConfig);
    }
    return account;
}
Also used : Account(com.axelor.apps.account.db.Account) AccountingSituation(com.axelor.apps.account.db.AccountingSituation) AccountConfig(com.axelor.apps.account.db.AccountConfig)

Example 42 with AccountConfig

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

the class BatchReimbursementImport method process.

@Override
protected void process() {
    if (!end) {
        Company company = batch.getAccountingBatch().getCompany();
        company = companyRepo.find(company.getId());
        AccountConfig accountConfig = company.getAccountConfig();
        Map<List<String[]>, String> data = null;
        try {
            String dataImportDir = AppService.getFileUploadDir();
            String reimbursementImportFolderPathCFONB = accountConfig.getReimbursementImportFolderPathCFONB() == null ? null : dataImportDir + accountConfig.getReimbursementImportFolderPathCFONB();
            rejectImportService.createFilePath(reimbursementImportFolderPathCFONB);
            data = rejectImportService.getCFONBFileByLot(reimbursementImportFolderPathCFONB, accountConfig.getTempReimbImportFolderPathCFONB() == null ? null : dataImportDir + accountConfig.getTempReimbImportFolderPathCFONB(), company, 0);
        } catch (AxelorException e) {
            TraceBackService.trace(new AxelorException(e, e.getCategory(), I18n.get(IExceptionMessage.BATCH_REIMBURSEMENT_6), batch.getId()), ExceptionOriginRepository.REIMBURSEMENT, batch.getId());
            incrementAnomaly();
            stop();
        } catch (Exception e) {
            TraceBackService.trace(new Exception(String.format(I18n.get(IExceptionMessage.BATCH_REIMBURSEMENT_6), batch.getId()), e), ExceptionOriginRepository.REIMBURSEMENT, batch.getId());
            incrementAnomaly();
            log.error("Bug(Anomalie) généré(e) pour le batch d'import des remboursements {}", batch.getId());
            stop();
        }
        int seq = 1;
        int i = 0;
        for (Entry<List<String[]>, String> entry : data.entrySet()) {
            LocalDate rejectDate = rejectImportService.createRejectDate(entry.getValue());
            Move move = this.createMove(company, rejectDate);
            for (String[] reject : entry.getKey()) {
                try {
                    Reimbursement reimbursement = reimbursementImportService.createReimbursementRejectMoveLine(reject, companyRepo.find(company.getId()), seq, moveRepo.find(move.getId()), rejectDate);
                    if (reimbursement != null) {
                        log.debug("Remboursement n° {} traité", reimbursement.getRef());
                        seq++;
                        i++;
                        updateReimbursement(reimbursement);
                    }
                } catch (AxelorException e) {
                    TraceBackService.trace(new AxelorException(e, e.getCategory(), I18n.get(IExceptionMessage.BATCH_REIMBURSEMENT_7), reject[1]), ExceptionOriginRepository.REIMBURSEMENT, batch.getId());
                    incrementAnomaly();
                } catch (Exception e) {
                    TraceBackService.trace(new Exception(String.format(I18n.get(IExceptionMessage.BATCH_REIMBURSEMENT_7), reject[1]), e), ExceptionOriginRepository.REIMBURSEMENT, batch.getId());
                    incrementAnomaly();
                    log.error("Bug(Anomalie) généré(e) pour le rejet de remboursement {}", reject[1]);
                } finally {
                    if (i % 10 == 0) {
                        JPA.clear();
                    }
                }
            }
            this.validateMove(move, rejectDate, seq);
        }
        updateCustomerAccountLog += batchAccountCustomer.updateAccountingSituationMarked(company);
    }
}
Also used : AxelorException(com.axelor.exception.AxelorException) Company(com.axelor.apps.base.db.Company) LocalDate(java.time.LocalDate) AxelorException(com.axelor.exception.AxelorException) AccountConfig(com.axelor.apps.account.db.AccountConfig) Move(com.axelor.apps.account.db.Move) List(java.util.List) Reimbursement(com.axelor.apps.account.db.Reimbursement)

Example 43 with AccountConfig

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

the class InvoiceServiceImpl method getJournal.

public Journal getJournal(Invoice invoice) throws AxelorException {
    Company company = invoice.getCompany();
    if (company == null)
        return null;
    AccountConfig accountConfig = accountConfigService.getAccountConfig(company);
    // Taken from legacy JournalService but negative cases seem rather strange
    switch(invoice.getOperationTypeSelect()) {
        case InvoiceRepository.OPERATION_TYPE_SUPPLIER_PURCHASE:
            return invoice.getInTaxTotal().signum() < 0 ? accountConfigService.getSupplierCreditNoteJournal(accountConfig) : accountConfigService.getSupplierPurchaseJournal(accountConfig);
        case InvoiceRepository.OPERATION_TYPE_SUPPLIER_REFUND:
            return invoice.getInTaxTotal().signum() < 0 ? accountConfigService.getSupplierPurchaseJournal(accountConfig) : accountConfigService.getSupplierCreditNoteJournal(accountConfig);
        case InvoiceRepository.OPERATION_TYPE_CLIENT_SALE:
            return invoice.getInTaxTotal().signum() < 0 ? accountConfigService.getCustomerCreditNoteJournal(accountConfig) : accountConfigService.getCustomerSalesJournal(accountConfig);
        case InvoiceRepository.OPERATION_TYPE_CLIENT_REFUND:
            return invoice.getInTaxTotal().signum() < 0 ? accountConfigService.getCustomerSalesJournal(accountConfig) : accountConfigService.getCustomerCreditNoteJournal(accountConfig);
        default:
            throw new AxelorException(invoice, TraceBackRepository.CATEGORY_MISSING_FIELD, I18n.get(IExceptionMessage.JOURNAL_1), invoice.getInvoiceId());
    }
}
Also used : AxelorException(com.axelor.exception.AxelorException) Company(com.axelor.apps.base.db.Company) AccountConfig(com.axelor.apps.account.db.AccountConfig)

Example 44 with AccountConfig

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

the class MoveAdjustementService method createAdjustmentCreditMove.

/**
 * Creating move of passage in gap regulation (on credit)
 *
 * @param debitMoveLine
 * @return
 * @throws AxelorException
 */
public MoveLine createAdjustmentCreditMove(MoveLine debitMoveLine) throws AxelorException {
    Partner partner = debitMoveLine.getPartner();
    Account account = debitMoveLine.getAccount();
    Move debitMove = debitMoveLine.getMove();
    Company company = debitMove.getCompany();
    BigDecimal debitAmountRemaining = debitMoveLine.getAmountRemaining();
    AccountConfig accountConfig = accountConfigService.getAccountConfig(company);
    Journal miscOperationJournal = accountConfigService.getAutoMiscOpeJournal(accountConfig);
    Move adjustmentMove = moveCreateService.createMove(miscOperationJournal, company, null, partner, null, MoveRepository.TECHNICAL_ORIGIN_AUTOMATIC, debitMove.getFunctionalOriginSelect());
    // Création de la ligne au crédit
    MoveLine creditAdjustmentMoveLine = moveLineService.createMoveLine(adjustmentMove, partner, account, debitAmountRemaining, false, appAccountService.getTodayDate(company), 1, null, null);
    // Création de la ligne au débit
    MoveLine debitAdjustmentMoveLine = moveLineService.createMoveLine(adjustmentMove, partner, accountConfigService.getCashPositionVariationAccount(accountConfig), debitAmountRemaining, true, appAccountService.getTodayDate(company), 2, null, null);
    adjustmentMove.addMoveLineListItem(creditAdjustmentMoveLine);
    adjustmentMove.addMoveLineListItem(debitAdjustmentMoveLine);
    moveValidateService.validate(adjustmentMove);
    moveRepository.save(adjustmentMove);
    return creditAdjustmentMoveLine;
}
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) Journal(com.axelor.apps.account.db.Journal) Partner(com.axelor.apps.base.db.Partner) BigDecimal(java.math.BigDecimal) AccountConfig(com.axelor.apps.account.db.AccountConfig)

Example 45 with AccountConfig

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

the class MoveAdjustementService method createMoveToPassOnTheOtherAccount.

/**
 * Méthode permettant de créer une écriture du passage du compte de l'écriture au debit vers le
 * compte de l'écriture au credit.
 *
 * @param debitMoveLineToReconcile Ecriture au débit
 * @param creditMoveLineToReconcile Ecriture au crédit
 * @param amount Montant
 * @return L'écriture de passage du compte de l'écriture au debit vers le compte de l'écriture au
 *     credit.
 * @throws AxelorException
 */
public Move createMoveToPassOnTheOtherAccount(MoveLine debitMoveLineToReconcile, MoveLine creditMoveLineToReconcile, BigDecimal amount) throws AxelorException {
    Partner partnerDebit = debitMoveLineToReconcile.getPartner();
    Partner partnerCredit = creditMoveLineToReconcile.getPartner();
    Company company = debitMoveLineToReconcile.getMove().getCompany();
    AccountConfig accountConfig = accountConfigService.getAccountConfig(company);
    Journal journal = accountConfigService.getAutoMiscOpeJournal(accountConfig);
    // Move
    Move move = moveCreateService.createMove(journal, company, null, partnerDebit, null, MoveRepository.TECHNICAL_ORIGIN_AUTOMATIC, debitMoveLineToReconcile.getMove().getFunctionalOriginSelect());
    MoveLine debitMoveLine = moveLineService.createMoveLine(move, partnerCredit, creditMoveLineToReconcile.getAccount(), amount, true, appAccountService.getTodayDate(company), 1, null, null);
    MoveLine creditMoveLine = moveLineService.createMoveLine(move, partnerDebit, debitMoveLineToReconcile.getAccount(), amount, false, appAccountService.getTodayDate(company), 2, null, null);
    move.addMoveLineListItem(debitMoveLine);
    move.addMoveLineListItem(creditMoveLine);
    moveValidateService.validate(move);
    return move;
}
Also used : Company(com.axelor.apps.base.db.Company) Move(com.axelor.apps.account.db.Move) MoveLine(com.axelor.apps.account.db.MoveLine) Journal(com.axelor.apps.account.db.Journal) Partner(com.axelor.apps.base.db.Partner) 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