Search in sources :

Example 6 with SupplierCatalog

use of com.axelor.apps.purchase.db.SupplierCatalog 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);
}
Also used : PurchaseOrderLineRepository(com.axelor.apps.purchase.db.repo.PurchaseOrderLineRepository) Company(com.axelor.apps.base.db.Company) Blocking(com.axelor.apps.base.db.Blocking) BlockingService(com.axelor.apps.base.service.BlockingService) Product(com.axelor.apps.base.db.Product) SupplierCatalog(com.axelor.apps.purchase.db.SupplierCatalog) Partner(com.axelor.apps.base.db.Partner) Transactional(com.google.inject.persist.Transactional)

Aggregations

SupplierCatalog (com.axelor.apps.purchase.db.SupplierCatalog)6 Product (com.axelor.apps.base.db.Product)4 Currency (com.axelor.apps.base.db.Currency)3 BigDecimal (java.math.BigDecimal)3 Partner (com.axelor.apps.base.db.Partner)2 Blocking (com.axelor.apps.base.db.Blocking)1 Company (com.axelor.apps.base.db.Company)1 BlockingService (com.axelor.apps.base.service.BlockingService)1 PurchaseOrderLineRepository (com.axelor.apps.purchase.db.repo.PurchaseOrderLineRepository)1 SupplierCatalogRepository (com.axelor.apps.purchase.db.repo.SupplierCatalogRepository)1 AxelorException (com.axelor.exception.AxelorException)1 Transactional (com.google.inject.persist.Transactional)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1