use of com.axelor.apps.account.db.Invoice in project axelor-open-suite by axelor.
the class InvoicePaymentCreateServiceImpl method getInvoiceIdsToPay.
@Override
public List<Long> getInvoiceIdsToPay(List<Long> invoiceIdList) throws AxelorException {
Company company = null;
Currency currency = null;
List<Long> invoiceToPay = new ArrayList<>();
Boolean isActivatePassedForPayment = Beans.get(AppAccountService.class).getAppAccount().getActivatePassedForPayment();
for (Long invoiceId : invoiceIdList) {
Invoice invoice = Beans.get(InvoiceRepository.class).find(invoiceId);
if ((invoice.getStatusSelect() != InvoiceRepository.STATUS_VENTILATED && invoice.getOperationSubTypeSelect() != InvoiceRepository.OPERATION_SUB_TYPE_ADVANCE) || (invoice.getOperationSubTypeSelect() == InvoiceRepository.OPERATION_SUB_TYPE_ADVANCE && invoice.getStatusSelect() != InvoiceRepository.STATUS_VALIDATED)) {
continue;
}
if (invoice.getAmountRemaining().compareTo(BigDecimal.ZERO) <= 0) {
continue;
}
if (company == null) {
company = invoice.getCompany();
}
if (currency == null) {
currency = invoice.getCurrency();
}
if (invoice.getCompany() == null || company == null || !invoice.getCompany().equals(company)) {
throw new AxelorException(TraceBackRepository.CATEGORY_INCONSISTENCY, I18n.get(IExceptionMessage.INVOICE_MERGE_ERROR_COMPANY));
}
if (invoice.getCurrency() == null || currency == null || !invoice.getCurrency().equals(currency)) {
throw new AxelorException(TraceBackRepository.CATEGORY_INCONSISTENCY, I18n.get(IExceptionMessage.INVOICE_MERGE_ERROR_CURRENCY));
}
if (isActivatePassedForPayment && invoice.getPfpValidateStatusSelect() != InvoiceRepository.PFP_STATUS_VALIDATED) {
throw new AxelorException(TraceBackRepository.CATEGORY_INCONSISTENCY, I18n.get(IExceptionMessage.INVOICE_MASS_PAYMENT_ERROR_PFP_LITIGATION));
}
invoiceToPay.add(invoiceId);
}
return invoiceToPay;
}
use of com.axelor.apps.account.db.Invoice in project axelor-open-suite by axelor.
the class PaymentVoucherConfirmService method waitForDepositSlip.
private void waitForDepositSlip(PaymentVoucher paymentVoucher) {
for (PayVoucherElementToPay payVoucherElementToPay : paymentVoucher.getPayVoucherElementToPayList()) {
Invoice invoice = payVoucherElementToPay.getMoveLine().getMove().getInvoice();
boolean hasPendingPayments = payVoucherElementToPay.getRemainingAmountAfterPayment().signum() <= 0;
invoice.setHasPendingPayments(hasPendingPayments);
}
paymentVoucher.setStatusSelect(PaymentVoucherRepository.STATUS_WAITING_FOR_DEPOSIT_SLIP);
}
use of com.axelor.apps.account.db.Invoice in project axelor-open-suite by axelor.
the class ClientViewServiceImpl method getTotalRemainingIndicator.
protected String getTotalRemainingIndicator(User user) {
List<Filter> filters = getTotalRemainingOfUser(user);
List<Invoice> invoiceList = Filter.and(filters).build(Invoice.class).fetch();
if (!invoiceList.isEmpty()) {
BigDecimal total = invoiceList.stream().map(Invoice::getAmountRemaining).reduce((x, y) -> x.add(y)).orElse(BigDecimal.ZERO);
return total.toString() + invoiceList.get(0).getCurrency().getSymbol();
}
return BigDecimal.ZERO.toString();
}
use of com.axelor.apps.account.db.Invoice in project axelor-open-suite by axelor.
the class InvoiceController method exportAnnex.
public void exportAnnex(ActionRequest request, ActionResponse response) throws AxelorException {
Invoice invoice = Beans.get(InvoiceRepository.class).find(request.getContext().asType(Invoice.class).getId());
try {
List<String> reportInfo = Beans.get(InvoiceServiceProjectImpl.class).editInvoiceAnnex(invoice, invoice.getId().toString(), false);
if (reportInfo == null || reportInfo.isEmpty()) {
return;
}
response.setView(ActionView.define(reportInfo.get(0)).add("html", reportInfo.get(1)).map());
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
use of com.axelor.apps.account.db.Invoice in project axelor-open-suite by axelor.
the class InvoiceController method fillEstimatedPaymentDate.
public void fillEstimatedPaymentDate(ActionRequest request, ActionResponse response) {
Invoice invoice = request.getContext().asType(Invoice.class);
try {
LocalDate estimatedPaymentDate = Beans.get(InvoiceEstimatedPaymentService.class).computeEstimatedPaymentDate(invoice);
response.setValue("estimatedPaymentDate", estimatedPaymentDate);
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
Aggregations