Search in sources :

Example 26 with MoveLine

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

the class BatchReimbursementImport method validateMove.

public void validateMove(Move move, LocalDate rejectDate, int seq) {
    try {
        if (seq != 1) {
            MoveLine oppositeMoveLine = reimbursementImportService.createOppositeRejectMoveLine(moveRepo.find(move.getId()), seq, rejectDate);
            reimbursementImportService.validateMove(moveRepo.find(move.getId()));
            this.totalAmount = this.totalAmount.add(moveLineRepo.find(oppositeMoveLine.getId()).getDebit());
        } else {
            reimbursementImportService.deleteMove(moveRepo.find(move.getId()));
        }
    } catch (AxelorException e) {
        TraceBackService.trace(new AxelorException(e, e.getCategory(), I18n.get(IExceptionMessage.BATCH_REIMBURSEMENT_6), batch.getId()), ExceptionOriginRepository.REIMBURSEMENT, batch.getId());
        incrementAnomaly();
    } 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());
    }
}
Also used : AxelorException(com.axelor.exception.AxelorException) MoveLine(com.axelor.apps.account.db.MoveLine) AxelorException(com.axelor.exception.AxelorException)

Example 27 with MoveLine

use of com.axelor.apps.account.db.MoveLine 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 28 with MoveLine

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

the class MoveManagementRepository method save.

@Override
public Move save(Move move) {
    try {
        if (move.getStatusSelect() == MoveRepository.STATUS_ACCOUNTED) {
            Beans.get(MoveValidateService.class).checkPreconditions(move);
        }
        Beans.get(MoveSequenceService.class).setDraftSequence(move);
        List<MoveLine> moveLineList = move.getMoveLineList();
        if (moveLineList != null) {
            for (MoveLine moveLine : moveLineList) {
                List<AnalyticMoveLine> analyticMoveLineList = moveLine.getAnalyticMoveLineList();
                if (analyticMoveLineList != null) {
                    for (AnalyticMoveLine analyticMoveLine : analyticMoveLineList) {
                        analyticMoveLine.setAccount(moveLine.getAccount());
                        analyticMoveLine.setAccountType(moveLine.getAccount().getAccountType());
                    }
                }
            }
        }
        return super.save(move);
    } catch (Exception e) {
        TraceBackService.traceExceptionFromSaveMethod(e);
        throw new PersistenceException(e.getMessage(), e);
    }
}
Also used : MoveValidateService(com.axelor.apps.account.service.move.MoveValidateService) MoveSequenceService(com.axelor.apps.account.service.move.MoveSequenceService) MoveLine(com.axelor.apps.account.db.MoveLine) AnalyticMoveLine(com.axelor.apps.account.db.AnalyticMoveLine) PersistenceException(javax.persistence.PersistenceException) AxelorException(com.axelor.exception.AxelorException) PersistenceException(javax.persistence.PersistenceException) AnalyticMoveLine(com.axelor.apps.account.db.AnalyticMoveLine)

Example 29 with MoveLine

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

the class SubrogationReleaseController method displayMoveLines.

public void displayMoveLines(ActionRequest request, ActionResponse response) {
    try {
        SubrogationRelease subrogationRelease = request.getContext().asType(SubrogationRelease.class);
        List<Long> moveLineIdList = new ArrayList<Long>();
        for (Move move : subrogationRelease.getMoveList()) {
            for (MoveLine moveLine : move.getMoveLineList()) {
                moveLineIdList.add(moveLine.getId());
            }
        }
        response.setView(ActionView.define("MoveLines").model(MoveLine.class.getName()).add("grid", "move-line-grid").add("form", "move-line-form").param("search-filters", "move-line-filters").domain("self.id in (" + Joiner.on(",").join(moveLineIdList) + ")").map());
    } catch (Exception e) {
        response.setError(e.getMessage());
        TraceBackService.trace(e);
    }
}
Also used : Move(com.axelor.apps.account.db.Move) SubrogationRelease(com.axelor.apps.account.db.SubrogationRelease) ArrayList(java.util.ArrayList) MoveLine(com.axelor.apps.account.db.MoveLine)

Example 30 with MoveLine

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

the class ImportMove method importFECMove.

@Transactional(rollbackOn = { AxelorException.class, Exception.class })
public Object importFECMove(Object bean, Map<String, Object> values) throws AxelorException {
    assert bean instanceof MoveLine;
    MoveLine moveLine = (MoveLine) bean;
    try {
        moveLine.setCounter(1);
        if (values.get("EcritureNum") == null) {
            return null;
        }
        String moveReference = values.get("EcritureNum").toString();
        MoveLine mvLine = moveLineRepo.all().filter("self.name LIKE '" + moveReference + "-%'").order("-counter").fetchOne();
        if (mvLine != null) {
            int counter = mvLine.getCounter() + 1;
            moveLine.setCounter(counter);
        }
        if (values.get("EcritureDate") != null) {
            LocalDate moveLineDate = LocalDate.parse(values.get("EcritureDate").toString(), DateTimeFormatter.BASIC_ISO_DATE);
            moveLine.setDate(moveLineDate);
        }
        Move move = moveRepository.all().filter("self.reference = ?", moveReference).fetchOne();
        if (move == null) {
            move = new Move();
            move.setReference(moveReference);
            if (values.get("ValidDate") != null) {
                move.setStatusSelect(MoveRepository.STATUS_VALIDATED);
                move.setValidationDate(LocalDate.parse(values.get("ValidDate").toString(), DateTimeFormatter.BASIC_ISO_DATE));
            } else {
                move.setStatusSelect(MoveRepository.STATUS_ACCOUNTED);
            }
            move.setCompany(getCompany(values));
            move.setCompanyCurrency(move.getCompany().getCurrency());
            move.setDate(LocalDate.parse(values.get("EcritureDate").toString(), DateTimeFormatter.BASIC_ISO_DATE));
            move.setPeriod(Beans.get(PeriodService.class).getPeriod(move.getDate(), move.getCompany(), YearRepository.TYPE_FISCAL));
            if (values.get("Idevise") != null) {
                move.setCurrency(Beans.get(CurrencyRepository.class).findByCode(values.get("Idevise").toString()));
                move.setCurrencyCode(values.get("Idevise").toString());
            }
            if (values.get("JournalCode") != null) {
                Journal journal = Beans.get(JournalRepository.class).all().filter("self.code = ?1 AND self.company.id = ?2", values.get("JournalCode").toString(), move.getCompany().getId()).fetchOne();
                move.setJournal(journal);
            }
            if (values.get("CompAuxNum") != null) {
                Partner partner = Beans.get(PartnerRepository.class).all().filter("self.partnerSeq = ?", values.get("CompAuxNum").toString()).fetchOne();
                move.setPartner(partner);
            }
            moveRepository.save(move);
        }
        if (values.get("CompteNum") != null) {
            Account account = Beans.get(AccountRepository.class).all().filter("self.code = ?1 AND self.company.id = ?2", values.get("CompteNum").toString(), move.getCompany().getId()).fetchOne();
            moveLine.setAccount(account);
        }
        moveLine.setMove(move);
    } catch (Exception e) {
        TraceBackService.trace(e);
        throw new AxelorException(TraceBackRepository.CATEGORY_CONFIGURATION_ERROR, e.getMessage());
    }
    return moveLine;
}
Also used : Account(com.axelor.apps.account.db.Account) AxelorException(com.axelor.exception.AxelorException) AccountRepository(com.axelor.apps.account.db.repo.AccountRepository) Journal(com.axelor.apps.account.db.Journal) LocalDate(java.time.LocalDate) AxelorException(com.axelor.exception.AxelorException) PartnerRepository(com.axelor.apps.base.db.repo.PartnerRepository) JournalRepository(com.axelor.apps.account.db.repo.JournalRepository) Move(com.axelor.apps.account.db.Move) MoveLine(com.axelor.apps.account.db.MoveLine) Partner(com.axelor.apps.base.db.Partner) Transactional(com.google.inject.persist.Transactional)

Aggregations

MoveLine (com.axelor.apps.account.db.MoveLine)135 BigDecimal (java.math.BigDecimal)60 Move (com.axelor.apps.account.db.Move)51 Transactional (com.google.inject.persist.Transactional)42 AxelorException (com.axelor.exception.AxelorException)40 Company (com.axelor.apps.base.db.Company)38 ArrayList (java.util.ArrayList)38 Partner (com.axelor.apps.base.db.Partner)33 Account (com.axelor.apps.account.db.Account)28 LocalDate (java.time.LocalDate)27 AnalyticMoveLine (com.axelor.apps.account.db.AnalyticMoveLine)25 Journal (com.axelor.apps.account.db.Journal)22 Reconcile (com.axelor.apps.account.db.Reconcile)22 AccountConfig (com.axelor.apps.account.db.AccountConfig)17 Invoice (com.axelor.apps.account.db.Invoice)15 List (java.util.List)13 TaxPaymentMoveLine (com.axelor.apps.account.db.TaxPaymentMoveLine)8 Tax (com.axelor.apps.account.db.Tax)7 TaxLine (com.axelor.apps.account.db.TaxLine)7 MoveLineRepository (com.axelor.apps.account.db.repo.MoveLineRepository)7