use of com.axelor.apps.contract.db.Contract in project axelor-open-suite by axelor.
the class ContractVersionController method newDraft.
public void newDraft(ActionRequest request, ActionResponse response) {
Long contractId = Long.valueOf(request.getContext().get("_xContractId").toString());
Contract contract = Beans.get(ContractRepository.class).find(contractId);
ContractVersion newVersion = Beans.get(ContractVersionService.class).newDraft(contract);
response.setValues(Mapper.toMap(newVersion));
}
use of com.axelor.apps.contract.db.Contract in project axelor-open-suite by axelor.
the class ContractController method saveNextVersion.
public void saveNextVersion(ActionRequest request, ActionResponse response) {
final ContractVersion version = JPA.find(ContractVersion.class, request.getContext().asType(ContractVersion.class).getId());
if (version.getNextContract() != null) {
return;
}
Object xContractId = request.getContext().get("_xContractId");
Long contractId;
if (xContractId != null) {
contractId = Long.valueOf(xContractId.toString());
} else if (version.getContract() != null) {
contractId = version.getContract().getId();
} else {
contractId = null;
}
if (contractId == null) {
return;
}
JPA.runInTransaction(new Runnable() {
@Override
public void run() {
Contract contract = JPA.find(Contract.class, contractId);
contract.setNextVersion(version);
Beans.get(ContractRepository.class).save(contract);
}
});
response.setReload(true);
}
use of com.axelor.apps.contract.db.Contract in project axelor-open-suite by axelor.
the class ContractController method renew.
public void renew(ActionRequest request, ActionResponse response) {
Contract contract = Beans.get(ContractRepository.class).find(request.getContext().asType(Contract.class).getId());
try {
Beans.get(ContractService.class).renewContract(contract, getTodayDate(contract.getCompany()));
response.setReload(true);
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
use of com.axelor.apps.contract.db.Contract 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));
}
}
use of com.axelor.apps.contract.db.Contract in project axelor-open-suite by axelor.
the class ContractController method close.
public void close(ActionRequest request, ActionResponse response) {
Contract contract = Beans.get(ContractRepository.class).find(request.getContext().asType(Contract.class).getId());
ContractService service = Beans.get(ContractService.class);
try {
service.checkCanTerminateContract(contract);
service.close(contract, contract.getTerminatedDate());
response.setReload(true);
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
Aggregations