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;
}
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;
}
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() : "");
}
}
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);
}
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;
}
Aggregations