First commit (wating to add alerts in budget)
This commit is contained in:
@@ -1,16 +1,13 @@
|
||||
package com.axelor.apps.stock.db.repo;
|
||||
|
||||
import javax.persistence.PersistenceException;
|
||||
|
||||
import com.axelor.apps.base.service.administration.SequenceService;
|
||||
import com.axelor.apps.stock.db.StockMove;
|
||||
import com.axelor.apps.stock.db.StockProductionRequest;
|
||||
import com.axelor.apps.stock.service.StockMoveToolService;
|
||||
import com.axelor.inject.Beans;
|
||||
import com.google.common.base.Strings;
|
||||
import javax.persistence.PersistenceException;
|
||||
|
||||
public class StockProductionRequestManagementRepository extends StockProductionRequestRepository {
|
||||
|
||||
public class StockProductionRequestManagementRepository extends StockProductionRequestRepository{
|
||||
|
||||
@Override
|
||||
public StockProductionRequest save(StockProductionRequest entity) {
|
||||
try {
|
||||
@@ -18,12 +15,15 @@ public class StockProductionRequestManagementRepository extends StockProduction
|
||||
SequenceService sequenceService = Beans.get(SequenceService.class);
|
||||
|
||||
if (Strings.isNullOrEmpty(productionRequest.getStockProductionRequestSeq())) {
|
||||
productionRequest.setStockProductionRequestSeq(sequenceService.getDraftSequenceNumber(productionRequest));
|
||||
productionRequest.setStockProductionRequestSeq(
|
||||
sequenceService.getDraftSequenceNumber(productionRequest));
|
||||
}
|
||||
|
||||
if (Strings.isNullOrEmpty(productionRequest.getName())
|
||||
|| productionRequest.getName().startsWith(productionRequest.getStockProductionRequestSeq())) {
|
||||
productionRequest.setName(productionRequest.getStockProductionRequestSeq());
|
||||
|| productionRequest
|
||||
.getName()
|
||||
.startsWith(productionRequest.getStockProductionRequestSeq())) {
|
||||
productionRequest.setName(productionRequest.getStockProductionRequestSeq());
|
||||
}
|
||||
|
||||
return productionRequest;
|
||||
@@ -31,5 +31,4 @@ public class StockProductionRequestManagementRepository extends StockProduction
|
||||
throw new PersistenceException(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -129,6 +129,8 @@ public interface IExceptionMessage {
|
||||
"You must configure a default receipt stock location for the company %s" /*)*/;
|
||||
static final String STOCK_CONFIG_PICKUP = /*$$(*/
|
||||
"You must configure a default pickup stock location for the company %s" /*)*/;
|
||||
static final String STOCK_CONFIG_NON_COMPLIANT = /*$$(*/
|
||||
"You must configure a default non compliant stock location for the company %s" /*)*/;
|
||||
|
||||
/** Stock Location Controller */
|
||||
static final String LOCATION_1 = /*$$(*/
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
package com.axelor.apps.stock.service;
|
||||
|
||||
import com.axelor.apps.base.db.Company;
|
||||
import com.axelor.apps.base.db.Product;
|
||||
import com.axelor.apps.stock.db.InternalTrackingNumber;
|
||||
import com.axelor.apps.stock.db.StockConfig;
|
||||
import com.axelor.apps.stock.db.TrackingNumber;
|
||||
import com.axelor.apps.stock.db.repo.InternalTrackingNumberRepository;
|
||||
import com.axelor.apps.stock.db.repo.StockConfigRepository;
|
||||
import com.axelor.exception.AxelorException;
|
||||
import com.axelor.inject.Beans;
|
||||
import com.google.inject.persist.Transactional;
|
||||
import java.time.LocalDate;
|
||||
|
||||
public class InternalTrackingNumberService {
|
||||
|
||||
@Transactional(rollbackOn = {Exception.class})
|
||||
public InternalTrackingNumber createInternalTrackingNumber(
|
||||
Product product, Company company, LocalDate date, TrackingNumber trackingNumber)
|
||||
throws AxelorException {
|
||||
|
||||
InternalTrackingNumber internalTrackingNumber = new InternalTrackingNumber();
|
||||
internalTrackingNumber.setProduct(product);
|
||||
internalTrackingNumber.setTrackingNumber(trackingNumber);
|
||||
internalTrackingNumber.setPerishableExpirationDate(
|
||||
trackingNumber.getPerishableExpirationDate());
|
||||
internalTrackingNumber.setFabricationDate(internalTrackingNumber.getFabricationDate());
|
||||
internalTrackingNumber.setReceptionDate(date);
|
||||
|
||||
Long categoryId = product.getFamilleProduit().getId();
|
||||
|
||||
StockConfig stockConfig =
|
||||
Beans.get(StockConfigRepository.class).all().filter("self.company = ?", company).fetchOne();
|
||||
|
||||
String sequence = "";
|
||||
|
||||
switch (categoryId.intValue()) {
|
||||
case 67:
|
||||
sequence = Beans.get(StockMoveToolServiceImpl.class).getInternalSequence(36, company, date);
|
||||
stockConfig.setMpInternalSeq((stockConfig.getMpInternalSeq() + 1));
|
||||
break;
|
||||
case 68:
|
||||
sequence = Beans.get(StockMoveToolServiceImpl.class).getInternalSequence(36, company, date);
|
||||
stockConfig.setMpInternalSeq((stockConfig.getMpInternalSeq() + 1));
|
||||
break;
|
||||
case 59:
|
||||
sequence = Beans.get(StockMoveToolServiceImpl.class).getInternalSequence(35, company, date);
|
||||
stockConfig.setAcInternalSeq((stockConfig.getMpInternalSeq() + 1));
|
||||
break;
|
||||
default:
|
||||
// sequence = "AC" + stockConfig.getAcInternalSeq() + month + formattedYear;
|
||||
// stockConfig.setAcInternalSeq((stockConfig.getMpInternalSeq() + 1));
|
||||
break;
|
||||
}
|
||||
|
||||
Beans.get(StockConfigRepository.class).save(stockConfig);
|
||||
internalTrackingNumber.setTrackingNumberSeq(sequence);
|
||||
|
||||
return internalTrackingNumber;
|
||||
}
|
||||
|
||||
public InternalTrackingNumber getInternalTrackingNumber(
|
||||
Product product, TrackingNumber trackingNumber) {
|
||||
InternalTrackingNumber internalTrackingNumber =
|
||||
Beans.get(InternalTrackingNumberRepository.class)
|
||||
.all()
|
||||
.filter("self.product = ?1 and self.trackingNumber = ?2", product, trackingNumber)
|
||||
.fetchOne();
|
||||
|
||||
return internalTrackingNumber;
|
||||
}
|
||||
}
|
||||
@@ -31,15 +31,13 @@ import com.axelor.db.Query;
|
||||
import com.axelor.inject.Beans;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.persist.Transactional;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
public class InventoryLineService {
|
||||
|
||||
@Inject
|
||||
private ProductRepository productRepository;
|
||||
@Inject private ProductRepository productRepository;
|
||||
private TrackingNumberRepository trackingNumberRepository;
|
||||
private InventoryLineRepository inventoryLineRepository;
|
||||
|
||||
@@ -110,60 +108,67 @@ public class InventoryLineService {
|
||||
return inventoryLine;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void setInventoryLine(
|
||||
Inventory inventory,
|
||||
Product product,
|
||||
TrackingNumber trackingNumber,
|
||||
int countingType,
|
||||
BigDecimal firstCounting,
|
||||
BigDecimal secondCounting,
|
||||
BigDecimal controlCounting) {
|
||||
InventoryLine line;
|
||||
|
||||
@Transactional
|
||||
public void setInventoryLine(Inventory inventory, Product product,TrackingNumber trackingNumber,int countingType,
|
||||
BigDecimal firstCounting,BigDecimal secondCounting,BigDecimal controlCounting
|
||||
) {
|
||||
InventoryLine line;
|
||||
|
||||
Query<InventoryLine> query = Beans.get(InventoryLineRepository.class).all();
|
||||
Query<InventoryLine> query = Beans.get(InventoryLineRepository.class).all();
|
||||
|
||||
if(trackingNumber != null){
|
||||
line = query
|
||||
.filter(
|
||||
"self.product.id = ?1 AND self.trackingNumber.id = ?2 and self.inventory.id = ?3",
|
||||
product.getId(),trackingNumber.getId(),inventory.getId())
|
||||
.fetchOne();
|
||||
}else{
|
||||
line = query
|
||||
.filter(
|
||||
"self.product.id = ?1 AND self.trackingNumber is null and self.inventory.id = ?2",
|
||||
product.getId(),inventory.getId())
|
||||
.fetchOne();
|
||||
if (trackingNumber != null) {
|
||||
line =
|
||||
query
|
||||
.filter(
|
||||
"self.product.id = ?1 AND self.trackingNumber.id = ?2 and self.inventory.id = ?3",
|
||||
product.getId(),
|
||||
trackingNumber.getId(),
|
||||
inventory.getId())
|
||||
.fetchOne();
|
||||
} else {
|
||||
line =
|
||||
query
|
||||
.filter(
|
||||
"self.product.id = ?1 AND self.trackingNumber is null and self.inventory.id = ?2",
|
||||
product.getId(),
|
||||
inventory.getId())
|
||||
.fetchOne();
|
||||
}
|
||||
|
||||
if (line == null) {
|
||||
line = this.createInventoryLine(inventory, product, BigDecimal.ZERO, null, trackingNumber);
|
||||
}
|
||||
|
||||
if(line == null){
|
||||
line = this.createInventoryLine(inventory, product, BigDecimal.ZERO, null, trackingNumber);
|
||||
}
|
||||
BigDecimal counting = BigDecimal.ZERO;
|
||||
|
||||
BigDecimal counting = BigDecimal.ZERO;
|
||||
|
||||
switch (countingType) {
|
||||
case 1:
|
||||
counting = line.getFirstCounting() != null ? line.getFirstCounting() : BigDecimal.ZERO;
|
||||
line.setFirstCounting(counting.add(firstCounting));
|
||||
line.setFirstCountingByUser(AuthUtils.getUser());
|
||||
line.setFirstCountingDate(LocalDateTime.now());
|
||||
break;
|
||||
case 2:
|
||||
counting = line.getSecondCounting() != null ? line.getSecondCounting() : BigDecimal.ZERO;
|
||||
line.setSecondCounting(counting.add(secondCounting));
|
||||
line.setSecondCountingByUser(AuthUtils.getUser());
|
||||
line.setSecondCountingDate(LocalDateTime.now());
|
||||
break;
|
||||
case 3:
|
||||
counting = line.getControlCounting() != null ? line.getControlCounting() : BigDecimal.ZERO;
|
||||
line.setControlCounting(counting.add(controlCounting));
|
||||
line.setControlCountingByUser(AuthUtils.getUser());
|
||||
line.setControlCountingDate(LocalDateTime.now());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
Beans.get(InventoryLineRepository.class).save(line);
|
||||
}
|
||||
switch (countingType) {
|
||||
case 1:
|
||||
counting = line.getFirstCounting() != null ? line.getFirstCounting() : BigDecimal.ZERO;
|
||||
line.setFirstCounting(counting.add(firstCounting));
|
||||
line.setFirstCountingByUser(AuthUtils.getUser());
|
||||
line.setFirstCountingDate(LocalDateTime.now());
|
||||
break;
|
||||
case 2:
|
||||
counting = line.getSecondCounting() != null ? line.getSecondCounting() : BigDecimal.ZERO;
|
||||
line.setSecondCounting(counting.add(secondCounting));
|
||||
line.setSecondCountingByUser(AuthUtils.getUser());
|
||||
line.setSecondCountingDate(LocalDateTime.now());
|
||||
break;
|
||||
case 3:
|
||||
counting = line.getControlCounting() != null ? line.getControlCounting() : BigDecimal.ZERO;
|
||||
line.setControlCounting(counting.add(controlCounting));
|
||||
line.setControlCountingByUser(AuthUtils.getUser());
|
||||
line.setControlCountingDate(LocalDateTime.now());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
Beans.get(InventoryLineRepository.class).save(line);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ import com.axelor.meta.MetaFiles;
|
||||
import com.axelor.meta.db.MetaFile;
|
||||
import com.google.common.io.Files;
|
||||
import com.google.inject.Inject;
|
||||
|
||||
import com.google.inject.persist.Transactional;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
@@ -54,16 +54,11 @@ import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collector;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.persistence.Query;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -83,7 +78,7 @@ public class StockHistoryServiceImpl implements StockHistoryService {
|
||||
}
|
||||
|
||||
public List<StockHistoryLine> computeStockHistoryLineList(
|
||||
Long productId, Long companyId, Long stockLocationId,LocalDate beginDate, LocalDate endDate)
|
||||
Long productId, Long companyId, Long stockLocationId, LocalDate beginDate, LocalDate endDate)
|
||||
throws AxelorException {
|
||||
List<StockHistoryLine> stockHistoryLineList = new ArrayList<>();
|
||||
|
||||
@@ -126,6 +121,7 @@ public class StockHistoryServiceImpl implements StockHistoryService {
|
||||
return stockHistoryLineList;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
protected void fetchAndFillResultForStockHistoryQuery(
|
||||
StockHistoryLine stockHistoryLine,
|
||||
Long productId,
|
||||
@@ -135,30 +131,31 @@ public class StockHistoryServiceImpl implements StockHistoryService {
|
||||
LocalDate periodEndDate,
|
||||
boolean incoming,
|
||||
boolean allLocations,
|
||||
Long trackingNumberId)
|
||||
TrackingNumber trackingNumber)
|
||||
throws AxelorException {
|
||||
Long trackingNumberId = trackingNumber.getId();
|
||||
String filter =
|
||||
"self.product.id = :productId "
|
||||
+ "AND self.stockMove.statusSelect = :realized "
|
||||
+ "AND self.stockMove.company.id = :companyId "
|
||||
+ "AND self.stockMove.realDate >= :beginDate "
|
||||
+ "AND self.stockMove.realDate < :endDate ";
|
||||
|
||||
|
||||
if (incoming) {
|
||||
if(allLocations == true){
|
||||
if (allLocations == true) {
|
||||
filter += "AND self.stockMove.fromStockLocation.typeSelect = :typeSelect ";
|
||||
}else{
|
||||
} else {
|
||||
filter += "AND self.stockMove.toStockLocation.id = :stockLocationId ";
|
||||
}
|
||||
} else {
|
||||
if(allLocations == true){
|
||||
if (allLocations == true) {
|
||||
filter += "AND self.stockMove.toStockLocation.typeSelect = :typeSelect ";
|
||||
}else{
|
||||
} else {
|
||||
filter += "AND self.stockMove.fromStockLocation.id = :stockLocationId ";
|
||||
}
|
||||
}
|
||||
|
||||
if(trackingNumberId != null){
|
||||
if (trackingNumberId != null) {
|
||||
filter += " AND self.trackingNumber.id = :trackingNumberId";
|
||||
}
|
||||
|
||||
@@ -362,30 +359,45 @@ public class StockHistoryServiceImpl implements StockHistoryService {
|
||||
return stockHistoryLine;
|
||||
}
|
||||
|
||||
|
||||
public List<StockHistoryLine> compuHistoryLinesPerDate(Long productId, Long companyId, Long stockLocationId, LocalDate beginDate, LocalDate endDate,Long categoryId,Long trackingNumberId,Integer searchTypeSelect) throws AxelorException {
|
||||
@Transactional
|
||||
public List<StockHistoryLine> compuHistoryLinesPerDate(
|
||||
Long productId,
|
||||
Long companyId,
|
||||
Long stockLocationId,
|
||||
LocalDate beginDate,
|
||||
LocalDate endDate,
|
||||
Long categoryId,
|
||||
Long trackingNumberId,
|
||||
Integer searchTypeSelect)
|
||||
throws AxelorException {
|
||||
List<StockHistoryLine> stockHistoryLineList = new ArrayList<>();
|
||||
Company company = Beans.get(CompanyRepository.class).find(companyId);
|
||||
|
||||
//ALL
|
||||
if(searchTypeSelect == 1){
|
||||
// ALL
|
||||
if (searchTypeSelect == 1) {
|
||||
|
||||
List<Product> products = Beans.get(ProductRepository.class).all().fetch();
|
||||
for (Product product : products) {
|
||||
StockHistoryLine stockHistoryLine = new StockHistoryLine();
|
||||
stockHistoryLine.setLabel(product.getFullName().toString());
|
||||
List<Product> products =
|
||||
Beans.get(StockLocationLineRepository.class)
|
||||
.all()
|
||||
.fetchStream()
|
||||
.map(StockLocationLine::getProduct)
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
for (Product product : products) {
|
||||
StockHistoryLine stockHistoryLine = new StockHistoryLine();
|
||||
stockHistoryLine.setLabel(product.getFullName().toString());
|
||||
|
||||
fetchAndFillResultForStockHistoryQuery(
|
||||
stockHistoryLine,
|
||||
product.getId(),
|
||||
companyId,
|
||||
stockLocationId,
|
||||
beginDate,
|
||||
endDate,
|
||||
true,
|
||||
true,
|
||||
null);
|
||||
|
||||
fetchAndFillResultForStockHistoryQuery(
|
||||
stockHistoryLine,
|
||||
product.getId(),
|
||||
companyId,
|
||||
stockLocationId,
|
||||
beginDate,
|
||||
endDate,
|
||||
true,
|
||||
true,
|
||||
null);
|
||||
|
||||
fetchAndFillResultForStockHistoryQuery(
|
||||
stockHistoryLine,
|
||||
product.getId(),
|
||||
@@ -396,146 +408,27 @@ public class StockHistoryServiceImpl implements StockHistoryService {
|
||||
false,
|
||||
true,
|
||||
null);
|
||||
|
||||
BigDecimal totalQty = this.getTotalQty(product, company, stockLocationId,true,null);
|
||||
BigDecimal realQty = totalQty.add(stockHistoryLine.getSumOutQtyPeriod()).subtract(stockHistoryLine.getSumIncQtyPeriod());
|
||||
stockHistoryLine.setRealQty(realQty);
|
||||
stockHistoryLineList.add(stockHistoryLine);
|
||||
}
|
||||
|
||||
}else if(searchTypeSelect == 3){
|
||||
List<Product> products = Beans.get(ProductRepository.class).all().filter("self.familleProduit.id in ("+String.valueOf(categoryId)+")").fetch();
|
||||
BigDecimal totalQty = this.getTotalQty(product, company, stockLocationId, true, null);
|
||||
BigDecimal realQty =
|
||||
totalQty
|
||||
.add(stockHistoryLine.getSumOutQtyPeriod())
|
||||
.subtract(stockHistoryLine.getSumIncQtyPeriod());
|
||||
stockHistoryLine.setRealQty(realQty);
|
||||
stockHistoryLineList.add(stockHistoryLine);
|
||||
}
|
||||
|
||||
} else if (searchTypeSelect == 3) {
|
||||
List<Product> products =
|
||||
Beans.get(ProductRepository.class)
|
||||
.all()
|
||||
.filter("self.familleProduit.id in (" + String.valueOf(categoryId) + ")")
|
||||
.fetch();
|
||||
for (Product product : products) {
|
||||
StockHistoryLine stockHistoryLine = new StockHistoryLine();
|
||||
stockHistoryLine.setLabel(product.getFullName().toString());
|
||||
|
||||
fetchAndFillResultForStockHistoryQuery(
|
||||
stockHistoryLine,
|
||||
product.getId(),
|
||||
companyId,
|
||||
stockLocationId,
|
||||
beginDate,
|
||||
endDate,
|
||||
true,
|
||||
true,
|
||||
null);
|
||||
|
||||
fetchAndFillResultForStockHistoryQuery(
|
||||
stockHistoryLine,
|
||||
product.getId(),
|
||||
companyId,
|
||||
stockLocationId,
|
||||
beginDate,
|
||||
endDate,
|
||||
false,
|
||||
true,
|
||||
null);
|
||||
|
||||
BigDecimal totalQty = this.getTotalQty(product, company, stockLocationId,true,null);
|
||||
BigDecimal realQty = totalQty.add(stockHistoryLine.getSumOutQtyPeriod()).subtract(stockHistoryLine.getSumIncQtyPeriod());
|
||||
stockHistoryLine.setRealQty(realQty);
|
||||
stockHistoryLineList.add(stockHistoryLine);
|
||||
}
|
||||
|
||||
}else if(searchTypeSelect == 2){
|
||||
StockHistoryLine stockHistoryLine = new StockHistoryLine();
|
||||
stockHistoryLine.setLabel(beginDate.toString());
|
||||
|
||||
fetchAndFillResultForStockHistoryQuery(
|
||||
stockHistoryLine,
|
||||
productId,
|
||||
companyId,
|
||||
stockLocationId,
|
||||
beginDate,
|
||||
endDate,
|
||||
true,
|
||||
false,
|
||||
null);
|
||||
|
||||
fetchAndFillResultForStockHistoryQuery(
|
||||
stockHistoryLine,
|
||||
productId,
|
||||
companyId,
|
||||
stockLocationId,
|
||||
beginDate,
|
||||
endDate,
|
||||
false,
|
||||
false,
|
||||
null);
|
||||
|
||||
Product product = Beans.get(ProductRepository.class).find(productId);
|
||||
BigDecimal totalQty = this.getTotalQty(product, company, stockLocationId,false,null);
|
||||
BigDecimal realQty = totalQty.add(stockHistoryLine.getSumOutQtyPeriod()).subtract(stockHistoryLine.getSumIncQtyPeriod());
|
||||
stockHistoryLine.setRealQty(realQty);
|
||||
stockHistoryLineList.add(stockHistoryLine);
|
||||
}
|
||||
else if(searchTypeSelect == 4){
|
||||
StockHistoryLine stockHistoryLine = new StockHistoryLine();
|
||||
TrackingNumber trackingNumber = Beans.get(TrackingNumberRepository.class).find(trackingNumberId);
|
||||
Product product = Beans.get(ProductRepository.class).find(productId);
|
||||
|
||||
stockHistoryLine.setLabel(beginDate.toString() + " " + product.getName() + " " + trackingNumber.getTrackingNumberSeq());
|
||||
|
||||
fetchAndFillResultForStockHistoryQuery(
|
||||
stockHistoryLine,
|
||||
productId,
|
||||
companyId,
|
||||
stockLocationId,
|
||||
beginDate,
|
||||
endDate,
|
||||
true,
|
||||
true,
|
||||
trackingNumberId);
|
||||
|
||||
fetchAndFillResultForStockHistoryQuery(
|
||||
stockHistoryLine,
|
||||
productId,
|
||||
companyId,
|
||||
stockLocationId,
|
||||
beginDate,
|
||||
endDate,
|
||||
false,
|
||||
true,
|
||||
trackingNumberId);
|
||||
|
||||
BigDecimal totalQty = this.getTotalQty(product, company, stockLocationId,true,trackingNumberId);
|
||||
System.out.println("***************totalQty*******************");
|
||||
System.out.println(trackingNumberId);
|
||||
System.out.println(totalQty);
|
||||
System.out.println("***************totalQty*******************");
|
||||
BigDecimal realQty = totalQty.add(stockHistoryLine.getSumOutQtyPeriod()).subtract(stockHistoryLine.getSumIncQtyPeriod());
|
||||
stockHistoryLine.setRealQty(realQty);
|
||||
stockHistoryLineList.add(stockHistoryLine);
|
||||
} else if(searchTypeSelect == 5){
|
||||
List<StockLocationLine> stockLocationLines = Beans.get(StockLocationLineRepository.class).all().filter("self.detailsStockLocation.typeSelect != " + StockLocationRepository.TYPE_VIRTUAL + " AND self.detailsStockLocation != null AND self.product.familleProduit.id in ("+String.valueOf(categoryId)+")").fetch();
|
||||
|
||||
log.debug("stockLocationLines : {}",stockLocationLines);
|
||||
log.debug("stockLocationLines size : {}",stockLocationLines.size());
|
||||
log.debug("categoryId : {}",categoryId);
|
||||
log.debug("categoryId : {}",categoryId);
|
||||
|
||||
int sizeWithoutTraccking = stockLocationLines.stream().filter(t -> t.getTrackingNumber() == null).collect(Collectors.toList()).size();
|
||||
|
||||
log.debug("sizeWithoutTraccking : {}",sizeWithoutTraccking);
|
||||
|
||||
List<TrackingNumber> trackingNumbers = Beans.get(TrackingNumberRepository.class).all().fetch();
|
||||
List<Product> products = Beans.get(ProductRepository.class).all().fetch();
|
||||
|
||||
for (StockLocationLine line : stockLocationLines) {
|
||||
|
||||
TrackingNumber trackingNumber = trackingNumbers.stream().filter(t -> t.getId() == line.getTrackingNumber().getId()).findFirst().get();
|
||||
Product product = products.stream().filter(t -> t.getId() == line.getProduct().getId()).findFirst().get();
|
||||
|
||||
Long trackingNumberId2 = trackingNumber.getId();
|
||||
|
||||
if(trackingNumber != null){
|
||||
log.debug("trackingNumber >>>>>> : {}",trackingNumber);
|
||||
log.debug("product >>>>>> : {}",product);
|
||||
|
||||
StockHistoryLine stockHistoryLine = new StockHistoryLine();
|
||||
stockHistoryLine.setLabel(beginDate.toString());
|
||||
|
||||
fetchAndFillResultForStockHistoryQuery(
|
||||
stockHistoryLine,
|
||||
product.getId(),
|
||||
companyId,
|
||||
@@ -544,66 +437,248 @@ public class StockHistoryServiceImpl implements StockHistoryService {
|
||||
endDate,
|
||||
true,
|
||||
true,
|
||||
trackingNumberId2);
|
||||
|
||||
null);
|
||||
|
||||
fetchAndFillResultForStockHistoryQuery(
|
||||
stockHistoryLine,
|
||||
product.getId(),
|
||||
companyId,
|
||||
stockLocationId,
|
||||
beginDate,
|
||||
endDate,
|
||||
false,
|
||||
true,
|
||||
null);
|
||||
|
||||
BigDecimal totalQty = this.getTotalQty(product, company, stockLocationId, true, null);
|
||||
BigDecimal realQty =
|
||||
totalQty
|
||||
.add(stockHistoryLine.getSumOutQtyPeriod())
|
||||
.subtract(stockHistoryLine.getSumIncQtyPeriod());
|
||||
stockHistoryLine.setRealQty(realQty);
|
||||
stockHistoryLineList.add(stockHistoryLine);
|
||||
}
|
||||
|
||||
} else if (searchTypeSelect == 2) {
|
||||
StockHistoryLine stockHistoryLine = new StockHistoryLine();
|
||||
stockHistoryLine.setLabel(beginDate.toString());
|
||||
|
||||
fetchAndFillResultForStockHistoryQuery(
|
||||
stockHistoryLine,
|
||||
productId,
|
||||
companyId,
|
||||
stockLocationId,
|
||||
beginDate,
|
||||
endDate,
|
||||
true,
|
||||
false,
|
||||
null);
|
||||
|
||||
fetchAndFillResultForStockHistoryQuery(
|
||||
stockHistoryLine,
|
||||
productId,
|
||||
companyId,
|
||||
stockLocationId,
|
||||
beginDate,
|
||||
endDate,
|
||||
false,
|
||||
false,
|
||||
null);
|
||||
|
||||
Product product = Beans.get(ProductRepository.class).find(productId);
|
||||
BigDecimal totalQty = this.getTotalQty(product, company, stockLocationId, false, null);
|
||||
BigDecimal realQty =
|
||||
totalQty
|
||||
.add(stockHistoryLine.getSumOutQtyPeriod())
|
||||
.subtract(stockHistoryLine.getSumIncQtyPeriod());
|
||||
stockHistoryLine.setRealQty(realQty);
|
||||
stockHistoryLineList.add(stockHistoryLine);
|
||||
} else if (searchTypeSelect == 4) {
|
||||
StockHistoryLine stockHistoryLine = new StockHistoryLine();
|
||||
TrackingNumber trackingNumber =
|
||||
Beans.get(TrackingNumberRepository.class).find(trackingNumberId);
|
||||
Product product = Beans.get(ProductRepository.class).find(productId);
|
||||
|
||||
stockHistoryLine.setLabel(
|
||||
beginDate.toString()
|
||||
+ " "
|
||||
+ product.getName()
|
||||
+ " "
|
||||
+ trackingNumber.getTrackingNumberSeq());
|
||||
|
||||
fetchAndFillResultForStockHistoryQuery(
|
||||
stockHistoryLine,
|
||||
productId,
|
||||
companyId,
|
||||
stockLocationId,
|
||||
beginDate,
|
||||
endDate,
|
||||
true,
|
||||
true,
|
||||
trackingNumber);
|
||||
|
||||
fetchAndFillResultForStockHistoryQuery(
|
||||
stockHistoryLine,
|
||||
productId,
|
||||
companyId,
|
||||
stockLocationId,
|
||||
beginDate,
|
||||
endDate,
|
||||
false,
|
||||
true,
|
||||
trackingNumber);
|
||||
|
||||
BigDecimal totalQty =
|
||||
this.getTotalQty(product, company, stockLocationId, true, trackingNumberId);
|
||||
System.out.println("***************totalQty*******************");
|
||||
System.out.println(trackingNumberId);
|
||||
System.out.println(totalQty);
|
||||
System.out.println("***************totalQty*******************");
|
||||
BigDecimal realQty =
|
||||
totalQty
|
||||
.add(stockHistoryLine.getSumOutQtyPeriod())
|
||||
.subtract(stockHistoryLine.getSumIncQtyPeriod());
|
||||
stockHistoryLine.setRealQty(realQty);
|
||||
stockHistoryLineList.add(stockHistoryLine);
|
||||
} else if (searchTypeSelect == 5) {
|
||||
List<StockLocationLine> stockLocationLines =
|
||||
Beans.get(StockLocationLineRepository.class)
|
||||
.all()
|
||||
.filter(
|
||||
"self.detailsStockLocation.typeSelect != "
|
||||
+ StockLocationRepository.TYPE_VIRTUAL
|
||||
+ " AND self.detailsStockLocation != null AND self.product.familleProduit.id in ("
|
||||
+ String.valueOf(categoryId)
|
||||
+ ")")
|
||||
.fetch();
|
||||
|
||||
log.debug("stockLocationLines : {}", stockLocationLines);
|
||||
log.debug("stockLocationLines size : {}", stockLocationLines.size());
|
||||
log.debug("categoryId : {}", categoryId);
|
||||
log.debug("categoryId : {}", categoryId);
|
||||
|
||||
int sizeWithoutTraccking =
|
||||
stockLocationLines
|
||||
.stream()
|
||||
.filter(t -> t.getTrackingNumber() == null)
|
||||
.collect(Collectors.toList())
|
||||
.size();
|
||||
|
||||
log.debug("sizeWithoutTraccking : {}", sizeWithoutTraccking);
|
||||
|
||||
List<TrackingNumber> trackingNumbers =
|
||||
Beans.get(TrackingNumberRepository.class).all().fetch();
|
||||
List<Product> products = Beans.get(ProductRepository.class).all().fetch();
|
||||
|
||||
this.sumGroupByStocklocation(null, null, beginDate, null);
|
||||
|
||||
for (StockLocationLine line : stockLocationLines) {
|
||||
|
||||
TrackingNumber trackingNumber =
|
||||
trackingNumbers
|
||||
.stream()
|
||||
.filter(t -> t.getId() == line.getTrackingNumber().getId())
|
||||
.findFirst()
|
||||
.get();
|
||||
Product product =
|
||||
products.stream().filter(t -> t.getId() == line.getProduct().getId()).findFirst().get();
|
||||
|
||||
Long trackingNumberId2 = trackingNumber.getId();
|
||||
|
||||
if (trackingNumber != null) {
|
||||
StockLocation location = line.getDetailsStockLocation();
|
||||
log.debug("trackingNumber >>>>>> : {}", trackingNumber);
|
||||
log.debug("product >>>>>> : {}", product);
|
||||
|
||||
StockHistoryLine stockHistoryLine = new StockHistoryLine();
|
||||
stockHistoryLine.setLabel(
|
||||
product.getName()
|
||||
+ "*"
|
||||
+ trackingNumber.getTrackingNumberSeq()
|
||||
+ "*"
|
||||
+ location.getName());
|
||||
|
||||
fetchAndFillResultForStockHistoryQuery(
|
||||
stockHistoryLine,
|
||||
product.getId(),
|
||||
companyId,
|
||||
stockLocationId,
|
||||
location.getId(),
|
||||
beginDate,
|
||||
endDate,
|
||||
true,
|
||||
false,
|
||||
trackingNumber);
|
||||
|
||||
fetchAndFillResultForStockHistoryQuery(
|
||||
stockHistoryLine,
|
||||
product.getId(),
|
||||
companyId,
|
||||
location.getId(),
|
||||
beginDate,
|
||||
endDate,
|
||||
false,
|
||||
true,
|
||||
trackingNumberId2);
|
||||
|
||||
BigDecimal totalQty = this.getTotalQty(product, company, stockLocationId,true,trackingNumberId2);
|
||||
BigDecimal realQty = totalQty.add(stockHistoryLine.getSumOutQtyPeriod()).subtract(stockHistoryLine.getSumIncQtyPeriod());
|
||||
false,
|
||||
trackingNumber);
|
||||
|
||||
log.debug("*** trackingNumber || totalQty || realQty : {} {} {}",trackingNumber,totalQty,realQty);
|
||||
BigDecimal totalQty =
|
||||
this.getTotalQty(product, company, location.getId(), false, trackingNumberId2);
|
||||
BigDecimal realQty =
|
||||
totalQty
|
||||
.add(stockHistoryLine.getSumOutQtyPeriod())
|
||||
.subtract(stockHistoryLine.getSumIncQtyPeriod());
|
||||
|
||||
stockHistoryLine.setRealQty(realQty);
|
||||
stockHistoryLineList.add(stockHistoryLine);
|
||||
log.debug(
|
||||
"*** trackingNumber || totalQty || realQty : {} {} {}",
|
||||
trackingNumber,
|
||||
totalQty,
|
||||
realQty);
|
||||
|
||||
stockHistoryLine.setRealQty(realQty);
|
||||
stockHistoryLineList.add(stockHistoryLine);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
return stockHistoryLineList;
|
||||
}
|
||||
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
public BigDecimal getTotalQty(Product product, Company company,Long StockLocationId,boolean allLocations,Long trackingNumberId) {
|
||||
public BigDecimal getTotalQty(
|
||||
Product product,
|
||||
Company company,
|
||||
Long StockLocationId,
|
||||
boolean allLocations,
|
||||
Long trackingNumberId) {
|
||||
Long productId = product.getId();
|
||||
String query = "";
|
||||
|
||||
query =
|
||||
"SELECT new list(self.id, self.avgPrice, self.currentQty) FROM StockLocationLine as self "
|
||||
+ "WHERE self.product.id = "
|
||||
+ productId;
|
||||
|
||||
if(trackingNumberId == null){
|
||||
query += " AND self.stockLocation.typeSelect != " + StockLocationRepository.TYPE_VIRTUAL;
|
||||
}else{
|
||||
query += " AND self.detailsStockLocation.typeSelect != " + StockLocationRepository.TYPE_VIRTUAL + " AND self.trackingNumber.id = "+trackingNumberId;
|
||||
}
|
||||
query =
|
||||
"SELECT new list(self.id, self.avgPrice, self.currentQty) FROM StockLocationLine as self "
|
||||
+ "WHERE self.product.id = "
|
||||
+ productId;
|
||||
|
||||
|
||||
if (trackingNumberId == null) {
|
||||
query += " AND self.stockLocation.typeSelect != " + StockLocationRepository.TYPE_VIRTUAL;
|
||||
} else {
|
||||
query +=
|
||||
" AND self.detailsStockLocation.typeSelect != "
|
||||
+ StockLocationRepository.TYPE_VIRTUAL
|
||||
+ " AND self.trackingNumber.id = "
|
||||
+ trackingNumberId;
|
||||
}
|
||||
|
||||
if(!allLocations){
|
||||
if(trackingNumberId == null){
|
||||
query += " AND self.stockLocation.id in ("+StockLocationId+")" ;
|
||||
}else{
|
||||
query += " AND self.detailsStockLocation.id in ("+StockLocationId+")" ;
|
||||
if (!allLocations) {
|
||||
if (trackingNumberId == null) {
|
||||
query += " AND self.stockLocation.id in (" + StockLocationId + ")";
|
||||
} else {
|
||||
query += " AND self.detailsStockLocation.id in (" + StockLocationId + ")";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (company != null) {
|
||||
if(trackingNumberId == null){
|
||||
if (trackingNumberId == null) {
|
||||
query += " AND self.stockLocation.company = " + company.getId();
|
||||
}else{
|
||||
} else {
|
||||
query += " AND self.detailsStockLocation.company = " + company.getId();
|
||||
}
|
||||
}
|
||||
@@ -623,7 +698,6 @@ public class StockHistoryServiceImpl implements StockHistoryService {
|
||||
return qtyTot;
|
||||
}
|
||||
|
||||
|
||||
public MetaFile exportToCSV(List<HashMap<String, Object>> historyLines)
|
||||
throws AxelorException, IOException {
|
||||
List<String[]> allMoveLineData = new ArrayList<>();
|
||||
@@ -632,15 +706,30 @@ public class StockHistoryServiceImpl implements StockHistoryService {
|
||||
System.out.println(historyLines.size());
|
||||
System.out.println("***************************************");
|
||||
|
||||
for (HashMap<String, Object> historyLine : historyLines) {
|
||||
for (HashMap<String, Object> historyLine : historyLines) {
|
||||
String[] items = new String[6];
|
||||
int inc = historyLine.get("countIncMvtStockPeriod") != null ? Integer.parseInt(historyLine.get("countIncMvtStockPeriod").toString()) : 0;
|
||||
int out = historyLine.get("countOutMvtStockPeriod") != null ? Integer.parseInt(historyLine.get("countOutMvtStockPeriod").toString()) : 0;
|
||||
int inc =
|
||||
historyLine.get("countIncMvtStockPeriod") != null
|
||||
? Integer.parseInt(historyLine.get("countIncMvtStockPeriod").toString())
|
||||
: 0;
|
||||
int out =
|
||||
historyLine.get("countOutMvtStockPeriod") != null
|
||||
? Integer.parseInt(historyLine.get("countOutMvtStockPeriod").toString())
|
||||
: 0;
|
||||
String label = historyLine.get("label") != null ? historyLine.get("label").toString() : "";
|
||||
BigDecimal sumInc = historyLine.get("sumIncQtyPeriod") != null ? new BigDecimal(historyLine.get("sumIncQtyPeriod").toString()) : BigDecimal.ZERO;
|
||||
BigDecimal sumOut = historyLine.get("sumOutQtyPeriod") != null ? new BigDecimal(historyLine.get("sumOutQtyPeriod").toString()) : BigDecimal.ZERO;
|
||||
BigDecimal realQty = historyLine.get("realQty") != null ? new BigDecimal(historyLine.get("realQty").toString()) : BigDecimal.ZERO;
|
||||
|
||||
BigDecimal sumInc =
|
||||
historyLine.get("sumIncQtyPeriod") != null
|
||||
? new BigDecimal(historyLine.get("sumIncQtyPeriod").toString())
|
||||
: BigDecimal.ZERO;
|
||||
BigDecimal sumOut =
|
||||
historyLine.get("sumOutQtyPeriod") != null
|
||||
? new BigDecimal(historyLine.get("sumOutQtyPeriod").toString())
|
||||
: BigDecimal.ZERO;
|
||||
BigDecimal realQty =
|
||||
historyLine.get("realQty") != null
|
||||
? new BigDecimal(historyLine.get("realQty").toString())
|
||||
: BigDecimal.ZERO;
|
||||
|
||||
items[0] = label;
|
||||
items[1] = String.valueOf(inc);
|
||||
items[2] = String.valueOf(sumInc);
|
||||
@@ -650,7 +739,6 @@ public class StockHistoryServiceImpl implements StockHistoryService {
|
||||
allMoveLineData.add(items);
|
||||
}
|
||||
|
||||
|
||||
String filePath = Files.createTempDir().getAbsolutePath();
|
||||
|
||||
if (filePath == null) {
|
||||
@@ -677,22 +765,45 @@ public class StockHistoryServiceImpl implements StockHistoryService {
|
||||
try (InputStream is = new FileInputStream(file)) {
|
||||
return Beans.get(MetaFiles.class).upload(is, fileName);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void sumGroupByStocklocation() {
|
||||
Query q =
|
||||
JPA.em()
|
||||
.createQuery(
|
||||
"select slLine.product,slLine.trackingNumber,sum(lLine.real_qty) FROM StockMove as slLine "+
|
||||
" LEFT JOIN Product p on p.id = StokLocationLine.product"
|
||||
+ "WHERE ml in ?1 group by ml.account");
|
||||
// q.setParameter(1, );
|
||||
public void sumGroupByStocklocation(
|
||||
Long detailsStockLocationId, Long productId, LocalDate date, Long trackingNumberId) {
|
||||
Query q =
|
||||
JPA.em()
|
||||
.createNativeQuery(
|
||||
"select coalesce(m2.sum,0) inn,coalesce(m1.sum,0) outt from"
|
||||
+ " (SELECT product,line.tracking_number,from_stock_location,sum(real_qty)"
|
||||
+ " FROM STOCK_STOCK_MOVE_LINE LINE left join stock_stock_move move on move.id = line.stock_move"
|
||||
+ " where (line.archived = false OR line.archived is null) and move.estimated_date >= ?1 "
|
||||
+ " group by product,line.tracking_number,from_stock_location) m1"
|
||||
+ " full outer join"
|
||||
+ " (SELECT product,line.tracking_number,to_stock_location,sum(real_qty)"
|
||||
+ " FROM STOCK_STOCK_MOVE_LINE LINE left join stock_stock_move move on move.id = line.stock_move"
|
||||
+ " where (line.archived = false OR line.archived is null) and move.estimated_date >= ?2 "
|
||||
+ " group by product,line.tracking_number,to_stock_location) m2 "
|
||||
+ " on m1.product = m2.product and ((m1.tracking_number is null and m2.tracking_number is null) or m1.tracking_number = m2.tracking_number) and m1.from_stock_location = m2.to_stock_location"
|
||||
// " where"+
|
||||
// " coalesce(m1.product, m2.product) = ?3 and "+
|
||||
// " coalesce(m1.tracking_number,m2.tracking_number) = ?4"+
|
||||
// " and coalesce(m1.from_stock_location,m2.to_stock_location) = ?5"
|
||||
);
|
||||
|
||||
// List<Map<Account, BigDecimal>> allMap = new ArrayList<Map<Account, BigDecimal>>();
|
||||
// allMap = q.getResultList();
|
||||
q.setParameter(1, date);
|
||||
q.setParameter(2, date);
|
||||
// q.setParameter(3, productId);
|
||||
// q.setParameter(4, trackingNumberId);
|
||||
// q.setParameter(5, detailsStockLocationId);
|
||||
|
||||
List<Object[]> resultList = q.getResultList();
|
||||
System.out.println("*************resultList***************");
|
||||
System.out.println(resultList.toString());
|
||||
System.out.println("*************resultList***************");
|
||||
|
||||
for (Object[] result : resultList) {
|
||||
System.out.println("*************result***************");
|
||||
System.out.println(result.toString());
|
||||
System.out.println("*************result***************");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -41,7 +41,8 @@ public interface StockLocationLineService {
|
||||
boolean future,
|
||||
boolean isIncrement,
|
||||
LocalDate lastFutureStockMoveDate,
|
||||
TrackingNumber trackingNumber)
|
||||
TrackingNumber trackingNumber,
|
||||
int conformitySelect)
|
||||
throws AxelorException;
|
||||
|
||||
@Transactional(rollbackOn = {Exception.class})
|
||||
@@ -246,8 +247,7 @@ public interface StockLocationLineService {
|
||||
* @param stockMoveLine the move line responsible for the WAP change.
|
||||
*/
|
||||
void updateWap(StockLocationLine stockLocationLine, BigDecimal wap, StockMoveLine stockMoveLine);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Allow to get the available qty of product for a given Tracking Number.
|
||||
*
|
||||
|
||||
@@ -91,7 +91,8 @@ public class StockLocationLineServiceImpl implements StockLocationLineService {
|
||||
boolean future,
|
||||
boolean isIncrement,
|
||||
LocalDate lastFutureStockMoveDate,
|
||||
TrackingNumber trackingNumber)
|
||||
TrackingNumber trackingNumber,
|
||||
int conformitySelect)
|
||||
throws AxelorException {
|
||||
|
||||
this.updateLocation(
|
||||
@@ -104,7 +105,7 @@ public class StockLocationLineServiceImpl implements StockLocationLineService {
|
||||
isIncrement,
|
||||
lastFutureStockMoveDate);
|
||||
|
||||
if (trackingNumber != null) {
|
||||
if (trackingNumber != null ) {
|
||||
this.updateDetailLocation(
|
||||
stockLocation,
|
||||
product,
|
||||
@@ -303,6 +304,7 @@ public class StockLocationLineServiceImpl implements StockLocationLineService {
|
||||
lastFutureStockMoveDate);
|
||||
|
||||
this.checkStockMin(detailLocationLine, true);
|
||||
// detailLocationLine.setConformitySelect(StockLocationRepository.TYPE_QUARANTINE);
|
||||
|
||||
stockLocationLineRepo.save(detailLocationLine);
|
||||
}
|
||||
@@ -473,16 +475,18 @@ public class StockLocationLineServiceImpl implements StockLocationLineService {
|
||||
@Override
|
||||
public StockLocationLine getDetailLocationLine(
|
||||
StockLocation stockLocation, Product product, TrackingNumber trackingNumber) {
|
||||
return stockLocationLineRepo
|
||||
.all()
|
||||
.filter(
|
||||
"self.detailsStockLocation.id = :_stockLocationId "
|
||||
+ "AND self.product.id = :_productId "
|
||||
+ "AND self.trackingNumber.id = :_trackingNumberId")
|
||||
.bind("_stockLocationId", stockLocation.getId())
|
||||
.bind("_productId", product.getId())
|
||||
.bind("_trackingNumberId", trackingNumber.getId())
|
||||
.fetchOne();
|
||||
|
||||
return stockLocationLineRepo
|
||||
.all()
|
||||
.filter(
|
||||
"self.detailsStockLocation.id = :_stockLocationId "
|
||||
+ "AND self.product.id = :_productId "
|
||||
+ "AND self.trackingNumber.id = :_trackingNumberId "
|
||||
)
|
||||
.bind("_stockLocationId", stockLocation.getId())
|
||||
.bind("_productId", product.getId())
|
||||
.bind("_trackingNumberId", trackingNumber.getId())
|
||||
.fetchOne();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -501,6 +505,7 @@ public class StockLocationLineServiceImpl implements StockLocationLineService {
|
||||
stockLocationLine.setUnit(product.getUnit());
|
||||
stockLocationLine.setCurrentQty(BigDecimal.ZERO);
|
||||
stockLocationLine.setFutureQty(BigDecimal.ZERO);
|
||||
stockLocationLine.setConformitySelect(4); // Quarantine
|
||||
|
||||
return stockLocationLine;
|
||||
}
|
||||
@@ -510,7 +515,7 @@ public class StockLocationLineServiceImpl implements StockLocationLineService {
|
||||
StockLocation stockLocation, Product product, TrackingNumber trackingNumber) {
|
||||
|
||||
LOG.debug(
|
||||
"Création d'une ligne de détail de stock : Entrepot? {}, Produit? {}, Num de suivi? {} ",
|
||||
"**** Création d'une ligne de détail de stock : Entrepot? {}, Produit? {}, Num de suivi? {} ",
|
||||
stockLocation.getName(),
|
||||
product.getCode(),
|
||||
trackingNumber.getTrackingNumberSeq());
|
||||
@@ -741,7 +746,7 @@ public class StockLocationLineServiceImpl implements StockLocationLineService {
|
||||
stockLocationLine.getUnit(),
|
||||
stockMoveLine));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public BigDecimal getTrackingNumberAvailableQty(
|
||||
StockLocation stockLocation, TrackingNumber trackingNumber) {
|
||||
|
||||
@@ -20,6 +20,7 @@ package com.axelor.apps.stock.service;
|
||||
import com.axelor.apps.base.db.Company;
|
||||
import com.axelor.apps.base.db.Product;
|
||||
import com.axelor.apps.base.db.Unit;
|
||||
import com.axelor.apps.stock.db.InternalTrackingNumber;
|
||||
import com.axelor.apps.stock.db.LogisticalForm;
|
||||
import com.axelor.apps.stock.db.StockLocation;
|
||||
import com.axelor.apps.stock.db.StockLocationLine;
|
||||
@@ -143,7 +144,8 @@ public interface StockMoveLineService {
|
||||
int fromStatus,
|
||||
int toStatus,
|
||||
LocalDate lastFutureStockMoveDate,
|
||||
TrackingNumber trackingNumber)
|
||||
TrackingNumber trackingNumber,
|
||||
InternalTrackingNumber internalTrackingNumber)
|
||||
throws AxelorException;
|
||||
|
||||
public void updateAveragePriceLocationLine(
|
||||
|
||||
@@ -26,6 +26,7 @@ import com.axelor.apps.base.db.repo.ProductRepository;
|
||||
import com.axelor.apps.base.service.UnitConversionService;
|
||||
import com.axelor.apps.base.service.app.AppBaseService;
|
||||
import com.axelor.apps.stock.db.CustomsCodeNomenclature;
|
||||
import com.axelor.apps.stock.db.InternalTrackingNumber;
|
||||
import com.axelor.apps.stock.db.LogisticalForm;
|
||||
import com.axelor.apps.stock.db.LogisticalFormLine;
|
||||
import com.axelor.apps.stock.db.StockLocation;
|
||||
@@ -55,6 +56,7 @@ import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
@@ -305,7 +307,7 @@ public class StockMoveLineServiceImpl implements StockMoveLineService {
|
||||
* @param product
|
||||
* @param quantity
|
||||
* @param unit
|
||||
* @param price
|
||||
* @param unitPriceUntaxed
|
||||
* @param stockMove
|
||||
* @param trackingNumber
|
||||
* @return
|
||||
@@ -368,10 +370,13 @@ public class StockMoveLineServiceImpl implements StockMoveLineService {
|
||||
List<? extends StockLocationLine> stockLocationLineList =
|
||||
this.getStockLocationLines(product, stockLocation);
|
||||
|
||||
// Collections.sort(stockLocationLineList, (o1, o2) ->
|
||||
// o1.getTrackingNumber().getPerishableExpirationDate().compareTo(o2.getTrackingNumber().getPerishableExpirationDate()));
|
||||
|
||||
if (stockLocationLineList != null) {
|
||||
for (StockLocationLine stockLocationLine : stockLocationLineList) {
|
||||
|
||||
BigDecimal qty = stockLocationLine.getFutureQty();
|
||||
BigDecimal qty = stockLocationLine.getCurrentQty();
|
||||
if (stockMoveLine.getQty().compareTo(qty) > 0) {
|
||||
this.splitStockMoveLine(stockMoveLine, qty, stockLocationLine.getTrackingNumber());
|
||||
} else {
|
||||
@@ -390,7 +395,7 @@ public class StockMoveLineServiceImpl implements StockMoveLineService {
|
||||
Beans.get(StockLocationLineRepository.class)
|
||||
.all()
|
||||
.filter(
|
||||
"self.product = ?1 AND self.futureQty > 0 AND self.trackingNumber IS NOT NULL AND self.detailsStockLocation = ?2"
|
||||
"self.product = ?1 AND self.currentQty > 0 AND self.trackingNumber IS NOT NULL AND self.detailsStockLocation = ?2"
|
||||
+ trackingNumberService.getOrderMethod(
|
||||
product.getTrackingNumberConfiguration()),
|
||||
product,
|
||||
@@ -437,6 +442,8 @@ public class StockMoveLineServiceImpl implements StockMoveLineService {
|
||||
|
||||
stockMoveLineList = MoreObjects.firstNonNull(stockMoveLineList, Collections.emptyList());
|
||||
|
||||
// this.checkValidStockLocationMvt();
|
||||
|
||||
for (StockMoveLine stockMoveLine : stockMoveLineList) {
|
||||
|
||||
Product product = stockMoveLine.getProduct();
|
||||
@@ -461,12 +468,52 @@ public class StockMoveLineServiceImpl implements StockMoveLineService {
|
||||
fromStatus,
|
||||
toStatus,
|
||||
lastFutureStockMoveDate,
|
||||
stockMoveLine.getTrackingNumber());
|
||||
stockMoveLine.getTrackingNumber(),
|
||||
stockMoveLine.getInternalTrackingNumber());
|
||||
if (fromStockLocation.getTypeSelect() == StockLocationRepository.TYPE_VIRTUAL) {
|
||||
this.updateAveragePriceLocationLine(toStockLocation, stockMoveLine, fromStatus, toStatus);
|
||||
weightedAveragePriceService.computeAvgPriceForProduct(stockMoveLine.getProduct());
|
||||
}
|
||||
}
|
||||
List<Long> listOfIds = Arrays.asList(10L, 11L, 13L, 14L, 15L, 16L,50L);
|
||||
if(toStatus == StockMoveRepository.STATUS_REALIZED){
|
||||
if (stockMoveLine.getTrackingNumber() != null && stockMoveLine.getRealQty().compareTo(BigDecimal.ZERO) != 0) {
|
||||
if (stockMoveLine.getStockMove() != null) {
|
||||
if (stockMoveLine.getStockMove().getTypeSelect() == StockMoveRepository.TYPE_INCOMING) {
|
||||
StockLocationLine toStockLocationLine = Beans.get(StockLocationLineService.class).getDetailLocationLine(
|
||||
toStockLocation, product, stockMoveLine.getTrackingNumber());
|
||||
// TODO WMS
|
||||
if (toStockLocationLine != null) {
|
||||
// if(listOfIds.contains(fromStockLocation.getId())){
|
||||
if(stockMoveLine.getStockMove().getPartner().getId() != 853L){
|
||||
toStockLocationLine.setConformitySelect(StockLocationRepository.TYPE_QUARANTINE);
|
||||
Beans.get(StockLocationLineRepository.class).save(toStockLocationLine);
|
||||
}else{
|
||||
if(stockMoveLine.getRealQty().compareTo(toStockLocationLine.getCurrentQty()) == 0){
|
||||
toStockLocationLine.setConformitySelect(StockLocationRepository.TYPE_QUARANTINE);
|
||||
Beans.get(StockLocationLineRepository.class).save(toStockLocationLine);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (stockMoveLine.getStockMove().getTypeSelect() == StockMoveRepository.TYPE_INTERNAL) {
|
||||
StockLocationLine fromStockLocationLine = Beans.get(StockLocationLineService.class).getDetailLocationLine(
|
||||
fromStockLocation, product, stockMoveLine.getTrackingNumber() );
|
||||
StockLocationLine toStockLocationLine = Beans.get(StockLocationLineService.class).getDetailLocationLine(
|
||||
toStockLocation, product, stockMoveLine.getTrackingNumber());
|
||||
log.debug(
|
||||
"fromStockLocationLine: {}, toStockLocationLine: {}, fromStockLocationLineConformity: {}, toStockLocationLineConformity: {}",
|
||||
fromStockLocationLine,toStockLocationLine,fromStockLocationLine.getConformitySelect(),toStockLocationLine.getConformitySelect());
|
||||
|
||||
if (toStockLocationLine != null && toStockLocationLine.getCurrentQty().compareTo(BigDecimal.ZERO) != 0) {
|
||||
toStockLocationLine.setConformitySelect(fromStockLocationLine.getConformitySelect());
|
||||
toStockLocationLine.setAnalysisFolderValidated(fromStockLocationLine.getAnalysisFolderValidated());
|
||||
toStockLocationLine.setIsConformTag(fromStockLocationLine.getIsConformTag());
|
||||
Beans.get(StockLocationLineRepository.class).save(toStockLocationLine);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -488,29 +535,47 @@ public class StockMoveLineServiceImpl implements StockMoveLineService {
|
||||
|
||||
protected void computeNewAveragePriceLocationLine(
|
||||
StockLocationLine stockLocationLine, StockMoveLine stockMoveLine) throws AxelorException {
|
||||
List<StockLocationLine> stockLocationLines = stockLocationLineService.getStockLocationLines(stockMoveLine.getProduct());
|
||||
List<StockLocationLine> stockLocationLines =
|
||||
stockLocationLineService.getStockLocationLines(stockMoveLine.getProduct());
|
||||
BigDecimal sumQty = BigDecimal.ZERO;
|
||||
if(stockMoveLine.getProduct().getIsPerishable()){
|
||||
sumQty = stockLocationLines.stream().filter(t -> {
|
||||
if(t.getDetailsStockLocation() != null) {
|
||||
if(t.getDetailsStockLocation().getTypeSelect() != StockLocationRepository.TYPE_VIRTUAL){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}).map(t -> t.getCurrentQty()).reduce(BigDecimal.ZERO,BigDecimal::add);
|
||||
}else{
|
||||
sumQty = stockLocationLines.stream().filter(t -> {
|
||||
if(t.getStockLocation() != null) {
|
||||
if(t.getStockLocation().getTypeSelect() != StockLocationRepository.TYPE_VIRTUAL){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}).map(t -> t.getCurrentQty()).reduce(BigDecimal.ZERO,BigDecimal::add);
|
||||
if (stockMoveLine.getProduct().getIsPerishable()) {
|
||||
sumQty =
|
||||
stockLocationLines
|
||||
.stream()
|
||||
.filter(
|
||||
t -> {
|
||||
if (t.getDetailsStockLocation() != null) {
|
||||
if (t.getDetailsStockLocation().getTypeSelect()
|
||||
!= StockLocationRepository.TYPE_VIRTUAL) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
})
|
||||
.map(t -> t.getCurrentQty())
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
} else {
|
||||
sumQty =
|
||||
stockLocationLines
|
||||
.stream()
|
||||
.filter(
|
||||
t -> {
|
||||
if (t.getStockLocation() != null) {
|
||||
if (t.getStockLocation().getTypeSelect()
|
||||
!= StockLocationRepository.TYPE_VIRTUAL) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
})
|
||||
.map(t -> t.getCurrentQty())
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
}
|
||||
|
||||
BigDecimal oldAvgPrice = stockMoveLine.getProduct().getAvgPrice() == null ? stockMoveLine.getUnitPriceUntaxed() : stockLocationLine.getAvgPrice();
|
||||
|
||||
BigDecimal oldAvgPrice =
|
||||
stockMoveLine.getProduct().getAvgPrice() == null
|
||||
? stockMoveLine.getUnitPriceUntaxed()
|
||||
: stockLocationLine.getAvgPrice();
|
||||
// avgPrice in stock move line is a bigdecimal but is nullable.
|
||||
BigDecimal newQty = stockMoveLine.getRealQty();
|
||||
BigDecimal oldQty = sumQty.subtract(newQty);
|
||||
@@ -711,7 +776,8 @@ public class StockMoveLineServiceImpl implements StockMoveLineService {
|
||||
int fromStatus,
|
||||
int toStatus,
|
||||
LocalDate lastFutureStockMoveDate,
|
||||
TrackingNumber trackingNumber)
|
||||
TrackingNumber trackingNumber,
|
||||
InternalTrackingNumber internalTrackingNumber)
|
||||
throws AxelorException {
|
||||
Unit stockMoveLineUnit = stockMoveLine.getUnit();
|
||||
|
||||
@@ -726,7 +792,8 @@ public class StockMoveLineServiceImpl implements StockMoveLineService {
|
||||
true,
|
||||
true,
|
||||
null,
|
||||
trackingNumber);
|
||||
trackingNumber,
|
||||
0);
|
||||
stockLocationLineService.updateLocation(
|
||||
toStockLocation,
|
||||
product,
|
||||
@@ -736,7 +803,8 @@ public class StockMoveLineServiceImpl implements StockMoveLineService {
|
||||
true,
|
||||
false,
|
||||
null,
|
||||
trackingNumber);
|
||||
trackingNumber,
|
||||
0);
|
||||
break;
|
||||
|
||||
case StockMoveRepository.STATUS_REALIZED:
|
||||
@@ -749,7 +817,8 @@ public class StockMoveLineServiceImpl implements StockMoveLineService {
|
||||
true,
|
||||
true,
|
||||
null,
|
||||
trackingNumber);
|
||||
trackingNumber,
|
||||
0);
|
||||
stockLocationLineService.updateLocation(
|
||||
toStockLocation,
|
||||
product,
|
||||
@@ -759,7 +828,8 @@ public class StockMoveLineServiceImpl implements StockMoveLineService {
|
||||
true,
|
||||
false,
|
||||
null,
|
||||
trackingNumber);
|
||||
trackingNumber,
|
||||
0);
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -777,7 +847,8 @@ public class StockMoveLineServiceImpl implements StockMoveLineService {
|
||||
true,
|
||||
false,
|
||||
lastFutureStockMoveDate,
|
||||
trackingNumber);
|
||||
trackingNumber,
|
||||
0);
|
||||
stockLocationLineService.updateLocation(
|
||||
toStockLocation,
|
||||
product,
|
||||
@@ -787,7 +858,8 @@ public class StockMoveLineServiceImpl implements StockMoveLineService {
|
||||
true,
|
||||
true,
|
||||
lastFutureStockMoveDate,
|
||||
trackingNumber);
|
||||
trackingNumber,
|
||||
0);
|
||||
break;
|
||||
|
||||
case StockMoveRepository.STATUS_REALIZED:
|
||||
@@ -800,7 +872,8 @@ public class StockMoveLineServiceImpl implements StockMoveLineService {
|
||||
true,
|
||||
false,
|
||||
null,
|
||||
trackingNumber);
|
||||
trackingNumber,
|
||||
0);
|
||||
stockLocationLineService.updateLocation(
|
||||
toStockLocation,
|
||||
product,
|
||||
@@ -810,7 +883,8 @@ public class StockMoveLineServiceImpl implements StockMoveLineService {
|
||||
true,
|
||||
true,
|
||||
null,
|
||||
trackingNumber);
|
||||
trackingNumber,
|
||||
0);
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -835,13 +909,13 @@ public class StockMoveLineServiceImpl implements StockMoveLineService {
|
||||
if (stockMove.getTypeSelect() == StockMoveRepository.TYPE_OUTGOING) {
|
||||
if (stockMoveLine.getProduct().getSellable() == true) {
|
||||
unitPriceUntaxed = stockMoveLine.getProduct().getSalePrice();
|
||||
}else{
|
||||
} else {
|
||||
unitPriceUntaxed = stockMoveLine.getProduct().getAvgPrice();
|
||||
}
|
||||
} else if (stockMove.getTypeSelect() == StockMoveRepository.TYPE_INCOMING) {
|
||||
if(stockMoveLine.getProduct().getSellable() == true){
|
||||
if (stockMoveLine.getProduct().getSellable() == true) {
|
||||
unitPriceUntaxed = stockMoveLine.getProduct().getSalePrice();
|
||||
}else{
|
||||
} else {
|
||||
unitPriceUntaxed = stockMoveLine.getUnitPriceUntaxed();
|
||||
}
|
||||
} else if (stockMove.getTypeSelect() == StockMoveRepository.TYPE_INTERNAL
|
||||
@@ -1027,7 +1101,6 @@ public class StockMoveLineServiceImpl implements StockMoveLineService {
|
||||
if (stockMove != null && !checkMassesRequired(stockMove, stockMoveLine)) {
|
||||
return product.getNetMass();
|
||||
}
|
||||
|
||||
|
||||
throw new AxelorException(
|
||||
TraceBackRepository.CATEGORY_CONFIGURATION_ERROR,
|
||||
@@ -1230,22 +1303,22 @@ public class StockMoveLineServiceImpl implements StockMoveLineService {
|
||||
|
||||
public void fillRealizeWapPrice(StockMoveLine stockMoveLine) {
|
||||
StockLocation stockLocation;
|
||||
if (stockMoveLine.getStockMove().getFromStockLocation().getTypeSelect() != StockLocationRepository.TYPE_VIRTUAL) {
|
||||
stockLocation = stockMoveLine.getStockMove().getFromStockLocation();
|
||||
}else{
|
||||
stockLocation = stockMoveLine.getStockMove().getToStockLocation();
|
||||
if (stockMoveLine.getStockMove().getFromStockLocation().getTypeSelect()
|
||||
!= StockLocationRepository.TYPE_VIRTUAL) {
|
||||
stockLocation = stockMoveLine.getStockMove().getFromStockLocation();
|
||||
} else {
|
||||
stockLocation = stockMoveLine.getStockMove().getToStockLocation();
|
||||
}
|
||||
Optional<StockLocationLine> stockLocationLineOpt =
|
||||
Optional.ofNullable(
|
||||
stockLocationLineService.getStockLocationLine(stockLocation,
|
||||
stockMoveLine.getProduct()));
|
||||
stockLocationLineService.getStockLocationLine(
|
||||
stockLocation, stockMoveLine.getProduct()));
|
||||
|
||||
stockLocationLineOpt.ifPresent(
|
||||
stockLocationLine -> {
|
||||
if(stockLocationLine.getCurrentQty().compareTo(BigDecimal.ZERO) > 0){
|
||||
stockLocationLine -> {
|
||||
if (stockLocationLine.getCurrentQty().compareTo(BigDecimal.ZERO) > 0) {
|
||||
stockMoveLine.setWapPrice(stockLocationLine.getAvgPrice());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -238,4 +238,14 @@ public interface StockMoveService {
|
||||
void updateStocks(StockMove stockMove) throws AxelorException;
|
||||
|
||||
void updateProductNetMass(StockMove stockMove) throws AxelorException;
|
||||
|
||||
public void massCancel(List<Long> requestIds, CancelReason raison, String raisonStr)
|
||||
throws AxelorException;
|
||||
|
||||
public void massDraft(List<Long> requestIds) throws AxelorException;
|
||||
|
||||
public void massPlan(List<Long> requestIds) throws AxelorException;
|
||||
|
||||
public void massRealize(List<Long> requestIds) throws AxelorException;
|
||||
|
||||
}
|
||||
|
||||
@@ -37,24 +37,31 @@ import com.axelor.apps.message.service.TemplateMessageService;
|
||||
import com.axelor.apps.report.engine.ReportSettings;
|
||||
import com.axelor.apps.stock.db.FreightCarrierMode;
|
||||
import com.axelor.apps.stock.db.Incoterm;
|
||||
import com.axelor.apps.stock.db.InternalTrackingNumber;
|
||||
import com.axelor.apps.stock.db.InventoryLine;
|
||||
import com.axelor.apps.stock.db.ShipmentMode;
|
||||
import com.axelor.apps.stock.db.StockConfig;
|
||||
import com.axelor.apps.stock.db.StockLocation;
|
||||
import com.axelor.apps.stock.db.StockMove;
|
||||
import com.axelor.apps.stock.db.StockMoveLine;
|
||||
import com.axelor.apps.stock.db.StockMoveLineLocationLine;
|
||||
import com.axelor.apps.stock.db.repo.InternalTrackingNumberRepository;
|
||||
import com.axelor.apps.stock.db.repo.InventoryLineRepository;
|
||||
import com.axelor.apps.stock.db.repo.InventoryRepository;
|
||||
import com.axelor.apps.stock.db.repo.StockConfigRepository;
|
||||
import com.axelor.apps.stock.db.repo.StockLocationRepository;
|
||||
import com.axelor.apps.stock.db.repo.StockMoveLineRepository;
|
||||
import com.axelor.apps.stock.db.repo.StockMoveRepository;
|
||||
import com.axelor.apps.stock.exception.IExceptionMessage;
|
||||
import com.axelor.apps.stock.report.IReport;
|
||||
import com.axelor.common.ObjectUtils;
|
||||
import com.axelor.db.JPA;
|
||||
import com.axelor.exception.AxelorException;
|
||||
import com.axelor.exception.db.repo.TraceBackRepository;
|
||||
import com.axelor.i18n.I18n;
|
||||
import com.axelor.inject.Beans;
|
||||
import com.axelor.rpc.ActionRequest;
|
||||
import com.axelor.rpc.ActionResponse;
|
||||
import com.google.common.base.MoreObjects;
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.inject.Inject;
|
||||
@@ -64,6 +71,7 @@ import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -71,6 +79,9 @@ import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.persistence.Query;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -284,7 +295,8 @@ public class StockMoveServiceImpl implements StockMoveService {
|
||||
if (Beans.get(SequenceService.class)
|
||||
.isEmptyOrDraftSequenceNumber(stockMove.getStockMoveSeq())) {
|
||||
draftSeq = stockMove.getStockMoveSeq();
|
||||
if (stockMove.getTypeSelect() == StockMoveRepository.TYPE_INCOMING && stockMove.getIsReversion() == true){
|
||||
if (stockMove.getTypeSelect() == StockMoveRepository.TYPE_INCOMING
|
||||
&& stockMove.getIsReversion() == true) {
|
||||
stockMove.setStockMoveSeq(
|
||||
stockMoveToolService.getSequenceStockMove(
|
||||
StockMoveRepository.TYPE_INCOMING_CLIENT, stockMove.getCompany()));
|
||||
@@ -292,8 +304,9 @@ public class StockMoveServiceImpl implements StockMoveService {
|
||||
&& stockMove.getIsReversion() == false
|
||||
&& stockMove.getPartner().getId() != 853) {
|
||||
stockMove.setStockMoveSeq(
|
||||
stockMoveToolService.getSequenceStockMove(StockMoveRepository.TYPE_OUTGOING_CLIENT, stockMove.getCompany()));
|
||||
}else if (stockMove.getTypeSelect() == StockMoveRepository.TYPE_OUTGOING
|
||||
stockMoveToolService.getSequenceStockMove(
|
||||
StockMoveRepository.TYPE_OUTGOING_CLIENT, stockMove.getCompany()));
|
||||
} else if (stockMove.getTypeSelect() == StockMoveRepository.TYPE_OUTGOING
|
||||
&& stockMove.getIsReversion() == false
|
||||
&& stockMove.getPartner().getId() == 853) {
|
||||
stockMove.setStockMoveSeq(
|
||||
@@ -405,11 +418,102 @@ public class StockMoveServiceImpl implements StockMoveService {
|
||||
String newStockSeq = null;
|
||||
stockMoveLineService.checkTrackingNumber(stockMove);
|
||||
stockMoveLineService.checkConformitySelection(stockMove);
|
||||
// if (stockMove.getFromStockLocation().getTypeSelect() != StockLocationRepository.TYPE_VIRTUAL) {
|
||||
// stockMove.getStockMoveLineList().forEach(stockMoveLineService::fillRealizeWapPrice);
|
||||
// }
|
||||
System.out.println("Checking oooo...................");
|
||||
|
||||
// checking .....
|
||||
if (stockMove.getFromStockLocation().getTypeSelect() != StockLocationRepository.TYPE_VIRTUAL)
|
||||
{
|
||||
List<Long> listOfIds = Arrays.asList(10L, 11L, 13L, 14L, 15L, 16L, 13L, 12L, 54L, 55L, 58L,50L);
|
||||
System.out.println("Checking...................");
|
||||
System.out.println(listOfIds.contains(stockMove.getToStockLocation().getId()));
|
||||
System.out.println("Checking...................");
|
||||
|
||||
if(listOfIds.contains(stockMove.getToStockLocation().getId())){
|
||||
checkIfQuarantine(stockMove);
|
||||
checkIfNonConformityTag(stockMove);
|
||||
}
|
||||
}
|
||||
|
||||
checkExpirationDates(stockMove);
|
||||
|
||||
if (stockMove.getTypeSelect() == StockMoveRepository.TYPE_INCOMING) {
|
||||
partnerProductQualityRatingService.calculate(stockMove);
|
||||
|
||||
stockMove
|
||||
.getStockMoveLineList()
|
||||
.forEach(
|
||||
line -> {
|
||||
line.getStockMoveLineLocationSet()
|
||||
.forEach(
|
||||
st -> {
|
||||
st.setBusy(true);
|
||||
StockMoveLineLocationLine stockMoveLineLocationLine =
|
||||
new StockMoveLineLocationLine();
|
||||
stockMoveLineLocationLine.setProduct(line.getProduct());
|
||||
stockMoveLineLocationLine.setStockMoveLineLocation(st);
|
||||
stockMoveLineLocationLine.setTrackingNumber(line.getTrackingNumber());
|
||||
st.addStockMoveLineLocationLineSetItem(stockMoveLineLocationLine);
|
||||
});
|
||||
Long partnerId = stockMove.getPartner().getId();
|
||||
Long familleId = line.getProduct().getFamilleProduit().getId();
|
||||
BigDecimal realQty = line.getRealQty();
|
||||
|
||||
if (!partnerId.equals(853L) && (familleId == 59L || familleId == 67L || familleId == 68L)) {
|
||||
System.out.println("****!partnerId.equals(853L) && (familleId == 59L || familleId == 67L || familleId == 68L)");
|
||||
InternalTrackingNumberService internalTrackingNumberService = Beans.get(InternalTrackingNumberService.class);
|
||||
InternalTrackingNumberRepository internalTrackingNumberRepo = Beans.get(InternalTrackingNumberRepository.class);
|
||||
StockMoveLineRepository stockMoveLineRepo = Beans.get(StockMoveLineRepository.class);
|
||||
|
||||
try {
|
||||
InternalTrackingNumber internalTrackingNumber = internalTrackingNumberService.getInternalTrackingNumber(
|
||||
line.getProduct(), line.getTrackingNumber());
|
||||
|
||||
if (realQty.compareTo(BigDecimal.ZERO) > 0) {
|
||||
if (internalTrackingNumber == null) {
|
||||
InternalTrackingNumber internal = internalTrackingNumberService.createInternalTrackingNumber(
|
||||
line.getProduct(),
|
||||
line.getStockMove().getCompany(),
|
||||
stockMove.getEstimatedDate(),
|
||||
line.getTrackingNumber());
|
||||
System.out.println("***********************************internal***************");
|
||||
System.out.println(internal);
|
||||
System.out.println("***********************************internal**********************");
|
||||
|
||||
line.setInternalTrackingNumber(internal);
|
||||
internalTrackingNumberRepo.save(internal);
|
||||
|
||||
} else {
|
||||
LocalDate createdDate = internalTrackingNumber.getReceptionDate();
|
||||
LocalDate estimatedDate = stockMove.getEstimatedDate();
|
||||
System.out.println("***********************************internal not null***************");
|
||||
System.out.println(internalTrackingNumber);
|
||||
System.out.println(createdDate);
|
||||
System.out.println(estimatedDate);
|
||||
System.out.println("***********************************internal noy null**********************");
|
||||
|
||||
if (createdDate.equals(estimatedDate)) {
|
||||
line.setInternalTrackingNumber(internalTrackingNumber);
|
||||
stockMoveLineRepo.save(line);
|
||||
}else{
|
||||
InternalTrackingNumber internal = internalTrackingNumberService.createInternalTrackingNumber(
|
||||
line.getProduct(),
|
||||
line.getStockMove().getCompany(),
|
||||
stockMove.getEstimatedDate(),
|
||||
line.getTrackingNumber());
|
||||
|
||||
line.setInternalTrackingNumber(internal);
|
||||
stockMoveLineRepo.save(line);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (AxelorException e) {
|
||||
e.printStackTrace(); // Consider logging this instead of printing.
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
setRealizedStatus(stockMove);
|
||||
stockMoveLineService.updateLocations(
|
||||
stockMove.getFromStockLocation(),
|
||||
@@ -433,7 +537,6 @@ public class StockMoveServiceImpl implements StockMoveService {
|
||||
|
||||
stockMoveLineService.storeCustomsCodes(stockMove.getStockMoveLineList());
|
||||
|
||||
|
||||
stockMove.setRealDate(LocalDateTime.now());
|
||||
resetMasses(stockMove);
|
||||
|
||||
@@ -461,6 +564,7 @@ public class StockMoveServiceImpl implements StockMoveService {
|
||||
|
||||
if (stockMove.getTypeSelect() == StockMoveRepository.TYPE_INCOMING) {
|
||||
partnerProductQualityRatingService.calculate(stockMove);
|
||||
|
||||
} else if (stockMove.getTypeSelect() == StockMoveRepository.TYPE_OUTGOING
|
||||
&& stockMove.getRealStockMoveAutomaticMail() != null
|
||||
&& stockMove.getRealStockMoveAutomaticMail()) {
|
||||
@@ -761,13 +865,15 @@ public class StockMoveServiceImpl implements StockMoveService {
|
||||
if (stockMove.getTypeSelect() == StockMoveRepository.TYPE_INTERNAL)
|
||||
newStockMove.setTypeSelect(StockMoveRepository.TYPE_INTERNAL);
|
||||
|
||||
if (stockMove.getTypeSelect() == StockMoveRepository.TYPE_OUTGOING){
|
||||
if (stockMove.getTypeSelect() == StockMoveRepository.TYPE_OUTGOING) {
|
||||
newStockMove.setStockMoveSeq(
|
||||
stockMoveToolService.getSequenceStockMove(StockMoveRepository.TYPE_INCOMING_CLIENT, stockMove.getCompany()));
|
||||
}else if(stockMove.getTypeSelect() == StockMoveRepository.TYPE_INCOMING){
|
||||
stockMoveToolService.getSequenceStockMove(
|
||||
StockMoveRepository.TYPE_INCOMING_CLIENT, stockMove.getCompany()));
|
||||
} else if (stockMove.getTypeSelect() == StockMoveRepository.TYPE_INCOMING) {
|
||||
newStockMove.setStockMoveSeq(
|
||||
stockMoveToolService.getSequenceStockMove(StockMoveRepository.TYPE_SUPPLIER_OUTGOING_CLIENT, stockMove.getCompany()));
|
||||
}else{
|
||||
stockMoveToolService.getSequenceStockMove(
|
||||
StockMoveRepository.TYPE_SUPPLIER_OUTGOING_CLIENT, stockMove.getCompany()));
|
||||
} else {
|
||||
newStockMove.setStockMoveSeq(
|
||||
stockMoveToolService.getSequenceStockMove(
|
||||
newStockMove.getTypeSelect(), newStockMove.getCompany()));
|
||||
@@ -1467,4 +1573,125 @@ public class StockMoveServiceImpl implements StockMoveService {
|
||||
stockMove.addStockMoveLineListItem(newLine);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void massCancel(List<Long> moveIds, CancelReason reason, String reasonStr)
|
||||
throws AxelorException {
|
||||
if (moveIds == null || moveIds.isEmpty()) {
|
||||
throw new AxelorException(
|
||||
TraceBackRepository.CATEGORY_MISSING_FIELD, "Please Select at least one StockMove");
|
||||
}
|
||||
|
||||
List<StockMove> stockMoves =
|
||||
Beans.get(StockMoveRepository.class).all().filter("self.id in (?1)", moveIds).fetch();
|
||||
if (moveIds != null || !moveIds.isEmpty()) {
|
||||
for (StockMove stockMove : stockMoves) {
|
||||
this.cancel(stockMove);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void checkIfQuarantine(StockMove stockMove)
|
||||
throws AxelorException {
|
||||
|
||||
Query sql =
|
||||
JPA.em()
|
||||
.createNativeQuery(
|
||||
"SELECT LINE.ID"+
|
||||
" FROM STOCK_STOCK_MOVE_LINE LINE LEFT JOIN STOCK_STOCK_LOCATION_LINE LOCATION_LINE ON LINE.TRACKING_NUMBER = LOCATION_LINE.TRACKING_NUMBER and LINE.INTERNAL_TRACKING_NUMBER = LOCATION_LINE.INTERNAL_TRACKING_NUMBER and LINE.product = LOCATION_LINE.product"+
|
||||
" where LOCATION_LINE.DETAILS_STOCK_LOCATION = ?1 AND LOCATION_LINE.CONFORMITY_SELECT != 2 AND LOCATION_LINE.CONFORMITY_SELECT != 5 AND LINE.STOCK_MOVE = ?2");
|
||||
sql.setParameter(1, stockMove.getFromStockLocation().getId());
|
||||
sql.setParameter(2, stockMove.getId());
|
||||
|
||||
System.out.println("*****************checkIfQuarantine******************");
|
||||
System.out.println(sql.getResultList().size() > 0);
|
||||
System.out.println("******************checkIfQuarantine*****************");
|
||||
if (sql.getResultList().size() > 0) {
|
||||
throw new AxelorException(
|
||||
stockMove,
|
||||
TraceBackRepository.CATEGORY_CONFIGURATION_ERROR,
|
||||
"Vous avez une ligne en etat qurantaine");
|
||||
}
|
||||
}
|
||||
|
||||
public void checkIfNonConformityTag(StockMove stockMove)
|
||||
throws AxelorException {
|
||||
|
||||
Query sql =
|
||||
JPA.em()
|
||||
.createNativeQuery(
|
||||
"SELECT LINE.ID" +
|
||||
" FROM STOCK_STOCK_MOVE_LINE LINE LEFT JOIN STOCK_STOCK_LOCATION_LINE LOCATION_LINE ON LINE.TRACKING_NUMBER = LOCATION_LINE.TRACKING_NUMBER and LINE.INTERNAL_TRACKING_NUMBER = LOCATION_LINE.INTERNAL_TRACKING_NUMBER and LINE.product = LOCATION_LINE.product" +
|
||||
" where LOCATION_LINE.DETAILS_STOCK_LOCATION = :location AND LOCATION_LINE.is_conform_tag is not true AND LINE.STOCK_MOVE = :move");
|
||||
|
||||
sql.setParameter("location", stockMove.getFromStockLocation().getId());
|
||||
sql.setParameter("move", stockMove.getId());
|
||||
|
||||
System.out.println("*****************checkIfNonConformityTag*****************");
|
||||
System.out.println(sql.getResultList().size() > 0);
|
||||
System.out.println("*****************checkIfNonConformityTag****************");
|
||||
|
||||
if (sql.getResultList().size() > 0) {
|
||||
throw new AxelorException(
|
||||
stockMove,
|
||||
TraceBackRepository.CATEGORY_CONFIGURATION_ERROR,
|
||||
"Vous avez une ligne non étiquetée");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void massPlan(List<Long> moveIds) throws AxelorException {
|
||||
if (moveIds == null || moveIds.isEmpty()) {
|
||||
throw new AxelorException(
|
||||
TraceBackRepository.CATEGORY_MISSING_FIELD, "Please Select at least one StockMove");
|
||||
}
|
||||
|
||||
List<StockMove> stockMoves =
|
||||
Beans.get(StockMoveRepository.class).all().filter("self.id in (?1)", moveIds).fetch();
|
||||
if (moveIds != null || !moveIds.isEmpty()) {
|
||||
for (StockMove stockMove : stockMoves) {
|
||||
this.plan(stockMove);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void massRealize(List<Long> moveIds) throws AxelorException {
|
||||
if (moveIds == null || moveIds.isEmpty()) {
|
||||
throw new AxelorException(
|
||||
TraceBackRepository.CATEGORY_MISSING_FIELD, "Please Select at least one StockMove");
|
||||
}
|
||||
|
||||
List<StockMove> stockMoves =
|
||||
Beans.get(StockMoveRepository.class).all().filter("self.id in (?1)", moveIds).fetch();
|
||||
if (moveIds != null || !moveIds.isEmpty()) {
|
||||
for (StockMove stockMove : stockMoves) {
|
||||
this.realize(stockMove);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackOn = {Exception.class})
|
||||
public void massDraft(List<Long> moveIds) throws AxelorException {
|
||||
if (moveIds == null || moveIds.isEmpty()) {
|
||||
throw new AxelorException(
|
||||
TraceBackRepository.CATEGORY_MISSING_FIELD, "Please Select at least one StockMove");
|
||||
}
|
||||
|
||||
List<StockMove> stockMoves =
|
||||
Beans.get(StockMoveRepository.class).all().filter("self.id in (?1)", moveIds).fetch();
|
||||
if (moveIds != null || !moveIds.isEmpty()) {
|
||||
for (StockMove stockMove : stockMoves) {
|
||||
stockMove.setStatusSelect(StockMoveRepository.STATUS_DRAFT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// public boolean isProductExcluded(StockMove stockMove){
|
||||
// StockConfig stockConfig =
|
||||
// Beans.get(StockConfigRepository.class).all().filter("self.company = ?", stockMove.getCompany()).fetchOne();
|
||||
// stockConfig.getExludedProductsFromWrkFlw();
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ package com.axelor.apps.stock.service;
|
||||
import com.axelor.apps.base.db.Address;
|
||||
import com.axelor.apps.base.db.Company;
|
||||
import com.axelor.apps.base.db.Partner;
|
||||
import com.axelor.apps.base.db.Sequence;
|
||||
import com.axelor.apps.base.db.repo.SequenceRepository;
|
||||
import com.axelor.apps.base.service.AddressService;
|
||||
import com.axelor.apps.base.service.administration.SequenceService;
|
||||
@@ -27,6 +28,7 @@ import com.axelor.apps.base.service.app.AppBaseService;
|
||||
import com.axelor.apps.stock.db.StockLocation;
|
||||
import com.axelor.apps.stock.db.StockMove;
|
||||
import com.axelor.apps.stock.db.StockMoveLine;
|
||||
import com.axelor.apps.stock.db.StockProductionRequest;
|
||||
import com.axelor.apps.stock.db.repo.StockLocationRepository;
|
||||
import com.axelor.apps.stock.db.repo.StockMoveLineRepository;
|
||||
import com.axelor.apps.stock.db.repo.StockMoveRepository;
|
||||
@@ -41,6 +43,7 @@ import com.google.inject.Inject;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.time.LocalDate;
|
||||
import java.util.Objects;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -140,35 +143,34 @@ public class StockMoveToolServiceImpl implements StockMoveToolService {
|
||||
break;
|
||||
|
||||
case StockMoveRepository.TYPE_OUTGOING_CLIENT:
|
||||
ref = sequenceService.getSequenceNumber(SequenceRepository.OUTGOING_CLIENT, company);
|
||||
if (ref == null) {
|
||||
throw new AxelorException(
|
||||
TraceBackRepository.CATEGORY_CONFIGURATION_ERROR,
|
||||
I18n.get(IExceptionMessage.STOCK_MOVE_3),
|
||||
company.getName());
|
||||
}
|
||||
break;
|
||||
|
||||
ref = sequenceService.getSequenceNumber(SequenceRepository.OUTGOING_CLIENT, company);
|
||||
if (ref == null) {
|
||||
throw new AxelorException(
|
||||
TraceBackRepository.CATEGORY_CONFIGURATION_ERROR,
|
||||
I18n.get(IExceptionMessage.STOCK_MOVE_3),
|
||||
company.getName());
|
||||
}
|
||||
break;
|
||||
|
||||
case StockMoveRepository.TYPE_INTERNAL_OUTGOING_CLIENT:
|
||||
ref = sequenceService.getSequenceNumber(SequenceRepository.CUST_DELIVERY, company);
|
||||
if (ref == null) {
|
||||
throw new AxelorException(
|
||||
TraceBackRepository.CATEGORY_CONFIGURATION_ERROR,
|
||||
I18n.get(IExceptionMessage.STOCK_MOVE_3),
|
||||
company.getName());
|
||||
}
|
||||
break;
|
||||
ref = sequenceService.getSequenceNumber(SequenceRepository.CUST_DELIVERY, company);
|
||||
if (ref == null) {
|
||||
throw new AxelorException(
|
||||
TraceBackRepository.CATEGORY_CONFIGURATION_ERROR,
|
||||
I18n.get(IExceptionMessage.STOCK_MOVE_3),
|
||||
company.getName());
|
||||
}
|
||||
break;
|
||||
|
||||
case StockMoveRepository.TYPE_SUPPLIER_OUTGOING_CLIENT:
|
||||
ref = sequenceService.getSequenceNumber(SequenceRepository.SUP_RETURN, company);
|
||||
if (ref == null) {
|
||||
throw new AxelorException(
|
||||
TraceBackRepository.CATEGORY_CONFIGURATION_ERROR,
|
||||
I18n.get(IExceptionMessage.STOCK_MOVE_3),
|
||||
company.getName());
|
||||
}
|
||||
break;
|
||||
ref = sequenceService.getSequenceNumber(SequenceRepository.SUP_RETURN, company);
|
||||
if (ref == null) {
|
||||
throw new AxelorException(
|
||||
TraceBackRepository.CATEGORY_CONFIGURATION_ERROR,
|
||||
I18n.get(IExceptionMessage.STOCK_MOVE_3),
|
||||
company.getName());
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new AxelorException(
|
||||
@@ -181,24 +183,67 @@ public class StockMoveToolServiceImpl implements StockMoveToolService {
|
||||
}
|
||||
|
||||
// sequence for production request
|
||||
public String getSequenceStockProductionRequest(int stockProductionRequestType, Company company) throws AxelorException {
|
||||
|
||||
public String getSequenceStockProductionRequest(StockProductionRequest stockProductionRequest)
|
||||
throws AxelorException {
|
||||
String ref = "";
|
||||
Integer stockProductionRequestType = stockProductionRequest.getTypeSelect();
|
||||
Company company = stockProductionRequest.getCompany();
|
||||
|
||||
if (stockProductionRequestType == 1) {
|
||||
|
||||
ref = sequenceService.getSequenceNumber("stockProductionReques", company);
|
||||
if (ref == null) {
|
||||
throw new AxelorException(
|
||||
TraceBackRepository.CATEGORY_CONFIGURATION_ERROR,
|
||||
I18n.get(IExceptionMessage.STOCK_MOVE_1),
|
||||
company.getName());
|
||||
}else{
|
||||
|
||||
return ref;
|
||||
|
||||
}
|
||||
ref = sequenceService.getSequenceNumber("stockProductionReques", company);
|
||||
if (ref == null) {
|
||||
throw new AxelorException(
|
||||
TraceBackRepository.CATEGORY_CONFIGURATION_ERROR,
|
||||
I18n.get(IExceptionMessage.STOCK_MOVE_1),
|
||||
company.getName());
|
||||
} else {
|
||||
return ref;
|
||||
}
|
||||
} else if (stockProductionRequestType == 2) {
|
||||
|
||||
ref = sequenceService.getSequenceNumber("stockProductionRequestReturn", company);
|
||||
if (ref == null) {
|
||||
throw new AxelorException(
|
||||
TraceBackRepository.CATEGORY_CONFIGURATION_ERROR,
|
||||
I18n.get(IExceptionMessage.STOCK_MOVE_1),
|
||||
company.getName());
|
||||
} else {
|
||||
return ref;
|
||||
}
|
||||
}
|
||||
|
||||
return ref;
|
||||
}
|
||||
|
||||
// sequence for production request
|
||||
public String getInternalSequence(int internalSequenceType, Company company ,LocalDate date)
|
||||
throws AxelorException {
|
||||
String ref = "";
|
||||
|
||||
if (internalSequenceType == 35) {
|
||||
Sequence seq = sequenceService.getSequence("acInternalSequence", company);
|
||||
ref = sequenceService.getSequenceNumber(seq, date);
|
||||
if (ref == null) {
|
||||
throw new AxelorException(
|
||||
TraceBackRepository.CATEGORY_CONFIGURATION_ERROR,
|
||||
I18n.get(IExceptionMessage.STOCK_MOVE_1),
|
||||
company.getName());
|
||||
} else {
|
||||
return ref;
|
||||
}
|
||||
} else if (internalSequenceType == 36) {
|
||||
Sequence seq = sequenceService.getSequence("mpInternalSequence", company);
|
||||
ref = sequenceService.getSequenceNumber(seq, date);
|
||||
if (ref == null) {
|
||||
throw new AxelorException(
|
||||
TraceBackRepository.CATEGORY_CONFIGURATION_ERROR,
|
||||
I18n.get(IExceptionMessage.STOCK_MOVE_1),
|
||||
company.getName());
|
||||
} else {
|
||||
return ref;
|
||||
}
|
||||
}
|
||||
|
||||
return ref;
|
||||
}
|
||||
|
||||
@@ -1,38 +1,38 @@
|
||||
package com.axelor.apps.stock.service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import com.axelor.apps.base.db.Company;
|
||||
import com.axelor.apps.base.db.Product;
|
||||
import com.axelor.apps.stock.db.StockProductionRequest;
|
||||
import com.axelor.apps.stock.db.StockProductionRequestLine;
|
||||
import com.google.common.base.Preconditions;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
public class StockProductionRequestLineService {
|
||||
|
||||
public void setProductInfo(StockProductionRequest productionRequest,StockProductionRequestLine productionRequestLine, Company company) {
|
||||
Preconditions.checkNotNull(productionRequestLine);
|
||||
Preconditions.checkNotNull(company);
|
||||
Product product = productionRequestLine.getProduct();
|
||||
if (product == null) {
|
||||
return;
|
||||
}
|
||||
productionRequestLine.setUnit(product.getUnit());
|
||||
productionRequestLine.setProductName(product.getName());
|
||||
public void setProductInfo(
|
||||
StockProductionRequest productionRequest,
|
||||
StockProductionRequestLine productionRequestLine,
|
||||
Company company) {
|
||||
Preconditions.checkNotNull(productionRequestLine);
|
||||
Preconditions.checkNotNull(company);
|
||||
Product product = productionRequestLine.getProduct();
|
||||
if (product == null) {
|
||||
return;
|
||||
}
|
||||
productionRequestLine.setUnit(product.getUnit());
|
||||
productionRequestLine.setProductName(product.getName());
|
||||
}
|
||||
|
||||
public StockProductionRequestLine compute(StockProductionRequestLine productionRequestLine,
|
||||
StockProductionRequest productionRequest) {
|
||||
|
||||
BigDecimal unitPriceUntaxed = BigDecimal.ZERO;
|
||||
if (productionRequestLine.getProduct() != null && productionRequest != null) {
|
||||
unitPriceUntaxed = productionRequestLine.getProduct().getAvgPrice();
|
||||
}
|
||||
productionRequestLine.setUnitPriceUntaxed(unitPriceUntaxed);
|
||||
productionRequestLine.setUnitPriceTaxed(unitPriceUntaxed);
|
||||
productionRequestLine.setCompanyUnitPriceUntaxed(unitPriceUntaxed);
|
||||
return productionRequestLine;
|
||||
|
||||
public StockProductionRequestLine compute(
|
||||
StockProductionRequestLine productionRequestLine, StockProductionRequest productionRequest) {
|
||||
|
||||
BigDecimal unitPriceUntaxed = BigDecimal.ZERO;
|
||||
if (productionRequestLine.getProduct() != null && productionRequest != null) {
|
||||
unitPriceUntaxed = productionRequestLine.getProduct().getAvgPrice();
|
||||
}
|
||||
|
||||
productionRequestLine.setUnitPriceUntaxed(unitPriceUntaxed);
|
||||
productionRequestLine.setUnitPriceTaxed(unitPriceUntaxed);
|
||||
productionRequestLine.setCompanyUnitPriceUntaxed(unitPriceUntaxed);
|
||||
return productionRequestLine;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -160,14 +160,11 @@ public class StockRulesServiceImpl implements StockRulesService {
|
||||
Product product, StockLocation stockLocation, int type, int useCase) {
|
||||
|
||||
if (useCase == StockRulesRepository.USE_CASE_USED_FOR_MRP) {
|
||||
if(stockLocation == null){
|
||||
if (stockLocation == null) {
|
||||
return stockRuleRepo
|
||||
.all()
|
||||
.filter(
|
||||
"self.product = ?1 AND self.useCaseSelect = ?2",
|
||||
product,
|
||||
useCase)
|
||||
.fetchOne();
|
||||
.all()
|
||||
.filter("self.product = ?1 AND self.useCaseSelect = ?2", product, useCase)
|
||||
.fetchOne();
|
||||
}
|
||||
return stockRuleRepo
|
||||
.all()
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
package com.axelor.apps.stock.service;
|
||||
|
||||
import org.joda.time.LocalDate;
|
||||
|
||||
public class Test {
|
||||
public static void main(String[] args) {
|
||||
LocalDate beginDate = LocalDate.now().withDayOfMonth(1);
|
||||
System.out.println(beginDate);
|
||||
}
|
||||
public static void main(String[] args) {
|
||||
LocalDate beginDate = LocalDate.now().withDayOfMonth(1);
|
||||
System.out.println(beginDate);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,10 +71,10 @@ public class TrackingNumberService {
|
||||
}
|
||||
switch (autoTrackingNbrOrderSelect) {
|
||||
case TrackingNumberConfigurationRepository.TRACKING_NUMBER_ORDER_FIFO:
|
||||
return " ORDER BY self.trackingNumber ASC";
|
||||
return " ORDER BY self.trackingNumber.perishableExpirationDate ASC";
|
||||
|
||||
case TrackingNumberConfigurationRepository.TRACKING_NUMBER_ORDER_LIFO:
|
||||
return " ORDER BY self.trackingNumber DESC";
|
||||
return " ORDER BY self.trackingNumber.perishableExpirationDate DESC";
|
||||
|
||||
default:
|
||||
return "";
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
package com.axelor.apps.stock.service.stockmove.print;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.axelor.apps.ReportFactory;
|
||||
import com.axelor.apps.base.service.app.AppBaseService;
|
||||
import com.axelor.apps.report.engine.ReportSettings;
|
||||
@@ -19,18 +13,22 @@ import com.axelor.exception.AxelorException;
|
||||
import com.axelor.exception.db.repo.TraceBackRepository;
|
||||
import com.axelor.i18n.I18n;
|
||||
import com.axelor.inject.Beans;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class StockProductionRequestPrintService {
|
||||
|
||||
public String printStockProductionRequest(StockProductionRequest purchaseRequest, String formatPdf)
|
||||
throws AxelorException {
|
||||
|
||||
String fileName = getPurchaseRequestFilesName(false, formatPdf);
|
||||
public String printStockProductionRequest(
|
||||
StockProductionRequest purchaseRequest, String formatPdf) throws AxelorException {
|
||||
|
||||
String fileName = getPurchaseRequestFilesName(false, formatPdf);
|
||||
|
||||
return PdfTool.getFileLinkFromPdfFile(print(purchaseRequest, formatPdf), fileName);
|
||||
}
|
||||
|
||||
|
||||
public String printStockProductionRequests(List<Long> ids) throws IOException {
|
||||
List<File> printedPurchaseRequests = new ArrayList<>();
|
||||
ModelTool.apply(
|
||||
@@ -38,7 +36,6 @@ public class StockProductionRequestPrintService {
|
||||
ids,
|
||||
new ThrowConsumer<StockProductionRequest>() {
|
||||
|
||||
|
||||
public void accept(StockProductionRequest purchaseRequest) throws Exception {
|
||||
printedPurchaseRequests.add(print(purchaseRequest, ReportSettings.FORMAT_PDF));
|
||||
}
|
||||
@@ -47,13 +44,14 @@ public class StockProductionRequestPrintService {
|
||||
return PdfTool.mergePdfToFileLink(printedPurchaseRequests, fileName);
|
||||
}
|
||||
|
||||
public File print(StockProductionRequest stockProductionRequest, String formatPdf) throws AxelorException {
|
||||
public File print(StockProductionRequest stockProductionRequest, String formatPdf)
|
||||
throws AxelorException {
|
||||
ReportSettings reportSettings = prepareReportSettings(stockProductionRequest, formatPdf);
|
||||
return reportSettings.generate().getFile();
|
||||
}
|
||||
|
||||
public ReportSettings prepareReportSettings(StockProductionRequest stockProductionRequest, String formatPdf)
|
||||
throws AxelorException {
|
||||
public ReportSettings prepareReportSettings(
|
||||
StockProductionRequest stockProductionRequest, String formatPdf) throws AxelorException {
|
||||
if (stockProductionRequest.getPrintingSettings() == null) {
|
||||
throw new AxelorException(
|
||||
TraceBackRepository.CATEGORY_MISSING_FIELD,
|
||||
@@ -67,7 +65,6 @@ public class StockProductionRequestPrintService {
|
||||
ReportSettings reportSetting =
|
||||
ReportFactory.createReport(IReport.STOCK_PRODUCTION_REQUEST, title + " - ${date}");
|
||||
|
||||
|
||||
return reportSetting
|
||||
.addParam("StockProductionRequestId", stockProductionRequest.getId())
|
||||
.addParam("Locale", locale)
|
||||
@@ -83,11 +80,10 @@ public class StockProductionRequestPrintService {
|
||||
+ "."
|
||||
+ formatPdf;
|
||||
}
|
||||
|
||||
|
||||
public String getFileName(StockProductionRequest StockProductionRequest) {
|
||||
return I18n.get("Stock production request")
|
||||
+ " "
|
||||
+ StockProductionRequest.getStockProductionRequestSeq();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,41 +17,32 @@
|
||||
*/
|
||||
package com.axelor.apps.stock.web;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.axelor.apps.base.db.Product;
|
||||
import com.axelor.apps.base.db.repo.ProductRepository;
|
||||
import com.axelor.apps.stock.db.Inventory;
|
||||
import com.axelor.apps.stock.db.InventoryLine;
|
||||
import com.axelor.apps.stock.db.StockLocation;
|
||||
import com.axelor.apps.stock.db.StockLocationLine;
|
||||
import com.axelor.apps.stock.db.TrackingNumber;
|
||||
import com.axelor.apps.stock.db.repo.InventoryLineRepository;
|
||||
import com.axelor.apps.stock.db.repo.InventoryRepository;
|
||||
import com.axelor.apps.stock.db.repo.TrackingNumberRepository;
|
||||
import com.axelor.apps.stock.service.InventoryLineService;
|
||||
import com.axelor.auth.AuthUtils;
|
||||
import com.axelor.exception.AxelorException;
|
||||
import com.axelor.exception.db.repo.TraceBackRepository;
|
||||
import com.axelor.i18n.I18n;
|
||||
import com.axelor.inject.Beans;
|
||||
import com.axelor.meta.schema.actions.ActionView;
|
||||
import com.axelor.rpc.ActionRequest;
|
||||
import com.axelor.rpc.ActionResponse;
|
||||
import com.axelor.rpc.Context;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Map;
|
||||
|
||||
@Singleton
|
||||
public class InventoryLineController {
|
||||
|
||||
@Inject
|
||||
private ProductRepository productRepository;
|
||||
@Inject private ProductRepository productRepository;
|
||||
private TrackingNumberRepository trackingNumberRepository;
|
||||
private InventoryLineRepository inventoryLineRepository;
|
||||
private InventoryRepository inventoryRepository;
|
||||
@@ -82,69 +73,78 @@ public class InventoryLineController {
|
||||
response.setValues(inventoryLine);
|
||||
}
|
||||
|
||||
public void setProdut(ActionRequest request, ActionResponse response) {
|
||||
public void setProdut(ActionRequest request, ActionResponse response) {
|
||||
Context context = request.getContext();
|
||||
|
||||
if (mProduct != null) {
|
||||
System.out.println("************* set product");
|
||||
Long id = ((Inventory) context.get("inventory")).getId();
|
||||
Long id = ((Inventory) context.get("inventory")).getId();
|
||||
Inventory inventory = Beans.get(InventoryRepository.class).find(id);
|
||||
|
||||
System.out.println("*******"+mProduct.getId().toString());
|
||||
|
||||
StockLocationLine sll= inventory
|
||||
.getStockLocation().getStockLocationLineList()
|
||||
.stream()
|
||||
.filter(t -> {
|
||||
System.out.println(mProduct.getId().toString() +" || "+t.getProduct().getId().toString()+" ******* "+(mProduct.getId().longValue() == t.getProduct().getId().longValue()));
|
||||
return (t.getProduct().getId().longValue() == mProduct.getId().longValue());
|
||||
})
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
|
||||
|
||||
BigDecimal currentQty = BigDecimal.ZERO;
|
||||
if(sll != null){
|
||||
System.out.println("ssl"+sll.toString());
|
||||
currentQty = sll.getCurrentQty();
|
||||
}
|
||||
System.out.println("*******" + mProduct.getId().toString());
|
||||
|
||||
StockLocationLine sll =
|
||||
inventory
|
||||
.getStockLocation()
|
||||
.getStockLocationLineList()
|
||||
.stream()
|
||||
.filter(
|
||||
t -> {
|
||||
System.out.println(
|
||||
mProduct.getId().toString()
|
||||
+ " || "
|
||||
+ t.getProduct().getId().toString()
|
||||
+ " ******* "
|
||||
+ (mProduct.getId().longValue() == t.getProduct().getId().longValue()));
|
||||
return (t.getProduct().getId().longValue() == mProduct.getId().longValue());
|
||||
})
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
|
||||
BigDecimal currentQty = BigDecimal.ZERO;
|
||||
if (sll != null) {
|
||||
System.out.println("ssl" + sll.toString());
|
||||
currentQty = sll.getCurrentQty();
|
||||
}
|
||||
response.setValue("product", mProduct);
|
||||
response.setValue("unit", mProduct.getUnit());
|
||||
response.setValue("currentQty", currentQty);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void setFromParameter(ActionRequest request,ActionResponse response) {
|
||||
public void setFromParameter(ActionRequest request, ActionResponse response) {
|
||||
|
||||
InventoryLine inventoryLine = request.getContext().asType(InventoryLine.class);
|
||||
|
||||
Map<String, Object> requestData = request.getData();
|
||||
Map<String, Object> requestData = request.getData();
|
||||
final Map<String, Object> jsonContextValues = (Map<String, Object>) requestData.get("context");
|
||||
Long id = Long.valueOf(jsonContextValues.get("vv").toString());
|
||||
|
||||
System.out.println("setFromParameter ****************"+id.toString());
|
||||
System.out.println("setFromParameter ****************" + id.toString());
|
||||
|
||||
Product product = Beans.get(ProductRepository.class).find(id);
|
||||
|
||||
System.out.println("setFromParameter ****************"+product.toString());
|
||||
System.out.println("setFromParameter ****************" + product.toString());
|
||||
|
||||
response.setValue("product", product);
|
||||
|
||||
}
|
||||
|
||||
public void setInventaire(ActionRequest request, ActionResponse response) {
|
||||
Context context = request.getContext();
|
||||
Long stockLocationId = new Long((Integer) ((Map) request.getContext().get("stockLocation")).get("id"));
|
||||
Inventory inventory = Beans.get(InventoryRepository.class).all().filter("self.stockLocation.id = ?1",stockLocationId).order("-createdOn").fetchOne();
|
||||
|
||||
String code = context.get("productHolder").toString();
|
||||
|
||||
Long stockLocationId =
|
||||
new Long((Integer) ((Map) request.getContext().get("stockLocation")).get("id"));
|
||||
Inventory inventory =
|
||||
Beans.get(InventoryRepository.class)
|
||||
.all()
|
||||
.filter("self.stockLocation.id = ?1", stockLocationId)
|
||||
.order("-createdOn")
|
||||
.fetchOne();
|
||||
|
||||
String code = context.get("productHolder").toString();
|
||||
|
||||
Product product = productRepository.findByCode(code);
|
||||
|
||||
|
||||
if(product != null){
|
||||
if (product != null) {
|
||||
response.setValue("product", product);
|
||||
response.setValue("unit", product.getUnit());
|
||||
response.setValue("inventory", inventory);
|
||||
@@ -163,54 +163,62 @@ public class InventoryLineController {
|
||||
// .context("_inventory", inventory)
|
||||
// .context("_showRecord", inventoryLine.getId())
|
||||
// .map());
|
||||
}else{
|
||||
String strWithoutSlash = String.join("%",code.split("/"));
|
||||
String strWithoutDash = String.join("%",strWithoutSlash.split("_"));
|
||||
product = productRepository.all().filter("self.code like '"+strWithoutDash+"'").fetchOne();
|
||||
} else {
|
||||
String strWithoutSlash = String.join("%", code.split("/"));
|
||||
String strWithoutDash = String.join("%", strWithoutSlash.split("_"));
|
||||
product =
|
||||
productRepository.all().filter("self.code like '" + strWithoutDash + "'").fetchOne();
|
||||
response.setValue("product", product);
|
||||
response.setValue("unit", product.getUnit());
|
||||
response.setValue("inventory", inventory);
|
||||
// response.setFlash("Veuillez contacter votre administrateur");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void setInventoryLine(ActionRequest request, ActionResponse response) throws AxelorException {
|
||||
Context context = request.getContext();
|
||||
|
||||
Inventory inventory = ((Inventory) context.get("inventory"));
|
||||
// Long stockLocationId = new Long((Integer) ((Map) request.getContext().get("inventory")).get("id"));
|
||||
// Long trackingNumberId = new Long((Integer) ((Map) request.getContext().get("trackingNumber")).get("id"));
|
||||
TrackingNumber trackingNumber = ((TrackingNumber) context.get("trackingNumber"));
|
||||
Product product = ((Product) context.get("product"));
|
||||
public void setInventoryLine(ActionRequest request, ActionResponse response)
|
||||
throws AxelorException {
|
||||
Context context = request.getContext();
|
||||
|
||||
// Inventory inventory = Beans.get(InventoryRepository.class).find(stockLocationId);
|
||||
// TrackingNumber trackingNumber = Beans.get(TrackingNumberRepository.class).find(trackingNumberId);
|
||||
|
||||
Inventory inventory = ((Inventory) context.get("inventory"));
|
||||
// Long stockLocationId = new Long((Integer) ((Map)
|
||||
// request.getContext().get("inventory")).get("id"));
|
||||
// Long trackingNumberId = new Long((Integer) ((Map)
|
||||
// request.getContext().get("trackingNumber")).get("id"));
|
||||
TrackingNumber trackingNumber = ((TrackingNumber) context.get("trackingNumber"));
|
||||
Product product = ((Product) context.get("product"));
|
||||
|
||||
System.out.println(inventory.toString());
|
||||
System.out.println(trackingNumber);
|
||||
System.out.println(product.toString());
|
||||
// Inventory inventory = Beans.get(InventoryRepository.class).find(stockLocationId);
|
||||
// TrackingNumber trackingNumber =
|
||||
// Beans.get(TrackingNumberRepository.class).find(trackingNumberId);
|
||||
|
||||
// Product product = productRepository.find(productId);
|
||||
// Inventory inventory = inventoryRepository.find(inventoryId);
|
||||
// TrackingNumber trackingNumber = trackingNumberRepository.find(trackingNumberId);
|
||||
|
||||
if(inventory == null || product == null ){
|
||||
throw new AxelorException(
|
||||
TraceBackRepository.CATEGORY_NO_VALUE,
|
||||
I18n.get("Cannot find the data"));
|
||||
}
|
||||
|
||||
System.out.println(inventory.toString());
|
||||
System.out.println(trackingNumber);
|
||||
System.out.println(product.toString());
|
||||
|
||||
Integer countingType = Integer.parseInt(context.get("countingTypeSelect").toString());
|
||||
BigDecimal firstCounting = (BigDecimal) context.get("firstCounting");
|
||||
BigDecimal secondCounting = (BigDecimal) context.get("secondCounting");
|
||||
BigDecimal controlCounting = (BigDecimal) context.get("controlCounting");
|
||||
// Product product = productRepository.find(productId);
|
||||
// Inventory inventory = inventoryRepository.find(inventoryId);
|
||||
// TrackingNumber trackingNumber = trackingNumberRepository.find(trackingNumberId);
|
||||
|
||||
Beans.get(InventoryLineService.class).setInventoryLine(inventory, product, trackingNumber, countingType, firstCounting, secondCounting, controlCounting);
|
||||
response.setFlash("Updated Successfully");
|
||||
// response.setReload(true);
|
||||
if (inventory == null || product == null) {
|
||||
throw new AxelorException(
|
||||
TraceBackRepository.CATEGORY_NO_VALUE, I18n.get("Cannot find the data"));
|
||||
}
|
||||
|
||||
Integer countingType = Integer.parseInt(context.get("countingTypeSelect").toString());
|
||||
BigDecimal firstCounting = (BigDecimal) context.get("firstCounting");
|
||||
BigDecimal secondCounting = (BigDecimal) context.get("secondCounting");
|
||||
BigDecimal controlCounting = (BigDecimal) context.get("controlCounting");
|
||||
|
||||
Beans.get(InventoryLineService.class)
|
||||
.setInventoryLine(
|
||||
inventory,
|
||||
product,
|
||||
trackingNumber,
|
||||
countingType,
|
||||
firstCounting,
|
||||
secondCounting,
|
||||
controlCounting);
|
||||
response.setFlash("Updated Successfully");
|
||||
// response.setReload(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
*/
|
||||
package com.axelor.apps.stock.web;
|
||||
|
||||
import com.axelor.apps.base.db.FamilleProduit;
|
||||
import com.axelor.apps.stock.db.StockHistoryLine;
|
||||
import com.axelor.apps.stock.service.StockHistoryService;
|
||||
import com.axelor.apps.stock.service.StockHistoryServiceImpl;
|
||||
@@ -29,7 +28,6 @@ import com.axelor.meta.schema.actions.ActionView;
|
||||
import com.axelor.rpc.ActionRequest;
|
||||
import com.axelor.rpc.ActionResponse;
|
||||
import com.axelor.rpc.Context;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
@@ -91,8 +89,7 @@ public class StockHistoryController {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
/**
|
||||
* Called from stock history form view, on new and on date change. Call {@link
|
||||
* StockHistoryService#computeStockHistoryLineList(Long, Long, Long, LocalDate, LocalDate)}
|
||||
*
|
||||
@@ -123,19 +120,20 @@ public class StockHistoryController {
|
||||
beginDate = LocalDate.parse(beginDateContext.toString());
|
||||
}
|
||||
|
||||
Integer searchTypeSelect = Integer.parseInt( (String) context.get("productSearchTypeSelect"));
|
||||
Integer searchTypeSelect = Integer.parseInt((String) context.get("productSearchTypeSelect"));
|
||||
|
||||
Long categoryId = null;
|
||||
if(context.get("familleProduit") != null){
|
||||
categoryId = Long.parseLong(((LinkedHashMap) context.get("familleProduit")).get("id").toString());
|
||||
Long categoryId = null;
|
||||
if (context.get("familleProduit") != null) {
|
||||
categoryId =
|
||||
Long.parseLong(((LinkedHashMap) context.get("familleProduit")).get("id").toString());
|
||||
}
|
||||
|
||||
Long trackingNumberId = null;
|
||||
if(context.get("trackingNumber") != null){
|
||||
trackingNumberId = Long.parseLong(((LinkedHashMap) context.get("trackingNumber")).get("id").toString());
|
||||
Long trackingNumberId = null;
|
||||
if (context.get("trackingNumber") != null) {
|
||||
trackingNumberId =
|
||||
Long.parseLong(((LinkedHashMap) context.get("trackingNumber")).get("id").toString());
|
||||
}
|
||||
|
||||
|
||||
System.out.println("**************searchTypeSelect**********************");
|
||||
System.out.println(searchTypeSelect);
|
||||
System.out.println(categoryId);
|
||||
@@ -151,13 +149,19 @@ public class StockHistoryController {
|
||||
// && stockLocationId != null
|
||||
// && beginDate != null
|
||||
// ) {
|
||||
stockHistoryLineList =
|
||||
Beans.get(StockHistoryService.class)
|
||||
.compuHistoryLinesPerDate(
|
||||
productId, companyId, stockLocationId, beginDate, endDate,categoryId, trackingNumberId,searchTypeSelect);
|
||||
stockHistoryLineList =
|
||||
Beans.get(StockHistoryService.class)
|
||||
.compuHistoryLinesPerDate(
|
||||
productId,
|
||||
companyId,
|
||||
stockLocationId,
|
||||
beginDate,
|
||||
endDate,
|
||||
categoryId,
|
||||
trackingNumberId,
|
||||
searchTypeSelect);
|
||||
// }
|
||||
|
||||
|
||||
response.setValue("$stockHistoryLineList", stockHistoryLineList);
|
||||
|
||||
} catch (Exception e) {
|
||||
@@ -166,11 +170,12 @@ public class StockHistoryController {
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static void exportStockHistoryLines(ActionRequest request, ActionResponse response) throws AxelorException, IOException {
|
||||
public static void exportStockHistoryLines(ActionRequest request, ActionResponse response)
|
||||
throws AxelorException, IOException {
|
||||
|
||||
Context context = request.getContext();
|
||||
|
||||
List<HashMap<String, Object>> stockHistoryLineList = new ArrayList<>();
|
||||
List<HashMap<String, Object>> stockHistoryLineList = new ArrayList<>();
|
||||
|
||||
if (context.get("stockHistoryLineList") != null) {
|
||||
stockHistoryLineList = (List<HashMap<String, Object>>) context.get("stockHistoryLineList");
|
||||
@@ -179,14 +184,13 @@ public class StockHistoryController {
|
||||
MetaFile metaFile = Beans.get(StockHistoryServiceImpl.class).exportToCSV(stockHistoryLineList);
|
||||
|
||||
response.setView(
|
||||
ActionView.define("name")
|
||||
.add(
|
||||
"html",
|
||||
"ws/rest/com.axelor.meta.db.MetaFile/"
|
||||
+ metaFile.getId()
|
||||
+ "/content/download?v="
|
||||
+ metaFile.getVersion())
|
||||
.map());
|
||||
ActionView.define("name")
|
||||
.add(
|
||||
"html",
|
||||
"ws/rest/com.axelor.meta.db.MetaFile/"
|
||||
+ metaFile.getId()
|
||||
+ "/content/download?v="
|
||||
+ metaFile.getVersion())
|
||||
.map());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -17,13 +17,17 @@
|
||||
*/
|
||||
package com.axelor.apps.stock.web;
|
||||
|
||||
import com.axelor.apps.base.db.CancelReason;
|
||||
import com.axelor.apps.base.db.PrintingSettings;
|
||||
import com.axelor.apps.base.db.Product;
|
||||
import com.axelor.apps.base.service.BarcodeGeneratorService;
|
||||
import com.axelor.apps.base.service.TradingNameService;
|
||||
import com.axelor.apps.base.service.app.AppBaseService;
|
||||
import com.axelor.apps.report.engine.ReportSettings;
|
||||
import com.axelor.apps.stock.db.StockMove;
|
||||
import com.axelor.apps.stock.db.StockMoveLine;
|
||||
import com.axelor.apps.stock.db.StockMoveLineLocation;
|
||||
import com.axelor.apps.stock.db.repo.StockMoveLineLocationRepository;
|
||||
import com.axelor.apps.stock.db.repo.StockMoveLineRepository;
|
||||
import com.axelor.apps.stock.db.repo.StockMoveRepository;
|
||||
import com.axelor.apps.stock.exception.IExceptionMessage;
|
||||
@@ -41,11 +45,15 @@ import com.axelor.exception.db.repo.TraceBackRepository;
|
||||
import com.axelor.exception.service.TraceBackService;
|
||||
import com.axelor.i18n.I18n;
|
||||
import com.axelor.inject.Beans;
|
||||
import com.axelor.meta.MetaFiles;
|
||||
import com.axelor.meta.db.MetaFile;
|
||||
import com.axelor.meta.schema.actions.ActionView;
|
||||
import com.axelor.rpc.ActionRequest;
|
||||
import com.axelor.rpc.ActionResponse;
|
||||
import com.axelor.rpc.Context;
|
||||
import com.google.inject.Singleton;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
@@ -58,6 +66,7 @@ import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.persistence.Query;
|
||||
import javax.validation.ValidationException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -147,6 +156,93 @@ public class StockMoveController {
|
||||
}
|
||||
}
|
||||
|
||||
public void massDraft(ActionRequest request, ActionResponse response) {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
List<Long> requestIds = (List<Long>) request.getContext().get("_ids");
|
||||
|
||||
if (requestIds == null || requestIds.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
if (!requestIds.isEmpty()) {
|
||||
Beans.get(StockMoveService.class).massDraft(requestIds);
|
||||
response.setReload(true);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
TraceBackService.trace(response, e);
|
||||
}
|
||||
}
|
||||
|
||||
public void massCancel(ActionRequest request, ActionResponse response) {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
List<Long> requestIds = (List<Long>) request.getContext().get("_ids");
|
||||
CancelReason raison = (CancelReason) request.getContext().get("cancelRaison");
|
||||
String raisonStr = (String) request.getContext().get("cancelRaisonStr");
|
||||
StockMove stockMove = request.getContext().asType(StockMove.class);
|
||||
|
||||
|
||||
System.out.println("*********************************************");
|
||||
System.out.println(raisonStr);
|
||||
System.out.println(raison);
|
||||
System.out.println(stockMove.getCancelReason());
|
||||
System.out.println(stockMove.getCancelReasonStr());
|
||||
System.out.println("*********************************************");
|
||||
|
||||
if (requestIds == null || requestIds.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
if (!requestIds.isEmpty()) {
|
||||
Beans.get(StockMoveService.class).massCancel(requestIds, raison, raisonStr);
|
||||
response.setReload(true);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
TraceBackService.trace(response, e);
|
||||
}
|
||||
}
|
||||
|
||||
public void massPlan(ActionRequest request, ActionResponse response) {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
List<Long> requestIds = (List<Long>) request.getContext().get("_ids");
|
||||
|
||||
if (requestIds == null || requestIds.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
if (!requestIds.isEmpty()) {
|
||||
Beans.get(StockMoveService.class).massPlan(requestIds);
|
||||
response.setReload(true);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
TraceBackService.trace(response, e);
|
||||
}
|
||||
}
|
||||
|
||||
public void massRealize(ActionRequest request, ActionResponse response) {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
List<Long> requestIds = (List<Long>) request.getContext().get("_ids");
|
||||
|
||||
if (requestIds == null || requestIds.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
if (!requestIds.isEmpty()) {
|
||||
Beans.get(StockMoveService.class).massRealize(requestIds);
|
||||
response.setReload(true);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
TraceBackService.trace(response, e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method called from stock move form and grid view. Print one or more stock move as PDF
|
||||
*
|
||||
@@ -718,4 +814,90 @@ public class StockMoveController {
|
||||
"vous avez deja une facture sur cette Piece");
|
||||
}
|
||||
}
|
||||
|
||||
public void checkIfQuarantine(ActionRequest request, ActionResponse response)
|
||||
throws AxelorException {
|
||||
|
||||
StockMove stockMoveFromRequest = request.getContext().asType(StockMove.class);
|
||||
|
||||
StockMove stockMove = Beans.get(StockMoveRepository.class).find(stockMoveFromRequest.getId());
|
||||
Query sql =
|
||||
JPA.em()
|
||||
.createNativeQuery(
|
||||
"SELECT LINE.ID"+
|
||||
" FROM STOCK_STOCK_MOVE_LINE LINE LEFT JOIN STOCK_STOCK_LOCATION_LINE LOCATION_LINE ON LINE.TRACKING_NUMBER = LOCATION_LINE.TRACKING_NUMBER and LINE.product = LOCATION_LINE.product"+
|
||||
" where LOCATION_LINE.DETAILS_STOCK_LOCATION = ?1 AND LOCATION_LINE.CONFORMITY_SELECT != 2 AND LOCATION_LINE.CONFORMITY_SELECT != 5 AND LINE.STOCK_MOVE = ?2");
|
||||
sql.setParameter(1, stockMove.getFromStockLocation().getId());
|
||||
sql.setParameter(2, stockMove.getId());
|
||||
logger.debug("sql.getResultList().size()",sql.getResultList().size());
|
||||
if (sql.getResultList().size() > 0) {
|
||||
throw new AxelorException(
|
||||
stockMove,
|
||||
TraceBackRepository.CATEGORY_CONFIGURATION_ERROR,
|
||||
"vous avez une ligne en etat qurantaine");
|
||||
}
|
||||
}
|
||||
|
||||
public void checkIfNonConformityTag(ActionRequest request, ActionResponse response)
|
||||
throws AxelorException {
|
||||
|
||||
StockMove stockMoveFromContext = request.getContext().asType(StockMove.class);
|
||||
StockMove stockMove = Beans.get(StockMoveRepository.class).find(stockMoveFromContext.getId());
|
||||
Query sql =
|
||||
JPA.em()
|
||||
.createNativeQuery(
|
||||
"SELECT LINE.ID " +
|
||||
" FROM STOCK_STOCK_MOVE_LINE LINE LEFT JOIN STOCK_STOCK_LOCATION_LINE LOCATION_LINE ON LINE.TRACKING_NUMBER = LOCATION_LINE.TRACKING_NUMBER and LINE.product = LOCATION_LINE.product"
|
||||
+" where LOCATION_LINE.DETAILS_STOCK_LOCATION = ?1 AND LOCATION_LINE.is_conform_tag is not true AND LINE.STOCK_MOVE = ?2");
|
||||
sql.setParameter(1, stockMove.getToStockLocation().getId());
|
||||
sql.setParameter(2, stockMove.getId());
|
||||
logger.debug("sql.getResultList().size()",sql.getResultList().size());
|
||||
if (sql.getResultList().size() > 0) {
|
||||
throw new AxelorException(
|
||||
stockMove,
|
||||
TraceBackRepository.CATEGORY_CONFIGURATION_ERROR,
|
||||
"vous avez une ligne non étiqueté");
|
||||
}
|
||||
}
|
||||
|
||||
public void createStockMoveLineLocationBarCodeSeq(
|
||||
ActionRequest request, ActionResponse response) {
|
||||
try {
|
||||
boolean addPadding = false;
|
||||
InputStream inStream = null;
|
||||
|
||||
StockMoveLineLocation stockMoveLineLocationContext =
|
||||
request.getContext().asType(StockMoveLineLocation.class);
|
||||
|
||||
StockMoveLineLocation stockMoveLineLocation =
|
||||
Beans.get(StockMoveLineLocationRepository.class)
|
||||
.find(stockMoveLineLocationContext.getId());
|
||||
|
||||
inStream =
|
||||
Beans.get(BarcodeGeneratorService.class)
|
||||
.createBarCode(
|
||||
stockMoveLineLocation.getCode(),
|
||||
Beans.get(AppBaseService.class)
|
||||
.getAppBase()
|
||||
.getBarcodeTypeConfigPurchaseOrderSeq(),
|
||||
addPadding);
|
||||
|
||||
if (inStream != null) {
|
||||
MetaFile barcodeFile =
|
||||
Beans.get(MetaFiles.class)
|
||||
.upload(
|
||||
inStream,
|
||||
String.format("StockMoveLineLocation%d.png", stockMoveLineLocation.getId()));
|
||||
stockMoveLineLocation.setBarCodeSeq(barcodeFile);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} catch (AxelorException e) {
|
||||
throw new ValidationException(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public void showPopup(ActionRequest request, ActionResponse response) {
|
||||
response.setAlert("Hello words!!");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,7 +67,8 @@ public class StockMoveLineController {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if(!(stockMove.getPartner() != stockMove.getCompany().getPartner() || stockMove.getTypeSelect()== StockMoveRepository.TYPE_INCOMING)) {
|
||||
if (!(stockMove.getPartner() != stockMove.getCompany().getPartner()
|
||||
|| stockMove.getTypeSelect() == StockMoveRepository.TYPE_INCOMING)) {
|
||||
stockMoveLine = Beans.get(StockMoveLineService.class).compute(stockMoveLine, stockMove);
|
||||
response.setValue("unitPriceUntaxed", stockMoveLine.getUnitPriceUntaxed());
|
||||
response.setValue("unitPriceTaxed", stockMoveLine.getUnitPriceTaxed());
|
||||
|
||||
@@ -1,20 +1,11 @@
|
||||
package com.axelor.apps.stock.web;
|
||||
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.axelor.apps.report.engine.ReportSettings;
|
||||
import com.axelor.apps.stock.db.StockMove;
|
||||
import com.axelor.apps.stock.db.StockProductionRequest;
|
||||
import com.axelor.apps.stock.db.repo.StockMoveRepository;
|
||||
import com.axelor.apps.stock.db.repo.StockProductionRequestRepository;
|
||||
import com.axelor.apps.stock.exception.IExceptionMessage;
|
||||
import com.axelor.apps.stock.service.StockMoveService;
|
||||
import com.axelor.apps.stock.service.stockmove.print.StockProductionRequestPrintService;
|
||||
import com.axelor.common.ObjectUtils;
|
||||
import com.axelor.exception.AxelorException;
|
||||
@@ -29,65 +20,77 @@ import com.axelor.rpc.Context;
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.collect.Lists;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.util.List;
|
||||
import javax.annotation.Nullable;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class StockProductionRequestController {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
|
||||
|
||||
public void draft(ActionRequest request, ActionResponse response) {
|
||||
StockProductionRequest productionRequest = request.getContext().asType(StockProductionRequest.class);
|
||||
try {
|
||||
Beans.get(StockProductionRequestService.class)
|
||||
.draft(Beans.get(StockProductionRequestRepository.class).find(productionRequest.getId()));
|
||||
response.setReload(true);
|
||||
} catch (Exception e) {
|
||||
TraceBackService.trace(response, e);
|
||||
}
|
||||
}
|
||||
|
||||
public void plan(ActionRequest request, ActionResponse response) {
|
||||
StockProductionRequest productionRequest = request.getContext().asType(StockProductionRequest.class);
|
||||
try {
|
||||
Beans.get(StockProductionRequestService.class)
|
||||
.plan(Beans.get(StockProductionRequestRepository.class).find(productionRequest.getId()));
|
||||
response.setReload(true);
|
||||
} catch (Exception e) {
|
||||
TraceBackService.trace(response, e);
|
||||
}
|
||||
}
|
||||
|
||||
public void realize(ActionRequest request, ActionResponse response) {
|
||||
StockProductionRequest productionRequest = request.getContext().asType(StockProductionRequest.class);
|
||||
try {
|
||||
Beans.get(StockProductionRequestService.class)
|
||||
.realize(Beans.get(StockProductionRequestRepository.class).find(productionRequest.getId()));
|
||||
response.setReload(true);
|
||||
} catch (Exception e) {
|
||||
TraceBackService.trace(response, e);
|
||||
}
|
||||
}
|
||||
private final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
|
||||
|
||||
public void cancel(ActionRequest request, ActionResponse response) {
|
||||
StockProductionRequest productionRequest = request.getContext().asType(StockProductionRequest.class);
|
||||
try {
|
||||
Beans.get(StockProductionRequestService.class)
|
||||
.cancel(Beans.get(StockProductionRequestRepository.class).find(productionRequest.getId()));
|
||||
response.setReload(true);
|
||||
} catch (Exception e) {
|
||||
TraceBackService.trace(response, e);
|
||||
}
|
||||
public void draft(ActionRequest request, ActionResponse response) {
|
||||
StockProductionRequest productionRequest =
|
||||
request.getContext().asType(StockProductionRequest.class);
|
||||
try {
|
||||
Beans.get(StockProductionRequestService.class)
|
||||
.draft(Beans.get(StockProductionRequestRepository.class).find(productionRequest.getId()));
|
||||
response.setReload(true);
|
||||
} catch (Exception e) {
|
||||
TraceBackService.trace(response, e);
|
||||
}
|
||||
}
|
||||
|
||||
public void print(ActionRequest request, ActionResponse response) {
|
||||
public void plan(ActionRequest request, ActionResponse response) {
|
||||
StockProductionRequest productionRequest =
|
||||
request.getContext().asType(StockProductionRequest.class);
|
||||
try {
|
||||
Beans.get(StockProductionRequestService.class)
|
||||
.plan(Beans.get(StockProductionRequestRepository.class).find(productionRequest.getId()));
|
||||
response.setReload(true);
|
||||
} catch (Exception e) {
|
||||
TraceBackService.trace(response, e);
|
||||
}
|
||||
}
|
||||
|
||||
public void realize(ActionRequest request, ActionResponse response) {
|
||||
StockProductionRequest productionRequest =
|
||||
request.getContext().asType(StockProductionRequest.class);
|
||||
try {
|
||||
Beans.get(StockProductionRequestService.class)
|
||||
.realize(
|
||||
Beans.get(StockProductionRequestRepository.class).find(productionRequest.getId()));
|
||||
response.setReload(true);
|
||||
} catch (Exception e) {
|
||||
TraceBackService.trace(response, e);
|
||||
}
|
||||
}
|
||||
|
||||
public void cancel(ActionRequest request, ActionResponse response) {
|
||||
StockProductionRequest productionRequest =
|
||||
request.getContext().asType(StockProductionRequest.class);
|
||||
try {
|
||||
Beans.get(StockProductionRequestService.class)
|
||||
.cancel(
|
||||
Beans.get(StockProductionRequestRepository.class).find(productionRequest.getId()));
|
||||
response.setReload(true);
|
||||
} catch (Exception e) {
|
||||
TraceBackService.trace(response, e);
|
||||
}
|
||||
}
|
||||
|
||||
public void print(ActionRequest request, ActionResponse response) {
|
||||
|
||||
Context context = request.getContext();
|
||||
String fileLink;
|
||||
String title;
|
||||
StockProductionRequestPrintService productionRequestPrintService = Beans.get(StockProductionRequestPrintService.class);
|
||||
StockProductionRequestPrintService productionRequestPrintService =
|
||||
Beans.get(StockProductionRequestPrintService.class);
|
||||
|
||||
try {
|
||||
if (!ObjectUtils.isEmpty(request.getContext().get("_ids"))) {
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
List<Long> ids =
|
||||
Lists.transform(
|
||||
(List) request.getContext().get("_ids"),
|
||||
@@ -101,10 +104,11 @@ public class StockProductionRequestController {
|
||||
fileLink = productionRequestPrintService.printStockProductionRequests(ids);
|
||||
title = I18n.get("Purchase requests");
|
||||
} else if (context.get("id") != null) {
|
||||
StockProductionRequest productionRequest = request.getContext().asType(StockProductionRequest.class);
|
||||
StockProductionRequest productionRequest =
|
||||
request.getContext().asType(StockProductionRequest.class);
|
||||
title = productionRequestPrintService.getFileName(productionRequest);
|
||||
fileLink =
|
||||
productionRequestPrintService.printStockProductionRequest(
|
||||
productionRequestPrintService.printStockProductionRequest(
|
||||
productionRequest, ReportSettings.FORMAT_PDF);
|
||||
logger.debug("Printing " + title);
|
||||
} else {
|
||||
@@ -118,18 +122,19 @@ public class StockProductionRequestController {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void createStockMove(ActionRequest request, ActionResponse response) {
|
||||
|
||||
StockProductionRequest productionRequest = request.getContext().asType(StockProductionRequest.class);
|
||||
StockProductionRequest productionRequest =
|
||||
request.getContext().asType(StockProductionRequest.class);
|
||||
|
||||
try {
|
||||
if (productionRequest.getId() != null) {
|
||||
|
||||
StockProductionRequestService productionRequestService = Beans.get(StockProductionRequestService.class);
|
||||
StockProductionRequestService productionRequestService =
|
||||
Beans.get(StockProductionRequestService.class);
|
||||
|
||||
List<Long> stockMoveList =
|
||||
productionRequestService.createStocksMovesFromStockProductionRequest(
|
||||
productionRequestService.createStocksMovesFromStockProductionRequest(
|
||||
Beans.get(StockProductionRequestRepository.class).find(productionRequest.getId()));
|
||||
|
||||
if (stockMoveList != null && stockMoveList.size() == 1) {
|
||||
@@ -161,4 +166,29 @@ public class StockProductionRequestController {
|
||||
}
|
||||
}
|
||||
|
||||
public void generateReversion(ActionRequest request, ActionResponse response)
|
||||
throws AxelorException {
|
||||
StockProductionRequest productionRequestContext =
|
||||
request.getContext().asType(StockProductionRequest.class);
|
||||
StockProductionRequest productionRequest =
|
||||
Beans.get(StockProductionRequestRepository.class).find(productionRequestContext.getId());
|
||||
|
||||
StockProductionRequestService productionRequestService =
|
||||
Beans.get(StockProductionRequestService.class);
|
||||
|
||||
StockProductionRequest stockProductionRequest =
|
||||
productionRequestService.generateReversion(productionRequest);
|
||||
|
||||
if (stockProductionRequest != null) {
|
||||
response.setView(
|
||||
ActionView.define(I18n.get("Stock production request"))
|
||||
.model(StockProductionRequest.class.getName())
|
||||
.add("form", "stock-production-request-form")
|
||||
.add("grid", "stock-production-request-grid")
|
||||
.param("forceEdit", "true")
|
||||
.domain("self.id = " + stockProductionRequest.getId())
|
||||
.context("_showRecord", String.valueOf(stockProductionRequest.getId()))
|
||||
.map());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
package com.axelor.apps.stock.web;
|
||||
|
||||
import com.axelor.apps.stock.db.StockMove;
|
||||
import com.axelor.apps.stock.db.StockMoveLine;
|
||||
import com.axelor.apps.stock.db.StockProductionRequest;
|
||||
import com.axelor.apps.stock.db.StockProductionRequestLine;
|
||||
import com.axelor.apps.stock.service.StockMoveLineService;
|
||||
import com.axelor.apps.stock.service.StockProductionRequestLineService;
|
||||
import com.axelor.db.mapper.Mapper;
|
||||
import com.axelor.exception.AxelorException;
|
||||
@@ -16,54 +13,56 @@ import com.axelor.rpc.ActionResponse;
|
||||
import com.axelor.rpc.Context;
|
||||
|
||||
public class StockProductionRequestLineController {
|
||||
|
||||
|
||||
public void setProductInfo(ActionRequest request, ActionResponse response) {
|
||||
public void setProductInfo(ActionRequest request, ActionResponse response) {
|
||||
|
||||
StockProductionRequestLine productionRequestLine;
|
||||
StockProductionRequestLine productionRequestLine;
|
||||
|
||||
try {
|
||||
productionRequestLine = request.getContext().asType(StockProductionRequestLine.class);
|
||||
StockProductionRequest productionRequest = productionRequestLine.getStockProductionRequest();
|
||||
try {
|
||||
productionRequestLine = request.getContext().asType(StockProductionRequestLine.class);
|
||||
StockProductionRequest productionRequest = productionRequestLine.getStockProductionRequest();
|
||||
|
||||
if (productionRequest == null) {
|
||||
productionRequest = request.getContext().getParent().asType(StockProductionRequest.class);
|
||||
}
|
||||
if (productionRequest == null) {
|
||||
productionRequest = request.getContext().getParent().asType(StockProductionRequest.class);
|
||||
}
|
||||
|
||||
if (productionRequestLine.getProduct() == null) {
|
||||
productionRequestLine = new StockProductionRequestLine();
|
||||
response.setValues(Mapper.toMap(productionRequestLine));
|
||||
return;
|
||||
}
|
||||
if (productionRequestLine.getProduct() == null) {
|
||||
productionRequestLine = new StockProductionRequestLine();
|
||||
response.setValues(Mapper.toMap(productionRequestLine));
|
||||
return;
|
||||
}
|
||||
|
||||
Beans.get(StockProductionRequestLineService.class).setProductInfo(productionRequest, productionRequestLine, productionRequest.getCompany());
|
||||
response.setValues(productionRequestLine);
|
||||
} catch (Exception e) {
|
||||
productionRequestLine = new StockProductionRequestLine();
|
||||
response.setValues(Mapper.toMap(productionRequestLine));
|
||||
TraceBackService.trace(response, e, ResponseMessageType.INFORMATION);
|
||||
}
|
||||
Beans.get(StockProductionRequestLineService.class)
|
||||
.setProductInfo(productionRequest, productionRequestLine, productionRequest.getCompany());
|
||||
response.setValues(productionRequestLine);
|
||||
} catch (Exception e) {
|
||||
productionRequestLine = new StockProductionRequestLine();
|
||||
response.setValues(Mapper.toMap(productionRequestLine));
|
||||
TraceBackService.trace(response, e, ResponseMessageType.INFORMATION);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void compute(ActionRequest request, ActionResponse response) throws AxelorException {
|
||||
StockProductionRequestLine productionRequestLine = request.getContext().asType(StockProductionRequestLine.class);
|
||||
StockProductionRequest productionRequest = productionRequestLine.getStockProductionRequest();
|
||||
if (productionRequest == null) {
|
||||
Context parentContext = request.getContext().getParent();
|
||||
Context superParentContext = parentContext.getParent();
|
||||
if (parentContext.getContextClass().equals(StockProductionRequest.class)) {
|
||||
productionRequest = parentContext.asType(StockProductionRequest.class);
|
||||
} else if (superParentContext.getContextClass().equals(StockProductionRequest.class)) {
|
||||
productionRequest = superParentContext.asType(StockProductionRequest.class);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
productionRequestLine = Beans.get(StockProductionRequestLineService.class).compute(productionRequestLine, productionRequest);
|
||||
response.setValue("unitPriceUntaxed", productionRequestLine.getUnitPriceUntaxed());
|
||||
response.setValue("unitPriceTaxed", productionRequestLine.getUnitPriceTaxed());
|
||||
response.setValue("companyUnitPriceUntaxed", productionRequestLine.getCompanyUnitPriceUntaxed());
|
||||
public void compute(ActionRequest request, ActionResponse response) throws AxelorException {
|
||||
StockProductionRequestLine productionRequestLine =
|
||||
request.getContext().asType(StockProductionRequestLine.class);
|
||||
StockProductionRequest productionRequest = productionRequestLine.getStockProductionRequest();
|
||||
if (productionRequest == null) {
|
||||
Context parentContext = request.getContext().getParent();
|
||||
Context superParentContext = parentContext.getParent();
|
||||
if (parentContext.getContextClass().equals(StockProductionRequest.class)) {
|
||||
productionRequest = parentContext.asType(StockProductionRequest.class);
|
||||
} else if (superParentContext.getContextClass().equals(StockProductionRequest.class)) {
|
||||
productionRequest = superParentContext.asType(StockProductionRequest.class);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
productionRequestLine =
|
||||
Beans.get(StockProductionRequestLineService.class)
|
||||
.compute(productionRequestLine, productionRequest);
|
||||
response.setValue("unitPriceUntaxed", productionRequestLine.getUnitPriceUntaxed());
|
||||
response.setValue("unitPriceTaxed", productionRequestLine.getUnitPriceTaxed());
|
||||
response.setValue(
|
||||
"companyUnitPriceUntaxed", productionRequestLine.getCompanyUnitPriceUntaxed());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,24 +1,11 @@
|
||||
package com.axelor.apps.stock.web;
|
||||
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.axelor.apps.account.db.TaxLine;
|
||||
import com.axelor.apps.base.db.Company;
|
||||
import com.axelor.apps.base.db.Product;
|
||||
import com.axelor.apps.base.db.Unit;
|
||||
import com.axelor.apps.base.db.repo.ProductRepository;
|
||||
import com.axelor.apps.base.service.UnitConversionService;
|
||||
import com.axelor.apps.base.service.app.AppBaseService;
|
||||
import com.axelor.apps.stock.db.StockConfig;
|
||||
import com.axelor.apps.stock.db.StockLocation;
|
||||
import com.axelor.apps.stock.db.StockMove;
|
||||
import com.axelor.apps.stock.db.StockMoveLine;
|
||||
@@ -38,217 +25,288 @@ import com.axelor.exception.AxelorException;
|
||||
import com.axelor.inject.Beans;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.persist.Transactional;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class StockProductionRequestService {
|
||||
|
||||
protected StockProductionRequestRepository productionRequestRepository;
|
||||
protected StockMoveService stockMoveService;
|
||||
protected StockMoveLineService stockMoveLineService;
|
||||
protected StockConfigService stockConfigService;
|
||||
protected UnitConversionService unitConversionService;
|
||||
protected StockMoveLineRepository stockMoveLineRepository;
|
||||
protected AppBaseService appBaseService;
|
||||
protected StockMoveToolService stockMoveToolService;
|
||||
protected StockProductionRequestRepository productionRequestRepository;
|
||||
protected StockMoveService stockMoveService;
|
||||
protected StockMoveLineService stockMoveLineService;
|
||||
protected StockConfigService stockConfigService;
|
||||
protected UnitConversionService unitConversionService;
|
||||
protected StockMoveLineRepository stockMoveLineRepository;
|
||||
protected AppBaseService appBaseService;
|
||||
protected StockMoveToolService stockMoveToolService;
|
||||
|
||||
private static final Logger logger =
|
||||
LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
|
||||
|
||||
|
||||
private static final Logger logger =
|
||||
LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
|
||||
|
||||
@Inject
|
||||
public StockProductionRequestService(StockProductionRequestRepository productionRequestRepository,
|
||||
StockMoveService stockMoveService,
|
||||
@Inject
|
||||
public StockProductionRequestService(
|
||||
StockProductionRequestRepository productionRequestRepository,
|
||||
StockMoveService stockMoveService,
|
||||
StockMoveLineService stockMoveLineService,
|
||||
StockConfigService stockConfigService,
|
||||
UnitConversionService unitConversionService,
|
||||
StockMoveLineRepository stockMoveLineRepository,
|
||||
StockMoveToolService stockMoveToolService,
|
||||
AppBaseService appBaseService){
|
||||
this.productionRequestRepository = productionRequestRepository;
|
||||
this.stockMoveService = stockMoveService;
|
||||
this.stockMoveLineService = stockMoveLineService;
|
||||
this.stockConfigService = stockConfigService;
|
||||
this.unitConversionService = unitConversionService;
|
||||
this.stockMoveLineRepository = stockMoveLineRepository;
|
||||
this.appBaseService = appBaseService;
|
||||
this.stockMoveToolService = stockMoveToolService;
|
||||
AppBaseService appBaseService) {
|
||||
this.productionRequestRepository = productionRequestRepository;
|
||||
this.stockMoveService = stockMoveService;
|
||||
this.stockMoveLineService = stockMoveLineService;
|
||||
this.stockConfigService = stockConfigService;
|
||||
this.unitConversionService = unitConversionService;
|
||||
this.stockMoveLineRepository = stockMoveLineRepository;
|
||||
this.appBaseService = appBaseService;
|
||||
this.stockMoveToolService = stockMoveToolService;
|
||||
}
|
||||
|
||||
|
||||
@Transactional(rollbackOn = {Exception.class})
|
||||
public void draft(StockProductionRequest stockProductionRequest) {
|
||||
stockProductionRequest.setStatusSelect(1);
|
||||
productionRequestRepository.save(stockProductionRequest);
|
||||
}
|
||||
|
||||
@Transactional(rollbackOn = {Exception.class})
|
||||
public void plan(StockProductionRequest stockProductionRequest) throws AxelorException {
|
||||
stockProductionRequest.setStatusSelect(2);
|
||||
stockProductionRequest.setStockProductionRequestSeq(
|
||||
Beans.get(StockMoveToolServiceImpl.class)
|
||||
.getSequenceStockProductionRequest(stockProductionRequest));
|
||||
productionRequestRepository.save(stockProductionRequest);
|
||||
}
|
||||
|
||||
@Transactional(rollbackOn = {Exception.class})
|
||||
public void realize(StockProductionRequest stockProductionRequest) {
|
||||
stockProductionRequest.setStatusSelect(3);
|
||||
productionRequestRepository.save(stockProductionRequest);
|
||||
}
|
||||
|
||||
@Transactional(rollbackOn = {Exception.class})
|
||||
public void cancel(StockProductionRequest stockProductionRequest) {
|
||||
stockProductionRequest.setStatusSelect(4);
|
||||
productionRequestRepository.save(stockProductionRequest);
|
||||
}
|
||||
|
||||
@Transactional(rollbackOn = {Exception.class})
|
||||
public List<Long> createStocksMovesFromStockProductionRequest(
|
||||
StockProductionRequest stockProductionRequest) throws AxelorException {
|
||||
|
||||
List<Long> stockMoveList = new ArrayList<>();
|
||||
|
||||
// StockLocationLine stockLocationLine = this.getOrCreateStockLocationLine(stockLocation,
|
||||
// product);
|
||||
|
||||
// UnitConversionService unitConversionService = Beans.get(UnitConversionService.class);
|
||||
// Unit stockLocationLineUnit = stockLocationLine.getUnit();
|
||||
|
||||
// if (stockLocationLineUnit != null && !stockLocationLineUnit.equals(stockMoveLineUnit)) {
|
||||
// qty =
|
||||
// unitConversionService.convert(
|
||||
// stockMoveLineUnit, stockLocationLineUnit, qty, qty.scale(), product);
|
||||
// }
|
||||
|
||||
Company company = stockProductionRequest.getCompany();
|
||||
StockMove stockMove = this.createStockMove(stockProductionRequest, company, LocalDate.now());
|
||||
|
||||
stockMove.setExTaxTotal(stockMoveToolService.compute(stockMove));
|
||||
|
||||
stockMoveService.plan(stockMove);
|
||||
|
||||
logger.debug("stockMove ************ {}", stockMove.toString());
|
||||
|
||||
stockMoveList.add(stockMove.getId());
|
||||
|
||||
for (StockProductionRequestLine productionRequestLine :
|
||||
stockProductionRequest.getStockProductionRequestLineList()) {
|
||||
if (productionRequestLine.getIsWithBackorder()) {
|
||||
StockMoveLine line =
|
||||
this.createStockMoveLine(
|
||||
stockMove, productionRequestLine, productionRequestLine.getRealQty());
|
||||
logger.debug("createStockMoveLine ************ {}", line.toString());
|
||||
}
|
||||
}
|
||||
|
||||
logger.debug("stockMoveList ************ {}", stockMoveList);
|
||||
return stockMoveList;
|
||||
}
|
||||
|
||||
@Transactional(rollbackOn = {Exception.class})
|
||||
public void draft(StockProductionRequest stockProductionRequest) {
|
||||
stockProductionRequest.setStatusSelect(1);
|
||||
productionRequestRepository.save(stockProductionRequest);
|
||||
}
|
||||
|
||||
@Transactional(rollbackOn = {Exception.class})
|
||||
public void plan(StockProductionRequest stockProductionRequest) throws AxelorException {
|
||||
stockProductionRequest.setStatusSelect(2);
|
||||
stockProductionRequest.setStockProductionRequestSeq(
|
||||
Beans.get(StockMoveToolServiceImpl.class).getSequenceStockProductionRequest(1, stockProductionRequest.getCompany()));
|
||||
productionRequestRepository.save(stockProductionRequest);
|
||||
}
|
||||
|
||||
@Transactional(rollbackOn = {Exception.class})
|
||||
public void realize(StockProductionRequest stockProductionRequest) {
|
||||
stockProductionRequest.setStatusSelect(3);
|
||||
productionRequestRepository.save(stockProductionRequest);
|
||||
}
|
||||
|
||||
@Transactional(rollbackOn = {Exception.class})
|
||||
public void cancel(StockProductionRequest stockProductionRequest) {
|
||||
stockProductionRequest.setStatusSelect(4);
|
||||
productionRequestRepository.save(stockProductionRequest);
|
||||
}
|
||||
public StockMove createStockMove(
|
||||
StockProductionRequest stockProductionRequest,
|
||||
Company company,
|
||||
LocalDate estimatedDeliveryDate)
|
||||
throws AxelorException {
|
||||
|
||||
|
||||
@Transactional(rollbackOn = {Exception.class})
|
||||
public List<Long> createStocksMovesFromStockProductionRequest(StockProductionRequest stockProductionRequest) throws AxelorException {
|
||||
|
||||
List<Long> stockMoveList = new ArrayList<>();
|
||||
|
||||
Company company = stockProductionRequest.getCompany();
|
||||
StockMove stockMove = this.createStockMove(stockProductionRequest, company, LocalDate.now());
|
||||
|
||||
stockMove.setExTaxTotal(stockMoveToolService.compute(stockMove));
|
||||
|
||||
stockMoveService.plan(stockMove);
|
||||
|
||||
logger.debug("stockMove ************ {}",stockMove.toString());
|
||||
|
||||
stockMoveList.add(stockMove.getId());
|
||||
|
||||
for (StockProductionRequestLine productionRequestLine : stockProductionRequest.getStockProductionRequestLineList()) {
|
||||
if(productionRequestLine.getIsWithBackorder()){
|
||||
StockMoveLine line = this.createStockMoveLine(stockMove, productionRequestLine,productionRequestLine.getRealQty());
|
||||
logger.debug("createStockMoveLine ************ {}",line.toString());
|
||||
}
|
||||
}
|
||||
|
||||
logger.debug("stockMoveList ************ {}",stockMoveList);
|
||||
return stockMoveList;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public StockMove createStockMove(
|
||||
StockProductionRequest stockProductionRequest, Company company, LocalDate estimatedDeliveryDate)
|
||||
throws AxelorException {
|
||||
|
||||
StockLocation fromStockLocation = stockConfigService.getRawMaterialsDefaultStockLocation(stockConfigService.getStockConfig(company));
|
||||
StockLocationRepository stockLocationRepository = Beans.get(StockLocationRepository.class);
|
||||
|
||||
|
||||
switch (stockProductionRequest.getFamilleProduit().getId().intValue()) {
|
||||
// matiere premiere
|
||||
case 67:
|
||||
fromStockLocation = stockLocationRepository.find(3L);
|
||||
break;
|
||||
// MATIERE PREMIERE INJECTABLE
|
||||
case 68:
|
||||
fromStockLocation = stockLocationRepository.find(4L);
|
||||
break;
|
||||
// ARTICLES DE CONDITIONEMENT
|
||||
case 59:
|
||||
fromStockLocation = stockLocationRepository.find(2L);
|
||||
break;
|
||||
|
||||
default:
|
||||
fromStockLocation = stockConfigService.getRawMaterialsDefaultStockLocation(stockConfigService.getStockConfig(company));
|
||||
break;
|
||||
}
|
||||
|
||||
// stockProductionRequest.getStocklocation();
|
||||
|
||||
StockLocation toStockLocation =
|
||||
stockConfigService.getCustomerVirtualStockLocation(
|
||||
StockLocation fromStockLocation =
|
||||
stockConfigService.getRawMaterialsDefaultStockLocation(
|
||||
stockConfigService.getStockConfig(company));
|
||||
StockLocationRepository stockLocationRepository = Beans.get(StockLocationRepository.class);
|
||||
|
||||
StockMove stockMove =
|
||||
stockMoveService.createStockMove(
|
||||
null,
|
||||
null,
|
||||
company,
|
||||
stockProductionRequest.getPartner(),
|
||||
fromStockLocation,
|
||||
toStockLocation,
|
||||
null,
|
||||
estimatedDeliveryDate,
|
||||
stockProductionRequest.getNote(),
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
StockMoveRepository.TYPE_OUTGOING);
|
||||
switch (stockProductionRequest.getFamilleProduit().getId().intValue()) {
|
||||
// matiere premiere
|
||||
case 67:
|
||||
fromStockLocation = stockLocationRepository.find(75L);
|
||||
break;
|
||||
// MATIERE PREMIERE INJECTABLE
|
||||
case 68:
|
||||
fromStockLocation = stockLocationRepository.find(75L);
|
||||
break;
|
||||
// ARTICLES DE CONDITIONEMENT
|
||||
case 59:
|
||||
fromStockLocation = stockLocationRepository.find(75L);
|
||||
break;
|
||||
|
||||
stockMove.setToAddressStr(null);
|
||||
stockMove.setOriginId(stockProductionRequest.getId());
|
||||
stockMove.setOriginTypeSelect(StockMoveRepository.ORIGIN_STOCK_PRODUCTION_REQUEST);
|
||||
stockMove.setOrigin(stockProductionRequest.getStockProductionRequestSeq());
|
||||
stockMove.setStockMoveLineList(new ArrayList<>());
|
||||
stockMove.setTradingName(null);
|
||||
stockMove.setNote(stockProductionRequest.getNote());
|
||||
return stockMove;
|
||||
default:
|
||||
fromStockLocation =
|
||||
stockConfigService.getRawMaterialsDefaultStockLocation(
|
||||
stockConfigService.getStockConfig(company));
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
public StockMoveLine createStockMoveLine(
|
||||
StockMove stockMove, StockProductionRequestLine productionRequestLine, BigDecimal qty) throws AxelorException {
|
||||
|
||||
// stockProductionRequest.getStocklocation();
|
||||
|
||||
StockLocation toStockLocation = stockProductionRequest.getStocklocation();
|
||||
// stockConfigService.getCustomerVirtualStockLocation(
|
||||
// stockConfigService.getStockConfig(company));
|
||||
int stockType = StockMoveRepository.TYPE_INTERNAL;
|
||||
if (stockProductionRequest.getTypeSelect()
|
||||
== StockProductionRequestRepository.TYPE_SELECT_RETURN) {
|
||||
toStockLocation = fromStockLocation;
|
||||
fromStockLocation =
|
||||
// stockProductionRequest.getStocklocation();
|
||||
stockConfigService.getCustomerVirtualStockLocation(
|
||||
stockConfigService.getStockConfig(company));
|
||||
stockType = StockMoveRepository.TYPE_INCOMING;
|
||||
System.out.println("***************************************yes*********************");
|
||||
System.out.println(stockProductionRequest.getTypeSelect());
|
||||
System.out.println(StockProductionRequestRepository.TYPE_SELECT_RETURN);
|
||||
System.out.println(fromStockLocation);
|
||||
System.out.println(toStockLocation);
|
||||
System.out.println("***************************************yes*********************");
|
||||
}
|
||||
|
||||
StockMove stockMove =
|
||||
stockMoveService.createStockMove(
|
||||
null,
|
||||
null,
|
||||
company,
|
||||
stockProductionRequest.getPartner(),
|
||||
fromStockLocation,
|
||||
toStockLocation,
|
||||
null,
|
||||
estimatedDeliveryDate,
|
||||
stockProductionRequest.getNote(),
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
stockType);
|
||||
|
||||
stockMove.setToAddressStr(null);
|
||||
stockMove.setOriginId(stockProductionRequest.getId());
|
||||
stockMove.setOriginTypeSelect(StockMoveRepository.ORIGIN_STOCK_PRODUCTION_REQUEST);
|
||||
stockMove.setOrigin(stockProductionRequest.getStockProductionRequestSeq());
|
||||
stockMove.setStockMoveLineList(new ArrayList<>());
|
||||
stockMove.setTradingName(null);
|
||||
stockMove.setNote(stockProductionRequest.getNote());
|
||||
return stockMove;
|
||||
}
|
||||
|
||||
public StockMoveLine createStockMoveLine(
|
||||
StockMove stockMove, StockProductionRequestLine productionRequestLine, BigDecimal qty)
|
||||
throws AxelorException {
|
||||
|
||||
int scale = Beans.get(AppBaseService.class).getNbDecimalDigitForSalePrice();
|
||||
if (this.isStockMoveProduct(productionRequestLine)) {
|
||||
|
||||
Unit unit = productionRequestLine.getProduct().getUnit();
|
||||
|
||||
|
||||
if (unit != null && !unit.equals(productionRequestLine.getUnit())) {
|
||||
qty =
|
||||
unitConversionService.convert(
|
||||
productionRequestLine.getUnit(), unit, qty, qty.scale(), productionRequestLine.getProduct());
|
||||
productionRequestLine.getUnit(),
|
||||
unit,
|
||||
qty,
|
||||
qty.scale(),
|
||||
productionRequestLine.getProduct());
|
||||
}
|
||||
|
||||
BigDecimal priceDiscounted = productionRequestLine.getUnitPriceTaxed();
|
||||
BigDecimal companyUnitPriceUntaxed = productionRequestLine.getCompanyUnitPriceUntaxed();
|
||||
BigDecimal unitPriceUntaxed = productionRequestLine.getUnitPriceUntaxed();
|
||||
|
||||
BigDecimal companyUnitPriceUntaxed = productionRequestLine.getCompanyUnitPriceUntaxed();
|
||||
BigDecimal unitPriceUntaxed = productionRequestLine.getUnitPriceUntaxed();
|
||||
|
||||
StockMoveLine stockMoveLine =
|
||||
stockMoveLineService.createStockMoveLine(
|
||||
productionRequestLine.getProduct(),
|
||||
productionRequestLine.getProductName(),
|
||||
productionRequestLine.getDescription(),
|
||||
qty,
|
||||
unitPriceUntaxed,
|
||||
companyUnitPriceUntaxed,
|
||||
unit,
|
||||
stockMove,
|
||||
StockMoveLineService.TYPE_NULL,
|
||||
false,
|
||||
BigDecimal.ZERO);
|
||||
return stockMoveLine;
|
||||
|
||||
stockMoveLineService.createStockMoveLine(
|
||||
productionRequestLine.getProduct(),
|
||||
productionRequestLine.getProductName(),
|
||||
productionRequestLine.getDescription(),
|
||||
qty,
|
||||
unitPriceUntaxed,
|
||||
companyUnitPriceUntaxed,
|
||||
companyUnitPriceUntaxed,
|
||||
unit,
|
||||
stockMove,
|
||||
productionRequestLine.getTrackingNumber());
|
||||
return stockMoveLine;
|
||||
}
|
||||
if (productionRequestLine.getDeliveryState() == 0) {
|
||||
productionRequestLine.setDeliveryState(StockProductionRequestLineRepository.DELIVERY_STATE_NOT_DELIVERED);
|
||||
productionRequestLine.setDeliveryState(
|
||||
StockProductionRequestLineRepository.DELIVERY_STATE_NOT_DELIVERED);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Transactional(rollbackOn = {Exception.class})
|
||||
public StockProductionRequest generateReversion(StockProductionRequest stockProductionRequest)
|
||||
throws AxelorException {
|
||||
StockProductionRequestRepository moveRepository =
|
||||
Beans.get(StockProductionRequestRepository.class);
|
||||
StockProductionRequestLineRepository moveRepositoryLineRepository =
|
||||
Beans.get(StockProductionRequestLineRepository.class);
|
||||
StockProductionRequest newStockProductionRequest =
|
||||
moveRepository.copy(stockProductionRequest, false);
|
||||
newStockProductionRequest.setStockProductionRequestSeq(null);
|
||||
newStockProductionRequest.setStatusSelect(StockProductionRequestRepository.STATUS_DRAFT);
|
||||
newStockProductionRequest.setTypeSelect(StockProductionRequestRepository.TYPE_SELECT_RETURN);
|
||||
|
||||
for (StockProductionRequestLine requestLine :
|
||||
stockProductionRequest.getStockProductionRequestLineList()) {
|
||||
StockProductionRequestLine sLine = moveRepositoryLineRepository.copy(requestLine, false);
|
||||
newStockProductionRequest.addStockProductionRequestLineListItem(sLine);
|
||||
}
|
||||
|
||||
return moveRepository.save(newStockProductionRequest);
|
||||
// StockMove stockMove = Beans.get(StockMoveRepository.class).all()
|
||||
// .filter(
|
||||
// "self.originTypeSelect = ?1 AND self.originId = ?2 AND self.statusSelect = ?3",
|
||||
// StockMoveRepository.ORIGIN_STOCK_PRODUCTION_REQUEST,
|
||||
// stockProductionRequest.getId())
|
||||
// .fetchOne();
|
||||
// Optional<StockMove> stockMove =
|
||||
// Beans.get(StockMoveServiceImpl.class).copyAndSplitStockMoveReverse(stockMove, false);
|
||||
// return stockMove;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public boolean isStockMoveProduct(StockProductionRequestLine productionRequestLine) throws AxelorException {
|
||||
return isStockMoveProduct(productionRequestLine, productionRequestLine.getStockProductionRequest());
|
||||
public boolean isStockMoveProduct(StockProductionRequestLine productionRequestLine)
|
||||
throws AxelorException {
|
||||
return isStockMoveProduct(
|
||||
productionRequestLine, productionRequestLine.getStockProductionRequest());
|
||||
}
|
||||
|
||||
public boolean isStockMoveProduct(StockProductionRequestLine productionRequestLine, StockProductionRequest productionRequest)
|
||||
public boolean isStockMoveProduct(
|
||||
StockProductionRequestLine productionRequestLine, StockProductionRequest productionRequest)
|
||||
throws AxelorException {
|
||||
|
||||
Product product = productionRequestLine.getProduct();
|
||||
return (product != null && (product.getProductTypeSelect().equals(ProductRepository.PRODUCT_TYPE_STORABLE)));
|
||||
return (product != null
|
||||
&& (product.getProductTypeSelect().equals(ProductRepository.PRODUCT_TYPE_STORABLE)));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -14,12 +14,12 @@
|
||||
<date name="perishableExpirationDate" title="Perishable expiration date" readonly="true"/>
|
||||
<string name="trackingNumberSeq" namecolumn="true" title="Tracking Nbr." required="true"/>
|
||||
<decimal name="counter" title="Counter"/>
|
||||
|
||||
<unique-constraint columns="product,trackingNumberSeq"/>
|
||||
<date name="receptionDate" title="Reception date" />
|
||||
<decimal name="physicalQty" title="PhysicalQty"/>
|
||||
<integer name="conformitySelect" title="Conformity" selection="stock.move.line.conformity.select"/>
|
||||
|
||||
<finder-method name="findBySeq" using="trackingNumberSeq"/>
|
||||
|
||||
|
||||
<track>
|
||||
<field name="perishableExpirationDate"/>
|
||||
<field name="product"/>
|
||||
|
||||
@@ -29,7 +29,8 @@
|
||||
<many-to-one name="validatedBy" title="Validated By" ref="com.axelor.auth.db.User"/>
|
||||
<many-to-one name="completedBy" title="User" ref="com.axelor.auth.db.User"/>
|
||||
<date name="validatedOn" title="Validated On"/>
|
||||
<integer name="typeSelect" title="Type" selection="product.inventory.type.select" required="true"/>
|
||||
<integer name="typeSelect" title="Type" selection="product.inventory.type.select" required="true"/>
|
||||
<many-to-one name="period" title="Period" ref="com.axelor.apps.base.db.Period"/>
|
||||
|
||||
<unique-constraint columns="inventorySeq,stockLocation"/>
|
||||
|
||||
|
||||
@@ -8,35 +8,68 @@
|
||||
<entity name="InventoryLine" lang="java">
|
||||
|
||||
<many-to-one name="inventory" ref="com.axelor.apps.stock.db.Inventory" title="Inventory"/>
|
||||
<many-to-one name="product" ref="com.axelor.apps.base.db.Product" title="Product" required="true"/>
|
||||
<many-to-one name="product" ref="com.axelor.apps.base.db.Product" title="Product" required="false"/>
|
||||
<string name="productName" title="Product name" />
|
||||
<decimal name="currentQty" title="Current Qty"/>
|
||||
<decimal name="realQty" title="Real Qty" nullable="true"/>
|
||||
<many-to-one name="unit" title="Unit" ref="com.axelor.apps.base.db.Unit"/>
|
||||
<string name="description" title="Description" large="true" multiline="true"/>
|
||||
<string name="observation" title="Observation" large="true" multiline="true"/>
|
||||
<string name="ticketId" title="Ticket id" large="true" multiline="true"/>
|
||||
<string name="rack" title="Rack"/>
|
||||
<many-to-one name="trackingNumber" ref="com.axelor.apps.stock.db.TrackingNumber" title="TrackingNumber"/>
|
||||
<decimal name="gap" title="Gap" readonly="true"/>
|
||||
<decimal name="gapValue" title="Gap value" readonly="true"/>
|
||||
|
||||
<integer name="countingTypeSelect" title="Counting type" required="true" selection="inventory.line.count.type.select"/>
|
||||
<integer name="countingTypeSelect" title="Counting type" required="false" selection="inventory.line.count.type.select"/>
|
||||
<many-to-one name="stockLocation" ref="com.axelor.apps.stock.db.StockLocation" title="Stock location" required="true"/>
|
||||
|
||||
|
||||
<decimal name="firstCounting" title="First counting" nullable="true"/>
|
||||
<decimal name="secondCounting" title="Second counting" nullable="true"/>
|
||||
<decimal name="thirdCounting" title="third counting" nullable="true"/>
|
||||
<decimal name="forthCounting" title="forth counting" nullable="true"/>
|
||||
<decimal name="controlCounting" title="Control counting" nullable="true"/>
|
||||
<decimal name="fifthCounting" title="Fifth counting" nullable="true"/>
|
||||
<decimal name="sixthCounting" title="Sixth counting" nullable="true"/>
|
||||
|
||||
<many-to-one name="firstCountingByUser" ref="com.axelor.auth.db.User" readonly="true" title="First counting by"/>
|
||||
<many-to-one name="secondCountingByUser" ref="com.axelor.auth.db.User" readonly="true" title="Second counting by"/>
|
||||
<many-to-one name="thirdCountingByUser" ref="com.axelor.auth.db.User" readonly="true" title="Third counting by"/>
|
||||
<many-to-one name="forthCountingByUser" ref="com.axelor.auth.db.User" readonly="true" title="Forth counting by"/>
|
||||
<many-to-one name="controlCountingByUser" ref="com.axelor.auth.db.User" readonly="true" title="Control counting by"/>
|
||||
<many-to-one name="fifthCountingByUser" ref="com.axelor.auth.db.User" readonly="true" title="Fifth counting by"/>
|
||||
<many-to-one name="sixthCountingByUser" ref="com.axelor.auth.db.User" readonly="true" title="Sixth counting by"/>
|
||||
|
||||
|
||||
<datetime name="firstCountingDate" readonly="true" title="First counting date"/>
|
||||
<datetime name="secondCountingDate" readonly="true" title="Second counting date"/>
|
||||
<datetime name="thirdCountingDate" readonly="true" title="Third counting date"/>
|
||||
<datetime name="forthCountingDate" readonly="true" title="Forth counting date"/>
|
||||
<datetime name="controlCountingDate" readonly="true" title="Control counting date"/>
|
||||
<datetime name="fifthCountingDate" readonly="true" title="Fifth counting date"/>
|
||||
<datetime name="sixthCountingDate" readonly="true" title="Sixth counting date"/>
|
||||
|
||||
<string name="productHolder" title="Product Holder" />
|
||||
<boolean name="justifiedGap" title="Justified gap"/>
|
||||
<boolean name="isVentilated" title="Is ventilated"/>
|
||||
|
||||
<string name="trackingNumberStr" title="Tracking number str"/>
|
||||
<string name="internalTrackingNumberStr" title="Internal tracking number str"/>
|
||||
|
||||
<integer name="conformitySelect" title="Conformity" selection="stock.move.line.conformity.select"/>
|
||||
<integer name="stateSelect" title="State" selection="inventory.line.state.select"/>
|
||||
|
||||
|
||||
<track>
|
||||
<field name="firstCounting" />
|
||||
<field name="secondCounting" />
|
||||
<field name="thirdCounting" />
|
||||
<field name="forthCounting" />
|
||||
<field name="controlCounting" />
|
||||
<field name="fifthCounting" />
|
||||
<field name="sixthCounting" />
|
||||
</track>
|
||||
|
||||
</entity>
|
||||
</domain-models>
|
||||
|
||||
@@ -55,6 +55,10 @@
|
||||
<boolean name="displayTrackNbrOnCertificateOfConformityPrinting" title="Display tracking number details on certificate of conformity printing"/>
|
||||
<boolean name="displayExtRefOnCertificateOfConformityPrinting" title="Display external ref. on certificate of conformity printing"/>
|
||||
<many-to-one name="stockRuleMessageTemplate" ref="com.axelor.apps.message.db.Template" title="Message template for stock rules"/>
|
||||
<one-to-many name="exludedProductsFromWrkFlw" ref="com.axelor.apps.base.db.Product" title="Excluded products from workflow (WMS)"/>
|
||||
|
||||
<integer name="mpInternalSeq" title="MP internal sequence" />
|
||||
<integer name="acInternalSeq" title="AC internal sequence" />
|
||||
|
||||
<track>
|
||||
<field name="company" on="UPDATE"/>
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
<boolean name="includeOutOfStock" title="Include out of stocks products" default="false"/>
|
||||
<decimal name="stockLocationValue" title="Stock location value" transient="true"/>
|
||||
<boolean name="excludeValorisation" title="Exclude valorisation" default="false"/>
|
||||
<many-to-many name="stockLocationList" ref="com.axelor.apps.stock.db.StockLocation" title="Stock locations"/>
|
||||
<many-to-one name="picture" ref="com.axelor.meta.db.MetaFile" title="Photo" index="false"/>
|
||||
|
||||
<finder-method name="findByCompany" using="company"/>
|
||||
<finder-method name="findByPartner" using="partner"/>
|
||||
@@ -33,6 +35,10 @@
|
||||
public static final int PRINT_TYPE_LOCATION_FINANCIAL_DATA = 1;
|
||||
public static final int PRINT_TYPE_STOCK_LOCATION_CONTENT = 2;
|
||||
|
||||
public static final int TYPE_COMPLIANT = 2;
|
||||
public static final int TYPE_NOT_COMPLIANT = 3;
|
||||
public static final int TYPE_QUARANTINE = 4;
|
||||
|
||||
|
||||
]]></extra-code>
|
||||
|
||||
|
||||
@@ -20,9 +20,29 @@
|
||||
<string name="rack" title="Rack"/>
|
||||
<many-to-one name="trackingNumber" ref="com.axelor.apps.stock.db.TrackingNumber" title="Tracking Nbr" readonly="true"/>
|
||||
<many-to-one name="detailsStockLocation" ref="com.axelor.apps.stock.db.StockLocation" title="Stock location details" readonly="true"/>
|
||||
<many-to-one name="internalDetailsStockLocation" ref="com.axelor.apps.stock.db.StockLocation" title="Internal stock location details" readonly="true"/>
|
||||
|
||||
<decimal name="lastInventoryRealQty"/>
|
||||
<datetime name="lastInventoryDateT" tz="true" title="Last inventory date"/>
|
||||
|
||||
<integer name="conformitySelect" title="Conformity" selection="stock.move.line.conformity.select"/>
|
||||
<!-- QA/QC for the commercial liberation -->
|
||||
<boolean name="checkToRelease" title="Check to release" default="false"/>
|
||||
|
||||
<!-- QA/QC -->
|
||||
<boolean name="isConformTag" title="Conformity Tag" />
|
||||
|
||||
<boolean name="analysisFolderValidated" title="Analysis folder validated" />
|
||||
|
||||
<many-to-one name="internalTrackingNumber" ref="com.axelor.apps.stock.db.InternalTrackingNumber" title="Internal tracking Nbr" readonly="true"/>
|
||||
|
||||
<track>
|
||||
<field name="conformitySelect"/>
|
||||
<field name="isConformTag"/>
|
||||
<field name="checkToRelease"/>
|
||||
<field name="analysisFolderValidated"/>
|
||||
</track>
|
||||
|
||||
|
||||
</entity>
|
||||
</domain-models>
|
||||
|
||||
@@ -95,6 +95,8 @@
|
||||
<decimal name="convertedExTaxTotal" title="Converted ExTaxTotal" scale="6" precision="20" />
|
||||
<decimal name="convertedInTaxTotal" title="Converted InTaxTotal" scale="6" precision="20" />
|
||||
|
||||
<many-to-many ref="StockMoveLineLocation" name="stockMoveLineLocationSet" />
|
||||
|
||||
<extra-code><![CDATA[
|
||||
// CONFORMITY SELECT
|
||||
public static final int CONFORMITY_NONE = 1;
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<domain-models xmlns="http://axelor.com/xml/ns/domain-models"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://axelor.com/xml/ns/domain-models http://axelor.com/xml/ns/domain-models/domain-models_5.2.xsd">
|
||||
|
||||
<module name="stock" package="com.axelor.apps.stock.db"/>
|
||||
|
||||
<entity name="StockMoveLineLocation" lang="java">
|
||||
|
||||
|
||||
<string name="code" title="Code" >
|
||||
<![CDATA[
|
||||
String code = "";
|
||||
if(lane != null && rack != null && racklevel != null && position != null )
|
||||
code += lane.toString() + "-" + rack.toString() + "-" + racklevel.toString() + "-" + position.toString();
|
||||
return code;
|
||||
]]>
|
||||
</string>
|
||||
|
||||
<string name="lane" title="Stock lane" />
|
||||
<integer name="rack" title="Rack" />
|
||||
<integer name="racklevel" title="Level" />
|
||||
<string name="position" title="Position" />
|
||||
|
||||
<many-to-one name="barCodeSeq" title="Barcode" ref="com.axelor.meta.db.MetaFile" />
|
||||
<many-to-one name="image" title="Picture" ref="com.axelor.meta.db.MetaFile" />
|
||||
|
||||
<many-to-many name="stockMoveLineLocationLineSet" title="Stock move line location line" ref="StockMoveLineLocationLine" />
|
||||
|
||||
<boolean name="busy" title="Busy"/>
|
||||
|
||||
<track>
|
||||
<field name="code"/>
|
||||
</track>
|
||||
</entity>
|
||||
|
||||
|
||||
|
||||
</domain-models>
|
||||
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<domain-models xmlns="http://axelor.com/xml/ns/domain-models"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://axelor.com/xml/ns/domain-models http://axelor.com/xml/ns/domain-models/domain-models_5.2.xsd">
|
||||
|
||||
<module name="stock" package="com.axelor.apps.stock.db"/>
|
||||
|
||||
<entity name="StockMoveLineLocationLine" lang="java">
|
||||
|
||||
<many-to-one name="stockMoveLineLocation" ref="StockMoveLineLocation" title="StockMoveLocation"/>
|
||||
<many-to-one name="product" ref="com.axelor.apps.base.db.Product" title="Product"/>
|
||||
<many-to-one name="trackingNumber" ref="com.axelor.apps.stock.db.TrackingNumber" title="trackingNumber"/>
|
||||
</entity>
|
||||
|
||||
|
||||
|
||||
</domain-models>
|
||||
@@ -37,6 +37,11 @@
|
||||
public static final int STATUS_REALIZED = 3;
|
||||
public static final int STATUS_CANCELED = 4;
|
||||
|
||||
|
||||
// TYPE SELECT
|
||||
public static final int TYPE_SELECT_ORDER = 1;
|
||||
public static final int TYPE_SELECT_RETURN = 2;
|
||||
|
||||
]]></extra-code>
|
||||
|
||||
<track>
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
|
||||
<integer name="deliveryState" title="Delivery State" selection="sale.order.delivery.state" readonly="true" default="1"/>
|
||||
<boolean name="isWithBackorder" title="Manage backorder" default="true"/>
|
||||
|
||||
<many-to-one name="trackingNumber" ref="com.axelor.apps.stock.db.TrackingNumber" title="Tracking Nbr."/>
|
||||
|
||||
<extra-code><![CDATA[
|
||||
// CONFORMITY SELECT
|
||||
|
||||
Reference in New Issue
Block a user