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);
}
}
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);
}
}
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);
}
}
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);
}
}
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);
}
}
Aggregations