use of com.axelor.apps.account.db.InvoicePayment in project axelor-open-suite by axelor.
the class InvoiceManagementRepository method save.
@Override
public Invoice save(Invoice invoice) {
try {
List<InvoicePayment> invoicePayments = invoice.getInvoicePaymentList();
if (CollectionUtils.isNotEmpty(invoicePayments)) {
LocalDate latestPaymentDate = invoicePayments.stream().filter(invoicePayment -> invoicePayment.getStatusSelect() == InvoicePaymentRepository.STATUS_VALIDATED).map(InvoicePayment::getPaymentDate).max(LocalDate::compareTo).orElse(null);
invoice.setPaymentDate(latestPaymentDate);
}
invoice = super.save(invoice);
Beans.get(InvoiceService.class).setDraftSequence(invoice);
return invoice;
} catch (Exception e) {
TraceBackService.traceExceptionFromSaveMethod(e);
throw new PersistenceException(e.getMessage(), e);
}
}
use of com.axelor.apps.account.db.InvoicePayment in project axelor-open-suite by axelor.
the class BankOrderServiceImpl method validatePayment.
@Override
@Transactional(rollbackOn = { Exception.class })
public void validatePayment(BankOrder bankOrder) throws AxelorException {
List<InvoicePayment> invoicePaymentList = invoicePaymentRepo.findByBankOrder(bankOrder).fetch();
InvoicePaymentValidateServiceBankPayImpl invoicePaymentValidateServiceBankPayImpl = Beans.get(InvoicePaymentValidateServiceBankPayImpl.class);
for (InvoicePayment invoicePayment : invoicePaymentList) {
if (invoicePayment != null && invoicePayment.getStatusSelect() != InvoicePaymentRepository.STATUS_VALIDATED && invoicePayment.getInvoice() != null) {
if (bankOrderLineOriginService.existBankOrderLineOrigin(bankOrder, invoicePayment.getInvoice())) {
invoicePaymentValidateServiceBankPayImpl.validateFromBankOrder(invoicePayment, true);
}
}
}
}
use of com.axelor.apps.account.db.InvoicePayment 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);
}
}
}
use of com.axelor.apps.account.db.InvoicePayment in project axelor-open-suite by axelor.
the class ReconcileServiceImpl method updateInvoicePaymentsCanceled.
public void updateInvoicePaymentsCanceled(Reconcile reconcile) throws AxelorException {
log.debug("updateInvoicePaymentsCanceled : reconcile : {}", reconcile);
List<InvoicePayment> invoicePaymentList = Beans.get(InvoicePaymentRepository.class).all().filter("self.reconcile = ?1", reconcile).fetch();
for (InvoicePayment invoicePayment : invoicePaymentList) {
invoicePaymentCancelService.updateCancelStatus(invoicePayment);
}
}
use of com.axelor.apps.account.db.InvoicePayment in project axelor-open-suite by axelor.
the class BatchBankPaymentServiceImpl method createBankOrders.
@Transactional(rollbackOn = { Exception.class })
protected void createBankOrders(Batch batch, Reconcile reconcile) throws AxelorException, JAXBException, IOException, DatatypeConfigurationException {
for (InvoicePayment invoicePayment : invoicePaymentRepo.findByReconcile(reconcile).fetch()) {
if (invoicePayment.getBankOrder() != null) {
continue;
}
invoicePaymentValidateService.validate(invoicePayment, true);
if (invoicePayment.getBankOrder() == null) {
throw new AxelorException(invoicePayment, TraceBackRepository.CATEGORY_INCONSISTENCY, I18n.get("Failed to create bank order from invoice payment"));
}
invoicePayment.getBankOrder().setBatch(batch);
bankOrderRepo.save(invoicePayment.getBankOrder());
}
}
Aggregations