Search in sources :

Example 91 with MoveLine

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

the class MoveLineController method balanceCreditDebit.

public void balanceCreditDebit(ActionRequest request, ActionResponse response) {
    MoveLine moveLine = request.getContext().asType(MoveLine.class);
    Move move = request.getContext().getParent().asType(Move.class);
    try {
        moveLine = Beans.get(MoveLineService.class).balanceCreditDebit(moveLine, move);
        response.setValues(moveLine);
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : Move(com.axelor.apps.account.db.Move) MoveLine(com.axelor.apps.account.db.MoveLine) AxelorException(com.axelor.exception.AxelorException)

Example 92 with MoveLine

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

the class MoveLineController method computeAnalyticDistribution.

public void computeAnalyticDistribution(ActionRequest request, ActionResponse response) {
    MoveLine moveLine = request.getContext().asType(MoveLine.class);
    try {
        if (Beans.get(AppAccountService.class).getAppAccount().getManageAnalyticAccounting()) {
            moveLine = Beans.get(MoveLineService.class).computeAnalyticDistribution(moveLine);
            response.setValue("analyticMoveLineList", moveLine.getAnalyticMoveLineList());
        }
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : MoveLine(com.axelor.apps.account.db.MoveLine) AxelorException(com.axelor.exception.AxelorException)

Example 93 with MoveLine

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

the class MoveLineController method passInIrrecoverable.

public void passInIrrecoverable(ActionRequest request, ActionResponse response) {
    MoveLine moveLine = request.getContext().asType(MoveLine.class);
    moveLine = Beans.get(MoveLineRepository.class).find(moveLine.getId());
    try {
        Beans.get(IrrecoverableService.class).passInIrrecoverable(moveLine, true, true);
        response.setReload(true);
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : MoveLine(com.axelor.apps.account.db.MoveLine) IrrecoverableService(com.axelor.apps.account.service.IrrecoverableService) AxelorException(com.axelor.exception.AxelorException)

Example 94 with MoveLine

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

the class MoveLineController method showCalculatedBalance.

public void showCalculatedBalance(ActionRequest request, ActionResponse response) {
    BigDecimal totalCredit = new BigDecimal(0), totalDebit = new BigDecimal(0), finalBalance;
    @SuppressWarnings("unchecked") List<Integer> idList = (List<Integer>) request.getContext().get("_ids");
    try {
        if (idList != null && !idList.isEmpty()) {
            MoveLineRepository moveLineRepository = Beans.get(MoveLineRepository.class);
            for (Integer id : idList) {
                if (id != null) {
                    MoveLine moveLine = moveLineRepository.find(id.longValue());
                    if (moveLine != null && moveLine.getMove() != null) {
                        Integer statusSelect = moveLine.getMove().getStatusSelect();
                        if (statusSelect.equals(MoveRepository.STATUS_VALIDATED) || statusSelect.equals(MoveRepository.STATUS_ACCOUNTED)) {
                            totalCredit = totalCredit.add(moveLine.getCredit());
                            totalDebit = totalDebit.add(moveLine.getDebit());
                        }
                    } else {
                        throw new AxelorException(TraceBackRepository.CATEGORY_NO_VALUE, I18n.get("Cannot find the move line with id: %s"), id.longValue());
                    }
                } else {
                    throw new AxelorException(MoveLine.class, TraceBackRepository.CATEGORY_NO_VALUE, I18n.get("One id is null"));
                }
            }
            finalBalance = totalDebit.subtract(totalCredit);
            response.setView(ActionView.define("Calculation").model(Wizard.class.getName()).add("form", "account-move-line-calculation-wizard-form").param("popup", "true").param("show-toolbar", "false").param("show-confirm", "false").param("width", "500").param("popup-save", "false").context("_credit", totalCredit).context("_debit", totalDebit).context("_balance", finalBalance).map());
        } else {
            response.setAlert(I18n.get(IExceptionMessage.NO_MOVE_LINE_SELECTED));
        }
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : AxelorException(com.axelor.exception.AxelorException) MoveLine(com.axelor.apps.account.db.MoveLine) ArrayList(java.util.ArrayList) List(java.util.List) MoveLineRepository(com.axelor.apps.account.db.repo.MoveLineRepository) BigDecimal(java.math.BigDecimal) AxelorException(com.axelor.exception.AxelorException)

Example 95 with MoveLine

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

the class NotificationController method displayMoveLines.

public void displayMoveLines(ActionRequest request, ActionResponse response) {
    try {
        Notification notification = request.getContext().asType(Notification.class);
        List<Long> moveLineIdList = new ArrayList<Long>();
        for (NotificationItem notificationItem : notification.getNotificationItemList()) {
            for (MoveLine moveLine : notificationItem.getMove().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) {
        TraceBackService.trace(response, e, ResponseMessageType.ERROR);
    }
}
Also used : NotificationItem(com.axelor.apps.account.db.NotificationItem) ArrayList(java.util.ArrayList) MoveLine(com.axelor.apps.account.db.MoveLine) Notification(com.axelor.apps.account.db.Notification)

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