use of com.axelor.apps.stock.db.ShipmentMode in project axelor-open-suite by axelor.
the class PurchaseOrderServiceSupplychainImpl method createShipmentCostLine.
@Override
public String createShipmentCostLine(PurchaseOrder purchaseOrder) throws AxelorException {
List<PurchaseOrderLine> purchaseOrderLines = purchaseOrder.getPurchaseOrderLineList();
ShipmentMode shipmentMode = purchaseOrder.getShipmentMode();
if (shipmentMode == null) {
return null;
}
Product shippingCostProduct = shipmentMode.getShippingCostsProduct();
if (shipmentMode.getHasCarriagePaidPossibility()) {
BigDecimal carriagePaidThreshold = shipmentMode.getCarriagePaidThreshold();
if (computeExTaxTotalWithoutShippingLines(purchaseOrder).compareTo(carriagePaidThreshold) >= 0) {
String message = removeShipmentCostLine(purchaseOrder);
this.computePurchaseOrder(purchaseOrder);
return message;
}
}
if (alreadyHasShippingCostLine(purchaseOrder, shippingCostProduct)) {
return null;
}
PurchaseOrderLine shippingCostLine = createShippingCostLine(purchaseOrder, shippingCostProduct);
purchaseOrderLines.add(shippingCostLine);
this.computePurchaseOrder(purchaseOrder);
return null;
}
use of com.axelor.apps.stock.db.ShipmentMode in project axelor-open-suite by axelor.
the class SaleOrderServiceSupplychainImpl method createShipmentCostLine.
@Override
public String createShipmentCostLine(SaleOrder saleOrder) throws AxelorException {
List<SaleOrderLine> saleOrderLines = saleOrder.getSaleOrderLineList();
Partner client = saleOrder.getClientPartner();
ShipmentMode shipmentMode = saleOrder.getShipmentMode();
if (shipmentMode == null) {
return null;
}
Product shippingCostProduct = shipmentMode.getShippingCostsProduct();
if (shippingCostProduct == null) {
return null;
}
BigDecimal carriagePaidThreshold = shipmentMode.getCarriagePaidThreshold();
if (client != null) {
List<CustomerShippingCarriagePaid> carriagePaids = client.getCustomerShippingCarriagePaidList();
for (CustomerShippingCarriagePaid customerShippingCarriagePaid : carriagePaids) {
if (shipmentMode.getId() == customerShippingCarriagePaid.getShipmentMode().getId()) {
if (customerShippingCarriagePaid.getShippingCostsProduct() != null) {
shippingCostProduct = customerShippingCarriagePaid.getShippingCostsProduct();
}
carriagePaidThreshold = customerShippingCarriagePaid.getCarriagePaidThreshold();
break;
}
}
}
if (carriagePaidThreshold != null && shipmentMode.getHasCarriagePaidPossibility()) {
if (computeExTaxTotalWithoutShippingLines(saleOrder).compareTo(carriagePaidThreshold) >= 0) {
String message = removeShipmentCostLine(saleOrder);
saleOrderComputeService.computeSaleOrder(saleOrder);
saleOrderMarginService.computeMarginSaleOrder(saleOrder);
return message;
}
}
if (alreadyHasShippingCostLine(saleOrder, shippingCostProduct)) {
return null;
}
SaleOrderLine shippingCostLine = createShippingCostLine(saleOrder, shippingCostProduct);
saleOrderLines.add(shippingCostLine);
saleOrderComputeService.computeSaleOrder(saleOrder);
saleOrderMarginService.computeMarginSaleOrder(saleOrder);
return null;
}
Aggregations