Search in sources :

Example 66 with InvoiceLine

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

the class WorkflowVentilationServiceSupplychainImpl method saleOrderProcess.

private void saleOrderProcess(Invoice invoice) throws AxelorException {
    // Get all different saleOrders from invoice
    Set<SaleOrder> saleOrderSet = new HashSet<>();
    for (InvoiceLine invoiceLine : invoice.getInvoiceLineList()) {
        SaleOrder saleOrder = null;
        saleOrder = this.saleOrderLineProcess(invoice, invoiceLine);
        if (saleOrder != null) {
            saleOrderSet.add(saleOrder);
        }
    }
    for (SaleOrder saleOrder : saleOrderSet) {
        log.debug("Update the invoiced amount of the sale order : {}", saleOrder.getSaleOrderSeq());
        saleOrderInvoiceService.update(saleOrder, invoice.getId(), false);
        saleOrderRepository.save(saleOrder);
        accountingSituationSupplychainService.updateUsedCredit(saleOrder.getClientPartner());
        // determine if the invoice is a balance invoice.
        if (saleOrder.getAmountInvoiced().compareTo(saleOrder.getExTaxTotal()) == 0 && invoice.getOperationSubTypeSelect() != InvoiceRepository.OPERATION_SUB_TYPE_SUBSCRIPTION) {
            invoice.setOperationSubTypeSelect(InvoiceRepository.OPERATION_SUB_TYPE_BALANCE);
        }
    }
}
Also used : InvoiceLine(com.axelor.apps.account.db.InvoiceLine) SaleOrder(com.axelor.apps.sale.db.SaleOrder) HashSet(java.util.HashSet)

Example 67 with InvoiceLine

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

the class ExpenseServiceProjectImpl method createInvoiceLines.

@Override
public List<InvoiceLine> createInvoiceLines(Invoice invoice, List<ExpenseLine> expenseLineList, int priority) throws AxelorException {
    if (!Beans.get(AppAccountService.class).isApp("business-project")) {
        return super.createInvoiceLines(invoice, expenseLineList, priority);
    }
    List<InvoiceLine> invoiceLineList = new ArrayList<InvoiceLine>();
    int count = 0;
    for (ExpenseLine expenseLine : expenseLineList) {
        invoiceLineList.addAll(this.createInvoiceLine(invoice, expenseLine, priority * 100 + count));
        count++;
        invoiceLineList.get(invoiceLineList.size() - 1).setProject(expenseLine.getProject());
    }
    return invoiceLineList;
}
Also used : InvoiceLine(com.axelor.apps.account.db.InvoiceLine) ArrayList(java.util.ArrayList) ExpenseLine(com.axelor.apps.hr.db.ExpenseLine)

Example 68 with InvoiceLine

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

the class InvoiceServiceProjectImpl method updateLines.

@Transactional(rollbackOn = Exception.class)
public Invoice updateLines(Invoice invoice) {
    AnalyticMoveLineRepository analyticMoveLineRepository = Beans.get(AnalyticMoveLineRepository.class);
    for (InvoiceLine invoiceLine : invoice.getInvoiceLineList()) {
        invoiceLine.setProject(invoice.getProject());
        for (AnalyticMoveLine analyticMoveLine : invoiceLine.getAnalyticMoveLineList()) {
            analyticMoveLine.setProject(invoice.getProject());
            analyticMoveLineRepository.save(analyticMoveLine);
        }
    }
    return invoice;
}
Also used : AnalyticMoveLineRepository(com.axelor.apps.account.db.repo.AnalyticMoveLineRepository) InvoiceLine(com.axelor.apps.account.db.InvoiceLine) AnalyticMoveLine(com.axelor.apps.account.db.AnalyticMoveLine) Transactional(com.google.inject.persist.Transactional)

Example 69 with InvoiceLine

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

the class InvoicingProjectService method createInvoiceLine.

public List<InvoiceLine> createInvoiceLine(Invoice invoice, SaleOrderLine saleOrderLine, int priority) throws AxelorException {
    Product product = saleOrderLine.getProduct();
    InvoiceLineGenerator invoiceLineGenerator = new InvoiceLineGeneratorSupplyChain(invoice, product, saleOrderLine.getProductName(), saleOrderLine.getDescription(), saleOrderLine.getQty(), saleOrderLine.getUnit(), priority, false, saleOrderLine, null, null) {

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

Example 70 with InvoiceLine

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

the class InvoicingProjectService method createSaleOrderInvoiceLines.

public List<InvoiceLine> createSaleOrderInvoiceLines(Invoice invoice, List<SaleOrderLine> saleOrderLineList, int priority) throws AxelorException {
    List<InvoiceLine> invoiceLineList = new ArrayList<InvoiceLine>();
    int count = 1;
    for (SaleOrderLine saleOrderLine : saleOrderLineList) {
        invoiceLineList.addAll(this.createInvoiceLine(invoice, saleOrderLine, priority * 100 + count));
        count++;
    }
    return invoiceLineList;
}
Also used : InvoiceLine(com.axelor.apps.account.db.InvoiceLine) ArrayList(java.util.ArrayList) SaleOrderLine(com.axelor.apps.sale.db.SaleOrderLine)

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