use of com.axelor.apps.account.db.Move in project axelor-open-suite by axelor.
the class MoveController method deleteMove.
public void deleteMove(ActionRequest request, ActionResponse response) throws AxelorException {
try {
Move move = request.getContext().asType(Move.class);
MoveRepository moveRepository = Beans.get(MoveRepository.class);
move = moveRepository.find(move.getId());
move = moveRepository.find(move.getId());
this.removeOneMove(move, response);
if (!move.getStatusSelect().equals(MoveRepository.STATUS_VALIDATED)) {
response.setView(ActionView.define("Moves").model(Move.class.getName()).add("grid", "move-grid").add("form", "move-form").param("search-filters", "move-filters").map());
response.setCanClose(true);
}
} catch (Exception e) {
TraceBackService.trace(response, e, ResponseMessageType.ERROR);
}
}
use of com.axelor.apps.account.db.Move in project axelor-open-suite by axelor.
the class MoveController method updateLines.
public void updateLines(ActionRequest request, ActionResponse response) {
Move move = request.getContext().asType(Move.class);
try {
move = Beans.get(MoveService.class).updateMoveLinesDateExcludeFromPeriodOnlyWithoutSave(move);
response.setValue("moveLineList", move.getMoveLineList());
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
use of com.axelor.apps.account.db.Move in project axelor-open-suite by axelor.
the class MoveController method checkRemoveLines.
public void checkRemoveLines(ActionRequest request, ActionResponse response) {
try {
Move moveView = request.getContext().asType(Move.class);
if (moveView.getId() == null) {
return;
}
Move moveBD = Beans.get(MoveRepository.class).find(moveView.getId());
List<String> moveLineReconciledAndRemovedNameList = new ArrayList<>();
for (MoveLine moveLineBD : moveBD.getMoveLineList()) {
if (!moveView.getMoveLineList().contains(moveLineBD)) {
if (moveLineBD.getReconcileGroup() != null) {
moveLineReconciledAndRemovedNameList.add(moveLineBD.getName());
}
}
}
if (moveLineReconciledAndRemovedNameList != null && !moveLineReconciledAndRemovedNameList.isEmpty()) {
response.setError(String.format(I18n.get(IExceptionMessage.MOVE_LINE_RECONCILE_LINE_CANNOT_BE_REMOVED), moveLineReconciledAndRemovedNameList.toString()));
}
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
use of com.axelor.apps.account.db.Move in project axelor-open-suite by axelor.
the class MoveController method autoTaxLineGenerate.
public void autoTaxLineGenerate(ActionRequest request, ActionResponse response) throws AxelorException {
Move move = request.getContext().asType(Move.class);
if (move.getMoveLineList() != null && !move.getMoveLineList().isEmpty() && move.getStatusSelect().equals(MoveRepository.STATUS_NEW)) {
Beans.get(MoveService.class).getMoveLineService().autoTaxLineGenerate(move);
response.setValue("moveLineList", move.getMoveLineList());
}
}
use of com.axelor.apps.account.db.Move in project axelor-open-suite by axelor.
the class ExpenseServiceImpl method createAndSetMove.
protected Move createAndSetMove(Expense expense) throws AxelorException {
LocalDate moveDate = expense.getMoveDate();
if (moveDate == null) {
moveDate = appAccountService.getTodayDate(expense.getCompany());
expense.setMoveDate(moveDate);
}
Company company = expense.getCompany();
Partner partner = expense.getUser().getPartner();
Account account = null;
AccountConfig accountConfig = accountConfigService.getAccountConfig(company);
if (partner == null) {
throw new AxelorException(expense, TraceBackRepository.CATEGORY_CONFIGURATION_ERROR, I18n.get(com.axelor.apps.account.exception.IExceptionMessage.USER_PARTNER), expense.getUser().getName());
}
Move move = moveService.getMoveCreateService().createMove(accountConfigService.getExpenseJournal(accountConfig), company, null, partner, moveDate, partner.getInPaymentMode(), MoveRepository.TECHNICAL_ORIGIN_AUTOMATIC, MoveRepository.FUNCTIONAL_ORIGIN_PURCHASE);
List<MoveLine> moveLines = new ArrayList<>();
Set<AnalyticAccount> analyticAccounts = new HashSet<>();
BigDecimal exTaxTotal = null;
int moveLineId = 1;
int expenseLineId = 1;
Account employeeAccount = accountingSituationService.getEmployeeAccount(partner, company);
moveLines.add(moveLineService.createMoveLine(move, partner, employeeAccount, expense.getInTaxTotal(), false, moveDate, moveDate, moveLineId++, expense.getExpenseSeq(), expense.getFullName()));
for (ExpenseLine expenseLine : getExpenseLineList(expense)) {
analyticAccounts.clear();
Product product = expenseLine.getExpenseProduct();
account = accountManagementService.getProductAccount(product, company, partner.getFiscalPosition(), true, false);
if (account == null) {
throw new AxelorException(expense, TraceBackRepository.CATEGORY_CONFIGURATION_ERROR, I18n.get(com.axelor.apps.account.exception.IExceptionMessage.MOVE_LINE_4), expenseLineId, company.getName());
}
exTaxTotal = expenseLine.getUntaxedAmount();
MoveLine moveLine = moveLineService.createMoveLine(move, partner, account, exTaxTotal, true, moveDate, moveDate, moveLineId++, expense.getExpenseSeq(), expenseLine.getComments() != null ? expenseLine.getComments().replaceAll("(\r\n|\n\r|\r|\n)", " ") : "");
for (AnalyticMoveLine analyticDistributionLineIt : expenseLine.getAnalyticMoveLineList()) {
AnalyticMoveLine analyticDistributionLine = Beans.get(AnalyticMoveLineRepository.class).copy(analyticDistributionLineIt, false);
analyticDistributionLine.setExpenseLine(null);
moveLine.addAnalyticMoveLineListItem(analyticDistributionLine);
}
moveLines.add(moveLine);
expenseLineId++;
}
moveLineService.consolidateMoveLines(moveLines);
account = accountConfigService.getExpenseTaxAccount(accountConfig);
BigDecimal taxTotal = BigDecimal.ZERO;
for (ExpenseLine expenseLine : getExpenseLineList(expense)) {
exTaxTotal = expenseLine.getTotalTax();
taxTotal = taxTotal.add(exTaxTotal);
}
if (taxTotal.signum() != 0) {
MoveLine moveLine = moveLineService.createMoveLine(move, partner, account, taxTotal, true, moveDate, moveDate, moveLineId++, expense.getExpenseSeq(), expense.getFullName());
moveLines.add(moveLine);
}
move.getMoveLineList().addAll(moveLines);
moveService.getMoveValidateService().validate(move);
expense.setMove(move);
return move;
}
Aggregations