use of com.axelor.rpc.Context in project axelor-open-suite by axelor.
the class SaleOrderLineController method supplierPartnerDomain.
/**
* Called from sale order line form. Set domain for supplier partner.
*
* @param request
* @param response
*/
public void supplierPartnerDomain(ActionRequest request, ActionResponse response) {
SaleOrderLine saleOrderLine = request.getContext().asType(SaleOrderLine.class);
String domain = "self.isContact = false AND self.isSupplier = true";
Product product = saleOrderLine.getProduct();
if (product != null) {
List<Long> authorizedPartnerIdsList = Beans.get(SaleOrderLineServiceSupplyChain.class).getSupplierPartnerList(saleOrderLine);
if (authorizedPartnerIdsList.isEmpty()) {
response.setAttr("supplierPartner", "domain", "self.id IN (0)");
return;
} else {
domain += String.format(" AND self.id IN (%s)", authorizedPartnerIdsList.stream().map(Object::toString).collect(Collectors.joining(",")));
}
}
SaleOrder saleOrder = saleOrderLine.getSaleOrder();
if (saleOrder == null) {
Context parentContext = request.getContext().getParent();
if (parentContext == null) {
response.setAttr("supplierPartner", "domain", domain);
return;
}
saleOrder = parentContext.asType(SaleOrder.class);
if (saleOrder == null) {
response.setAttr("supplierPartner", "domain", domain);
return;
}
}
String blockedPartnerQuery = Beans.get(BlockingService.class).listOfBlockedPartner(saleOrder.getCompany(), BlockingRepository.PURCHASE_BLOCKING);
if (!Strings.isNullOrEmpty(blockedPartnerQuery)) {
domain += String.format(" AND self.id NOT in (%s)", blockedPartnerQuery);
}
if (saleOrder.getCompany() != null) {
domain += " AND " + saleOrder.getCompany().getId() + " in (SELECT id FROM self.companySet)";
}
response.setAttr("supplierPartner", "domain", domain);
}
use of com.axelor.rpc.Context 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);
}
}
use of com.axelor.rpc.Context in project axelor-open-suite by axelor.
the class BankReconciliationController method validateMultipleReconcile.
public void validateMultipleReconcile(ActionRequest request, ActionResponse response) {
try {
Context context = request.getContext();
Map<String, Object> bankReconciliationContext = (Map<String, Object>) context.get("_bankReconciliation");
BankReconciliation bankReconciliation = Beans.get(BankReconciliationRepository.class).find(((Integer) bankReconciliationContext.get("id")).longValue());
List<HashMap<String, Object>> moveLinesToReconcileContext = (List<HashMap<String, Object>>) context.get("toReconcileMoveLineSet");
Map<String, Object> selectedBankReconciliationLineContext = (Map<String, Object>) context.get("_selectedBankReconciliationLine");
BankReconciliationLine bankReconciliationLine = Beans.get(BankReconciliationLineRepository.class).find(((Integer) selectedBankReconciliationLineContext.get("id")).longValue());
Beans.get(BankReconciliationValidateService.class).validateMultipleBankReconciles(bankReconciliation, bankReconciliationLine, moveLinesToReconcileContext);
response.setCanClose(true);
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
use of com.axelor.rpc.Context in project axelor-open-suite by axelor.
the class BankReconciliationLineController method setAccountDomain.
public void setAccountDomain(ActionRequest request, ActionResponse response) {
try {
Context parentContext = request.getContext().getParent();
BankReconciliation bankReconciliation = null;
if (parentContext != null && parentContext.getContextClass().toString().equals(BankReconciliation.class.toString())) {
bankReconciliation = parentContext.asType(BankReconciliation.class);
} else if (parentContext == null || !parentContext.getContextClass().toString().equals(BankReconciliation.class.toString())) {
bankReconciliation = (BankReconciliation) request.getContext().get("bankReconciliation");
}
String domain = Beans.get(BankReconciliationService.class).getAccountDomain(bankReconciliation);
response.setAttr("account", "domain", domain);
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
use of com.axelor.rpc.Context in project axelor-open-suite by axelor.
the class StockMoveLineController method compute.
public void compute(ActionRequest request, ActionResponse response) throws AxelorException {
StockMoveLine stockMoveLine = request.getContext().asType(StockMoveLine.class);
Optional<StockMove> stockMove = Optional.ofNullable(stockMoveLine.getStockMove());
if (!stockMove.isPresent()) {
Context parentContext = request.getContext().getParent();
if (parentContext.getContextClass().equals(StockMove.class)) {
stockMove = Optional.ofNullable(parentContext.asType(StockMove.class));
} else if (parentContext.getContextClass().equals(ManufOrder.class)) {
ManufOrder manufOrder = parentContext.asType(ManufOrder.class);
ManufOrderStockMoveService manufOrderStockMoveService = Beans.get(ManufOrderStockMoveService.class);
stockMove = manufOrderStockMoveService.getPlannedStockMove(manufOrder.getInStockMoveList());
}
if (!stockMove.isPresent()) {
return;
}
}
stockMoveLine = Beans.get(StockMoveLineService.class).compute(stockMoveLine, stockMove.get());
response.setValue("companyPurchasePrice", stockMoveLine.getCompanyPurchasePrice());
response.setValue("unitPriceUntaxed", stockMoveLine.getUnitPriceUntaxed());
response.setValue("unitPriceTaxed", stockMoveLine.getUnitPriceTaxed());
}
Aggregations