Search in sources :

Example 6 with PaymentSchedule

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

the class PaymentScheduleController method cancel.

// Cancel button
public void cancel(ActionRequest request, ActionResponse response) {
    PaymentSchedule paymentSchedule = request.getContext().asType(PaymentSchedule.class);
    paymentSchedule = Beans.get(PaymentScheduleRepository.class).find(paymentSchedule.getId());
    try {
        Beans.get(PaymentScheduleService.class).toCancelPaymentSchedule(paymentSchedule);
        response.setReload(true);
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : PaymentSchedule(com.axelor.apps.account.db.PaymentSchedule) PaymentScheduleService(com.axelor.apps.account.service.PaymentScheduleService) AxelorException(com.axelor.exception.AxelorException)

Example 7 with PaymentSchedule

use of com.axelor.apps.account.db.PaymentSchedule 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 8 with PaymentSchedule

use of com.axelor.apps.account.db.PaymentSchedule 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)

Example 9 with PaymentSchedule

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

the class PaymentScheduleController method fillCompanyBankDetails.

/**
 * Called on partner, company or payment mode change. Fill the bank details with a default value.
 *
 * @param request
 * @param response
 * @throws AxelorException
 */
public void fillCompanyBankDetails(ActionRequest request, ActionResponse response) throws AxelorException {
    PaymentSchedule paymentSchedule = request.getContext().asType(PaymentSchedule.class);
    PaymentMode paymentMode = paymentSchedule.getPaymentMode();
    Company company = paymentSchedule.getCompany();
    Partner partner = paymentSchedule.getPartner();
    if (company == null) {
        return;
    }
    if (partner != null) {
        partner = Beans.get(PartnerRepository.class).find(partner.getId());
    }
    BankDetails defaultBankDetails = Beans.get(BankDetailsService.class).getDefaultCompanyBankDetails(company, paymentMode, partner, null);
    response.setValue("companyBankDetails", defaultBankDetails);
}
Also used : BankDetailsService(com.axelor.apps.base.service.BankDetailsService) Company(com.axelor.apps.base.db.Company) PaymentSchedule(com.axelor.apps.account.db.PaymentSchedule) BankDetails(com.axelor.apps.base.db.BankDetails) Partner(com.axelor.apps.base.db.Partner) PaymentMode(com.axelor.apps.account.db.PaymentMode)

Example 10 with PaymentSchedule

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

the class PaymentScheduleController method notPassInIrrecoverable.

public void notPassInIrrecoverable(ActionRequest request, ActionResponse response) {
    PaymentSchedule paymentSchedule = request.getContext().asType(PaymentSchedule.class);
    paymentSchedule = Beans.get(PaymentScheduleRepository.class).find(paymentSchedule.getId());
    try {
        Beans.get(IrrecoverableService.class).notPassInIrrecoverable(paymentSchedule);
        response.setReload(true);
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : PaymentSchedule(com.axelor.apps.account.db.PaymentSchedule) IrrecoverableService(com.axelor.apps.account.service.IrrecoverableService) AxelorException(com.axelor.exception.AxelorException)

Aggregations

PaymentSchedule (com.axelor.apps.account.db.PaymentSchedule)20 AxelorException (com.axelor.exception.AxelorException)10 PaymentScheduleLine (com.axelor.apps.account.db.PaymentScheduleLine)7 Transactional (com.google.inject.persist.Transactional)7 Invoice (com.axelor.apps.account.db.Invoice)6 PaymentScheduleService (com.axelor.apps.account.service.PaymentScheduleService)6 BankDetails (com.axelor.apps.base.db.BankDetails)6 Partner (com.axelor.apps.base.db.Partner)6 MoveLine (com.axelor.apps.account.db.MoveLine)4 PaymentMode (com.axelor.apps.account.db.PaymentMode)4 BigDecimal (java.math.BigDecimal)4 Company (com.axelor.apps.base.db.Company)3 LocalDate (java.time.LocalDate)3 Move (com.axelor.apps.account.db.Move)2 Reconcile (com.axelor.apps.account.db.Reconcile)2 IrrecoverableService (com.axelor.apps.account.service.IrrecoverableService)2 SequenceService (com.axelor.apps.base.service.administration.SequenceService)2 Account (com.axelor.apps.account.db.Account)1 AccountingBatch (com.axelor.apps.account.db.AccountingBatch)1 InvoicePayment (com.axelor.apps.account.db.InvoicePayment)1