use of com.axelor.apps.account.db.Notification in project axelor-open-suite by axelor.
the class NotificationServiceImpl method populateNotificationItemList.
@Override
public void populateNotificationItemList(Notification notification) {
notification.clearNotificationItemList();
Comparator<Invoice> byInvoiceDate = (i1, i2) -> i1.getInvoiceDate().compareTo(i2.getInvoiceDate());
Comparator<Invoice> byDueDate = (i1, i2) -> i1.getDueDate().compareTo(i2.getDueDate());
Comparator<Invoice> byInvoiceId = (i1, i2) -> i1.getInvoiceId().compareTo(i2.getInvoiceId());
List<Invoice> invoiceList = new ArrayList<Invoice>();
if (notification.getSubrogationRelease() != null) {
invoiceList = notification.getSubrogationRelease().getInvoiceSet().stream().sorted(byInvoiceDate.thenComparing(byDueDate).thenComparing(byInvoiceId)).collect(Collectors.toList());
}
for (Invoice invoice : invoiceList) {
if (invoice.getAmountRemaining().signum() > 0) {
notification.addNotificationItemListItem(createNotificationItem(invoice));
}
}
}
use of com.axelor.apps.account.db.Notification in project axelor-open-suite by axelor.
the class NotificationController method validate.
public void validate(ActionRequest request, ActionResponse response) {
try {
Notification notification = request.getContext().asType(Notification.class);
notification = Beans.get(NotificationRepository.class).find(notification.getId());
Beans.get(NotificationService.class).validate(notification);
response.setReload(true);
} catch (Exception e) {
TraceBackService.trace(response, e, ResponseMessageType.ERROR);
}
}
use of com.axelor.apps.account.db.Notification in project axelor-open-suite by axelor.
the class NotificationController method populateNotificationItemList.
public void populateNotificationItemList(ActionRequest request, ActionResponse response) {
try {
Notification notification = request.getContext().asType(Notification.class);
Beans.get(NotificationService.class).populateNotificationItemList(notification);
response.setValue("notificationItemList", notification.getNotificationItemList());
} catch (Exception e) {
TraceBackService.trace(response, e, ResponseMessageType.ERROR);
}
}
use of com.axelor.apps.account.db.Notification in project axelor-open-suite by axelor.
the class NotificationController method displayMoveLines.
public void displayMoveLines(ActionRequest request, ActionResponse response) {
try {
Notification notification = request.getContext().asType(Notification.class);
List<Long> moveLineIdList = new ArrayList<Long>();
for (NotificationItem notificationItem : notification.getNotificationItemList()) {
for (MoveLine moveLine : notificationItem.getMove().getMoveLineList()) {
moveLineIdList.add(moveLine.getId());
}
}
response.setView(ActionView.define("MoveLines").model(MoveLine.class.getName()).add("grid", "move-line-grid").add("form", "move-line-form").param("search-filters", "move-line-filters").domain("self.id in (" + Joiner.on(",").join(moveLineIdList) + ")").map());
} catch (Exception e) {
TraceBackService.trace(response, e, ResponseMessageType.ERROR);
}
}
use of com.axelor.apps.account.db.Notification in project axelor-open-suite by axelor.
the class NotificationServiceImpl method createPaymentMove.
@Transactional(rollbackOn = { Exception.class })
protected Move createPaymentMove(NotificationItem notificationItem) throws AxelorException {
Notification notification = notificationItem.getNotification();
Invoice invoice = notificationItem.getInvoice();
Company company = invoice.getCompany();
AccountConfig accountConfig = accountConfigService.getAccountConfig(company);
Journal journal = getJournal(accountConfig);
SubrogationRelease subrogationRelease = getSubrogationRelease(notificationItem);
String origin = computeOrigin(subrogationRelease, invoice);
BigDecimal amountPaid = notificationItem.getAmountPaid();
if (amountPaid.compareTo(BigDecimal.ZERO) == 0) {
return null;
}
Move paymentMove = moveService.getMoveCreateService().createMove(journal, company, company.getCurrency(), invoice.getPartner(), notification.getPaymentDate(), null, MoveRepository.TECHNICAL_ORIGIN_AUTOMATIC, MoveRepository.FUNCTIONAL_ORIGIN_PAYMENT);
MoveLine creditMoveLine, debitMoveLine;
Account account = getAccount(accountConfig, notificationItem);
debitMoveLine = moveService.getMoveLineService().createMoveLine(paymentMove, invoice.getPartner(), account, amountPaid, true, notification.getPaymentDate(), null, 1, origin, invoice.getInvoiceId());
creditMoveLine = moveService.getMoveLineService().createMoveLine(paymentMove, invoice.getPartner(), invoice.getPartnerAccount(), amountPaid, false, notification.getPaymentDate(), null, 2, origin, invoice.getInvoiceId());
paymentMove.addMoveLineListItem(debitMoveLine);
paymentMove.addMoveLineListItem(creditMoveLine);
paymentMove = moveRepository.save(paymentMove);
moveService.getMoveValidateService().validate(paymentMove);
MoveLine invoiceMoveLine = findInvoiceAccountMoveLine(invoice);
MoveLine subrogationReleaseMoveLine = findSubrogationReleaseAccountMoveLine(invoice);
if (invoiceMoveLine.getAmountRemaining().compareTo(BigDecimal.ZERO) == 1) {
reconcileService.reconcile(invoiceMoveLine, creditMoveLine, true, true);
if (subrogationReleaseMoveLine != null && notificationItem.getTypeSelect() == NotificationRepository.TYPE_PAYMENT_TO_THE_FACTORE) {
reconcileService.reconcile(debitMoveLine, subrogationReleaseMoveLine, true, false);
}
}
notificationItem.setMove(paymentMove);
if (subrogationRelease != null) {
subrogationReleaseService.clear(subrogationRelease);
}
return paymentMove;
}
Aggregations