use of com.axelor.apps.contract.db.Contract in project axelor-open-suite by axelor.
the class ContractController method invoicing.
public void invoicing(ActionRequest request, ActionResponse response) {
Contract contract = Beans.get(ContractRepository.class).find(request.getContext().asType(Contract.class).getId());
try {
Invoice invoice = Beans.get(ContractService.class).invoicingContract(contract);
response.setReload(true);
response.setView(ActionView.define(I18n.get("Invoice")).model(Invoice.class.getName()).add("form", "invoice-form").add("grid", "invoice-grid").param("search-filters", "customer-invoices-filters").param("forceTitle", "true").context("_showRecord", invoice.getId().toString()).map());
} 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 deleteNextVersion.
public void deleteNextVersion(ActionRequest request, ActionResponse response) {
final Contract contract = JPA.find(Contract.class, request.getContext().asType(Contract.class).getId());
// TODO: move this code in Service
JPA.runInTransaction(new Runnable() {
@Override
public void run() {
ContractVersion version = contract.getNextVersion();
contract.setNextVersion(null);
Beans.get(ContractVersionRepository.class).remove(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 waiting.
public void waiting(ActionRequest request, ActionResponse response) {
Contract contract = Beans.get(ContractRepository.class).find(request.getContext().asType(Contract.class).getId());
try {
Beans.get(ContractService.class).waitingCurrentVersion(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 ContractVersionController method active.
public void active(ActionRequest request, ActionResponse response) {
try {
Long id = request.getContext().asType(ContractVersion.class).getId();
ContractVersion contractVersion = Beans.get(ContractVersionRepository.class).find(id);
if (contractVersion.getNextContract() == null) {
response.setError(I18n.get(IExceptionMessage.CONTRACT_VERSION_EMPTY_NEXT_CONTRACT));
return;
}
Beans.get(ContractService.class).activeNextVersion(contractVersion.getNextContract(), getTodayDate(contractVersion.getNextContract().getCompany()));
response.setView(ActionView.define("Contract").model(Contract.class.getName()).add("form", "contract-form").add("grid", "contract-grid").param("search-filters", "contract-filters").context("_showRecord", contractVersion.getContract().getId()).map());
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
use of com.axelor.apps.contract.db.Contract in project axelor-open-suite by axelor.
the class ContractVersionController method save.
public void save(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;
}
// TODO: move in service
JPA.runInTransaction(() -> {
Contract contract = JPA.find(Contract.class, contractId);
contract.setNextVersion(version);
Beans.get(ContractRepository.class).save(contract);
});
response.setReload(true);
}
Aggregations