Search in sources :

Example 31 with AccountConfig

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

the class NotificationServiceImpl method createPaymentMove.

@Transactional(rollbackOn = { Exception.class })
protected Move createPaymentMove(NotificationItem notificationItem) throws AxelorException {
    Notification notification = notificationItem.getNotification();
    Invoice invoice = notificationItem.getInvoice();
    Company company = invoice.getCompany();
    AccountConfig accountConfig = accountConfigService.getAccountConfig(company);
    Journal journal = getJournal(accountConfig);
    SubrogationRelease subrogationRelease = getSubrogationRelease(notificationItem);
    String origin = computeOrigin(subrogationRelease, invoice);
    BigDecimal amountPaid = notificationItem.getAmountPaid();
    if (amountPaid.compareTo(BigDecimal.ZERO) == 0) {
        return null;
    }
    Move paymentMove = moveService.getMoveCreateService().createMove(journal, company, company.getCurrency(), invoice.getPartner(), notification.getPaymentDate(), null, MoveRepository.TECHNICAL_ORIGIN_AUTOMATIC, MoveRepository.FUNCTIONAL_ORIGIN_PAYMENT);
    MoveLine creditMoveLine, debitMoveLine;
    Account account = getAccount(accountConfig, notificationItem);
    debitMoveLine = moveService.getMoveLineService().createMoveLine(paymentMove, invoice.getPartner(), account, amountPaid, true, notification.getPaymentDate(), null, 1, origin, invoice.getInvoiceId());
    creditMoveLine = moveService.getMoveLineService().createMoveLine(paymentMove, invoice.getPartner(), invoice.getPartnerAccount(), amountPaid, false, notification.getPaymentDate(), null, 2, origin, invoice.getInvoiceId());
    paymentMove.addMoveLineListItem(debitMoveLine);
    paymentMove.addMoveLineListItem(creditMoveLine);
    paymentMove = moveRepository.save(paymentMove);
    moveService.getMoveValidateService().validate(paymentMove);
    MoveLine invoiceMoveLine = findInvoiceAccountMoveLine(invoice);
    MoveLine subrogationReleaseMoveLine = findSubrogationReleaseAccountMoveLine(invoice);
    if (invoiceMoveLine.getAmountRemaining().compareTo(BigDecimal.ZERO) == 1) {
        reconcileService.reconcile(invoiceMoveLine, creditMoveLine, true, true);
        if (subrogationReleaseMoveLine != null && notificationItem.getTypeSelect() == NotificationRepository.TYPE_PAYMENT_TO_THE_FACTORE) {
            reconcileService.reconcile(debitMoveLine, subrogationReleaseMoveLine, true, false);
        }
    }
    notificationItem.setMove(paymentMove);
    if (subrogationRelease != null) {
        subrogationReleaseService.clear(subrogationRelease);
    }
    return paymentMove;
}
Also used : Account(com.axelor.apps.account.db.Account) Company(com.axelor.apps.base.db.Company) Invoice(com.axelor.apps.account.db.Invoice) Move(com.axelor.apps.account.db.Move) SubrogationRelease(com.axelor.apps.account.db.SubrogationRelease) MoveLine(com.axelor.apps.account.db.MoveLine) Journal(com.axelor.apps.account.db.Journal) Notification(com.axelor.apps.account.db.Notification) BigDecimal(java.math.BigDecimal) AccountConfig(com.axelor.apps.account.db.AccountConfig) Transactional(com.google.inject.persist.Transactional)

Example 32 with AccountConfig

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

the class BankDetailsServiceAccountImpl method createCompanyBankDetailsDomainFromFactorPartner.

private List<BankDetails> createCompanyBankDetailsDomainFromFactorPartner(Company company) throws AxelorException {
    AccountConfig accountConfig = Beans.get(AccountConfigService.class).getAccountConfig(company);
    List<BankDetails> bankDetailsList = accountConfig.getFactorPartner().getBankDetailsList();
    return bankDetailsList.stream().filter(bankDetails -> bankDetails.getActive()).collect(Collectors.toList());
}
Also used : Company(com.axelor.apps.base.db.Company) StringTool(com.axelor.apps.tool.StringTool) AppAccountService(com.axelor.apps.account.service.app.AppAccountService) AccountConfig(com.axelor.apps.account.db.AccountConfig) AccountManagement(com.axelor.apps.account.db.AccountManagement) PaymentModeRepository(com.axelor.apps.account.db.repo.PaymentModeRepository) PaymentModeService(com.axelor.apps.account.service.payment.PaymentModeService) PartnerRepository(com.axelor.apps.base.db.repo.PartnerRepository) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) List(java.util.List) AccountingSituation(com.axelor.apps.account.db.AccountingSituation) InvoiceRepository(com.axelor.apps.account.db.repo.InvoiceRepository) AxelorException(com.axelor.exception.AxelorException) Beans(com.axelor.inject.Beans) AccountConfigService(com.axelor.apps.account.service.config.AccountConfigService) PaymentMode(com.axelor.apps.account.db.PaymentMode) BankDetailsServiceImpl(com.axelor.apps.base.service.BankDetailsServiceImpl) Partner(com.axelor.apps.base.db.Partner) BankDetails(com.axelor.apps.base.db.BankDetails) BankDetails(com.axelor.apps.base.db.BankDetails) AccountConfigService(com.axelor.apps.account.service.config.AccountConfigService) AccountConfig(com.axelor.apps.account.db.AccountConfig)

Example 33 with AccountConfig

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

the class CfonbExportService method testCompanyExportCFONBField.

/**
 * Procédure permettant de vérifier la conformité des champs en rapport avec les exports CFONB
 * d'une société
 *
 * @param company La société
 * @throws AxelorException
 */
public void testCompanyExportCFONBField(Company company) throws AxelorException {
    AccountConfig accountConfig = cfonbConfigService.getAccountConfig(company);
    cfonbConfigService.getReimbursementExportFolderPathCFONB(accountConfig);
    cfonbConfigService.getPaymentScheduleExportFolderPathCFONB(accountConfig);
    this.init(cfonbConfigService.getCfonbConfig(company));
    cfonbConfigService.getSenderRecordCodeExportCFONB(this.cfonbConfig);
    cfonbConfigService.getSenderNumExportCFONB(this.cfonbConfig);
    cfonbConfigService.getSenderNameCodeExportCFONB(this.cfonbConfig);
    cfonbConfigService.getRecipientRecordCodeExportCFONB(this.cfonbConfig);
    cfonbConfigService.getTotalRecordCodeExportCFONB(this.cfonbConfig);
    cfonbConfigService.getTransferOperationCodeExportCFONB(this.cfonbConfig);
    cfonbConfigService.getDirectDebitOperationCodeExportCFONB(this.cfonbConfig);
}
Also used : AccountConfig(com.axelor.apps.account.db.AccountConfig)

Example 34 with AccountConfig

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

the class ReconcileServiceImpl method canBeZeroBalance.

/**
 * Procédure permettant de gérer les écarts de règlement, check sur la case à cocher 'Peut être
 * soldé' Alors nous utilisons la règle de gestion consitant à imputer l'écart sur un compte
 * transitoire si le seuil est respecté
 *
 * @param reconcile Une reconciliation
 * @throws AxelorException
 */
@Transactional(rollbackOn = { Exception.class })
public void canBeZeroBalance(Reconcile reconcile) throws AxelorException {
    MoveLine debitMoveLine = reconcile.getDebitMoveLine();
    BigDecimal debitAmountRemaining = debitMoveLine.getAmountRemaining();
    log.debug("Montant à payer / à lettrer au débit : {}", debitAmountRemaining);
    if (debitAmountRemaining.compareTo(BigDecimal.ZERO) > 0) {
        Company company = reconcile.getDebitMoveLine().getMove().getCompany();
        AccountConfig accountConfig = accountConfigService.getAccountConfig(company);
        if (debitAmountRemaining.plus().compareTo(accountConfig.getThresholdDistanceFromRegulation()) < 0 || reconcile.getMustBeZeroBalanceOk()) {
            log.debug("Seuil respecté");
            MoveLine creditAdjustMoveLine = moveAdjustementService.createAdjustmentCreditMove(debitMoveLine);
            // Création de la réconciliation
            Reconcile newReconcile = this.createReconcile(debitMoveLine, creditAdjustMoveLine, debitAmountRemaining, false);
            if (newReconcile != null) {
                this.confirmReconcile(newReconcile, true);
                reconcileRepository.save(newReconcile);
            }
        }
    }
    reconcile.setCanBeZeroBalanceOk(false);
    log.debug("Fin de la gestion des écarts de règlement");
}
Also used : Company(com.axelor.apps.base.db.Company) MoveLine(com.axelor.apps.account.db.MoveLine) BigDecimal(java.math.BigDecimal) AccountConfig(com.axelor.apps.account.db.AccountConfig) Reconcile(com.axelor.apps.account.db.Reconcile) Transactional(com.google.inject.persist.Transactional)

Example 35 with AccountConfig

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

the class ReconcileServiceImpl method balanceCredit.

/**
 * Solder le trop-perçu si il respect les règles de seuil
 *
 * @param creditMoveLine
 * @param company
 * @throws AxelorException
 */
public void balanceCredit(MoveLine creditMoveLine) throws AxelorException {
    if (creditMoveLine != null) {
        BigDecimal creditAmountRemaining = creditMoveLine.getAmountRemaining();
        log.debug("Montant à payer / à lettrer au crédit : {}", creditAmountRemaining);
        if (creditAmountRemaining.compareTo(BigDecimal.ZERO) > 0) {
            AccountConfig accountConfig = accountConfigService.getAccountConfig(creditMoveLine.getMove().getCompany());
            if (creditAmountRemaining.plus().compareTo(accountConfig.getThresholdDistanceFromRegulation()) < 0) {
                log.debug("Seuil respecté");
                MoveLine debitAdjustmentMoveLine = moveAdjustementService.createAdjustmentCreditMove(creditMoveLine);
                // Création de la réconciliation
                Reconcile newReconcile = this.createReconcile(debitAdjustmentMoveLine, creditMoveLine, creditAmountRemaining, false);
                if (newReconcile != null) {
                    this.confirmReconcile(newReconcile, true);
                    reconcileRepository.save(newReconcile);
                }
            }
        }
    }
}
Also used : MoveLine(com.axelor.apps.account.db.MoveLine) BigDecimal(java.math.BigDecimal) AccountConfig(com.axelor.apps.account.db.AccountConfig) Reconcile(com.axelor.apps.account.db.Reconcile)

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