Search in sources :

Example 1 with ContractLineService

use of com.axelor.apps.contract.service.ContractLineService in project axelor-open-suite by axelor.

the class ContractController method changeProduct.

public void changeProduct(ActionRequest request, ActionResponse response) {
    ContractLineService contractLineService = Beans.get(ContractLineService.class);
    ContractLine contractLine = new ContractLine();
    try {
        contractLine = request.getContext().asType(ContractLine.class);
        Contract contract = request.getContext().getParent().asType(Contract.class);
        Product product = contractLine.getProduct();
        contractLine = contractLineService.fillAndCompute(contractLine, contract, product);
        response.setValues(contractLine);
    } catch (Exception e) {
        response.setValues(contractLineService.reset(contractLine));
    }
}
Also used : ContractLine(com.axelor.apps.contract.db.ContractLine) ContractLineService(com.axelor.apps.contract.service.ContractLineService) Product(com.axelor.apps.base.db.Product) Contract(com.axelor.apps.contract.db.Contract)

Example 2 with ContractLineService

use of com.axelor.apps.contract.service.ContractLineService in project axelor-open-suite by axelor.

the class ContractVersionController method changeProduct.

public void changeProduct(ActionRequest request, ActionResponse response) {
    ContractLineService contractLineService = Beans.get(ContractLineService.class);
    ContractLine contractLine = new ContractLine();
    try {
        contractLine = request.getContext().asType(ContractLine.class);
        ContractVersion contractVersion = request.getContext().getParent().asType(ContractVersion.class);
        Contract contract = contractVersion.getNextContract() == null ? contractVersion.getContract() : contractVersion.getNextContract();
        Product product = contractLine.getProduct();
        contractLine = contractLineService.fillAndCompute(contractLine, contract, product);
        response.setValues(contractLine);
    } catch (Exception e) {
        response.setValues(contractLineService.reset(contractLine));
    }
}
Also used : ContractLine(com.axelor.apps.contract.db.ContractLine) ContractLineService(com.axelor.apps.contract.service.ContractLineService) Product(com.axelor.apps.base.db.Product) ContractVersion(com.axelor.apps.contract.db.ContractVersion) Contract(com.axelor.apps.contract.db.Contract)

Example 3 with ContractLineService

use of com.axelor.apps.contract.service.ContractLineService in project axelor-open-suite by axelor.

the class ContractLineController method computeTotal.

public void computeTotal(ActionRequest request, ActionResponse response) {
    ContractLine contractLine = request.getContext().asType(ContractLine.class);
    ContractLineService contractLineService = Beans.get(ContractLineService.class);
    try {
        contractLine = contractLineService.computeTotal(contractLine);
        response.setValues(contractLine);
    } catch (Exception e) {
        response.setValues(contractLineService.reset(contractLine));
    }
}
Also used : ContractLine(com.axelor.apps.contract.db.ContractLine) ContractLineService(com.axelor.apps.contract.service.ContractLineService)

Example 4 with ContractLineService

use of com.axelor.apps.contract.service.ContractLineService in project axelor-open-suite by axelor.

the class ContractTemplateController method changeProduct.

public void changeProduct(ActionRequest request, ActionResponse response) {
    ContractLineService contractLineService = Beans.get(ContractLineService.class);
    ContractLine contractLine = new ContractLine();
    try {
        contractLine = request.getContext().asType(ContractLine.class);
        Product product = contractLine.getProduct();
        contractLine = contractLineService.fill(contractLine, product);
        response.setValues(contractLine);
    } catch (Exception e) {
        response.setValues(contractLineService.reset(contractLine));
    }
}
Also used : ContractLine(com.axelor.apps.contract.db.ContractLine) ContractLineService(com.axelor.apps.contract.service.ContractLineService) Product(com.axelor.apps.base.db.Product)

Aggregations

ContractLine (com.axelor.apps.contract.db.ContractLine)4 ContractLineService (com.axelor.apps.contract.service.ContractLineService)4 Product (com.axelor.apps.base.db.Product)3 Contract (com.axelor.apps.contract.db.Contract)2 ContractVersion (com.axelor.apps.contract.db.ContractVersion)1