Search in sources :

Example 21 with InvoiceLine

use of com.axelor.apps.account.db.InvoiceLine in project axelor-open-suite by axelor.

the class InvoiceLineProjectController method setProjectToAnalyticDistribution.

public void setProjectToAnalyticDistribution(ActionRequest request, ActionResponse response) {
    try {
        InvoiceLine invoiceLine = request.getContext().asType(InvoiceLine.class);
        List<AnalyticMoveLine> analyticMoveLines = invoiceLine.getAnalyticMoveLineList();
        if (analyticMoveLines != null) {
            response.setValue("analyticMoveLineList", Beans.get(InvoiceLineProjectService.class).setProjectToAnalyticDistribution(invoiceLine, analyticMoveLines));
        }
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : InvoiceLine(com.axelor.apps.account.db.InvoiceLine) AnalyticMoveLine(com.axelor.apps.account.db.AnalyticMoveLine)

Example 22 with InvoiceLine

use of com.axelor.apps.account.db.InvoiceLine 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 23 with InvoiceLine

use of com.axelor.apps.account.db.InvoiceLine in project axelor-open-suite by axelor.

the class ProjectTaskBusinessProjectServiceImpl method createInvoiceLine.

@Override
public List<InvoiceLine> createInvoiceLine(Invoice invoice, ProjectTask projectTask, int priority) throws AxelorException {
    InvoiceLineGenerator invoiceLineGenerator = new InvoiceLineGenerator(invoice, projectTask.getProduct(), projectTask.getName(), projectTask.getUnitPrice(), BigDecimal.ZERO, projectTask.getPriceDiscounted(), projectTask.getDescription(), projectTask.getQuantity(), projectTask.getUnit(), null, priority, projectTask.getDiscountAmount(), projectTask.getDiscountTypeSelect(), projectTask.getExTaxTotal(), BigDecimal.ZERO, false) {

        @Override
        public List<InvoiceLine> creates() throws AxelorException {
            InvoiceLine invoiceLine = this.createInvoiceLine();
            invoiceLine.setProject(projectTask.getProject());
            invoiceLine.setSaleOrderLine(projectTask.getSaleOrderLine());
            projectTask.setInvoiceLine(invoiceLine);
            List<InvoiceLine> invoiceLines = new ArrayList<InvoiceLine>();
            invoiceLines.add(invoiceLine);
            return invoiceLines;
        }
    };
    return invoiceLineGenerator.creates();
}
Also used : InvoiceLine(com.axelor.apps.account.db.InvoiceLine) ArrayList(java.util.ArrayList) InvoiceLineGenerator(com.axelor.apps.account.service.invoice.generator.InvoiceLineGenerator)

Example 24 with InvoiceLine

use of com.axelor.apps.account.db.InvoiceLine in project axelor-open-suite by axelor.

the class ProjectTaskBusinessProjectServiceImpl method createInvoiceLines.

@Override
public List<InvoiceLine> createInvoiceLines(Invoice invoice, List<ProjectTask> projectTaskList, int priority) throws AxelorException {
    List<InvoiceLine> invoiceLineList = new ArrayList<>();
    int count = 0;
    for (ProjectTask projectTask : projectTaskList) {
        invoiceLineList.addAll(this.createInvoiceLine(invoice, projectTask, priority * 100 + count));
        count++;
    }
    return invoiceLineList;
}
Also used : InvoiceLine(com.axelor.apps.account.db.InvoiceLine) ArrayList(java.util.ArrayList) ProjectTask(com.axelor.apps.project.db.ProjectTask)

Example 25 with InvoiceLine

use of com.axelor.apps.account.db.InvoiceLine in project axelor-open-suite by axelor.

the class InvoiceLineProjectServiceImpl method setProject.

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

Aggregations

InvoiceLine (com.axelor.apps.account.db.InvoiceLine)80 ArrayList (java.util.ArrayList)36 Invoice (com.axelor.apps.account.db.Invoice)27 BigDecimal (java.math.BigDecimal)22 AxelorException (com.axelor.exception.AxelorException)20 Product (com.axelor.apps.base.db.Product)13 InvoiceLineGenerator (com.axelor.apps.account.service.invoice.generator.InvoiceLineGenerator)12 Transactional (com.google.inject.persist.Transactional)12 Context (com.axelor.rpc.Context)11 Account (com.axelor.apps.account.db.Account)8 InvoiceGenerator (com.axelor.apps.account.service.invoice.generator.InvoiceGenerator)8 TaxLine (com.axelor.apps.account.db.TaxLine)7 InvoiceLineService (com.axelor.apps.account.service.invoice.InvoiceLineService)7 RefundInvoice (com.axelor.apps.account.service.invoice.generator.invoice.RefundInvoice)6 SaleOrderLine (com.axelor.apps.sale.db.SaleOrderLine)6 InvoiceLineGeneratorSupplyChain (com.axelor.apps.supplychain.service.invoice.generator.InvoiceLineGeneratorSupplyChain)6 AnalyticMoveLine (com.axelor.apps.account.db.AnalyticMoveLine)5 InvoiceRepository (com.axelor.apps.account.db.repo.InvoiceRepository)5 HashSet (java.util.HashSet)5 List (java.util.List)5