Search in sources :

Example 86 with MoveLine

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;
}
Also used : AnalyticAccount(com.axelor.apps.account.db.AnalyticAccount) Account(com.axelor.apps.account.db.Account) ReconcileService(com.axelor.apps.account.service.ReconcileService) Company(com.axelor.apps.base.db.Company) Move(com.axelor.apps.account.db.Move) BankDetails(com.axelor.apps.base.db.BankDetails) MoveLine(com.axelor.apps.account.db.MoveLine) AnalyticMoveLine(com.axelor.apps.account.db.AnalyticMoveLine) Journal(com.axelor.apps.account.db.Journal) Partner(com.axelor.apps.base.db.Partner) LocalDate(java.time.LocalDate) BigDecimal(java.math.BigDecimal) PaymentMode(com.axelor.apps.account.db.PaymentMode)

Example 87 with MoveLine

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);
}
Also used : Account(com.axelor.apps.account.db.Account) MoveLine(com.axelor.apps.account.db.MoveLine) StockMoveLine(com.axelor.apps.stock.db.StockMoveLine) AnalyticMoveLine(com.axelor.apps.account.db.AnalyticMoveLine) Tax(com.axelor.apps.account.db.Tax) BigDecimal(java.math.BigDecimal) TaxLine(com.axelor.apps.account.db.TaxLine)

Example 88 with MoveLine

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);
    }
}
Also used : MoveLine(com.axelor.apps.account.db.MoveLine) AxelorException(com.axelor.exception.AxelorException)

Example 89 with MoveLine

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);
    }
}
Also used : MoveLineService(com.axelor.apps.account.service.move.MoveLineService) MoveLine(com.axelor.apps.account.db.MoveLine) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) MoveLineRepository(com.axelor.apps.account.db.repo.MoveLineRepository) AxelorException(com.axelor.exception.AxelorException)

Example 90 with MoveLine

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);
    }
}
Also used : MoveLine(com.axelor.apps.account.db.MoveLine) IrrecoverableService(com.axelor.apps.account.service.IrrecoverableService) AxelorException(com.axelor.exception.AxelorException)

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