Search in sources :

Example 96 with MoveLine

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

the class MoveBankPaymentRepository method copy.

@Override
public Move copy(Move entity, boolean deep) {
    Move copy = super.copy(entity, deep);
    List<MoveLine> moveLineList = copy.getMoveLineList();
    if (moveLineList != null) {
        moveLineList.forEach(moveLine -> moveLine.setBankReconciledAmount(BigDecimal.ZERO));
    }
    return copy;
}
Also used : Move(com.axelor.apps.account.db.Move) MoveLine(com.axelor.apps.account.db.MoveLine)

Example 97 with MoveLine

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

the class InvoiceServiceSupplychainImpl method getMoveLinesFromSOAdvancePayments.

@Override
public List<MoveLine> getMoveLinesFromSOAdvancePayments(Invoice invoice) {
    if (!Beans.get(AppSupplychainService.class).isApp("supplychain")) {
        return super.getMoveLinesFromSOAdvancePayments(invoice);
    }
    // search sale order in the invoice
    SaleOrder saleOrder = invoice.getSaleOrder();
    // search sale order in invoice lines
    List<SaleOrder> saleOrderList = invoice.getInvoiceLineList().stream().map(invoiceLine -> invoice.getSaleOrder()).collect(Collectors.toList());
    saleOrderList.add(saleOrder);
    // remove null value and duplicates
    saleOrderList = saleOrderList.stream().filter(Objects::nonNull).distinct().collect(Collectors.toList());
    if (saleOrderList.isEmpty()) {
        return new ArrayList<>();
    } else {
        // get move lines from sale order
        return saleOrderList.stream().flatMap(saleOrder1 -> saleOrder1.getAdvancePaymentList().stream()).filter(Objects::nonNull).distinct().map(AdvancePayment::getMove).filter(Objects::nonNull).distinct().flatMap(move -> moveToolService.getToReconcileCreditMoveLines(move).stream()).collect(Collectors.toList());
    }
}
Also used : Company(com.axelor.apps.base.db.Company) Query(com.axelor.db.Query) InvoiceLineService(com.axelor.apps.account.service.invoice.InvoiceLineService) AppAccountService(com.axelor.apps.account.service.app.AppAccountService) EntityHelper(com.axelor.db.EntityHelper) PartnerService(com.axelor.apps.base.service.PartnerService) Inject(com.google.inject.Inject) CancelFactory(com.axelor.apps.account.service.invoice.factory.CancelFactory) VentilateFactory(com.axelor.apps.account.service.invoice.factory.VentilateFactory) Transactional(com.google.inject.persist.Transactional) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) BigDecimal(java.math.BigDecimal) AxelorException(com.axelor.exception.AxelorException) InvoiceLine(com.axelor.apps.account.db.InvoiceLine) MoveLine(com.axelor.apps.account.db.MoveLine) MoveToolService(com.axelor.apps.account.service.move.MoveToolService) ValidateFactory(com.axelor.apps.account.service.invoice.factory.ValidateFactory) SaleOrder(com.axelor.apps.sale.db.SaleOrder) InvoiceServiceImpl(com.axelor.apps.account.service.invoice.InvoiceServiceImpl) InvoiceLineRepository(com.axelor.apps.account.db.repo.InvoiceLineRepository) Timetable(com.axelor.apps.supplychain.db.Timetable) Set(java.util.Set) Invoice(com.axelor.apps.account.db.Invoice) Collectors(java.util.stream.Collectors) Currency(com.axelor.apps.base.db.Currency) Objects(java.util.Objects) List(java.util.List) InvoiceRepository(com.axelor.apps.account.db.repo.InvoiceRepository) AdvancePayment(com.axelor.apps.sale.db.AdvancePayment) Beans(com.axelor.inject.Beans) AccountConfigService(com.axelor.apps.account.service.config.AccountConfigService) AlarmEngineService(com.axelor.apps.base.service.alarm.AlarmEngineService) ObjectUtils(com.axelor.common.ObjectUtils) TimetableRepository(com.axelor.apps.supplychain.db.repo.TimetableRepository) AppSupplychainService(com.axelor.apps.supplychain.service.app.AppSupplychainService) Comparator(java.util.Comparator) ArrayList(java.util.ArrayList) Objects(java.util.Objects) SaleOrder(com.axelor.apps.sale.db.SaleOrder) AdvancePayment(com.axelor.apps.sale.db.AdvancePayment)

Example 98 with MoveLine

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

the class AccountClearanceService method createAccountClearanceMove.

public Move createAccountClearanceMove(MoveLine moveLine, BigDecimal taxRate, Account taxAccount, Account profitAccount, Company company, Journal journal, AccountClearance accountClearance) throws AxelorException {
    Partner partner = moveLine.getPartner();
    // Move
    Move move = moveService.getMoveCreateService().createMove(journal, company, null, partner, null, MoveRepository.TECHNICAL_ORIGIN_AUTOMATIC, moveLine.getMove().getFunctionalOriginSelect());
    // Debit MoveLine 411
    BigDecimal amount = moveLine.getAmountRemaining();
    MoveLine debitMoveLine = moveLineService.createMoveLine(move, partner, moveLine.getAccount(), amount, true, appBaseService.getTodayDateTime().toLocalDate(), 1, null, null);
    move.getMoveLineList().add(debitMoveLine);
    // Credit MoveLine 77. (profit account)
    BigDecimal divid = taxRate.add(BigDecimal.ONE);
    BigDecimal profitAmount = amount.divide(divid, AppBaseService.DEFAULT_NB_DECIMAL_DIGITS, RoundingMode.HALF_UP).setScale(AppBaseService.DEFAULT_NB_DECIMAL_DIGITS, RoundingMode.HALF_UP);
    MoveLine creditMoveLine1 = moveLineService.createMoveLine(move, partner, profitAccount, profitAmount, false, appBaseService.getTodayDateTime().toLocalDate(), 2, null, null);
    move.getMoveLineList().add(creditMoveLine1);
    // Credit MoveLine 445 (Tax account)
    BigDecimal taxAmount = amount.subtract(profitAmount);
    MoveLine creditMoveLine2 = moveLineService.createMoveLine(move, partner, taxAccount, taxAmount, false, appBaseService.getTodayDateTime().toLocalDate(), 3, null, null);
    move.getMoveLineList().add(creditMoveLine2);
    Reconcile reconcile = reconcileService.createReconcile(debitMoveLine, moveLine, amount, false);
    if (reconcile != null) {
        reconcileService.confirmReconcile(reconcile, true);
    }
    debitMoveLine.setAccountClearance(accountClearance);
    creditMoveLine1.setAccountClearance(accountClearance);
    creditMoveLine2.setAccountClearance(accountClearance);
    return move;
}
Also used : Move(com.axelor.apps.account.db.Move) MoveLine(com.axelor.apps.account.db.MoveLine) Partner(com.axelor.apps.base.db.Partner) BigDecimal(java.math.BigDecimal) Reconcile(com.axelor.apps.account.db.Reconcile)

Example 99 with MoveLine

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

the class AccountingCloseAnnualServiceImpl method generateCloseAnnualMoveLine.

protected MoveLine generateCloseAnnualMoveLine(Move move, String origin, Account account, String moveDescription, LocalDate originDate, BigDecimal balance) throws AxelorException {
    LocalDate moveDate = move.getDate();
    MoveLine moveLine = moveLineService.createMoveLine(move, move.getPartner(), account, balance.abs(), balance.abs(), null, balance.compareTo(BigDecimal.ZERO) == 1, moveDate, moveDate, originDate, ++counter, origin, moveDescription);
    move.addMoveLineListItem(moveLine);
    return moveLine;
}
Also used : MoveLine(com.axelor.apps.account.db.MoveLine) LocalDate(java.time.LocalDate)

Example 100 with MoveLine

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

the class MoveManagementRepository method copy.

@Override
public Move copy(Move entity, boolean deep) {
    Move copy = super.copy(entity, deep);
    copy.setDate(Beans.get(AppBaseService.class).getTodayDate(copy.getCompany()));
    Period period = null;
    try {
        period = Beans.get(PeriodService.class).getActivePeriod(copy.getDate(), entity.getCompany(), YearRepository.TYPE_FISCAL);
    } catch (AxelorException e) {
        throw new PersistenceException(e.getMessage(), e);
    }
    copy.setStatusSelect(STATUS_NEW);
    copy.setTechnicalOriginSelect(MoveRepository.TECHNICAL_ORIGIN_ENTRY);
    copy.setReference(null);
    copy.setExportNumber(null);
    copy.setExportDate(null);
    copy.setAccountingReport(null);
    copy.setValidationDate(null);
    copy.setPeriod(period);
    copy.setAccountingOk(false);
    copy.setIgnoreInDebtRecoveryOk(false);
    copy.setPaymentVoucher(null);
    copy.setRejectOk(false);
    copy.setInvoice(null);
    List<MoveLine> moveLineList = copy.getMoveLineList();
    if (moveLineList != null) {
        moveLineList.forEach(moveLine -> resetMoveLine(moveLine, copy.getDate()));
    }
    return copy;
}
Also used : AxelorException(com.axelor.exception.AxelorException) Move(com.axelor.apps.account.db.Move) PersistenceException(javax.persistence.PersistenceException) MoveLine(com.axelor.apps.account.db.MoveLine) AnalyticMoveLine(com.axelor.apps.account.db.AnalyticMoveLine) Period(com.axelor.apps.base.db.Period)

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