Search in sources :

Example 1 with BankOrderService

use of com.axelor.apps.bankpayment.service.bankorder.BankOrderService in project axelor-open-suite by axelor.

the class BankOrderManagementRepository method save.

@Override
public BankOrder save(BankOrder entity) {
    try {
        BankOrderService bankOrderService = Beans.get(BankOrderService.class);
        bankOrderService.generateSequence(entity);
        bankOrderService.setSequenceOnBankOrderLines(entity);
        if (entity.getStatusSelect() == BankOrderRepository.STATUS_DRAFT) {
            bankOrderService.updateTotalAmounts(entity);
        }
        return super.save(entity);
    } catch (Exception e) {
        TraceBackService.traceExceptionFromSaveMethod(e);
        throw new PersistenceException(e.getMessage(), e);
    }
}
Also used : PersistenceException(javax.persistence.PersistenceException) BankOrderService(com.axelor.apps.bankpayment.service.bankorder.BankOrderService) PersistenceException(javax.persistence.PersistenceException)

Example 2 with BankOrderService

use of com.axelor.apps.bankpayment.service.bankorder.BankOrderService in project axelor-open-suite by axelor.

the class BankOrderController method validate.

public void validate(ActionRequest request, ActionResponse response) throws AxelorException {
    Context context = request.getContext();
    BankOrderService bankOrderService = Beans.get(BankOrderService.class);
    BankOrder bankOrder = context.asType(BankOrder.class);
    bankOrder = Beans.get(BankOrderRepository.class).find(bankOrder.getId());
    try {
        EbicsUser ebicsUser = bankOrder.getSignatoryEbicsUser();
        if (ebicsUser == null) {
            response.setError(I18n.get(IExceptionMessage.EBICS_MISSING_NAME));
        } else {
            if (ebicsUser.getEbicsPartner().getEbicsTypeSelect() == EbicsPartnerRepository.EBICS_TYPE_TS) {
                bankOrderService.validate(bankOrder);
            } else {
                if (context.get("password") == null) {
                    response.setError(I18n.get(IExceptionMessage.EBICS_WRONG_PASSWORD));
                }
                if (context.get("password") != null) {
                    String password = (String) context.get("password");
                    if (ebicsUser.getPassword() == null || !ebicsUser.getPassword().equals(password)) {
                        response.setValue("password", "");
                        response.setError(I18n.get(IExceptionMessage.EBICS_WRONG_PASSWORD));
                    } else {
                        bankOrderService.validate(bankOrder);
                    }
                }
                response.setReload(true);
            }
        }
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : Context(com.axelor.rpc.Context) EbicsUser(com.axelor.apps.bankpayment.db.EbicsUser) BankOrderService(com.axelor.apps.bankpayment.service.bankorder.BankOrderService) BankOrder(com.axelor.apps.bankpayment.db.BankOrder) AxelorException(com.axelor.exception.AxelorException)

Aggregations

BankOrderService (com.axelor.apps.bankpayment.service.bankorder.BankOrderService)2 BankOrder (com.axelor.apps.bankpayment.db.BankOrder)1 EbicsUser (com.axelor.apps.bankpayment.db.EbicsUser)1 AxelorException (com.axelor.exception.AxelorException)1 Context (com.axelor.rpc.Context)1 PersistenceException (javax.persistence.PersistenceException)1