Search in sources :

Example 11 with PaymentSchedule

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

the class PaymentScheduleController method fillPartnerBankDetails.

/**
 * Called on partner change. Fill the bank details with a default value.
 *
 * @param request
 * @param response
 */
public void fillPartnerBankDetails(ActionRequest request, ActionResponse response) {
    PaymentSchedule paymentSchedule = request.getContext().asType(PaymentSchedule.class);
    Partner partner = paymentSchedule.getPartner();
    if (partner != null) {
        partner = Beans.get(PartnerRepository.class).find(partner.getId());
    }
    BankDetails defaultBankDetails = Beans.get(PartnerService.class).getDefaultBankDetails(partner);
    response.setValue("bankDetails", defaultBankDetails);
}
Also used : PaymentSchedule(com.axelor.apps.account.db.PaymentSchedule) BankDetails(com.axelor.apps.base.db.BankDetails) PartnerService(com.axelor.apps.base.service.PartnerService) Partner(com.axelor.apps.base.db.Partner)

Example 12 with PaymentSchedule

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

the class PaymentScheduleController method createPaymentScheduleLines.

// Creating payment schedule lines button
public void createPaymentScheduleLines(ActionRequest request, ActionResponse response) {
    PaymentSchedule paymentSchedule = request.getContext().asType(PaymentSchedule.class);
    paymentSchedule = Beans.get(PaymentScheduleRepository.class).find(paymentSchedule.getId());
    Beans.get(PaymentScheduleService.class).createPaymentScheduleLines(paymentSchedule);
    response.setReload(true);
}
Also used : PaymentSchedule(com.axelor.apps.account.db.PaymentSchedule) PaymentScheduleService(com.axelor.apps.account.service.PaymentScheduleService)

Example 13 with PaymentSchedule

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

the class PaymentScheduleController method paymentScheduleScheduleId.

// Called on onSave event
public void paymentScheduleScheduleId(ActionRequest request, ActionResponse response) {
    try {
        PaymentSchedule paymentSchedule = request.getContext().asType(PaymentSchedule.class);
        Beans.get(PaymentScheduleService.class).checkTotalLineAmount(paymentSchedule);
        if (Strings.isNullOrEmpty(paymentSchedule.getPaymentScheduleSeq())) {
            String num = Beans.get(SequenceService.class).getSequenceNumber(SequenceRepository.PAYMENT_SCHEDULE, paymentSchedule.getCompany());
            if (Strings.isNullOrEmpty(num)) {
                response.setError(String.format(I18n.get(IExceptionMessage.PAYMENT_SCHEDULE_5), paymentSchedule.getCompany().getName()));
            } else {
                response.setValue("paymentScheduleSeq", num);
            }
        }
    } catch (Exception e) {
        TraceBackService.trace(response, e, ResponseMessageType.ERROR);
    }
}
Also used : PaymentSchedule(com.axelor.apps.account.db.PaymentSchedule) PaymentScheduleService(com.axelor.apps.account.service.PaymentScheduleService) SequenceService(com.axelor.apps.base.service.administration.SequenceService) AxelorException(com.axelor.exception.AxelorException)

Example 14 with PaymentSchedule

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

the class PaymentScheduleController method passInIrrecoverable.

public void passInIrrecoverable(ActionRequest request, ActionResponse response) {
    PaymentSchedule paymentSchedule = request.getContext().asType(PaymentSchedule.class);
    paymentSchedule = Beans.get(PaymentScheduleRepository.class).find(paymentSchedule.getId());
    try {
        Beans.get(IrrecoverableService.class).passInIrrecoverable(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)

Example 15 with PaymentSchedule

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

the class PaymentScheduleLineBankPaymentServiceImpl method cancelInvoicePayments.

@Transactional(rollbackOn = { Exception.class })
protected void cancelInvoicePayments(PaymentScheduleLine paymentScheduleLine) throws AxelorException {
    MoveLineService moveLineService = moveService.getMoveLineService();
    PaymentSchedule paymentSchedule = paymentScheduleLine.getPaymentSchedule();
    MoveLine creditMoveLine = paymentScheduleLine.getAdvanceMoveLine();
    Set<Invoice> invoiceSet = MoreObjects.firstNonNull(paymentSchedule.getInvoiceSet(), Collections.emptySet());
    for (Invoice invoice : invoiceSet) {
        MoveLine debitMoveLine = moveLineService.getDebitCustomerMoveLine(invoice);
        Reconcile reconcile = reconcileRepo.findByMoveLines(debitMoveLine, creditMoveLine);
        if (reconcile == null) {
            continue;
        }
        for (InvoicePayment invoicePayment : invoicePaymentRepo.findByReconcile(reconcile).fetch()) {
            invoicePaymentCancelService.cancel(invoicePayment);
        }
    }
}
Also used : InvoicePayment(com.axelor.apps.account.db.InvoicePayment) MoveLineService(com.axelor.apps.account.service.move.MoveLineService) Invoice(com.axelor.apps.account.db.Invoice) 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)

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