Search in sources :

Example 61 with MoveLine

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

the class InvoicePaymentToolServiceImpl method getCreditMoveLinesFromPayments.

@Override
public List<MoveLine> getCreditMoveLinesFromPayments(List<InvoicePayment> payments) {
    List<MoveLine> moveLines = new ArrayList<>();
    for (InvoicePayment payment : payments) {
        Move move = payment.getMove();
        if (move == null || move.getMoveLineList() == null || move.getMoveLineList().isEmpty()) {
            continue;
        }
        moveLines.addAll(moveToolService.getToReconcileCreditMoveLines(move));
    }
    return moveLines;
}
Also used : InvoicePayment(com.axelor.apps.account.db.InvoicePayment) Move(com.axelor.apps.account.db.Move) MoveLine(com.axelor.apps.account.db.MoveLine) ArrayList(java.util.ArrayList)

Example 62 with MoveLine

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

the class PaymentVoucherConfirmService method payMoveLine.

/**
 * @param paymentMove
 * @param moveLineSeq
 * @param payerPartner
 * @param moveLineToPay
 * @param amountToPay
 * @param payVoucherElementToPay
 * @return
 * @throws AxelorException
 */
public MoveLine payMoveLine(Move paymentMove, int moveLineSeq, Partner payerPartner, MoveLine moveLineToPay, BigDecimal amountToPay, PayVoucherElementToPay payVoucherElementToPay, boolean isDebitToPay, LocalDate paymentDate) throws AxelorException {
    String invoiceName = "";
    if (moveLineToPay.getMove().getInvoice() != null) {
        invoiceName = moveLineToPay.getMove().getInvoice().getInvoiceId();
    } else {
        invoiceName = payVoucherElementToPay.getPaymentVoucher().getRef();
    }
    MoveLine moveLine = moveLineService.createMoveLine(paymentMove, payerPartner, moveLineToPay.getAccount(), amountToPay, !isDebitToPay, paymentDate, moveLineSeq, invoiceName, null);
    paymentMove.addMoveLineListItem(moveLine);
    payVoucherElementToPay.setMoveLineGenerated(moveLine);
    BigDecimal amountInCompanyCurrency = moveLine.getDebit().add(moveLine.getCredit());
    Reconcile reconcile = reconcileService.createReconcile(moveLineToPay, moveLine, amountInCompanyCurrency, true);
    if (reconcile != null) {
        log.debug("Reconcile : : : {}", reconcile);
        reconcileService.confirmReconcile(reconcile, true);
    }
    return moveLine;
}
Also used : MoveLine(com.axelor.apps.account.db.MoveLine) BigDecimal(java.math.BigDecimal) Reconcile(com.axelor.apps.account.db.Reconcile)

Example 63 with MoveLine

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

the class BankReconciliationLineService method checkAmount.

public void checkAmount(BankReconciliationLine bankReconciliationLine) throws AxelorException {
    MoveLine moveLine = bankReconciliationLine.getMoveLine();
    BigDecimal bankDebit = bankReconciliationLine.getDebit();
    BigDecimal bankCredit = bankReconciliationLine.getCredit();
    BigDecimal moveLineDebit = moveLine.getDebit();
    BigDecimal moveLineCredit = moveLine.getCredit();
    if (bankDebit.add(bankCredit).compareTo(BigDecimal.ZERO) == 0) {
        throw new AxelorException(bankReconciliationLine, TraceBackRepository.CATEGORY_CONFIGURATION_ERROR, I18n.get(IExceptionMessage.BANK_STATEMENT_3), I18n.get(com.axelor.apps.base.exceptions.IExceptionMessage.EXCEPTION), bankReconciliationLine.getReference() != null ? bankReconciliationLine.getReference() : "");
    }
    if (!(bankDebit.compareTo(BigDecimal.ZERO) > 0 && moveLineCredit.compareTo(BigDecimal.ZERO) > 0 && bankDebit.compareTo(moveLineCredit.subtract(moveLine.getBankReconciledAmount())) == 0) && !(bankCredit.compareTo(BigDecimal.ZERO) > 0 && moveLineDebit.compareTo(BigDecimal.ZERO) > 0 && bankCredit.compareTo(moveLineDebit.subtract(moveLine.getBankReconciledAmount())) == 0)) {
        throw new AxelorException(bankReconciliationLine, TraceBackRepository.CATEGORY_CONFIGURATION_ERROR, I18n.get(IExceptionMessage.BANK_STATEMENT_2), I18n.get(com.axelor.apps.base.exceptions.IExceptionMessage.EXCEPTION), bankReconciliationLine.getReference() != null ? bankReconciliationLine.getReference() : "");
    }
}
Also used : AxelorException(com.axelor.exception.AxelorException) MoveLine(com.axelor.apps.account.db.MoveLine) BigDecimal(java.math.BigDecimal)

Example 64 with MoveLine

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

the class BankReconciliationValidateService method updateBankReconciledAmounts.

protected void updateBankReconciledAmounts(BankReconciliationLine bankReconciliationLine) {
    bankReconciliationLine.setIsPosted(true);
    BigDecimal bankReconciledAmount = bankReconciliationLine.getDebit().add(bankReconciliationLine.getCredit());
    BankStatementLine bankStatementLine = bankReconciliationLine.getBankStatementLine();
    if (bankStatementLine != null) {
        bankStatementLine.setAmountRemainToReconcile(bankStatementLine.getAmountRemainToReconcile().subtract(bankReconciledAmount));
    }
    MoveLine moveLine = bankReconciliationLine.getMoveLine();
    moveLine.setBankReconciledAmount(bankReconciledAmount);
}
Also used : BankStatementLine(com.axelor.apps.bankpayment.db.BankStatementLine) MoveLine(com.axelor.apps.account.db.MoveLine) BigDecimal(java.math.BigDecimal)

Example 65 with MoveLine

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

the class BankOrderMoveServiceImpl method generateSenderMove.

protected Move generateSenderMove(BankOrderLine bankOrderLine) throws AxelorException {
    Partner partner = bankOrderLine.getPartner();
    Move senderMove = moveService.getMoveCreateService().createMove(journal, senderCompany, this.getCurrency(bankOrderLine), partner, this.getDate(bankOrderLine), paymentMode, MoveRepository.TECHNICAL_ORIGIN_AUTOMATIC, MoveRepository.FUNCTIONAL_ORIGIN_PAYMENT);
    MoveLine bankMoveLine = moveService.getMoveLineService().createMoveLine(senderMove, partner, senderBankAccount, bankOrderLine.getBankOrderAmount(), !isDebit, senderMove.getDate(), 1, bankOrderLine.getReceiverReference(), bankOrderLine.getReceiverLabel());
    senderMove.addMoveLineListItem(bankMoveLine);
    MoveLine partnerMoveLine = moveService.getMoveLineService().createMoveLine(senderMove, partner, getPartnerAccount(partner, senderCompany, senderCompany), bankOrderLine.getBankOrderAmount(), isDebit, senderMove.getDate(), 2, bankOrderLine.getReceiverReference(), bankOrderLine.getReceiverLabel());
    senderMove.addMoveLineListItem(partnerMoveLine);
    return senderMove;
}
Also used : Move(com.axelor.apps.account.db.Move) MoveLine(com.axelor.apps.account.db.MoveLine) Partner(com.axelor.apps.base.db.Partner)

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