Search in sources :

Example 41 with SaleOrderLine

use of com.axelor.apps.sale.db.SaleOrderLine in project axelor-open-suite by axelor.

the class TestSaleOrderStockService method testUpdateDeliveryStatePartiallyDelivered2SaleOrder.

@Test
public void testUpdateDeliveryStatePartiallyDelivered2SaleOrder() throws AxelorException {
    SaleOrder saleOrder = new SaleOrder();
    SaleOrderLine saleOrderLine1 = new SaleOrderLine();
    SaleOrderLine saleOrderLine2 = new SaleOrderLine();
    saleOrderLine1.setDeliveryState(SaleOrderRepository.DELIVERY_STATE_NOT_DELIVERED);
    saleOrderLine2.setDeliveryState(SaleOrderRepository.DELIVERY_STATE_DELIVERED);
    saleOrder.addSaleOrderLineListItem(saleOrderLine1);
    saleOrder.addSaleOrderLineListItem(saleOrderLine2);
    saleOrderStockService.updateDeliveryState(saleOrder);
    Assert.assertEquals(SaleOrderRepository.DELIVERY_STATE_PARTIALLY_DELIVERED, (int) saleOrder.getDeliveryState());
}
Also used : SaleOrder(com.axelor.apps.sale.db.SaleOrder) SaleOrderLine(com.axelor.apps.sale.db.SaleOrderLine) Test(org.junit.Test)

Example 42 with SaleOrderLine

use of com.axelor.apps.sale.db.SaleOrderLine in project axelor-open-suite by axelor.

the class SaleOrderLineSupplychainRepository method populate.

@Override
public Map<String, Object> populate(Map<String, Object> json, Map<String, Object> context) {
    Long saleOrderLineId = (Long) json.get("id");
    SaleOrderLine saleOrderLine = find(saleOrderLineId);
    SaleOrder saleOrder = saleOrderLine.getSaleOrder();
    if (this.availabilityIsNotManaged(saleOrderLine, saleOrder)) {
        return super.populate(json, context);
    }
    BigDecimal availableStock = Beans.get(SaleOrderLineServiceSupplyChainImpl.class).getAvailableStock(saleOrder, saleOrderLine);
    BigDecimal allocatedStock = Beans.get(SaleOrderLineServiceSupplyChainImpl.class).getAllocatedStock(saleOrder, saleOrderLine);
    BigDecimal availableQty = availableStock.add(allocatedStock);
    BigDecimal realQty = saleOrderLine.getQty();
    if (availableQty.compareTo(realQty) >= 0) {
        saleOrderLine.setAvailableStatus(I18n.get("Available"));
        saleOrderLine.setAvailableStatusSelect(SaleOrderLineRepository.STATUS_AVAILABLE);
    } else if (availableQty.compareTo(realQty) < 0) {
        saleOrderLine.setAvailableStatus(I18n.get("Missing") + " (" + availableQty.subtract(realQty) + ")");
        saleOrderLine.setAvailableStatusSelect(SaleOrderLineRepository.STATUS_MISSING);
    }
    json.put("availableStatus", saleOrderLine.getAvailableStatus());
    json.put("availableStatusSelect", saleOrderLine.getAvailableStatusSelect());
    return super.populate(json, context);
}
Also used : SaleOrderLineServiceSupplyChainImpl(com.axelor.apps.supplychain.service.SaleOrderLineServiceSupplyChainImpl) SaleOrderLine(com.axelor.apps.sale.db.SaleOrderLine) SaleOrder(com.axelor.apps.sale.db.SaleOrder) BigDecimal(java.math.BigDecimal)

Example 43 with SaleOrderLine

use of com.axelor.apps.sale.db.SaleOrderLine 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 44 with SaleOrderLine

use of com.axelor.apps.sale.db.SaleOrderLine 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)

Example 45 with SaleOrderLine

use of com.axelor.apps.sale.db.SaleOrderLine in project axelor-open-suite by axelor.

the class ProjectAnalyticMoveLineServiceImpl method updateLines.

@Override
@Transactional(rollbackOn = Exception.class)
public SaleOrder updateLines(SaleOrder saleOrder) {
    for (SaleOrderLine orderLine : saleOrder.getSaleOrderLineList()) {
        orderLine.setProject(saleOrder.getProject());
        for (AnalyticMoveLine analyticMoveLine : orderLine.getAnalyticMoveLineList()) {
            analyticMoveLine.setProject(saleOrder.getProject());
            analyticMoveLineRepository.save(analyticMoveLine);
        }
    }
    return saleOrder;
}
Also used : SaleOrderLine(com.axelor.apps.sale.db.SaleOrderLine) AnalyticMoveLine(com.axelor.apps.account.db.AnalyticMoveLine) Transactional(com.google.inject.persist.Transactional)

Aggregations

SaleOrderLine (com.axelor.apps.sale.db.SaleOrderLine)116 AxelorException (com.axelor.exception.AxelorException)41 BigDecimal (java.math.BigDecimal)39 SaleOrder (com.axelor.apps.sale.db.SaleOrder)33 ArrayList (java.util.ArrayList)24 Transactional (com.google.inject.persist.Transactional)23 Product (com.axelor.apps.base.db.Product)21 Context (com.axelor.rpc.Context)16 SaleOrderLineService (com.axelor.apps.sale.service.saleorder.SaleOrderLineService)14 PurchaseOrderLine (com.axelor.apps.purchase.db.PurchaseOrderLine)9 Partner (com.axelor.apps.base.db.Partner)8 StockMoveLine (com.axelor.apps.stock.db.StockMoveLine)8 TaxLine (com.axelor.apps.account.db.TaxLine)7 Unit (com.axelor.apps.base.db.Unit)7 HashMap (java.util.HashMap)7 AnalyticMoveLine (com.axelor.apps.account.db.AnalyticMoveLine)6 InvoiceLine (com.axelor.apps.account.db.InvoiceLine)6 SaleOrderLineRepository (com.axelor.apps.sale.db.repo.SaleOrderLineRepository)6 ReservedQtyService (com.axelor.apps.supplychain.service.ReservedQtyService)6 List (java.util.List)6