use of com.axelor.apps.account.db.MoveLine in project axelor-open-suite by axelor.
the class ExpenseServiceImpl method createMoveForExpensePayment.
public Move createMoveForExpensePayment(Expense expense) throws AxelorException {
Company company = expense.getCompany();
PaymentMode paymentMode = expense.getPaymentMode();
Partner partner = expense.getUser().getPartner();
LocalDate paymentDate = expense.getPaymentDate();
BigDecimal paymentAmount = expense.getInTaxTotal();
BankDetails companyBankDetails = company.getDefaultBankDetails();
Account employeeAccount;
Journal journal = paymentModeService.getPaymentModeJournal(paymentMode, company, companyBankDetails);
MoveLine expenseMoveLine = this.getExpenseEmployeeMoveLineByLoop(expense);
if (expenseMoveLine == null) {
return null;
}
employeeAccount = expenseMoveLine.getAccount();
Move move = moveService.getMoveCreateService().createMove(journal, company, expense.getMove().getCurrency(), partner, paymentDate, paymentMode, MoveRepository.TECHNICAL_ORIGIN_AUTOMATIC, MoveRepository.FUNCTIONAL_ORIGIN_PAYMENT);
move.addMoveLineListItem(moveLineService.createMoveLine(move, partner, paymentModeService.getPaymentModeAccount(paymentMode, company, companyBankDetails), paymentAmount, false, paymentDate, null, 1, expense.getExpenseSeq(), null));
MoveLine employeeMoveLine = moveLineService.createMoveLine(move, partner, employeeAccount, paymentAmount, true, paymentDate, null, 2, expense.getExpenseSeq(), null);
employeeMoveLine.setTaxAmount(expense.getTaxTotal());
move.addMoveLineListItem(employeeMoveLine);
moveService.getMoveValidateService().validate(move);
expense.setPaymentMove(move);
Beans.get(ReconcileService.class).reconcile(expenseMoveLine, employeeMoveLine, true, false);
expenseRepository.save(expense);
return move;
}
use of com.axelor.apps.account.db.MoveLine in project axelor-open-suite by axelor.
the class AccountingCutOffServiceImpl method generateTaxMoveLine.
protected void generateTaxMoveLine(Move move, MoveLine productMoveLine, String origin, boolean isPurchase, boolean isFixedAssets, String moveDescription) throws AxelorException {
TaxLine taxLine = productMoveLine.getTaxLine();
Tax tax = taxLine.getTax();
Account taxAccount = taxAccountService.getAccount(tax, move.getCompany(), isPurchase, isFixedAssets);
BigDecimal currencyTaxAmount = InvoiceLineManagement.computeAmount(productMoveLine.getCurrencyAmount(), taxLine.getValue());
MoveLine taxMoveLine = moveLineService.createMoveLine(move, move.getPartner(), taxAccount, currencyTaxAmount, productMoveLine.getDebit().compareTo(BigDecimal.ZERO) == 1, productMoveLine.getOriginDate(), ++counter, origin, moveDescription);
taxMoveLine.setDate(move.getDate());
taxMoveLine.setDueDate(move.getDate());
move.addMoveLineListItem(taxMoveLine);
}
use of com.axelor.apps.account.db.MoveLine in project axelor-open-suite by axelor.
the class MoveLineController method createAnalyticDistributionWithTemplate.
public void createAnalyticDistributionWithTemplate(ActionRequest request, ActionResponse response) throws AxelorException {
try {
MoveLine moveLine = request.getContext().asType(MoveLine.class);
moveLine = Beans.get(MoveLineService.class).createAnalyticDistributionWithTemplate(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 accountingReconcile.
public void accountingReconcile(ActionRequest request, ActionResponse response) {
List<MoveLine> moveLineList = new ArrayList<>();
@SuppressWarnings("unchecked") List<Integer> idList = (List<Integer>) request.getContext().get("_ids");
try {
if (idList != null) {
for (Integer it : idList) {
MoveLine moveLine = Beans.get(MoveLineRepository.class).find(it.longValue());
if ((moveLine.getMove().getStatusSelect() == MoveRepository.STATUS_VALIDATED || moveLine.getMove().getStatusSelect() == MoveRepository.STATUS_ACCOUNTED) && moveLine.getAmountRemaining().compareTo(BigDecimal.ZERO) > 0) {
moveLineList.add(moveLine);
}
}
}
if (!moveLineList.isEmpty()) {
Beans.get(MoveLineService.class).reconcileMoveLinesWithCacheManagement(moveLineList);
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 notPassInIrrecoverable.
public void notPassInIrrecoverable(ActionRequest request, ActionResponse response) {
MoveLine moveLine = request.getContext().asType(MoveLine.class);
moveLine = Beans.get(MoveLineRepository.class).find(moveLine.getId());
try {
Beans.get(IrrecoverableService.class).notPassInIrrecoverable(moveLine, true);
response.setReload(true);
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
Aggregations