use of com.axelor.apps.base.db.Blocking in project axelor-open-suite by axelor.
the class SaleOrderWorkflowServiceImpl method finalizeQuotation.
@Override
@Transactional(rollbackOn = { Exception.class }, ignore = { BlockedSaleOrderException.class })
public void finalizeQuotation(SaleOrder saleOrder) throws AxelorException {
Partner partner = saleOrder.getClientPartner();
checkSaleOrderBeforeFinalization(saleOrder);
Blocking blocking = Beans.get(BlockingService.class).getBlocking(partner, saleOrder.getCompany(), BlockingRepository.SALE_BLOCKING);
if (blocking != null) {
saleOrder.setBlockedOnCustCreditExceed(true);
if (!saleOrder.getManualUnblock()) {
saleOrderRepo.save(saleOrder);
String reason = blocking.getBlockingReason() != null ? blocking.getBlockingReason().getName() : "";
throw new BlockedSaleOrderException(partner, I18n.get("Client is sale blocked:") + " " + reason);
}
}
if (saleOrder.getVersionNumber() == 1 && sequenceService.isEmptyOrDraftSequenceNumber(saleOrder.getSaleOrderSeq())) {
saleOrder.setSaleOrderSeq(this.getSequence(saleOrder.getCompany()));
}
saleOrder.setStatusSelect(SaleOrderRepository.STATUS_FINALIZED_QUOTATION);
if (appSaleService.getAppSale().getPrintingOnSOFinalization()) {
this.saveSaleOrderPDFAsAttachment(saleOrder);
}
saleOrderRepo.save(saleOrder);
}
use of com.axelor.apps.base.db.Blocking in project axelor-open-suite by axelor.
the class SaleOrderLineController method supplierPartnerDefault.
/**
* Called from sale order line form, on product change and on sale supply select change
*
* @param request
* @param response
*/
public void supplierPartnerDefault(ActionRequest request, ActionResponse response) {
SaleOrderLine saleOrderLine = request.getContext().asType(SaleOrderLine.class);
if (saleOrderLine.getSaleSupplySelect() != SaleOrderLineRepository.SALE_SUPPLY_PURCHASE) {
return;
}
SaleOrder saleOrder = saleOrderLine.getSaleOrder();
if (saleOrder == null) {
Context parentContext = request.getContext().getParent();
if (parentContext == null) {
return;
}
saleOrder = parentContext.asType(SaleOrder.class);
}
if (saleOrder == null) {
return;
}
Partner supplierPartner = null;
if (saleOrderLine.getProduct() != null) {
supplierPartner = saleOrderLine.getProduct().getDefaultSupplierPartner();
}
if (supplierPartner != null) {
Blocking blocking = Beans.get(BlockingService.class).getBlocking(supplierPartner, saleOrder.getCompany(), BlockingRepository.PURCHASE_BLOCKING);
if (blocking != null) {
supplierPartner = null;
}
}
response.setValue("supplierPartner", supplierPartner);
}
use of com.axelor.apps.base.db.Blocking in project axelor-open-suite by axelor.
the class PurchaseOrderServiceImpl method requestPurchaseOrder.
@Override
@Transactional(rollbackOn = { Exception.class })
public void requestPurchaseOrder(PurchaseOrder purchaseOrder) throws AxelorException {
purchaseOrder.setStatusSelect(PurchaseOrderRepository.STATUS_REQUESTED);
Partner partner = purchaseOrder.getSupplierPartner();
Company company = purchaseOrder.getCompany();
Blocking blocking = Beans.get(BlockingService.class).getBlocking(partner, company, BlockingRepository.PURCHASE_BLOCKING);
if (blocking != null) {
String reason = blocking.getBlockingReason() != null ? blocking.getBlockingReason().getName() : "";
throw new AxelorException(TraceBackRepository.CATEGORY_INCONSISTENCY, I18n.get(IExceptionMessage.SUPPLIER_BLOCKED) + " " + reason, partner);
}
if (purchaseOrder.getVersionNumber() == 1 && sequenceService.isEmptyOrDraftSequenceNumber(purchaseOrder.getPurchaseOrderSeq())) {
purchaseOrder.setPurchaseOrderSeq(this.getSequence(purchaseOrder.getCompany()));
}
purchaseOrderRepo.save(purchaseOrder);
if (appPurchaseService.getAppPurchase().getManagePurchaseOrderVersion()) {
this.savePurchaseOrderPDFAsAttachment(purchaseOrder);
}
}
use of com.axelor.apps.base.db.Blocking in project axelor-open-suite by axelor.
the class PurchaseOrderSupplierService method generateSuppliersRequests.
@Transactional
public void generateSuppliersRequests(PurchaseOrderLine purchaseOrderLine, PurchaseOrder purchaseOrder) {
if (purchaseOrder == null) {
return;
}
Product product = purchaseOrderLine.getProduct();
Company company = purchaseOrder.getCompany();
if (Beans.get(AppPurchaseService.class).getAppPurchase().getManageSupplierCatalog() && product != null && product.getSupplierCatalogList() != null) {
for (SupplierCatalog supplierCatalog : product.getSupplierCatalogList()) {
Partner supplierPartner = supplierCatalog.getSupplierPartner();
Blocking blocking = Beans.get(BlockingService.class).getBlocking(supplierPartner, company, BlockingRepository.PURCHASE_BLOCKING);
if (blocking == null) {
purchaseOrderLine.addPurchaseOrderSupplierLineListItem(purchaseOrderSupplierLineService.create(supplierPartner, supplierCatalog.getPrice()));
}
}
}
Beans.get(PurchaseOrderLineRepository.class).save(purchaseOrderLine);
}
Aggregations