use of com.axelor.apps.sale.db.SaleOrder in project axelor-open-suite by axelor.
the class SaleOrderLineServiceSupplyChainImpl method updateStockMoveReservationDateTime.
@Transactional(rollbackOn = { Exception.class })
public void updateStockMoveReservationDateTime(SaleOrderLine saleOrderLine) throws AxelorException {
SaleOrder saleOrder = saleOrderLine.getSaleOrder();
if (saleOrder == null) {
return;
}
if (SupplyChainConfigRepository.SALE_ORDER_SHIPPING_DATE != Beans.get(SupplyChainConfigService.class).getSupplyChainConfig(saleOrder.getCompany()).getSaleOrderReservationDateSelect()) {
return;
}
Beans.get(StockMoveLineRepository.class).all().filter("self.saleOrderLine = :saleOrderLineId").bind("saleOrderLineId", saleOrderLine.getId()).fetchStream().filter(stockMoveLine -> stockMoveLine.getStockMove() != null && stockMoveLine.getStockMove().getStatusSelect() == StockMoveRepository.STATUS_PLANNED).forEach(stockMoveLine -> stockMoveLine.setReservationDateTime(saleOrderLine.getEstimatedDelivDate().atStartOfDay()));
}
use of com.axelor.apps.sale.db.SaleOrder 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.SaleOrder in project axelor-open-suite by axelor.
the class SaleOrderController method createSaleOrder.
@SuppressWarnings("unchecked")
public void createSaleOrder(ActionRequest request, ActionResponse response) throws AxelorException {
SaleOrder origin = Beans.get(SaleOrderRepository.class).find(Long.parseLong(request.getContext().get("_idCopy").toString()));
if (origin != null) {
LinkedHashMap<String, Object> wizardCurrencyContext = (LinkedHashMap<String, Object>) request.getContext().get("_wizardCurrency");
Integer wizardCurrencyId = (Integer) wizardCurrencyContext.get("id");
Currency wizardCurrency = Beans.get(CurrencyRepository.class).find(Long.valueOf(wizardCurrencyId));
PriceList wizardPriceList = null;
if (request.getContext().get("_wizardPriceList") != null) {
LinkedHashMap<String, Object> wizardPriceListContext = (LinkedHashMap<String, Object>) request.getContext().get("_wizardPriceList");
Integer wizardPriceListId = (Integer) wizardPriceListContext.get("id");
wizardPriceList = Beans.get(PriceListRepository.class).find(Long.valueOf(wizardPriceListId));
}
SaleOrder copy = Beans.get(SaleOrderCreateService.class).createSaleOrder(origin, wizardCurrency, wizardPriceList);
response.setValues(Mapper.toMap(copy));
}
}
use of com.axelor.apps.sale.db.SaleOrder in project axelor-open-suite by axelor.
the class SaleOrderController method generateViewTemplate.
public void generateViewTemplate(ActionRequest request, ActionResponse response) {
SaleOrder context = request.getContext().asType(SaleOrder.class);
response.setView(ActionView.define("Template").model(SaleOrder.class.getName()).add("form", "sale-order-template-form-wizard").context("_idCopy", context.getId().toString()).map());
}
use of com.axelor.apps.sale.db.SaleOrder in project axelor-open-suite by axelor.
the class SaleOrderController method changePriceListDomain.
/**
* Called from sale order view on price list select. Call {@link
* PartnerPriceListService#getPriceListDomain(Partner, int)}.
*
* @param request
* @param response
*/
@SuppressWarnings("unchecked")
public void changePriceListDomain(ActionRequest request, ActionResponse response) {
SaleOrder saleOrder;
if (request.getContext().get("_saleOrderTemplate") != null) {
LinkedHashMap<String, Object> saleOrderTemplateContext = (LinkedHashMap<String, Object>) request.getContext().get("_saleOrderTemplate");
Integer saleOrderId = (Integer) saleOrderTemplateContext.get("id");
saleOrder = Beans.get(SaleOrderRepository.class).find(Long.valueOf(saleOrderId));
} else {
saleOrder = request.getContext().asType(SaleOrder.class);
}
String domain = Beans.get(PartnerPriceListService.class).getPriceListDomain(saleOrder.getClientPartner(), PriceListRepository.TYPE_SALE);
response.setAttr("priceList", "domain", domain);
}
Aggregations