Search in sources :

Example 26 with Company

use of com.axelor.apps.base.db.Company in project axelor-open-suite by axelor.

the class DoubtfulCustomerService method createDoubtFulCustomerMove.

/**
 * Procédure permettant de créer les écritures de passage en client douteux pour chaque écriture
 * de facture
 *
 * @param move Une écritures de facture
 * @param doubtfulCustomerAccount Un compte client douteux
 * @param debtPassReason Un motif de passage en client douteux
 * @throws AxelorException
 */
@Transactional(rollbackOn = { Exception.class })
public void createDoubtFulCustomerMove(Move move, Account doubtfulCustomerAccount, String debtPassReason) throws AxelorException {
    log.debug("Concerned account move : {} ", move.getReference());
    Company company = move.getCompany();
    Partner partner = move.getPartner();
    Invoice invoice = move.getInvoice();
    Move newMove = moveService.getMoveCreateService().createMove(company.getAccountConfig().getAutoMiscOpeJournal(), company, invoice.getCurrency(), partner, move.getPaymentMode(), MoveRepository.TECHNICAL_ORIGIN_AUTOMATIC, move.getFunctionalOriginSelect());
    newMove.setInvoice(invoice);
    LocalDate todayDate = appBaseService.getTodayDate(company);
    MoveLine invoicePartnerMoveLine = null;
    for (MoveLine moveLine : move.getMoveLineList()) {
        if (moveLine.getAccount().getUseForPartnerBalance() && moveLine.getAmountRemaining().compareTo(BigDecimal.ZERO) > 0 && moveLine.getAccount() != doubtfulCustomerAccount && moveLine.getDebit().compareTo(BigDecimal.ZERO) > 0) {
            invoicePartnerMoveLine = moveLine;
        }
    }
    String origin = "";
    BigDecimal amountRemaining = BigDecimal.ZERO;
    MoveLine creditMoveLine = null;
    if (invoicePartnerMoveLine != null) {
        amountRemaining = invoicePartnerMoveLine.getAmountRemaining();
        // Debit move line on partner account
        creditMoveLine = moveLineService.createMoveLine(newMove, partner, invoicePartnerMoveLine.getAccount(), amountRemaining, false, todayDate, 1, move.getInvoice().getInvoiceId(), debtPassReason);
        newMove.getMoveLineList().add(creditMoveLine);
        origin = creditMoveLine.getOrigin();
    }
    // Credit move line on partner account
    MoveLine debitMoveLine = moveLineService.createMoveLine(newMove, partner, doubtfulCustomerAccount, amountRemaining, true, todayDate, 2, origin, debtPassReason);
    newMove.getMoveLineList().add(debitMoveLine);
    debitMoveLine.setPassageReason(debtPassReason);
    moveService.getMoveValidateService().validate(newMove);
    moveRepo.save(newMove);
    if (creditMoveLine != null) {
        Reconcile reconcile = reconcileService.createReconcile(invoicePartnerMoveLine, creditMoveLine, amountRemaining, false);
        if (reconcile != null) {
            reconcileService.confirmReconcile(reconcile, true);
        }
    }
    this.invoiceProcess(newMove, doubtfulCustomerAccount, debtPassReason);
}
Also used : Company(com.axelor.apps.base.db.Company) Invoice(com.axelor.apps.account.db.Invoice) Move(com.axelor.apps.account.db.Move) MoveLine(com.axelor.apps.account.db.MoveLine) Partner(com.axelor.apps.base.db.Partner) LocalDate(java.time.LocalDate) BigDecimal(java.math.BigDecimal) Reconcile(com.axelor.apps.account.db.Reconcile) Transactional(com.google.inject.persist.Transactional)

Example 27 with Company

use of com.axelor.apps.base.db.Company in project axelor-open-suite by axelor.

the class BatchDoubtfulCustomer method process.

@SuppressWarnings("unchecked")
@Override
protected void process() {
    if (!end) {
        Company company = batch.getAccountingBatch().getCompany();
        AccountConfig accountConfig = company.getAccountConfig();
        Account doubtfulCustomerAccount = accountConfig.getDoubtfulCustomerAccount();
        String sixMonthDebtPassReason = accountConfig.getSixMonthDebtPassReason();
        String threeMonthDebtPassReason = accountConfig.getThreeMonthDebtPassReason();
        // FACTURES
        List<Move> moveList = doubtfulCustomerService.getMove(0, doubtfulCustomerAccount, company);
        log.debug("Nombre d'écritures de facture concernées (Créance de + 6 mois) au 411 : {} ", moveList.size());
        this.createDoubtFulCustomerMove(moveList, doubtfulCustomerAccount, sixMonthDebtPassReason);
        moveList = doubtfulCustomerService.getMove(1, doubtfulCustomerAccount, company);
        log.debug("Nombre d'écritures de facture concernées (Créance de + 3 mois) au 411 : {} ", moveList.size());
        this.createDoubtFulCustomerMove(moveList, doubtfulCustomerAccount, threeMonthDebtPassReason);
        // FACTURES REJETES
        List<MoveLine> moveLineList = (List<MoveLine>) doubtfulCustomerService.getRejectMoveLine(0, doubtfulCustomerAccount, company);
        log.debug("Nombre de lignes d'écriture de rejet concernées (Créance de + 6 mois) au 411 : {} ", moveLineList.size());
        this.createDoubtFulCustomerRejectMove(moveLineList, doubtfulCustomerAccount, sixMonthDebtPassReason);
        moveLineList = (List<MoveLine>) doubtfulCustomerService.getRejectMoveLine(1, doubtfulCustomerAccount, company);
        log.debug("Nombre de lignes d'écriture de rejet concernées (Créance de + 3 mois) au 411 : {} ", moveLineList.size());
        this.createDoubtFulCustomerRejectMove(moveLineList, doubtfulCustomerAccount, threeMonthDebtPassReason);
        updateCustomerAccountLog += batchAccountCustomer.updateAccountingSituationMarked(companyRepo.find(company.getId()));
    }
}
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) List(java.util.List) AccountConfig(com.axelor.apps.account.db.AccountConfig)

Example 28 with Company

use of com.axelor.apps.base.db.Company in project axelor-open-suite by axelor.

the class DebtRecoverySessionService method getDebtRecoveryMethod.

/**
 * Fonction permettant de récupérer une méthode de relance en fonction de la categorie du tiers et
 * d'une société
 *
 * @param debtRecovery Une relance
 * @return
 */
public DebtRecoveryMethod getDebtRecoveryMethod(DebtRecovery debtRecovery) {
    AccountingSituation accountingSituation = debtRecovery.getTradingName() == null ? debtRecovery.getAccountingSituation() : debtRecovery.getTradingNameAccountingSituation();
    Company company = accountingSituation.getCompany();
    Partner partner = accountingSituation.getPartner();
    List<DebtRecoveryConfigLine> debtRecoveryConfigLines = company.getAccountConfig().getDebtRecoveryConfigLineList();
    for (DebtRecoveryConfigLine debtRecoveryConfigLine : debtRecoveryConfigLines) {
        if (debtRecoveryConfigLine.getPartnerCategory().equals(partner.getPartnerCategory())) {
            log.debug("méthode de relance determinée ");
            return debtRecoveryConfigLine.getDebtRecoveryMethod();
        }
    }
    log.debug("méthode de relance non determinée ");
    return null;
}
Also used : Company(com.axelor.apps.base.db.Company) AccountingSituation(com.axelor.apps.account.db.AccountingSituation) Partner(com.axelor.apps.base.db.Partner) DebtRecoveryConfigLine(com.axelor.apps.account.db.DebtRecoveryConfigLine)

Example 29 with Company

use of com.axelor.apps.base.db.Company in project axelor-open-suite by axelor.

the class FixedAssetLineMoveServiceImpl method generateDisposalMove.

@Override
@Transactional(rollbackOn = { Exception.class })
public void generateDisposalMove(FixedAssetLine fixedAssetLine) throws AxelorException {
    FixedAsset fixedAsset = fixedAssetLine.getFixedAsset();
    Journal journal = fixedAsset.getJournal();
    Company company = fixedAsset.getCompany();
    Partner partner = fixedAsset.getPartner();
    LocalDate date = fixedAssetLine.getDepreciationDate();
    // Creating move
    Move move = moveCreateService.createMove(journal, company, company.getCurrency(), partner, date, null, MoveRepository.TECHNICAL_ORIGIN_AUTOMATIC, MoveRepository.FUNCTIONAL_ORIGIN_FIXED_ASSET);
    if (move != null) {
        List<MoveLine> moveLines = new ArrayList<MoveLine>();
        String origin = fixedAsset.getReference();
        Account chargeAccount = fixedAsset.getFixedAssetCategory().getChargeAccount();
        Account depreciationAccount = fixedAsset.getFixedAssetCategory().getDepreciationAccount();
        Account purchaseAccount = fixedAsset.getPurchaseAccount();
        BigDecimal chargeAmount = fixedAssetLine.getResidualValue();
        BigDecimal cumulativeDepreciationAmount = fixedAssetLine.getCumulativeDepreciation();
        // Creating accounting debit move line for charge account
        MoveLine chargeAccountDebitMoveLine = new MoveLine(move, partner, chargeAccount, date, null, 1, chargeAmount, BigDecimal.ZERO, fixedAsset.getName(), origin, null, BigDecimal.ZERO, date);
        moveLines.add(chargeAccountDebitMoveLine);
        this.addAnalyticToMoveLine(fixedAsset.getAnalyticDistributionTemplate(), chargeAccountDebitMoveLine);
        // Creating accounting debit move line for deprecation account
        MoveLine deprecationAccountDebitMoveLine = new MoveLine(move, partner, depreciationAccount, date, null, 1, cumulativeDepreciationAmount, BigDecimal.ZERO, fixedAsset.getName(), origin, null, BigDecimal.ZERO, date);
        moveLines.add(deprecationAccountDebitMoveLine);
        this.addAnalyticToMoveLine(fixedAsset.getAnalyticDistributionTemplate(), deprecationAccountDebitMoveLine);
        // Creating accounting credit move line
        MoveLine creditMoveLine = new MoveLine(move, partner, purchaseAccount, date, null, 2, BigDecimal.ZERO, fixedAsset.getGrossValue(), fixedAsset.getName(), origin, null, BigDecimal.ZERO, date);
        moveLines.add(creditMoveLine);
        this.addAnalyticToMoveLine(fixedAsset.getAnalyticDistributionTemplate(), creditMoveLine);
        move.getMoveLineList().addAll(moveLines);
    }
    moveRepo.save(move);
    fixedAsset.setDisposalMove(move);
}
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) ArrayList(java.util.ArrayList) Journal(com.axelor.apps.account.db.Journal) FixedAsset(com.axelor.apps.account.db.FixedAsset) Partner(com.axelor.apps.base.db.Partner) LocalDate(java.time.LocalDate) BigDecimal(java.math.BigDecimal) Transactional(com.google.inject.persist.Transactional)

Example 30 with Company

use of com.axelor.apps.base.db.Company in project axelor-open-suite by axelor.

the class PaymentModeServiceImpl method getAccountManagementDefaults.

@Override
public List<AccountManagement> getAccountManagementDefaults() {
    List<AccountManagement> accountManagementList = new ArrayList<>();
    List<Company> companyList = Beans.get(CompanyRepository.class).all().fetch();
    for (Company company : companyList) {
        AccountManagement accountManagement = new AccountManagement();
        accountManagement.setCompany(company);
        accountManagement.setTypeSelect(AccountManagementRepository.TYPE_PAYMENT);
        accountManagementList.add(accountManagement);
    }
    return accountManagementList;
}
Also used : Company(com.axelor.apps.base.db.Company) ArrayList(java.util.ArrayList) AccountManagement(com.axelor.apps.account.db.AccountManagement)

Aggregations

Company (com.axelor.apps.base.db.Company)213 Transactional (com.google.inject.persist.Transactional)72 Partner (com.axelor.apps.base.db.Partner)68 AxelorException (com.axelor.exception.AxelorException)65 BigDecimal (java.math.BigDecimal)54 Move (com.axelor.apps.account.db.Move)35 MoveLine (com.axelor.apps.account.db.MoveLine)35 LocalDate (java.time.LocalDate)35 ArrayList (java.util.ArrayList)31 PaymentMode (com.axelor.apps.account.db.PaymentMode)28 AccountConfig (com.axelor.apps.account.db.AccountConfig)27 Journal (com.axelor.apps.account.db.Journal)26 Account (com.axelor.apps.account.db.Account)25 Invoice (com.axelor.apps.account.db.Invoice)25 BankDetails (com.axelor.apps.base.db.BankDetails)22 Currency (com.axelor.apps.base.db.Currency)19 Product (com.axelor.apps.base.db.Product)17 StockLocation (com.axelor.apps.stock.db.StockLocation)17 StockMove (com.axelor.apps.stock.db.StockMove)15 List (java.util.List)15