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