Search in sources :

Example 26 with PurchaseOrderLine

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

the class ProjectStockMoveInvoiceServiceImpl method createInvoiceLine.

@Override
public InvoiceLine createInvoiceLine(Invoice invoice, StockMoveLine stockMoveLine, BigDecimal qty) throws AxelorException {
    InvoiceLine invoiceLine = super.createInvoiceLine(invoice, stockMoveLine, qty);
    if (invoiceLine == null || !Beans.get(AppBusinessProjectService.class).isApp("business-project")) {
        return invoiceLine;
    }
    SaleOrderLine saleOrderLine = invoiceLine.getSaleOrderLine();
    if (saleOrderLine != null) {
        invoiceLine.setProject(saleOrderLine.getProject());
    }
    PurchaseOrderLine purchaseOrderLine = invoiceLine.getPurchaseOrderLine();
    if (purchaseOrderLine != null) {
        invoiceLine.setProject(purchaseOrderLine.getProject());
    }
    return invoiceLine;
}
Also used : AppBusinessProjectService(com.axelor.apps.businessproject.service.app.AppBusinessProjectService) PurchaseOrderLine(com.axelor.apps.purchase.db.PurchaseOrderLine) InvoiceLine(com.axelor.apps.account.db.InvoiceLine) SaleOrderLine(com.axelor.apps.sale.db.SaleOrderLine)

Example 27 with PurchaseOrderLine

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

the class PurchaseOrderLineServiceProjectImpl method createAnalyticDistributionWithTemplate.

@Override
public PurchaseOrderLine createAnalyticDistributionWithTemplate(PurchaseOrderLine purchaseOrderLine) {
    PurchaseOrderLine poLine = super.createAnalyticDistributionWithTemplate(purchaseOrderLine);
    List<AnalyticMoveLine> analyticMoveLineList = poLine.getAnalyticMoveLineList();
    if (poLine.getProject() != null && analyticMoveLineList != null) {
        analyticMoveLineList.forEach(analyticLine -> analyticLine.setProject(poLine.getProject()));
    }
    return poLine;
}
Also used : PurchaseOrderLine(com.axelor.apps.purchase.db.PurchaseOrderLine) AnalyticMoveLine(com.axelor.apps.account.db.AnalyticMoveLine)

Example 28 with PurchaseOrderLine

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

the class PurchaseOrderLineServiceProjectImpl method setProject.

@Transactional
@Override
public void setProject(List<Long> purchaseOrderLineIds, Project project) {
    if (purchaseOrderLineIds != null) {
        List<PurchaseOrderLine> purchaseOrderLineList = purchaseOrderLineRepo.all().filter("self.id in ?1", purchaseOrderLineIds).fetch();
        for (PurchaseOrderLine line : purchaseOrderLineList) {
            line.setProject(project);
            purchaseOrderLineRepo.save(line);
        }
    }
}
Also used : PurchaseOrderLine(com.axelor.apps.purchase.db.PurchaseOrderLine) Transactional(com.google.inject.persist.Transactional)

Example 29 with PurchaseOrderLine

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

the class PurchaseOrderWorkflowServiceProjectImpl method cancelPurchaseOrder.

@Override
@Transactional
public void cancelPurchaseOrder(PurchaseOrder purchaseOrder) {
    super.cancelPurchaseOrder(purchaseOrder);
    for (PurchaseOrderLine purchaseOrderLine : purchaseOrder.getPurchaseOrderLineList()) {
        for (AnalyticMoveLine analyticMoveLine : purchaseOrderLine.getAnalyticMoveLineList()) {
            analyticMoveLine.setProject(null);
            analyticMoveLineRepository.save(analyticMoveLine);
        }
    }
}
Also used : PurchaseOrderLine(com.axelor.apps.purchase.db.PurchaseOrderLine) AnalyticMoveLine(com.axelor.apps.account.db.AnalyticMoveLine) Transactional(com.google.inject.persist.Transactional)

Example 30 with PurchaseOrderLine

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

the class InvoicingProjectService method populate.

public List<InvoiceLine> populate(Invoice invoice, InvoicingProject folder) throws AxelorException {
    List<SaleOrderLine> saleOrderLineList = new ArrayList<SaleOrderLine>(folder.getSaleOrderLineSet());
    List<PurchaseOrderLine> purchaseOrderLineList = new ArrayList<PurchaseOrderLine>(folder.getPurchaseOrderLineSet());
    List<TimesheetLine> timesheetLineList = new ArrayList<TimesheetLine>(folder.getLogTimesSet());
    List<ExpenseLine> expenseLineList = new ArrayList<ExpenseLine>(folder.getExpenseLineSet());
    List<ProjectTask> projectTaskList = new ArrayList<ProjectTask>(folder.getProjectTaskSet());
    List<InvoiceLine> invoiceLineList = new ArrayList<InvoiceLine>();
    invoiceLineList.addAll(this.createSaleOrderInvoiceLines(invoice, saleOrderLineList, folder.getSaleOrderLineSetPrioritySelect()));
    invoiceLineList.addAll(this.createPurchaseOrderInvoiceLines(invoice, purchaseOrderLineList, folder.getPurchaseOrderLineSetPrioritySelect()));
    invoiceLineList.addAll(timesheetService.createInvoiceLines(invoice, timesheetLineList, folder.getLogTimesSetPrioritySelect()));
    invoiceLineList.addAll(expenseService.createInvoiceLines(invoice, expenseLineList, folder.getExpenseLineSetPrioritySelect()));
    invoiceLineList.addAll(projectTaskBusinessProjectService.createInvoiceLines(invoice, projectTaskList, folder.getProjectTaskSetPrioritySelect()));
    Collections.sort(invoiceLineList, new InvoiceLineComparator());
    for (InvoiceLine invoiceLine : invoiceLineList) {
        invoiceLine.setSequence(sequence);
        sequence++;
    }
    return invoiceLineList;
}
Also used : InvoiceLineComparator(com.axelor.apps.account.util.InvoiceLineComparator) TimesheetLine(com.axelor.apps.hr.db.TimesheetLine) InvoiceLine(com.axelor.apps.account.db.InvoiceLine) ArrayList(java.util.ArrayList) SaleOrderLine(com.axelor.apps.sale.db.SaleOrderLine) PurchaseOrderLine(com.axelor.apps.purchase.db.PurchaseOrderLine) ExpenseLine(com.axelor.apps.hr.db.ExpenseLine) ProjectTask(com.axelor.apps.project.db.ProjectTask)

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