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