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());
}
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);
}
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;
}
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;
}
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;
}
Aggregations