use of com.axelor.apps.sale.db.SaleOrderLine in project axelor-open-suite by axelor.
the class SaleOrderPurchaseServiceImpl method splitBySupplierPartner.
@Override
public Map<Partner, List<SaleOrderLine>> splitBySupplierPartner(List<SaleOrderLine> saleOrderLineList) throws AxelorException {
Map<Partner, List<SaleOrderLine>> saleOrderLinesBySupplierPartner = new HashMap<>();
for (SaleOrderLine saleOrderLine : saleOrderLineList) {
if (saleOrderLine.getSaleSupplySelect() == ProductRepository.SALE_SUPPLY_PURCHASE) {
Partner supplierPartner = saleOrderLine.getSupplierPartner();
if (supplierPartner == null) {
throw new AxelorException(saleOrderLine, TraceBackRepository.CATEGORY_CONFIGURATION_ERROR, I18n.get(IExceptionMessage.SO_PURCHASE_1), saleOrderLine.getProductName());
}
if (!saleOrderLinesBySupplierPartner.containsKey(supplierPartner)) {
saleOrderLinesBySupplierPartner.put(supplierPartner, new ArrayList<SaleOrderLine>());
}
saleOrderLinesBySupplierPartner.get(supplierPartner).add(saleOrderLine);
}
}
return saleOrderLinesBySupplierPartner;
}
use of com.axelor.apps.sale.db.SaleOrderLine in project axelor-open-suite by axelor.
the class ReservedQtyServiceImpl method requestQty.
@Override
@Transactional(rollbackOn = { Exception.class })
public void requestQty(StockMoveLine stockMoveLine) throws AxelorException {
if (stockMoveLine.getProduct() == null || !stockMoveLine.getProduct().getStockManaged()) {
return;
}
SaleOrderLine saleOrderLine = stockMoveLine.getSaleOrderLine();
if (saleOrderLine != null) {
requestQty(saleOrderLine);
} else {
stockMoveLine.setReservationDateTime(appBaseService.getTodayDateTime().toLocalDateTime());
stockMoveLine.setIsQtyRequested(true);
if (stockMoveLine.getQty().signum() < 0) {
throw new AxelorException(TraceBackRepository.CATEGORY_INCONSISTENCY, I18n.get(IExceptionMessage.SALE_ORDER_LINE_REQUEST_QTY_NEGATIVE));
}
this.updateRequestedReservedQty(stockMoveLine, stockMoveLine.getQty());
}
}
use of com.axelor.apps.sale.db.SaleOrderLine in project axelor-open-suite by axelor.
the class SaleOrderSupplychainRepository method copy.
@Override
public SaleOrder copy(SaleOrder entity, boolean deep) {
SaleOrder copy = super.copy(entity, deep);
if (!Beans.get(AppService.class).isApp("supplychain")) {
return copy;
}
copy.setShipmentDate(null);
copy.setDeliveryState(DELIVERY_STATE_NOT_DELIVERED);
copy.setAmountInvoiced(null);
copy.setStockMoveList(null);
if (copy.getSaleOrderLineList() != null) {
for (SaleOrderLine saleOrderLine : copy.getSaleOrderLineList()) {
saleOrderLine.setDeliveryState(null);
saleOrderLine.setDeliveredQty(null);
saleOrderLine.setAmountInvoiced(null);
saleOrderLine.setInvoiced(null);
saleOrderLine.setInvoicingDate(null);
saleOrderLine.setIsInvoiceControlled(null);
saleOrderLine.setReservedQty(BigDecimal.ZERO);
}
}
return copy;
}
use of com.axelor.apps.sale.db.SaleOrderLine in project axelor-open-suite by axelor.
the class SaleOrderLineController method getProductInformation.
/**
* Called by the sale order line form. Update all fields when the product is changed.
*
* @param request
* @param response
*/
public void getProductInformation(ActionRequest request, ActionResponse response) {
try {
Context context = request.getContext();
SaleOrderLine saleOrderLine = context.asType(SaleOrderLine.class);
SaleOrderLineService saleOrderLineService = Beans.get(SaleOrderLineService.class);
SaleOrder saleOrder = saleOrderLineService.getSaleOrder(context);
Product product = saleOrderLine.getProduct();
if (saleOrder == null || product == null) {
resetProductInformation(response, saleOrderLine);
return;
}
try {
product = Beans.get(ProductRepository.class).find(product.getId());
saleOrderLineService.computeProductInformation(saleOrderLine, saleOrder);
response.setValue("saleSupplySelect", product.getSaleSupplySelect());
response.setValues(saleOrderLine);
} catch (Exception e) {
resetProductInformation(response, saleOrderLine);
TraceBackService.trace(response, e);
}
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
use of com.axelor.apps.sale.db.SaleOrderLine in project axelor-open-suite by axelor.
the class SaleOrderLineController method fillMaxDiscount.
/**
* Called from sale order line form view on load and on discount type select change. Call {@link
* SaleOrderLineService#computeMaxDiscount} and set the message to the view.
*
* @param request
* @param response
*/
public void fillMaxDiscount(ActionRequest request, ActionResponse response) {
try {
Context context = request.getContext();
SaleOrderLine saleOrderLine = context.asType(SaleOrderLine.class);
SaleOrderLineService saleOrderLineService = Beans.get(SaleOrderLineService.class);
SaleOrder saleOrder = saleOrderLineService.getSaleOrder(context);
BigDecimal maxDiscount = saleOrderLineService.computeMaxDiscount(saleOrder, saleOrderLine);
response.setValue("$maxDiscount", maxDiscount);
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
Aggregations