Search in sources :

Example 71 with PurchaseOrderLine

use of com.axelor.apps.purchase.db.PurchaseOrderLine in project axelor-open-suite by axelor.

the class PurchaseOrderSupplierService method splitBySupplierPartner.

public Map<Partner, List<PurchaseOrderLine>> splitBySupplierPartner(List<PurchaseOrderLine> purchaseOrderLineList) throws AxelorException {
    Map<Partner, List<PurchaseOrderLine>> purchaseOrderLinesBySupplierPartner = new HashMap<>();
    for (PurchaseOrderLine purchaseOrderLine : purchaseOrderLineList) {
        Partner supplierPartner = purchaseOrderLine.getSupplierPartner();
        if (supplierPartner == null) {
            throw new AxelorException(purchaseOrderLine, TraceBackRepository.CATEGORY_CONFIGURATION_ERROR, I18n.get(IExceptionMessage.SO_PURCHASE_1), purchaseOrderLine.getProductName());
        }
        if (!purchaseOrderLinesBySupplierPartner.containsKey(supplierPartner)) {
            purchaseOrderLinesBySupplierPartner.put(supplierPartner, new ArrayList<PurchaseOrderLine>());
        }
        purchaseOrderLinesBySupplierPartner.get(supplierPartner).add(purchaseOrderLine);
    }
    return purchaseOrderLinesBySupplierPartner;
}
Also used : PurchaseOrderLine(com.axelor.apps.purchase.db.PurchaseOrderLine) AxelorException(com.axelor.exception.AxelorException) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) List(java.util.List) Partner(com.axelor.apps.base.db.Partner)

Example 72 with PurchaseOrderLine

use of com.axelor.apps.purchase.db.PurchaseOrderLine in project axelor-open-suite by axelor.

the class PurchaseOrderSupplychainRepository method copy.

@Override
public PurchaseOrder copy(PurchaseOrder entity, boolean deep) {
    PurchaseOrder copy = super.copy(entity, deep);
    if (!appService.isApp("supplychain")) {
        return copy;
    }
    copy.setReceiptState(PurchaseOrderRepository.STATE_NOT_RECEIVED);
    copy.setAmountInvoiced(null);
    if (copy.getPurchaseOrderLineList() != null) {
        for (PurchaseOrderLine purchaseOrderLine : copy.getPurchaseOrderLineList()) {
            purchaseOrderLine.setReceiptState(null);
            purchaseOrderLine.setReceivedQty(null);
            purchaseOrderLine.setAmountInvoiced(null);
            purchaseOrderLine.setInvoiced(null);
        }
    }
    return copy;
}
Also used : PurchaseOrderLine(com.axelor.apps.purchase.db.PurchaseOrderLine) PurchaseOrder(com.axelor.apps.purchase.db.PurchaseOrder)

Example 73 with PurchaseOrderLine

use of com.axelor.apps.purchase.db.PurchaseOrderLine in project axelor-open-suite by axelor.

the class PurchaseOrderSupplierLineController method supplierPartnerDomain.

/**
 * Called on supplier partner select. Set the domain for the field supplierPartner
 *
 * @param request
 * @param response
 */
public void supplierPartnerDomain(ActionRequest request, ActionResponse response) {
    PurchaseOrderSupplierLine purchaseOrderSupplierLine = request.getContext().asType(PurchaseOrderSupplierLine.class);
    PurchaseOrderLine purchaseOrderLine = purchaseOrderSupplierLine.getPurchaseOrderLine();
    if (purchaseOrderLine == null) {
        purchaseOrderLine = request.getContext().getParent().asType(PurchaseOrderLine.class);
    }
    PurchaseOrder purchaseOrder = request.getContext().getParent().getParent().asType(PurchaseOrder.class);
    if (purchaseOrder.getId() != null) {
        purchaseOrder = purchaseOrderLine.getPurchaseOrder();
    }
    Company company = purchaseOrder.getCompany();
    String domain = "";
    if (Beans.get(AppPurchaseService.class).getAppPurchase().getManageSupplierCatalog() && purchaseOrderLine.getProduct() != null && !purchaseOrderLine.getProduct().getSupplierCatalogList().isEmpty()) {
        domain += "self.id != " + company.getPartner().getId() + " AND self.id IN " + purchaseOrderLine.getProduct().getSupplierCatalogList().stream().map(s -> s.getSupplierPartner().getId()).collect(Collectors.toList()).toString().replace('[', '(').replace(']', ')');
        String blockedPartnerQuery = Beans.get(BlockingService.class).listOfBlockedPartner(company, BlockingRepository.PURCHASE_BLOCKING);
        if (!Strings.isNullOrEmpty(blockedPartnerQuery)) {
            domain += String.format(" AND self.id NOT in (%s)", blockedPartnerQuery);
        }
    } else {
        domain += "self.id = 0";
    }
    domain += " AND " + company.getId() + " in (SELECT id FROM self.companySet)";
    response.setAttr("supplierPartner", "domain", domain);
}
Also used : PurchaseOrderLine(com.axelor.apps.purchase.db.PurchaseOrderLine) Company(com.axelor.apps.base.db.Company) PurchaseOrderSupplierLine(com.axelor.apps.suppliermanagement.db.PurchaseOrderSupplierLine) BlockingService(com.axelor.apps.base.service.BlockingService) PurchaseOrder(com.axelor.apps.purchase.db.PurchaseOrder)

Example 74 with PurchaseOrderLine

use of com.axelor.apps.purchase.db.PurchaseOrderLine in project axelor-open-suite by axelor.

the class WorkflowVentilationProjectServiceImpl method afterVentilation.

@Override
@Transactional(rollbackOn = { Exception.class })
public void afterVentilation(Invoice invoice) throws AxelorException {
    super.afterVentilation(invoice);
    if (!Beans.get(AppBusinessProjectService.class).isApp("business-project")) {
        return;
    }
    InvoicingProject invoicingProject = invoicingProjectRepo.all().filter("self.invoice.id = ?", invoice.getId()).fetchOne();
    if (invoicingProject != null) {
        for (SaleOrderLine saleOrderLine : invoicingProject.getSaleOrderLineSet()) {
            saleOrderLine.setInvoiced(true);
        }
        for (PurchaseOrderLine purchaseOrderLine : invoicingProject.getPurchaseOrderLineSet()) {
            purchaseOrderLine.setInvoiced(true);
        }
        for (TimesheetLine timesheetLine : invoicingProject.getLogTimesSet()) {
            timesheetLine.setInvoiced(true);
            if (timesheetLine.getProjectTask() == null) {
                continue;
            }
            timesheetLine.getProjectTask().setInvoiced(this.checkInvoicedTimesheetLines(timesheetLine.getProjectTask()));
        }
        for (ExpenseLine expenseLine : invoicingProject.getExpenseLineSet()) {
            expenseLine.setInvoiced(true);
        }
        for (ProjectTask projectTask : invoicingProject.getProjectTaskSet()) {
            projectTask.setInvoiced(true);
        }
        for (Project project : invoicingProject.getProjectSet()) {
            project.setInvoiced(true);
        }
        invoicingProject.setStatusSelect(InvoicingProjectRepository.STATUS_VENTILATED);
        invoicingProjectRepo.save(invoicingProject);
    }
}
Also used : PurchaseOrderLine(com.axelor.apps.purchase.db.PurchaseOrderLine) InvoicingProject(com.axelor.apps.businessproject.db.InvoicingProject) Project(com.axelor.apps.project.db.Project) TimesheetLine(com.axelor.apps.hr.db.TimesheetLine) ExpenseLine(com.axelor.apps.hr.db.ExpenseLine) ProjectTask(com.axelor.apps.project.db.ProjectTask) SaleOrderLine(com.axelor.apps.sale.db.SaleOrderLine) InvoicingProject(com.axelor.apps.businessproject.db.InvoicingProject) Transactional(com.google.inject.persist.Transactional)

Example 75 with PurchaseOrderLine

use of com.axelor.apps.purchase.db.PurchaseOrderLine in project axelor-open-suite by axelor.

the class ProjectAnalyticMoveLineServiceImpl method updateLines.

@Override
@Transactional(rollbackOn = Exception.class)
public PurchaseOrder updateLines(PurchaseOrder purchaseOrder) {
    for (PurchaseOrderLine orderLine : purchaseOrder.getPurchaseOrderLineList()) {
        orderLine.setProject(purchaseOrder.getProject());
        for (AnalyticMoveLine analyticMoveLine : orderLine.getAnalyticMoveLineList()) {
            analyticMoveLine.setProject(purchaseOrder.getProject());
            analyticMoveLineRepository.save(analyticMoveLine);
        }
    }
    return purchaseOrder;
}
Also used : PurchaseOrderLine(com.axelor.apps.purchase.db.PurchaseOrderLine) AnalyticMoveLine(com.axelor.apps.account.db.AnalyticMoveLine) Transactional(com.google.inject.persist.Transactional)

Aggregations

PurchaseOrderLine (com.axelor.apps.purchase.db.PurchaseOrderLine)76 BigDecimal (java.math.BigDecimal)28 PurchaseOrder (com.axelor.apps.purchase.db.PurchaseOrder)26 Transactional (com.google.inject.persist.Transactional)18 Product (com.axelor.apps.base.db.Product)14 ArrayList (java.util.ArrayList)13 AxelorException (com.axelor.exception.AxelorException)11 Context (com.axelor.rpc.Context)10 Company (com.axelor.apps.base.db.Company)9 Unit (com.axelor.apps.base.db.Unit)9 SaleOrderLine (com.axelor.apps.sale.db.SaleOrderLine)9 PurchaseOrderLineService (com.axelor.apps.purchase.service.PurchaseOrderLineService)8 LocalDate (java.time.LocalDate)8 Partner (com.axelor.apps.base.db.Partner)7 StockMoveLine (com.axelor.apps.stock.db.StockMoveLine)7 HashMap (java.util.HashMap)7 BudgetDistribution (com.axelor.apps.account.db.BudgetDistribution)5 InvoiceLine (com.axelor.apps.account.db.InvoiceLine)5 TaxLine (com.axelor.apps.account.db.TaxLine)5 List (java.util.List)5