use of com.axelor.apps.account.db.PaymentMode in project axelor-open-suite by axelor.
the class InvoicePaymentToolServiceImpl method findCompatibleBankDetails.
/**
* @inheritDoc
*/
@Override
public List<BankDetails> findCompatibleBankDetails(Company company, InvoicePayment invoicePayment) {
PaymentMode paymentMode = invoicePayment.getPaymentMode();
if (company == null || paymentMode == null) {
return new ArrayList<BankDetails>();
}
paymentMode = Beans.get(PaymentModeRepository.class).find(invoicePayment.getPaymentMode().getId());
return Beans.get(PaymentModeService.class).getCompatibleBankDetailsList(paymentMode, company);
}
use of com.axelor.apps.account.db.PaymentMode in project axelor-open-suite by axelor.
the class StockMoveInvoiceController method generateInvoiceConcatInStockMove.
/**
* Called from mass invoicing in stock move confirm view. Get parameters entered by the user, then
* call {@link StockMoveMultiInvoiceService#createInvoiceFromMultiIncomingStockMove(List,
* PaymentCondition, PaymentMode, Partner)} and show the generated invoice.
*
* @param request
* @param response
*/
public void generateInvoiceConcatInStockMove(ActionRequest request, ActionResponse response) {
try {
List<StockMove> stockMoveList = new ArrayList<>();
String stockMoveListStr = (String) request.getContext().get("supplierStockMoveToInvoice");
for (String stockMoveId : stockMoveListStr.split(",")) {
stockMoveList.add(JPA.em().find(StockMove.class, new Long(stockMoveId)));
}
PaymentCondition paymentCondition = null;
PaymentMode paymentMode = null;
Partner contactPartner = null;
if (request.getContext().get("paymentCondition") != null) {
paymentCondition = JPA.em().find(PaymentCondition.class, Long.valueOf((Integer) ((Map) request.getContext().get("paymentCondition")).get("id")));
}
if (request.getContext().get("paymentMode") != null) {
paymentMode = JPA.em().find(PaymentMode.class, Long.valueOf((Integer) ((Map) request.getContext().get("paymentMode")).get("id")));
}
if (request.getContext().get("contactPartner") != null) {
contactPartner = JPA.em().find(Partner.class, Long.valueOf((Integer) ((Map) request.getContext().get("contactPartner")).get("id")));
}
Optional<Invoice> invoice = Beans.get(StockMoveMultiInvoiceService.class).createInvoiceFromMultiIncomingStockMove(stockMoveList, paymentCondition, paymentMode, contactPartner);
invoice.ifPresent(inv -> response.setView(ActionView.define("Invoice").model(Invoice.class.getName()).add("grid", "invoice-grid").add("form", "invoice-form").param("search-filters", "customer-invoices-filters").param("forceEdit", "true").context("_showRecord", String.valueOf(inv.getId())).context("_operationTypeSelect", inv.getOperationTypeSelect()).context("todayDate", Beans.get(AppSupplychainService.class).getTodayDate(inv.getCompany())).map()));
response.setCanClose(true);
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
use of com.axelor.apps.account.db.PaymentMode in project axelor-open-suite by axelor.
the class BankOrderMergeServiceImpl method mergeBankOrders.
@Transactional(rollbackOn = { Exception.class })
public BankOrder mergeBankOrders(Collection<BankOrder> bankOrders) throws AxelorException {
if (bankOrders == null || bankOrders.size() <= 1) {
throw new AxelorException(TraceBackRepository.CATEGORY_INCONSISTENCY, IExceptionMessage.BANK_ORDER_MERGE_AT_LEAST_TWO_BANK_ORDERS);
}
this.checkSameElements(bankOrders);
BankOrder bankOrder = bankOrders.iterator().next();
bankOrders.remove(bankOrder);
bankOrder.setSenderLabel(null);
bankOrder.setSenderReference(null);
bankOrder.setBankOrderDate(Beans.get(AppBaseService.class).getTodayDate(bankOrder.getSenderCompany()));
bankOrder.setSignatoryUser(null);
bankOrder.setSignatoryEbicsUser(null);
PaymentMode paymentMode = bankOrder.getPaymentMode();
for (BankOrderLine bankOrderLine : this.getAllBankOrderLineList(bankOrders)) {
bankOrder.addBankOrderLineListItem(bankOrderLine);
}
bankOrderRepo.save(bankOrder);
for (BankOrder bankOrderToRemove : bankOrders) {
bankOrderToRemove = bankOrderRepo.find(bankOrderToRemove.getId());
List<InvoicePayment> invoicePaymentList = invoicePaymentRepo.findByBankOrder(bankOrderToRemove).fetch();
for (InvoicePayment invoicePayment : invoicePaymentList) {
invoicePayment.setBankOrder(bankOrder);
}
bankOrderRepo.remove(bankOrderToRemove);
}
if (paymentMode.getConsoBankOrderLinePerPartner()) {
consolidatePerPartner(bankOrder);
}
bankOrderService.updateTotalAmounts(bankOrder);
return bankOrderRepo.save(bankOrder);
}
use of com.axelor.apps.account.db.PaymentMode in project axelor-open-suite by axelor.
the class BankOrderServiceImpl method confirm.
@Override
@Transactional(rollbackOn = { Exception.class })
public void confirm(BankOrder bankOrder) throws AxelorException, JAXBException, IOException, DatatypeConfigurationException {
checkBankDetails(bankOrder.getSenderBankDetails(), bankOrder);
if (bankOrder.getGeneratedMetaFile() == null) {
checkLines(bankOrder);
}
setNbOfLines(bankOrder);
setSequenceOnBankOrderLines(bankOrder);
generateFile(bankOrder);
PaymentMode paymentMode = bankOrder.getPaymentMode();
if (Beans.get(AppBankPaymentService.class).getAppBankPayment().getEnableEbicsModule() && paymentMode != null && paymentMode.getAutomaticTransmission()) {
bankOrder.setConfirmationDateTime(Beans.get(AppBaseService.class).getTodayDateTime().toLocalDateTime());
bankOrder.setStatusSelect(BankOrderRepository.STATUS_AWAITING_SIGNATURE);
makeEbicsUserFollow(bankOrder);
bankOrderRepo.save(bankOrder);
} else {
validate(bankOrder);
}
}
use of com.axelor.apps.account.db.PaymentMode in project axelor-open-suite by axelor.
the class BatchDirectDebit method start.
@Override
protected void start() throws IllegalAccessException {
super.start();
PaymentMode directDebitPaymentMode = batch.getAccountingBatch().getPaymentMode();
generateBankOrderFlag = directDebitPaymentMode != null && directDebitPaymentMode.getGenerateBankOrder();
}
Aggregations