Search in sources :

Example 66 with MoveLine

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

the class BankOrderMoveServiceImpl method generateReceiverMove.

protected Move generateReceiverMove(BankOrderLine bankOrderLine) throws AxelorException {
    Partner partner = bankOrderLine.getPartner();
    Company receiverCompany = bankOrderLine.getReceiverCompany();
    BankDetails receiverBankDetails = bankOrderLine.getReceiverBankDetails();
    Journal receiverJournal = paymentModeService.getPaymentModeJournal(paymentMode, receiverCompany, receiverBankDetails);
    Account receiverBankAccount = paymentModeService.getPaymentModeAccount(paymentMode, receiverCompany, receiverBankDetails);
    Move receiverMove = moveService.getMoveCreateService().createMove(receiverJournal, receiverCompany, this.getCurrency(bankOrderLine), partner, this.getDate(bankOrderLine), paymentMode, MoveRepository.TECHNICAL_ORIGIN_AUTOMATIC, MoveRepository.FUNCTIONAL_ORIGIN_PAYMENT);
    MoveLine bankMoveLine = moveService.getMoveLineService().createMoveLine(receiverMove, partner, receiverBankAccount, bankOrderLine.getBankOrderAmount(), isDebit, receiverMove.getDate(), 1, bankOrderLine.getReceiverReference(), bankOrderLine.getReceiverLabel());
    receiverMove.addMoveLineListItem(bankMoveLine);
    MoveLine partnerMoveLine = moveService.getMoveLineService().createMoveLine(receiverMove, partner, getPartnerAccount(partner, receiverCompany, receiverMove.getCompany()), bankOrderLine.getBankOrderAmount(), !isDebit, receiverMove.getDate(), 2, bankOrderLine.getReceiverReference(), bankOrderLine.getReceiverLabel());
    receiverMove.addMoveLineListItem(partnerMoveLine);
    return receiverMove;
}
Also used : Account(com.axelor.apps.account.db.Account) 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) Journal(com.axelor.apps.account.db.Journal) Partner(com.axelor.apps.base.db.Partner)

Example 67 with MoveLine

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

the class BatchBankPaymentServiceImpl method createBankOrders.

@Transactional(rollbackOn = { Exception.class })
protected void createBankOrders(Batch batch, Collection<PaymentScheduleLine> paymentScheduleLines) throws AxelorException, JAXBException, IOException, DatatypeConfigurationException {
    for (PaymentScheduleLine paymentScheduleLine : paymentScheduleLines) {
        PaymentSchedule paymentSchedule = paymentScheduleLine.getPaymentSchedule();
        MoveLine creditMoveLine = paymentScheduleLine.getAdvanceMoveLine();
        for (Invoice invoice : paymentSchedule.getInvoiceSet()) {
            MoveLine debitMoveLine = moveService.getMoveLineService().getDebitCustomerMoveLine(invoice);
            Reconcile reconcile = reconcileRepo.findByMoveLines(debitMoveLine, creditMoveLine);
            if (reconcile == null) {
                continue;
            }
            createBankOrders(batch, reconcile);
        }
    }
}
Also used : Invoice(com.axelor.apps.account.db.Invoice) PaymentScheduleLine(com.axelor.apps.account.db.PaymentScheduleLine) PaymentSchedule(com.axelor.apps.account.db.PaymentSchedule) MoveLine(com.axelor.apps.account.db.MoveLine) Reconcile(com.axelor.apps.account.db.Reconcile) Transactional(com.google.inject.persist.Transactional)

Example 68 with MoveLine

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

the class MoveServiceBankPaymentImpl method generateReverseMoveLine.

protected MoveLine generateReverseMoveLine(Move reverseMove, MoveLine orgineMoveLine, LocalDate dateOfReversion, boolean isDebit) throws AxelorException {
    MoveLine reverseMoveLine = super.generateReverseMoveLine(reverseMove, orgineMoveLine, dateOfReversion, isDebit);
    reverseMoveLine.setBankReconciledAmount(reverseMoveLine.getDebit().add(reverseMoveLine.getCredit().subtract(orgineMoveLine.getBankReconciledAmount())));
    return reverseMoveLine;
}
Also used : MoveLine(com.axelor.apps.account.db.MoveLine)

Example 69 with MoveLine

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

the class PaymentScheduleLineBankPaymentServiceImpl method createRejectionMove.

@Transactional(rollbackOn = { Exception.class })
protected Move createRejectionMove(PaymentScheduleLine paymentScheduleLine) throws AxelorException {
    MoveValidateService moveValidateService = moveService.getMoveValidateService();
    MoveLineService moveLineService = moveService.getMoveLineService();
    Move advanceOrPaymentMove = paymentScheduleLine.getAdvanceOrPaymentMove();
    Move rejectionMove = moveService.generateReverse(advanceOrPaymentMove, true, true, false, advanceOrPaymentMove.getDate());
    rejectionMove.setRejectOk(true);
    moveValidateService.validate(rejectionMove);
    List<MoveLine> moveLineList = new ArrayList<>();
    moveLineList.addAll(advanceOrPaymentMove.getMoveLineList());
    moveLineList.addAll(rejectionMove.getMoveLineList());
    moveLineService.reconcileMoveLines(moveLineList);
    return rejectionMove;
}
Also used : MoveLineService(com.axelor.apps.account.service.move.MoveLineService) MoveValidateService(com.axelor.apps.account.service.move.MoveValidateService) Move(com.axelor.apps.account.db.Move) MoveLine(com.axelor.apps.account.db.MoveLine) ArrayList(java.util.ArrayList) Transactional(com.google.inject.persist.Transactional)

Example 70 with MoveLine

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

the class PaymentScheduleLineBankPaymentServiceImpl method reject.

@Override
@Transactional(rollbackOn = { Exception.class })
public void reject(PaymentScheduleLine paymentScheduleLine, InterbankCodeLine rejectionReason, boolean represent) throws AxelorException {
    Preconditions.checkNotNull(paymentScheduleLine, I18n.get("Payment schedule line cannot be null."));
    PaymentSchedule paymentSchedule = paymentScheduleLine.getPaymentSchedule();
    Preconditions.checkNotNull(paymentSchedule, I18n.get("Parent payment schedule cannot be null."));
    if (paymentScheduleLine.getStatusSelect() != PaymentScheduleLineRepository.STATUS_VALIDATED) {
        throw new AxelorException(paymentScheduleLine, TraceBackRepository.CATEGORY_INCONSISTENCY, I18n.get("Only validated payment schedule lines can be rejected."));
    }
    Move rejectionMove = createRejectionMove(paymentScheduleLine);
    if (paymentSchedule.getTypeSelect() == PaymentScheduleRepository.TYPE_TERMS) {
        cancelInvoicePayments(paymentScheduleLine);
    }
    if (represent) {
        representPaymentScheduleLine(paymentScheduleLine);
    }
    if (rejectionReason == null) {
        rejectionReason = getDefaultRejectionReason();
    }
    MoveLine rejectionMoveLine = moveService.findMoveLineByAccount(rejectionMove, paymentScheduleLine.getAdvanceMoveLine().getAccount());
    paymentScheduleLine.setInterbankCodeLine(rejectionReason);
    paymentScheduleLine.setRejectMoveLine(rejectionMoveLine);
    paymentScheduleLine.setRejectDate(rejectionMove.getDate());
    paymentScheduleLine.setAmountRejected(paymentScheduleLine.getRejectMoveLine().getDebit());
    paymentScheduleLine.setRejectedOk(true);
    paymentScheduleLine.setStatusSelect(PaymentScheduleLineRepository.STATUS_CLOSED);
}
Also used : AxelorException(com.axelor.exception.AxelorException) PaymentSchedule(com.axelor.apps.account.db.PaymentSchedule) Move(com.axelor.apps.account.db.Move) MoveLine(com.axelor.apps.account.db.MoveLine) Transactional(com.google.inject.persist.Transactional)

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