temporary branch
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
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;
|
||||
|
||||
public class StockProductionRequestManagementRepository extends StockProductionRequestRepository{
|
||||
|
||||
@Override
|
||||
public StockProductionRequest save(StockProductionRequest entity) {
|
||||
try {
|
||||
StockProductionRequest productionRequest = super.save(entity);
|
||||
SequenceService sequenceService = Beans.get(SequenceService.class);
|
||||
|
||||
if (Strings.isNullOrEmpty(productionRequest.getStockProductionRequestSeq())) {
|
||||
productionRequest.setStockProductionRequestSeq(sequenceService.getDraftSequenceNumber(productionRequest));
|
||||
}
|
||||
|
||||
if (Strings.isNullOrEmpty(productionRequest.getName())
|
||||
|| productionRequest.getName().startsWith(productionRequest.getStockProductionRequestSeq())) {
|
||||
productionRequest.setName(productionRequest.getStockProductionRequestSeq());
|
||||
}
|
||||
|
||||
return productionRequest;
|
||||
} catch (Exception e) {
|
||||
throw new PersistenceException(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -48,8 +48,8 @@ public class TrackingNumberManagementRepository extends TrackingNumberRepository
|
||||
if (stockLocation != null) {
|
||||
BigDecimal availableQty =
|
||||
stockLocationLineService.getTrackingNumberAvailableQty(
|
||||
stockLocation, trackingNumber);
|
||||
|
||||
stockLocation, trackingNumber);
|
||||
|
||||
json.put("$availableQty", availableQty);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,4 +24,5 @@ public interface IReport {
|
||||
public static final String CONFORMITY_CERTIFICATE = "ConformityCertificate.rptdesign";
|
||||
public static final String INVENTORY = "Inventory.rptdesign";
|
||||
public static final String STOCK_LOCATION = "StockLocation.rptdesign";
|
||||
public static final String STOCK_PRODUCTION_REQUEST = "StockProductionRequest.rptdesign";
|
||||
}
|
||||
|
||||
@@ -18,17 +18,31 @@
|
||||
package com.axelor.apps.stock.service;
|
||||
|
||||
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.TrackingNumberRepository;
|
||||
import com.axelor.auth.AuthUtils;
|
||||
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;
|
||||
private TrackingNumberRepository trackingNumberRepository;
|
||||
private InventoryLineRepository inventoryLineRepository;
|
||||
|
||||
public InventoryLine createInventoryLine(
|
||||
Inventory inventory,
|
||||
Product product,
|
||||
@@ -95,4 +109,61 @@ 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;
|
||||
|
||||
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(line == null){
|
||||
line = this.createInventoryLine(inventory, product, BigDecimal.ZERO, null, trackingNumber);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -437,7 +437,7 @@ public class InventoryService {
|
||||
|
||||
stockMoveService.plan(stockMove);
|
||||
stockMoveService.copyQtyToRealQty(stockMove);
|
||||
stockMoveService.realize(stockMove, false);
|
||||
// stockMoveService.realize(stockMove, false);
|
||||
}
|
||||
return stockMove;
|
||||
}
|
||||
|
||||
@@ -38,4 +38,19 @@ public interface StockHistoryService {
|
||||
List<StockHistoryLine> computeStockHistoryLineList(
|
||||
Long productId, Long companyId, Long stockLocationId, LocalDate beginDate, LocalDate endDate)
|
||||
throws AxelorException;
|
||||
|
||||
/**
|
||||
* Compute lines for stock history. Compute one line per month between beginDate and endDate and
|
||||
* add two lines for average and total.
|
||||
*
|
||||
* @param productId id of the queried product, cannot be null.
|
||||
* @param companyId id of the company used as filter, cannot be null.
|
||||
* @param stockLocationId id of the stock location used as filter, cannot be null.
|
||||
* @param beginDate mandatory date used for the generation.
|
||||
* @param endDate mandatory date used for the generation.
|
||||
* @return the computed lines.
|
||||
*/
|
||||
List<StockHistoryLine> compuHistoryLinesPerDate
|
||||
(Long productId, Long companyId, Long stockLocationId, LocalDate beginDate, LocalDate endDate,Long categoryId,Long trackingNumberId,Integer searchTypeSelect)
|
||||
throws AxelorException;
|
||||
}
|
||||
|
||||
@@ -17,27 +17,63 @@
|
||||
*/
|
||||
package com.axelor.apps.stock.service;
|
||||
|
||||
import com.axelor.app.AppSettings;
|
||||
import com.axelor.apps.base.db.Company;
|
||||
import com.axelor.apps.base.db.Product;
|
||||
import com.axelor.apps.base.db.repo.CompanyRepository;
|
||||
import com.axelor.apps.base.db.repo.ProductRepository;
|
||||
import com.axelor.apps.base.service.UnitConversionService;
|
||||
import com.axelor.apps.stock.db.StockHistoryLine;
|
||||
import com.axelor.apps.stock.db.StockLocation;
|
||||
import com.axelor.apps.stock.db.StockLocationLine;
|
||||
import com.axelor.apps.stock.db.StockMoveLine;
|
||||
import com.axelor.apps.stock.db.TrackingNumber;
|
||||
import com.axelor.apps.stock.db.repo.StockLocationLineRepository;
|
||||
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.db.repo.TrackingNumberRepository;
|
||||
import com.axelor.apps.tool.file.CsvTool;
|
||||
import com.axelor.db.JPA;
|
||||
import com.axelor.exception.AxelorException;
|
||||
import com.axelor.i18n.I18n;
|
||||
import com.axelor.inject.Beans;
|
||||
import com.axelor.meta.MetaFiles;
|
||||
import com.axelor.meta.db.MetaFile;
|
||||
import com.google.common.io.Files;
|
||||
import com.google.inject.Inject;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
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;
|
||||
|
||||
public class StockHistoryServiceImpl implements StockHistoryService {
|
||||
|
||||
protected StockMoveLineRepository stockMoveLineRepository;
|
||||
protected UnitConversionService unitConversionService;
|
||||
|
||||
private final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
|
||||
|
||||
@Inject
|
||||
public StockHistoryServiceImpl(
|
||||
StockMoveLineRepository stockMoveLineRepository,
|
||||
@@ -47,7 +83,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<>();
|
||||
|
||||
@@ -65,7 +101,9 @@ public class StockHistoryServiceImpl implements StockHistoryService {
|
||||
stockLocationId,
|
||||
periodBeginDate,
|
||||
periodEndDate,
|
||||
true);
|
||||
true,
|
||||
false,
|
||||
null);
|
||||
fetchAndFillResultForStockHistoryQuery(
|
||||
stockHistoryLine,
|
||||
productId,
|
||||
@@ -73,7 +111,9 @@ public class StockHistoryServiceImpl implements StockHistoryService {
|
||||
stockLocationId,
|
||||
periodBeginDate,
|
||||
periodEndDate,
|
||||
false);
|
||||
false,
|
||||
false,
|
||||
null);
|
||||
stockHistoryLineList.add(stockHistoryLine);
|
||||
}
|
||||
StockHistoryLine totalStockHistoryLine = createStockHistoryTotalLine(stockHistoryLineList);
|
||||
@@ -93,7 +133,9 @@ public class StockHistoryServiceImpl implements StockHistoryService {
|
||||
Long stockLocationId,
|
||||
LocalDate periodBeginDate,
|
||||
LocalDate periodEndDate,
|
||||
boolean incoming)
|
||||
boolean incoming,
|
||||
boolean allLocations,
|
||||
Long trackingNumberId)
|
||||
throws AxelorException {
|
||||
String filter =
|
||||
"self.product.id = :productId "
|
||||
@@ -101,13 +143,29 @@ public class StockHistoryServiceImpl implements StockHistoryService {
|
||||
+ "AND self.stockMove.company.id = :companyId "
|
||||
+ "AND self.stockMove.realDate >= :beginDate "
|
||||
+ "AND self.stockMove.realDate < :endDate ";
|
||||
|
||||
|
||||
if (incoming) {
|
||||
filter += "AND self.stockMove.toStockLocation.id = :stockLocationId ";
|
||||
if(allLocations == true){
|
||||
filter += "AND self.stockMove.fromStockLocation.typeSelect = :typeSelect ";
|
||||
}else{
|
||||
filter += "AND self.stockMove.toStockLocation.id = :stockLocationId ";
|
||||
}
|
||||
} else {
|
||||
filter += "AND self.stockMove.fromStockLocation.id = :stockLocationId ";
|
||||
if(allLocations == true){
|
||||
filter += "AND self.stockMove.toStockLocation.typeSelect = :typeSelect ";
|
||||
}else{
|
||||
filter += "AND self.stockMove.fromStockLocation.id = :stockLocationId ";
|
||||
}
|
||||
}
|
||||
|
||||
if(trackingNumberId != null){
|
||||
filter += " AND self.trackingNumber.id = :trackingNumberId";
|
||||
}
|
||||
|
||||
System.out.println("*************query filter************************");
|
||||
System.out.println(filter);
|
||||
System.out.println("*************query************************");
|
||||
|
||||
List<StockMoveLine> stockMoveLineList =
|
||||
stockMoveLineRepository
|
||||
.all()
|
||||
@@ -118,7 +176,14 @@ public class StockHistoryServiceImpl implements StockHistoryService {
|
||||
.bind("realized", StockMoveRepository.STATUS_REALIZED)
|
||||
.bind("beginDate", periodBeginDate)
|
||||
.bind("endDate", periodEndDate)
|
||||
.bind("typeSelect", StockLocationRepository.TYPE_VIRTUAL)
|
||||
.bind("trackingNumberId", trackingNumberId)
|
||||
.fetch();
|
||||
|
||||
System.out.println("stockMoveLineList size******************************************");
|
||||
System.out.println(stockMoveLineList.size());
|
||||
System.out.println("stockMoveLineList size******************************************");
|
||||
|
||||
if (incoming) {
|
||||
fillIncomingStockHistoryLineFields(stockHistoryLine, stockMoveLineList);
|
||||
} else {
|
||||
@@ -296,4 +361,338 @@ 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 {
|
||||
List<StockHistoryLine> stockHistoryLineList = new ArrayList<>();
|
||||
Company company = Beans.get(CompanyRepository.class).find(companyId);
|
||||
|
||||
//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());
|
||||
|
||||
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 == 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,
|
||||
stockLocationId,
|
||||
beginDate,
|
||||
endDate,
|
||||
true,
|
||||
true,
|
||||
trackingNumberId2);
|
||||
|
||||
fetchAndFillResultForStockHistoryQuery(
|
||||
stockHistoryLine,
|
||||
product.getId(),
|
||||
companyId,
|
||||
stockLocationId,
|
||||
beginDate,
|
||||
endDate,
|
||||
false,
|
||||
true,
|
||||
trackingNumberId2);
|
||||
|
||||
BigDecimal totalQty = this.getTotalQty(product, company, stockLocationId,true,trackingNumberId2);
|
||||
BigDecimal realQty = totalQty.add(stockHistoryLine.getSumOutQtyPeriod()).subtract(stockHistoryLine.getSumIncQtyPeriod());
|
||||
|
||||
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) {
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
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){
|
||||
query += " AND self.stockLocation.company = " + company.getId();
|
||||
}else{
|
||||
query += " AND self.detailsStockLocation.company = " + company.getId();
|
||||
}
|
||||
}
|
||||
|
||||
BigDecimal qtyTot = BigDecimal.ZERO;
|
||||
List<List<Object>> results = JPA.em().createQuery(query).getResultList();
|
||||
if (results.isEmpty()) {
|
||||
return BigDecimal.ZERO;
|
||||
}
|
||||
for (List<Object> result : results) {
|
||||
BigDecimal qty = (BigDecimal) result.get(2);
|
||||
qtyTot = qtyTot.add(qty);
|
||||
}
|
||||
if (qtyTot.compareTo(BigDecimal.ZERO) == 0) {
|
||||
return BigDecimal.ZERO;
|
||||
}
|
||||
return qtyTot;
|
||||
}
|
||||
|
||||
|
||||
public MetaFile exportToCSV(List<HashMap<String, Object>> historyLines)
|
||||
throws AxelorException, IOException {
|
||||
List<String[]> allMoveLineData = new ArrayList<>();
|
||||
|
||||
System.out.println("***************************************");
|
||||
System.out.println(historyLines.size());
|
||||
System.out.println("***************************************");
|
||||
|
||||
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;
|
||||
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;
|
||||
|
||||
items[0] = label;
|
||||
items[1] = String.valueOf(inc);
|
||||
items[2] = String.valueOf(sumInc);
|
||||
items[3] = String.valueOf(out);
|
||||
items[4] = String.valueOf(sumOut);
|
||||
items[5] = String.valueOf(realQty);
|
||||
allMoveLineData.add(items);
|
||||
}
|
||||
|
||||
|
||||
String filePath = Files.createTempDir().getAbsolutePath();
|
||||
|
||||
if (filePath == null) {
|
||||
filePath = AppSettings.get().get("file.upload.dir");
|
||||
} else {
|
||||
new File(filePath).mkdirs();
|
||||
}
|
||||
|
||||
String fileName = I18n.get("StockPerDate") + ".csv";
|
||||
Path path = Paths.get(filePath, fileName);
|
||||
File file = path.toFile();
|
||||
|
||||
String[] headers = {
|
||||
I18n.get("Product Name"),
|
||||
I18n.get("Inc"),
|
||||
I18n.get("SumInc"),
|
||||
I18n.get("Out"),
|
||||
I18n.get("SumOut"),
|
||||
I18n.get("Real Quantity"),
|
||||
};
|
||||
|
||||
CsvTool.csvWriter(filePath, fileName, ';', headers, allMoveLineData);
|
||||
|
||||
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, );
|
||||
|
||||
// List<Map<Account, BigDecimal>> allMap = new ArrayList<Map<Account, BigDecimal>>();
|
||||
// allMap = q.getResultList();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -339,11 +339,11 @@ public class StockMoveLineServiceImpl implements StockMoveLineService {
|
||||
|
||||
if (stockMove != null) {
|
||||
stockMove.addStockMoveLineListItem(stockMoveLine);
|
||||
stockMoveLine.setNetMass(
|
||||
this.computeNetMass(stockMove, stockMoveLine, stockMove.getCompany()));
|
||||
// stockMoveLine.setNetMass(
|
||||
// this.computeNetMass(stockMove, stockMoveLine, stockMove.getCompany()));
|
||||
stockMoveLine.setSequence(stockMove.getStockMoveLineList().size());
|
||||
} else {
|
||||
stockMoveLine.setNetMass(this.computeNetMass(stockMove, stockMoveLine, null));
|
||||
// stockMoveLine.setNetMass(this.computeNetMass(stockMove, stockMoveLine, null));
|
||||
}
|
||||
|
||||
stockMoveLine.setTotalNetMass(
|
||||
@@ -462,10 +462,10 @@ public class StockMoveLineServiceImpl implements StockMoveLineService {
|
||||
toStatus,
|
||||
lastFutureStockMoveDate,
|
||||
stockMoveLine.getTrackingNumber());
|
||||
if (toStockLocation.getTypeSelect() != StockLocationRepository.TYPE_VIRTUAL) {
|
||||
if (fromStockLocation.getTypeSelect() == StockLocationRepository.TYPE_VIRTUAL) {
|
||||
this.updateAveragePriceLocationLine(toStockLocation, stockMoveLine, fromStatus, toStatus);
|
||||
weightedAveragePriceService.computeAvgPriceForProduct(stockMoveLine.getProduct());
|
||||
}
|
||||
weightedAveragePriceService.computeAvgPriceForProduct(stockMoveLine.getProduct());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -488,10 +488,42 @@ public class StockMoveLineServiceImpl implements StockMoveLineService {
|
||||
|
||||
protected void computeNewAveragePriceLocationLine(
|
||||
StockLocationLine stockLocationLine, StockMoveLine stockMoveLine) throws AxelorException {
|
||||
BigDecimal oldAvgPrice = stockLocationLine.getAvgPrice();
|
||||
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);
|
||||
}
|
||||
|
||||
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 = stockLocationLine.getCurrentQty().subtract(newQty);
|
||||
BigDecimal oldQty = sumQty.subtract(newQty);
|
||||
System.out.println("*****************qty***************");
|
||||
System.out.println(stockLocationLine.getAvgPrice());
|
||||
System.out.println(oldQty);
|
||||
System.out.println(newQty);
|
||||
System.out.println(sumQty);
|
||||
System.out.println(oldAvgPrice);
|
||||
System.out.println("**************qty******************");
|
||||
System.out.println("*****************stockLocationLine***************");
|
||||
System.out.println(stockLocationLine);
|
||||
System.out.println("**************stockLocationLine******************");
|
||||
BigDecimal newPrice =
|
||||
stockMoveLine.getWapPrice() != null
|
||||
? stockMoveLine.getWapPrice()
|
||||
@@ -801,7 +833,7 @@ public class StockMoveLineServiceImpl implements StockMoveLineService {
|
||||
BigDecimal unitPriceUntaxed = BigDecimal.ZERO;
|
||||
if (stockMoveLine.getProduct() != null && stockMove != null) {
|
||||
if (stockMove.getTypeSelect() == StockMoveRepository.TYPE_OUTGOING) {
|
||||
if(stockMoveLine.getProduct().getSellable() == true){
|
||||
if (stockMoveLine.getProduct().getSellable() == true) {
|
||||
unitPriceUntaxed = stockMoveLine.getProduct().getSalePrice();
|
||||
}else{
|
||||
unitPriceUntaxed = stockMoveLine.getProduct().getAvgPrice();
|
||||
@@ -810,7 +842,7 @@ public class StockMoveLineServiceImpl implements StockMoveLineService {
|
||||
if(stockMoveLine.getProduct().getSellable() == true){
|
||||
unitPriceUntaxed = stockMoveLine.getProduct().getSalePrice();
|
||||
}else{
|
||||
unitPriceUntaxed = stockMoveLine.getProduct().getPurchasePrice();
|
||||
unitPriceUntaxed = stockMoveLine.getUnitPriceUntaxed();
|
||||
}
|
||||
} else if (stockMove.getTypeSelect() == StockMoveRepository.TYPE_INTERNAL
|
||||
&& stockMove.getFromStockLocation() != null
|
||||
@@ -1197,14 +1229,23 @@ public class StockMoveLineServiceImpl implements StockMoveLineService {
|
||||
}
|
||||
|
||||
public void fillRealizeWapPrice(StockMoveLine stockMoveLine) {
|
||||
StockLocation stockLocation = stockMoveLine.getStockMove().getFromStockLocation();
|
||||
StockLocation stockLocation;
|
||||
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 -> stockMoveLine.setWapPrice(stockLocationLine.getAvgPrice()));
|
||||
stockLocationLine -> {
|
||||
if(stockLocationLine.getCurrentQty().compareTo(BigDecimal.ZERO) > 0){
|
||||
stockMoveLine.setWapPrice(stockLocationLine.getAvgPrice());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -135,7 +135,8 @@ public interface StockMoveService {
|
||||
|
||||
void cancel(StockMove stockMove) throws AxelorException;
|
||||
|
||||
void cancel(StockMove stockMove, CancelReason cancelReason) throws AxelorException;
|
||||
void cancel(StockMove stockMove, CancelReason cancelReason, String cancelReasonStr)
|
||||
throws AxelorException;
|
||||
|
||||
@Transactional
|
||||
public Boolean splitStockMoveLinesUnit(List<StockMoveLine> stockMoveLines, BigDecimal splitQty);
|
||||
@@ -144,6 +145,10 @@ public interface StockMoveService {
|
||||
public void splitStockMoveLinesSpecial(
|
||||
StockMove stockMove, List<StockMoveLine> list, BigDecimal splitQty);
|
||||
|
||||
@Transactional
|
||||
public void splitStockMoveLinesSpecial2(
|
||||
StockMove stockMove, List<StockMoveLine> list, BigDecimal splitQty);
|
||||
|
||||
@Transactional
|
||||
public void copyQtyToRealQty(StockMove stockMove);
|
||||
|
||||
@@ -154,11 +159,9 @@ public interface StockMoveService {
|
||||
StockMove originalStockMove, List<StockMoveLine> modifiedStockMoveLines)
|
||||
throws AxelorException;
|
||||
|
||||
|
||||
public StockMove splitInto2SameMove(
|
||||
public StockMove splitInto2SameMove(
|
||||
StockMove originalStockMove, List<StockMoveLine> modifiedStockMoveLines)
|
||||
throws AxelorException;
|
||||
|
||||
|
||||
public List<Map<String, Object>> getStockPerDate(
|
||||
Long locationId, Long productId, LocalDate fromDate, LocalDate toDate);
|
||||
|
||||
@@ -51,7 +51,6 @@ 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;
|
||||
@@ -63,6 +62,7 @@ import com.google.inject.persist.Transactional;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
@@ -71,9 +71,6 @@ 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;
|
||||
|
||||
@@ -208,7 +205,7 @@ public class StockMoveServiceImpl implements StockMoveService {
|
||||
stockMoveToolService.computeAddressStr(stockMove);
|
||||
stockMove.setCompany(company);
|
||||
stockMove.setStatusSelect(StockMoveRepository.STATUS_DRAFT);
|
||||
stockMove.setRealDate(realDate);
|
||||
stockMove.setRealDate(LocalDateTime.now());
|
||||
stockMove.setEstimatedDate(estimatedDate);
|
||||
stockMove.setFromStockLocation(fromStockLocation);
|
||||
stockMove.setToStockLocation(toStockLocation);
|
||||
@@ -289,21 +286,28 @@ public class StockMoveServiceImpl implements StockMoveService {
|
||||
draftSeq = stockMove.getStockMoveSeq();
|
||||
if (stockMove.getTypeSelect() == StockMoveRepository.TYPE_INCOMING && stockMove.getIsReversion() == true){
|
||||
stockMove.setStockMoveSeq(
|
||||
stockMoveToolService.getSequenceStockMove(StockMoveRepository.TYPE_INCOMING_CLIENT, stockMove.getCompany()));
|
||||
}else if(stockMove.getTypeSelect() == StockMoveRepository.TYPE_OUTGOING && stockMove.getIsReversion() == false && stockMove.getPartner().getId() != 853 ){
|
||||
stockMoveToolService.getSequenceStockMove(
|
||||
StockMoveRepository.TYPE_INCOMING_CLIENT, stockMove.getCompany()));
|
||||
} else if (stockMove.getTypeSelect() == StockMoveRepository.TYPE_OUTGOING
|
||||
&& stockMove.getIsReversion() == false
|
||||
&& stockMove.getPartner().getId() != 853) {
|
||||
stockMove.setStockMoveSeq(
|
||||
stockMoveToolService.getSequenceStockMove(StockMoveRepository.TYPE_OUTGOING_CLIENT, stockMove.getCompany()));
|
||||
} else if(stockMove.getTypeSelect() == StockMoveRepository.TYPE_OUTGOING && stockMove.getIsReversion() == false && stockMove.getPartner().getId() == 853){
|
||||
stockMove.setStockMoveSeq(
|
||||
stockMoveToolService.getSequenceStockMove(StockMoveRepository.TYPE_INTERNAL_OUTGOING_CLIENT, stockMove.getCompany()));
|
||||
}else if(stockMove.getTypeSelect() == StockMoveRepository.TYPE_OUTGOING && stockMove.getIsReversion() == true){
|
||||
}else if (stockMove.getTypeSelect() == StockMoveRepository.TYPE_OUTGOING
|
||||
&& stockMove.getIsReversion() == false
|
||||
&& stockMove.getPartner().getId() == 853) {
|
||||
stockMove.setStockMoveSeq(
|
||||
stockMoveToolService.getSequenceStockMove(StockMoveRepository.TYPE_SUPPLIER_OUTGOING_CLIENT, stockMove.getCompany()));
|
||||
}
|
||||
else{
|
||||
stockMoveToolService.getSequenceStockMove(
|
||||
StockMoveRepository.TYPE_INTERNAL_OUTGOING_CLIENT, stockMove.getCompany()));
|
||||
} else if (stockMove.getTypeSelect() == StockMoveRepository.TYPE_OUTGOING
|
||||
&& stockMove.getIsReversion() == true) {
|
||||
stockMove.setStockMoveSeq(
|
||||
stockMoveToolService.getSequenceStockMove(
|
||||
stockMove.getTypeSelect(), stockMove.getCompany()));
|
||||
stockMoveToolService.getSequenceStockMove(
|
||||
StockMoveRepository.TYPE_SUPPLIER_OUTGOING_CLIENT, stockMove.getCompany()));
|
||||
} else {
|
||||
stockMove.setStockMoveSeq(
|
||||
stockMoveToolService.getSequenceStockMove(
|
||||
stockMove.getTypeSelect(), stockMove.getCompany()));
|
||||
}
|
||||
} else {
|
||||
draftSeq = null;
|
||||
@@ -401,9 +405,9 @@ 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);
|
||||
}
|
||||
// if (stockMove.getFromStockLocation().getTypeSelect() != StockLocationRepository.TYPE_VIRTUAL) {
|
||||
// stockMove.getStockMoveLineList().forEach(stockMoveLineService::fillRealizeWapPrice);
|
||||
// }
|
||||
checkExpirationDates(stockMove);
|
||||
|
||||
setRealizedStatus(stockMove);
|
||||
@@ -413,7 +417,7 @@ public class StockMoveServiceImpl implements StockMoveService {
|
||||
initialStatus,
|
||||
StockMoveRepository.STATUS_CANCELED,
|
||||
stockMove.getPlannedStockMoveLineList(),
|
||||
stockMove.getEstimatedDate(),
|
||||
LocalDate.now(),
|
||||
false);
|
||||
|
||||
stockMoveLineService.updateLocations(
|
||||
@@ -422,14 +426,15 @@ public class StockMoveServiceImpl implements StockMoveService {
|
||||
StockMoveRepository.STATUS_DRAFT,
|
||||
StockMoveRepository.STATUS_REALIZED,
|
||||
stockMove.getStockMoveLineList(),
|
||||
stockMove.getEstimatedDate(),
|
||||
LocalDate.now(),
|
||||
true);
|
||||
|
||||
stockMove.clearPlannedStockMoveLineList();
|
||||
|
||||
stockMoveLineService.storeCustomsCodes(stockMove.getStockMoveLineList());
|
||||
|
||||
stockMove.setRealDate(appBaseService.getTodayDate());
|
||||
|
||||
stockMove.setRealDate(LocalDateTime.now());
|
||||
resetMasses(stockMove);
|
||||
|
||||
if (stockMove.getIsWithBackorder() && mustBeSplit(stockMove.getStockMoveLineList())) {
|
||||
@@ -450,6 +455,8 @@ public class StockMoveServiceImpl implements StockMoveService {
|
||||
}
|
||||
}
|
||||
computeMasses(stockMove);
|
||||
stockMove.getStockMoveLineList().forEach(stockMoveLineService::fillRealizeWapPrice);
|
||||
|
||||
stockMoveRepo.save(stockMove);
|
||||
|
||||
if (stockMove.getTypeSelect() == StockMoveRepository.TYPE_INCOMING) {
|
||||
@@ -647,25 +654,33 @@ public class StockMoveServiceImpl implements StockMoveService {
|
||||
|
||||
stockMoveLines = MoreObjects.firstNonNull(stockMoveLines, Collections.emptyList());
|
||||
StockMove newStockMove = stockMoveRepo.copy(stockMove, false);
|
||||
if (stockMove.getTypeSelect() == StockMoveRepository.TYPE_INCOMING && stockMove.getIsReversion() == true){
|
||||
if (stockMove.getTypeSelect() == StockMoveRepository.TYPE_INCOMING
|
||||
&& stockMove.getIsReversion() == true) {
|
||||
newStockMove.setStockMoveSeq(
|
||||
stockMoveToolService.getSequenceStockMove(StockMoveRepository.TYPE_INCOMING_CLIENT, stockMove.getCompany()));
|
||||
}else if(stockMove.getTypeSelect() == StockMoveRepository.TYPE_OUTGOING && stockMove.getIsReversion() == false && stockMove.getPartner().getId() != 853 ){
|
||||
stockMoveToolService.getSequenceStockMove(
|
||||
StockMoveRepository.TYPE_INCOMING_CLIENT, stockMove.getCompany()));
|
||||
} else if (stockMove.getTypeSelect() == StockMoveRepository.TYPE_OUTGOING
|
||||
&& stockMove.getIsReversion() == false
|
||||
&& stockMove.getPartner().getId() != 853) {
|
||||
newStockMove.setStockMoveSeq(
|
||||
stockMoveToolService.getSequenceStockMove(StockMoveRepository.TYPE_OUTGOING_CLIENT, stockMove.getCompany()));
|
||||
} else if(stockMove.getTypeSelect() == StockMoveRepository.TYPE_OUTGOING && stockMove.getIsReversion() == false && stockMove.getPartner().getId() == 853){
|
||||
newStockMove.setStockMoveSeq(
|
||||
stockMoveToolService.getSequenceStockMove(StockMoveRepository.TYPE_INTERNAL_OUTGOING_CLIENT, stockMove.getCompany()));
|
||||
}else if(stockMove.getTypeSelect() == StockMoveRepository.TYPE_OUTGOING && stockMove.getIsReversion() == true){
|
||||
stockMoveToolService.getSequenceStockMove(
|
||||
StockMoveRepository.TYPE_OUTGOING_CLIENT, stockMove.getCompany()));
|
||||
} else if (stockMove.getTypeSelect() == StockMoveRepository.TYPE_OUTGOING
|
||||
&& stockMove.getIsReversion() == false
|
||||
&& stockMove.getPartner().getId() == 853) {
|
||||
newStockMove.setStockMoveSeq(
|
||||
stockMoveToolService.getSequenceStockMove(StockMoveRepository.TYPE_SUPPLIER_OUTGOING_CLIENT, stockMove.getCompany()));
|
||||
}
|
||||
else{
|
||||
stockMoveToolService.getSequenceStockMove(
|
||||
StockMoveRepository.TYPE_INTERNAL_OUTGOING_CLIENT, stockMove.getCompany()));
|
||||
} else if (stockMove.getTypeSelect() == StockMoveRepository.TYPE_OUTGOING
|
||||
&& stockMove.getIsReversion() == true) {
|
||||
newStockMove.setStockMoveSeq(
|
||||
stockMoveToolService.getSequenceStockMove(
|
||||
stockMove.getTypeSelect(), stockMove.getCompany()));
|
||||
stockMoveToolService.getSequenceStockMove(
|
||||
StockMoveRepository.TYPE_SUPPLIER_OUTGOING_CLIENT, stockMove.getCompany()));
|
||||
} else {
|
||||
newStockMove.setStockMoveSeq(
|
||||
stockMoveToolService.getSequenceStockMove(
|
||||
stockMove.getTypeSelect(), stockMove.getCompany()));
|
||||
}
|
||||
|
||||
newStockMove.setName(
|
||||
stockMoveToolService.computeName(
|
||||
newStockMove,
|
||||
@@ -690,7 +705,6 @@ public class StockMoveServiceImpl implements StockMoveService {
|
||||
}
|
||||
|
||||
newStockMove.setRealDate(null);
|
||||
|
||||
newStockMove.setExTaxTotal(stockMoveToolService.compute(newStockMove));
|
||||
|
||||
plan(newStockMove);
|
||||
@@ -818,8 +832,9 @@ public class StockMoveServiceImpl implements StockMoveService {
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackOn = {Exception.class})
|
||||
public void cancel(StockMove stockMove, CancelReason cancelReason) throws AxelorException {
|
||||
applyCancelReason(stockMove, cancelReason);
|
||||
public void cancel(StockMove stockMove, CancelReason cancelReason, String cancelReasonStr)
|
||||
throws AxelorException {
|
||||
applyCancelReason(stockMove, cancelReason, cancelReasonStr);
|
||||
cancel(stockMove);
|
||||
}
|
||||
|
||||
@@ -848,7 +863,7 @@ public class StockMoveServiceImpl implements StockMoveService {
|
||||
stockMove.getEstimatedDate(),
|
||||
true);
|
||||
|
||||
stockMove.setRealDate(appBaseService.getTodayDate());
|
||||
stockMove.setRealDate(LocalDateTime.now());
|
||||
}
|
||||
|
||||
stockMove.clearPlannedStockMoveLineList();
|
||||
@@ -1256,7 +1271,8 @@ public class StockMoveServiceImpl implements StockMoveService {
|
||||
}
|
||||
|
||||
@Transactional(rollbackOn = {Exception.class})
|
||||
protected void applyCancelReason(StockMove stockMove, CancelReason cancelReason)
|
||||
protected void applyCancelReason(
|
||||
StockMove stockMove, CancelReason cancelReason, String cancelReasonStr)
|
||||
throws AxelorException {
|
||||
if (cancelReason == null) {
|
||||
throw new AxelorException(
|
||||
@@ -1271,6 +1287,7 @@ public class StockMoveServiceImpl implements StockMoveService {
|
||||
I18n.get(IExceptionMessage.CANCEL_REASON_BAD_TYPE));
|
||||
}
|
||||
stockMove.setCancelReason(cancelReason);
|
||||
stockMove.setCancelReasonStr(cancelReasonStr);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1363,7 +1380,6 @@ public class StockMoveServiceImpl implements StockMoveService {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// same move
|
||||
@Override
|
||||
@Transactional(rollbackOn = {Exception.class})
|
||||
@@ -1429,4 +1445,26 @@ public class StockMoveServiceImpl implements StockMoveService {
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public void splitStockMoveLinesSpecial2(
|
||||
StockMove stockMove, List<StockMoveLine> stockMoveLines, BigDecimal splitQty) {
|
||||
LOG.debug("SplitQty: {}", splitQty);
|
||||
LOG.debug("stockMoveLines : {}", stockMoveLines);
|
||||
|
||||
for (StockMoveLine moveLine : stockMoveLines) {
|
||||
LOG.debug("Move line: {}", moveLine);
|
||||
BigDecimal totalQty = moveLine.getQty();
|
||||
totalQty = totalQty.subtract(splitQty);
|
||||
StockMoveLine newLine = stockMoveLineRepo.copy(moveLine, true);
|
||||
newLine.setQty(splitQty);
|
||||
newLine.setRealQty(splitQty);
|
||||
newLine.setWapPrice(moveLine.getWapPrice());
|
||||
newLine.setUnitPriceTaxed(moveLine.getUnitPriceTaxed());
|
||||
newLine.setUnitPriceUntaxed(moveLine.getUnitPriceUntaxed());
|
||||
moveLine.setQty(totalQty);
|
||||
moveLine.setRealQty(totalQty);
|
||||
stockMove.addStockMoveLineListItem(newLine);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -180,6 +180,29 @@ public class StockMoveToolServiceImpl implements StockMoveToolService {
|
||||
return ref;
|
||||
}
|
||||
|
||||
// sequence for production request
|
||||
public String getSequenceStockProductionRequest(int stockProductionRequestType, Company company) throws AxelorException {
|
||||
|
||||
String ref = "";
|
||||
|
||||
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;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return ref;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param clientPartner
|
||||
* @param toAddress
|
||||
|
||||
@@ -0,0 +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;
|
||||
|
||||
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 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,6 +160,15 @@ public class StockRulesServiceImpl implements StockRulesService {
|
||||
Product product, StockLocation stockLocation, int type, int useCase) {
|
||||
|
||||
if (useCase == StockRulesRepository.USE_CASE_USED_FOR_MRP) {
|
||||
if(stockLocation == null){
|
||||
return stockRuleRepo
|
||||
.all()
|
||||
.filter(
|
||||
"self.product = ?1 AND self.useCaseSelect = ?2",
|
||||
product,
|
||||
useCase)
|
||||
.fetchOne();
|
||||
}
|
||||
return stockRuleRepo
|
||||
.all()
|
||||
.filter(
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -110,4 +110,16 @@ public class StockConfigService {
|
||||
}
|
||||
return stockConfig.getPickupDefaultStockLocation();
|
||||
}
|
||||
|
||||
public StockLocation getRawMaterialsDefaultStockLocation(StockConfig stockConfig)
|
||||
throws AxelorException {
|
||||
if (stockConfig.getPickupDefaultStockLocation() == null) {
|
||||
throw new AxelorException(
|
||||
stockConfig,
|
||||
TraceBackRepository.CATEGORY_CONFIGURATION_ERROR,
|
||||
I18n.get(IExceptionMessage.STOCK_CONFIG_PICKUP),
|
||||
stockConfig.getCompany().getName());
|
||||
}
|
||||
return stockConfig.getRawMaterialsDefaultStockLocation();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
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;
|
||||
import com.axelor.apps.stock.db.StockProductionRequest;
|
||||
import com.axelor.apps.stock.exception.IExceptionMessage;
|
||||
import com.axelor.apps.stock.report.IReport;
|
||||
import com.axelor.apps.tool.ModelTool;
|
||||
import com.axelor.apps.tool.ThrowConsumer;
|
||||
import com.axelor.apps.tool.file.PdfTool;
|
||||
import com.axelor.exception.AxelorException;
|
||||
import com.axelor.exception.db.repo.TraceBackRepository;
|
||||
import com.axelor.i18n.I18n;
|
||||
import com.axelor.inject.Beans;
|
||||
|
||||
public class StockProductionRequestPrintService {
|
||||
|
||||
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(
|
||||
StockProductionRequest.class,
|
||||
ids,
|
||||
new ThrowConsumer<StockProductionRequest>() {
|
||||
|
||||
|
||||
public void accept(StockProductionRequest purchaseRequest) throws Exception {
|
||||
printedPurchaseRequests.add(print(purchaseRequest, ReportSettings.FORMAT_PDF));
|
||||
}
|
||||
});
|
||||
String fileName = getPurchaseRequestFilesName(true, ReportSettings.FORMAT_PDF);
|
||||
return PdfTool.mergePdfToFileLink(printedPurchaseRequests, fileName);
|
||||
}
|
||||
|
||||
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 {
|
||||
if (stockProductionRequest.getPrintingSettings() == null) {
|
||||
throw new AxelorException(
|
||||
TraceBackRepository.CATEGORY_MISSING_FIELD,
|
||||
String.format(
|
||||
I18n.get(IExceptionMessage.STOCK_MOVE_MISSING_TEMPLATE),
|
||||
stockProductionRequest.getStockProductionRequestSeq()),
|
||||
stockProductionRequest);
|
||||
}
|
||||
String locale = ReportSettings.getPrintingLocale(null);
|
||||
String title = getFileName(stockProductionRequest);
|
||||
ReportSettings reportSetting =
|
||||
ReportFactory.createReport(IReport.STOCK_PRODUCTION_REQUEST, title + " - ${date}");
|
||||
|
||||
|
||||
return reportSetting
|
||||
.addParam("StockProductionRequestId", stockProductionRequest.getId())
|
||||
.addParam("Locale", locale)
|
||||
.addParam("HeaderHeight", stockProductionRequest.getPrintingSettings().getPdfHeaderHeight())
|
||||
.addParam("FooterHeight", stockProductionRequest.getPrintingSettings().getPdfFooterHeight())
|
||||
.addFormat(formatPdf);
|
||||
}
|
||||
|
||||
protected String getPurchaseRequestFilesName(boolean plural, String formatPdf) {
|
||||
return I18n.get(plural ? "Stock production requests" : "Stock production request")
|
||||
+ " - "
|
||||
+ Beans.get(AppBaseService.class).getTodayDate().format(DateTimeFormatter.BASIC_ISO_DATE)
|
||||
+ "."
|
||||
+ formatPdf;
|
||||
}
|
||||
|
||||
public String getFileName(StockProductionRequest StockProductionRequest) {
|
||||
return I18n.get("Stock production request")
|
||||
+ " "
|
||||
+ StockProductionRequest.getStockProductionRequestSeq();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,18 +17,47 @@
|
||||
*/
|
||||
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;
|
||||
|
||||
@Singleton
|
||||
public class InventoryLineController {
|
||||
|
||||
@Inject
|
||||
private ProductRepository productRepository;
|
||||
private TrackingNumberRepository trackingNumberRepository;
|
||||
private InventoryLineRepository inventoryLineRepository;
|
||||
private InventoryRepository inventoryRepository;
|
||||
|
||||
private Product mProduct;
|
||||
|
||||
public void updateInventoryLine(ActionRequest request, ActionResponse response)
|
||||
throws AxelorException {
|
||||
|
||||
@@ -52,4 +81,136 @@ public class InventoryLineController {
|
||||
inventoryLine = Beans.get(InventoryLineService.class).compute(inventoryLine, inventory);
|
||||
response.setValues(inventoryLine);
|
||||
}
|
||||
|
||||
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();
|
||||
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();
|
||||
}
|
||||
response.setValue("product", mProduct);
|
||||
response.setValue("unit", mProduct.getUnit());
|
||||
response.setValue("currentQty", currentQty);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void setFromParameter(ActionRequest request,ActionResponse response) {
|
||||
|
||||
InventoryLine inventoryLine = request.getContext().asType(InventoryLine.class);
|
||||
|
||||
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());
|
||||
|
||||
Product product = Beans.get(ProductRepository.class).find(id);
|
||||
|
||||
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();
|
||||
|
||||
Product product = productRepository.findByCode(code);
|
||||
|
||||
|
||||
if(product != null){
|
||||
response.setValue("product", product);
|
||||
response.setValue("unit", product.getUnit());
|
||||
response.setValue("inventory", inventory);
|
||||
// response.setView(
|
||||
// ActionView.define("Inventory lines")
|
||||
// .model(InventoryLine.class.getName())
|
||||
// .add("form", "inventory-reports-wizard-form2")
|
||||
// .param("show-toolbar", "false")
|
||||
// .param("show-confirm", "false")
|
||||
// .param("popup-save", "false")
|
||||
// .param("show-toolbar","false")
|
||||
// .param("popup", "true")
|
||||
// .param("forceEdit", "true")
|
||||
// .context("_product", product)
|
||||
// .context("_unit", product.getUnit())
|
||||
// .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();
|
||||
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"));
|
||||
|
||||
// Inventory inventory = Beans.get(InventoryRepository.class).find(stockLocationId);
|
||||
// TrackingNumber trackingNumber = Beans.get(TrackingNumberRepository.class).find(trackingNumberId);
|
||||
|
||||
|
||||
System.out.println(inventory.toString());
|
||||
System.out.println(trackingNumber);
|
||||
System.out.println(product.toString());
|
||||
|
||||
// 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"));
|
||||
}
|
||||
|
||||
|
||||
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,15 +17,23 @@
|
||||
*/
|
||||
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;
|
||||
import com.axelor.exception.AxelorException;
|
||||
import com.axelor.exception.service.TraceBackService;
|
||||
import com.axelor.inject.Beans;
|
||||
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 java.io.IOException;
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
|
||||
@@ -82,4 +90,103 @@ public class StockHistoryController {
|
||||
TraceBackService.trace(response, e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Called from stock history form view, on new and on date change. Call {@link
|
||||
* StockHistoryService#computeStockHistoryLineList(Long, Long, Long, LocalDate, LocalDate)}
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
*/
|
||||
public void fillStockHistoryLineListPerDate(ActionRequest request, ActionResponse response) {
|
||||
try {
|
||||
Context context = request.getContext();
|
||||
Long productId = null;
|
||||
if (context.get("product") != null) {
|
||||
productId = Long.parseLong(((LinkedHashMap) context.get("product")).get("id").toString());
|
||||
}
|
||||
Long companyId = null;
|
||||
if (context.get("company") != null) {
|
||||
companyId = Long.parseLong(((LinkedHashMap) context.get("company")).get("id").toString());
|
||||
}
|
||||
Long stockLocationId = null;
|
||||
if (context.get("stockLocation") != null) {
|
||||
stockLocationId =
|
||||
Long.parseLong(((LinkedHashMap) context.get("stockLocation")).get("id").toString());
|
||||
}
|
||||
|
||||
Object beginDateContext = context.get("beginDate");
|
||||
|
||||
LocalDate beginDate = null;
|
||||
if (beginDateContext != null) {
|
||||
beginDate = LocalDate.parse(beginDateContext.toString());
|
||||
}
|
||||
|
||||
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 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);
|
||||
System.out.println(request.getContext().get("familleProduit"));
|
||||
System.out.println("**************searchTypeSelect**********************");
|
||||
|
||||
LocalDate endDate = LocalDate.now();
|
||||
|
||||
List<StockHistoryLine> stockHistoryLineList = new ArrayList<>();
|
||||
// if (
|
||||
// productId != null
|
||||
// && companyId != null
|
||||
// && stockLocationId != null
|
||||
// && beginDate != null
|
||||
// ) {
|
||||
stockHistoryLineList =
|
||||
Beans.get(StockHistoryService.class)
|
||||
.compuHistoryLinesPerDate(
|
||||
productId, companyId, stockLocationId, beginDate, endDate,categoryId, trackingNumberId,searchTypeSelect);
|
||||
// }
|
||||
|
||||
|
||||
response.setValue("$stockHistoryLineList", stockHistoryLineList);
|
||||
|
||||
} catch (Exception e) {
|
||||
TraceBackService.trace(response, e);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static void exportStockHistoryLines(ActionRequest request, ActionResponse response) throws AxelorException, IOException {
|
||||
|
||||
Context context = request.getContext();
|
||||
|
||||
List<HashMap<String, Object>> stockHistoryLineList = new ArrayList<>();
|
||||
|
||||
if (context.get("stockHistoryLineList") != null) {
|
||||
stockHistoryLineList = (List<HashMap<String, Object>>) context.get("stockHistoryLineList");
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ package com.axelor.apps.stock.web;
|
||||
import com.axelor.apps.base.db.PrintingSettings;
|
||||
import com.axelor.apps.base.db.Product;
|
||||
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;
|
||||
@@ -33,6 +34,7 @@ import com.axelor.apps.stock.service.stockmove.print.PickingStockMovePrintServic
|
||||
import com.axelor.apps.stock.service.stockmove.print.StockMovePrintService;
|
||||
import com.axelor.apps.tool.StringTool;
|
||||
import com.axelor.common.ObjectUtils;
|
||||
import com.axelor.db.JPA;
|
||||
import com.axelor.db.mapper.Mapper;
|
||||
import com.axelor.exception.AxelorException;
|
||||
import com.axelor.exception.db.repo.TraceBackRepository;
|
||||
@@ -55,11 +57,9 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.persistence.Query;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import com.axelor.db.JPA;
|
||||
import javax.persistence.Query;
|
||||
import com.axelor.apps.base.service.app.AppBaseService;
|
||||
|
||||
@Singleton
|
||||
public class StockMoveController {
|
||||
@@ -139,7 +139,8 @@ public class StockMoveController {
|
||||
Beans.get(StockMoveService.class)
|
||||
.cancel(
|
||||
Beans.get(StockMoveRepository.class).find(stockMove.getId()),
|
||||
stockMove.getCancelReason());
|
||||
stockMove.getCancelReason(),
|
||||
stockMove.getCancelReasonStr());
|
||||
response.setCanClose(true);
|
||||
} catch (Exception e) {
|
||||
TraceBackService.trace(response, e);
|
||||
@@ -354,6 +355,46 @@ public class StockMoveController {
|
||||
}
|
||||
}
|
||||
|
||||
// sophal
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
public void splitStockMoveLinesSpecial2(ActionRequest request, ActionResponse response) {
|
||||
try {
|
||||
List<HashMap> selectedStockMoveLineMapList =
|
||||
(List<HashMap>) request.getContext().get("stockMoveLineList");
|
||||
Map stockMoveMap = (Map<String, Object>) request.getContext().get("stockMove");
|
||||
if (selectedStockMoveLineMapList == null) {
|
||||
response.setFlash(I18n.get(IExceptionMessage.STOCK_MOVE_14));
|
||||
return;
|
||||
}
|
||||
|
||||
List<StockMoveLine> stockMoveLineList = new ArrayList<>();
|
||||
StockMoveLineRepository stockMoveLineRepo = Beans.get(StockMoveLineRepository.class);
|
||||
for (HashMap map : selectedStockMoveLineMapList) {
|
||||
StockMoveLine stockMoveLine = (StockMoveLine) Mapper.toBean(StockMoveLine.class, map);
|
||||
stockMoveLineList.add(stockMoveLineRepo.find(stockMoveLine.getId()));
|
||||
}
|
||||
|
||||
if (stockMoveLineList.isEmpty()) {
|
||||
response.setFlash(I18n.get(IExceptionMessage.STOCK_MOVE_15));
|
||||
return;
|
||||
}
|
||||
|
||||
BigDecimal splitQty = new BigDecimal(request.getContext().get("splitQty").toString());
|
||||
if (splitQty == null || splitQty.compareTo(BigDecimal.ZERO) < 1) {
|
||||
response.setFlash(I18n.get(IExceptionMessage.STOCK_MOVE_16));
|
||||
return;
|
||||
}
|
||||
|
||||
StockMove stockMove = Mapper.toBean(StockMove.class, stockMoveMap);
|
||||
stockMove = Beans.get(StockMoveRepository.class).find(stockMove.getId());
|
||||
Beans.get(StockMoveService.class)
|
||||
.splitStockMoveLinesSpecial2(stockMove, stockMoveLineList, splitQty);
|
||||
response.setCanClose(true);
|
||||
} catch (Exception e) {
|
||||
TraceBackService.trace(response, e);
|
||||
}
|
||||
}
|
||||
|
||||
public void shipReciveAllProducts(ActionRequest request, ActionResponse response) {
|
||||
StockMove stockMove = request.getContext().asType(StockMove.class);
|
||||
Beans.get(StockMoveService.class)
|
||||
@@ -413,14 +454,14 @@ public class StockMoveController {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void splitInto2Same(ActionRequest request, ActionResponse response) {
|
||||
StockMove stockMove = request.getContext().asType(StockMove.class);
|
||||
List<StockMoveLine> modifiedStockMoveLineList = stockMove.getStockMoveLineList();
|
||||
stockMove = Beans.get(StockMoveRepository.class).find(stockMove.getId());
|
||||
try {
|
||||
StockMove newStockMove =
|
||||
Beans.get(StockMoveService.class).splitInto2SameMove(stockMove, modifiedStockMoveLineList);
|
||||
Beans.get(StockMoveService.class)
|
||||
.splitInto2SameMove(stockMove, modifiedStockMoveLineList);
|
||||
|
||||
if (newStockMove == null) {
|
||||
response.setFlash(I18n.get(IExceptionMessage.STOCK_MOVE_SPLIT_NOT_GENERATED));
|
||||
@@ -579,104 +620,102 @@ public class StockMoveController {
|
||||
TraceBackService.trace(response, e);
|
||||
}
|
||||
}
|
||||
|
||||
//sortie de stock
|
||||
public void getSequenceOutStock(ActionRequest request, ActionResponse response) {
|
||||
Context context = request.getContext();
|
||||
if(context.get("stockMoveSeq") == null){
|
||||
|
||||
// sortie de stock
|
||||
public void getSequenceOutStock(ActionRequest request, ActionResponse response) {
|
||||
Context context = request.getContext();
|
||||
if (context.get("stockMoveSeq") == null) {
|
||||
String num;
|
||||
int currentYear = Beans.get(AppBaseService.class).getTodayDateTime().getYear();
|
||||
String[] splityear = Integer.toString(currentYear).split("20");
|
||||
String year = splityear[1];
|
||||
year ="SR"+year;
|
||||
year = "SR" + year;
|
||||
Query q =
|
||||
JPA.em()
|
||||
.createQuery(
|
||||
" select stockMoveSeq from StockMove where stockMoveSeq like ?1 ORDER BY stockMoveSeq DESC",
|
||||
String.class);
|
||||
q.setParameter(1, year + "%" );
|
||||
|
||||
if (q.getResultList().size() == 0) {
|
||||
response.setValue("stockMoveSeq", year+"00001");
|
||||
} else {
|
||||
String result = (String) q.getResultList().get(0);
|
||||
String arr[] = result.split(year);
|
||||
String nbrString = arr[1];
|
||||
int nbrInt = Integer.parseInt(nbrString);
|
||||
nbrInt = nbrInt + 1;
|
||||
num = Integer.toString(nbrInt);
|
||||
String padding = "00000".substring(num.length()) + num;
|
||||
result = year + padding;
|
||||
response.setValue("stockMoveSeq", result);
|
||||
}
|
||||
}
|
||||
JPA.em()
|
||||
.createQuery(
|
||||
" select stockMoveSeq from StockMove where stockMoveSeq like ?1 ORDER BY stockMoveSeq DESC",
|
||||
String.class);
|
||||
q.setParameter(1, year + "%");
|
||||
|
||||
if (q.getResultList().size() == 0) {
|
||||
response.setValue("stockMoveSeq", year + "00001");
|
||||
} else {
|
||||
String result = (String) q.getResultList().get(0);
|
||||
String arr[] = result.split(year);
|
||||
String nbrString = arr[1];
|
||||
int nbrInt = Integer.parseInt(nbrString);
|
||||
nbrInt = nbrInt + 1;
|
||||
num = Integer.toString(nbrInt);
|
||||
String padding = "00000".substring(num.length()) + num;
|
||||
result = year + padding;
|
||||
response.setValue("stockMoveSeq", result);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// controler les sequences pour les livraisons client => bloc si ne sont pas séquentielle
|
||||
public void controleSequenceBL(ActionRequest request, ActionResponse response) throws AxelorException {
|
||||
|
||||
StockMove stockMove = request.getContext().asType(StockMove.class);
|
||||
|
||||
}
|
||||
|
||||
if(stockMove.getTypeSelect() == StockMoveRepository.TYPE_OUTGOING &&
|
||||
stockMove.getIsReversion() == false && stockMove.getPartner().getId() != 853){
|
||||
// controler les sequences pour les livraisons client => bloc si ne sont pas séquentielle
|
||||
public void controleSequenceBL(ActionRequest request, ActionResponse response)
|
||||
throws AxelorException {
|
||||
|
||||
int currentYear = Beans.get(AppBaseService.class).getTodayDateTime().getYear();
|
||||
String[] splityear = Integer.toString(currentYear).split("20");
|
||||
String year ="BL"+splityear[1];
|
||||
Query q =
|
||||
JPA.em()
|
||||
.createQuery(
|
||||
" select stockMoveSeq from StockMove where stockMoveSeq like ?1 and stockMoveSeq != ?2"+
|
||||
" and LENGTH(stock_move_seq) = 9 and partner != 853 and is_reversion = false "+
|
||||
" ORDER BY stockMoveSeq DESC",
|
||||
String.class);
|
||||
q.setParameter(1, year + "%" );
|
||||
q.setParameter(2, stockMove.getStockMoveSeq());
|
||||
|
||||
StockMove stockMove = request.getContext().asType(StockMove.class);
|
||||
|
||||
if (q.getResultList().size() > 0) {
|
||||
List<String> squences = q.getResultList();
|
||||
String maxNumberString = squences.get(0);
|
||||
String[] a = maxNumberString.split(year);
|
||||
Integer maxNumber = Integer.parseInt(a[1]);
|
||||
|
||||
String originNumberString = stockMove.getStockMoveSeq();
|
||||
String[] b = originNumberString.split(year);
|
||||
Integer originNumber = Integer.parseInt(b[1]);
|
||||
if (stockMove.getTypeSelect() == StockMoveRepository.TYPE_OUTGOING
|
||||
&& stockMove.getIsReversion() == false
|
||||
&& stockMove.getPartner().getId() != 853) {
|
||||
|
||||
int currentYear = Beans.get(AppBaseService.class).getTodayDateTime().getYear();
|
||||
String[] splityear = Integer.toString(currentYear).split("20");
|
||||
String year = "BL" + splityear[1];
|
||||
Query q =
|
||||
JPA.em()
|
||||
.createQuery(
|
||||
" select stockMoveSeq from StockMove where stockMoveSeq like ?1 and stockMoveSeq != ?2"
|
||||
+ " and LENGTH(stock_move_seq) = 9 and partner != 853 and is_reversion = false "
|
||||
+ " ORDER BY stockMoveSeq DESC",
|
||||
String.class);
|
||||
q.setParameter(1, year + "%");
|
||||
q.setParameter(2, stockMove.getStockMoveSeq());
|
||||
|
||||
Integer nextNumber = maxNumber+1;
|
||||
String padding = "00000".substring(nextNumber.toString().length()) + nextNumber.toString();
|
||||
if(nextNumber != originNumber && originNumber > nextNumber){
|
||||
throw new AxelorException(
|
||||
if (q.getResultList().size() > 0) {
|
||||
List<String> squences = q.getResultList();
|
||||
String maxNumberString = squences.get(0);
|
||||
String[] a = maxNumberString.split(year);
|
||||
Integer maxNumber = Integer.parseInt(a[1]);
|
||||
|
||||
String originNumberString = stockMove.getStockMoveSeq();
|
||||
String[] b = originNumberString.split(year);
|
||||
Integer originNumber = Integer.parseInt(b[1]);
|
||||
|
||||
Integer nextNumber = maxNumber + 1;
|
||||
String padding = "00000".substring(nextNumber.toString().length()) + nextNumber.toString();
|
||||
if (nextNumber != originNumber && originNumber > nextNumber) {
|
||||
throw new AxelorException(
|
||||
stockMove,
|
||||
TraceBackRepository.CATEGORY_CONFIGURATION_ERROR,
|
||||
"please correct current sequence to: "+year+padding
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void checkIfAlreadyFactory(ActionRequest request, ActionResponse response) throws AxelorException {
|
||||
"please correct current sequence to: " + year + padding);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
StockMove stockMoveFromRequest = request.getContext().asType(StockMove.class);
|
||||
public void checkIfAlreadyFactory(ActionRequest request, ActionResponse response)
|
||||
throws AxelorException {
|
||||
|
||||
StockMove stockMove = Beans.get(StockMoveRepository.class).find(stockMoveFromRequest.getId());
|
||||
Query sql =
|
||||
StockMove stockMoveFromRequest = request.getContext().asType(StockMove.class);
|
||||
|
||||
StockMove stockMove = Beans.get(StockMoveRepository.class).find(stockMoveFromRequest.getId());
|
||||
Query sql =
|
||||
JPA.em()
|
||||
.createNativeQuery(
|
||||
"SELECT "
|
||||
+ " FROM account_invoice_stock_move_set"
|
||||
+ " FROM account_invoice_stock_move_set"
|
||||
+ " WHERE stock_move_set = :objectName");
|
||||
sql.setParameter("objectName", stockMove);
|
||||
if(sql.getResultList().size() > 0 ){
|
||||
throw new AxelorException(
|
||||
stockMove,
|
||||
TraceBackRepository.CATEGORY_CONFIGURATION_ERROR,
|
||||
"vous avez deja facture cette Piece");
|
||||
}
|
||||
sql.setParameter("objectName", stockMove);
|
||||
if (sql.getResultList().size() > 0) {
|
||||
throw new AxelorException(
|
||||
stockMove,
|
||||
TraceBackRepository.CATEGORY_CONFIGURATION_ERROR,
|
||||
"vous avez deja une facture sur cette Piece");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,164 @@
|
||||
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;
|
||||
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.schema.actions.ActionView;
|
||||
import com.axelor.rpc.ActionRequest;
|
||||
import com.axelor.rpc.ActionResponse;
|
||||
import com.axelor.rpc.Context;
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
try {
|
||||
if (!ObjectUtils.isEmpty(request.getContext().get("_ids"))) {
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
List<Long> ids =
|
||||
Lists.transform(
|
||||
(List) request.getContext().get("_ids"),
|
||||
new Function<Object, Long>() {
|
||||
@Nullable
|
||||
@Override
|
||||
public Long apply(@Nullable Object input) {
|
||||
return Long.parseLong(input.toString());
|
||||
}
|
||||
});
|
||||
fileLink = productionRequestPrintService.printStockProductionRequests(ids);
|
||||
title = I18n.get("Purchase requests");
|
||||
} else if (context.get("id") != null) {
|
||||
StockProductionRequest productionRequest = request.getContext().asType(StockProductionRequest.class);
|
||||
title = productionRequestPrintService.getFileName(productionRequest);
|
||||
fileLink =
|
||||
productionRequestPrintService.printStockProductionRequest(
|
||||
productionRequest, ReportSettings.FORMAT_PDF);
|
||||
logger.debug("Printing " + title);
|
||||
} else {
|
||||
throw new AxelorException(
|
||||
TraceBackRepository.CATEGORY_MISSING_FIELD,
|
||||
I18n.get(IExceptionMessage.INVENTORY_3_DATA_NULL_OR_EMPTY));
|
||||
}
|
||||
response.setView(ActionView.define(title).add("html", fileLink).map());
|
||||
} catch (Exception e) {
|
||||
TraceBackService.trace(response, e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void createStockMove(ActionRequest request, ActionResponse response) {
|
||||
|
||||
StockProductionRequest productionRequest = request.getContext().asType(StockProductionRequest.class);
|
||||
|
||||
try {
|
||||
if (productionRequest.getId() != null) {
|
||||
|
||||
StockProductionRequestService productionRequestService = Beans.get(StockProductionRequestService.class);
|
||||
|
||||
List<Long> stockMoveList =
|
||||
productionRequestService.createStocksMovesFromStockProductionRequest(
|
||||
Beans.get(StockProductionRequestRepository.class).find(productionRequest.getId()));
|
||||
|
||||
if (stockMoveList != null && stockMoveList.size() == 1) {
|
||||
response.setView(
|
||||
ActionView.define(I18n.get("Stock move"))
|
||||
.model(StockMove.class.getName())
|
||||
.add("form", "stock-move-form")
|
||||
.add("grid", "stock-move-grid")
|
||||
.param("forceEdit", "true")
|
||||
.domain("self.id = " + stockMoveList.get(0))
|
||||
.context("_showRecord", String.valueOf(stockMoveList.get(0)))
|
||||
.context("_userType", StockMoveRepository.USER_TYPE_SENDER)
|
||||
.map());
|
||||
} else if (stockMoveList != null && stockMoveList.size() > 1) {
|
||||
response.setView(
|
||||
ActionView.define(I18n.get("Stock move"))
|
||||
.model(StockMove.class.getName())
|
||||
.add("grid", "stock-move-grid")
|
||||
.add("form", "stock-move-form")
|
||||
.domain("self.id in (" + Joiner.on(",").join(stockMoveList) + ")")
|
||||
.context("_userType", StockMoveRepository.USER_TYPE_SENDER)
|
||||
.map());
|
||||
} else {
|
||||
response.setFlash(I18n.get(IExceptionMessage.STOCK_MOVE_4));
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
TraceBackService.trace(response, e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
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;
|
||||
import com.axelor.exception.ResponseMessageType;
|
||||
import com.axelor.exception.service.TraceBackService;
|
||||
import com.axelor.inject.Beans;
|
||||
import com.axelor.rpc.ActionRequest;
|
||||
import com.axelor.rpc.ActionResponse;
|
||||
import com.axelor.rpc.Context;
|
||||
|
||||
public class StockProductionRequestLineController {
|
||||
|
||||
|
||||
public void setProductInfo(ActionRequest request, ActionResponse response) {
|
||||
|
||||
StockProductionRequestLine productionRequestLine;
|
||||
|
||||
try {
|
||||
productionRequestLine = request.getContext().asType(StockProductionRequestLine.class);
|
||||
StockProductionRequest productionRequest = productionRequestLine.getStockProductionRequest();
|
||||
|
||||
if (productionRequest == null) {
|
||||
productionRequest = request.getContext().getParent().asType(StockProductionRequest.class);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,254 @@
|
||||
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;
|
||||
import com.axelor.apps.stock.db.StockProductionRequest;
|
||||
import com.axelor.apps.stock.db.StockProductionRequestLine;
|
||||
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.db.repo.StockProductionRequestLineRepository;
|
||||
import com.axelor.apps.stock.db.repo.StockProductionRequestRepository;
|
||||
import com.axelor.apps.stock.service.StockMoveLineService;
|
||||
import com.axelor.apps.stock.service.StockMoveService;
|
||||
import com.axelor.apps.stock.service.StockMoveToolService;
|
||||
import com.axelor.apps.stock.service.StockMoveToolServiceImpl;
|
||||
import com.axelor.apps.stock.service.config.StockConfigService;
|
||||
import com.axelor.exception.AxelorException;
|
||||
import com.axelor.inject.Beans;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.persist.Transactional;
|
||||
|
||||
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;
|
||||
|
||||
|
||||
|
||||
private static final Logger logger =
|
||||
LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
|
||||
|
||||
@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;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@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);
|
||||
}
|
||||
|
||||
|
||||
@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(
|
||||
stockConfigService.getStockConfig(company));
|
||||
|
||||
StockMove stockMove =
|
||||
stockMoveService.createStockMove(
|
||||
null,
|
||||
null,
|
||||
company,
|
||||
stockProductionRequest.getPartner(),
|
||||
fromStockLocation,
|
||||
toStockLocation,
|
||||
null,
|
||||
estimatedDeliveryDate,
|
||||
stockProductionRequest.getNote(),
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
StockMoveRepository.TYPE_OUTGOING);
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
BigDecimal priceDiscounted = productionRequestLine.getUnitPriceTaxed();
|
||||
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;
|
||||
|
||||
}
|
||||
if (productionRequestLine.getDeliveryState() == 0) {
|
||||
productionRequestLine.setDeliveryState(StockProductionRequestLineRepository.DELIVERY_STATE_NOT_DELIVERED);
|
||||
}
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public boolean isStockMoveProduct(StockProductionRequestLine productionRequestLine) throws AxelorException {
|
||||
return isStockMoveProduct(productionRequestLine, productionRequestLine.getStockProductionRequest());
|
||||
}
|
||||
|
||||
public boolean isStockMoveProduct(StockProductionRequestLine productionRequestLine, StockProductionRequest productionRequest)
|
||||
throws AxelorException {
|
||||
|
||||
Product product = productionRequestLine.getProduct();
|
||||
return (product != null && (product.getProductTypeSelect().equals(ProductRepository.PRODUCT_TYPE_STORABLE)));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -7,5 +7,7 @@
|
||||
<entity name="ImportationFolder" lang="java">
|
||||
<many-to-one name="shipmentMode" ref="com.axelor.apps.stock.db.ShipmentMode"/>
|
||||
<many-to-one name="freightCarrierMode" ref="com.axelor.apps.stock.db.FreightCarrierMode"/>
|
||||
<one-to-many name="stockMoveLineList" ref="com.axelor.apps.stock.db.StockMoveLine"/>
|
||||
<one-to-many name="importationFolderCostPriceList" ref="com.axelor.apps.stock.db.ImportationFolderCostPrice" mappedBy="importationFolder"/>
|
||||
</entity>
|
||||
</domain-models>
|
||||
</domain-models>
|
||||
@@ -0,0 +1,22 @@
|
||||
<?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="purchase" package="com.axelor.apps.stock.db"/>
|
||||
|
||||
<entity name="ImportationFolderCostPrice" lang="java">
|
||||
<many-to-one name="stockMoveLine" ref="com.axelor.apps.stock.db.StockMoveLine"/>
|
||||
<many-to-one name="product" ref="com.axelor.apps.base.db.Product"/>
|
||||
<many-to-one name="importationFolder" ref="com.axelor.apps.purchase.db.ImportationFolder"/>
|
||||
<integer name="valorisation" title="Valorisation Type" selection="importation.folder.valorisation.type.select" />
|
||||
<integer name="statusSelect" selection="purchase.importation.folder.valotisation.status.select" readonly="true" default="1" />
|
||||
<decimal name="costPrice" title="Cost price" precision="20" scale="10"/>
|
||||
<decimal name="percent" title="Percent"/>
|
||||
<decimal name="freightSplit" title="freightSplit"/>
|
||||
<decimal name="totalApproach" title="Total approach"/>
|
||||
<decimal name="totalInvoice" title="Total invoice"/>
|
||||
<date name="validationDate" title="Validation date" />
|
||||
<many-to-one name="printingSettings" ref="com.axelor.apps.base.db.PrintingSettings"/>
|
||||
|
||||
</entity>
|
||||
</domain-models>
|
||||
@@ -0,0 +1,31 @@
|
||||
<?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="InternalTrackingNumber" lang="java">
|
||||
|
||||
<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"/>
|
||||
<date name="fabricationDate" title="Fabrication date"/>
|
||||
<date name="warrantyExpirationDate" title="Warranty expiration date" readonly="true"/>
|
||||
<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"/>
|
||||
|
||||
<finder-method name="findBySeq" using="trackingNumberSeq"/>
|
||||
|
||||
|
||||
<track>
|
||||
<field name="perishableExpirationDate"/>
|
||||
<field name="product"/>
|
||||
<field name="trackingNumberSeq" />
|
||||
</track>
|
||||
|
||||
</entity>
|
||||
|
||||
</domain-models>
|
||||
@@ -17,5 +17,26 @@
|
||||
<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"/>
|
||||
|
||||
<decimal name="firstCounting" title="First counting" nullable="true"/>
|
||||
<decimal name="secondCounting" title="Second counting" nullable="true"/>
|
||||
<decimal name="controlCounting" title="Control 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="controlCountingByUser" ref="com.axelor.auth.db.User" readonly="true" title="Control counting by"/>
|
||||
|
||||
|
||||
<datetime name="firstCountingDate" readonly="true" title="First counting date"/>
|
||||
<datetime name="secondCountingDate" readonly="true" title="Second counting date"/>
|
||||
<datetime name="controlCountingDate" readonly="true" title="Control counting date"/>
|
||||
|
||||
<string name="productHolder" title="Product Holder" />
|
||||
<boolean name="justifiedGap" title="Justified gap"/>
|
||||
<boolean name="isVentilated" title="Is ventilated"/>
|
||||
|
||||
|
||||
</entity>
|
||||
</domain-models>
|
||||
|
||||
@@ -9,5 +9,4 @@
|
||||
<many-to-one name="shipmentMode" ref="com.axelor.apps.stock.db.ShipmentMode"/>
|
||||
<many-to-one name="freightCarrierMode" ref="com.axelor.apps.stock.db.FreightCarrierMode"/>
|
||||
</entity>
|
||||
</domain-models>
|
||||
|
||||
</domain-models>
|
||||
@@ -12,6 +12,7 @@
|
||||
<many-to-one name="receiptDefaultStockLocation" ref="com.axelor.apps.stock.db.StockLocation" title="Receipt default stock location"/>
|
||||
<many-to-one name="pickupDefaultStockLocation" ref="com.axelor.apps.stock.db.StockLocation" title="Pickup default stock location"/>
|
||||
<many-to-one name="qualityControlDefaultStockLocation" ref="com.axelor.apps.stock.db.StockLocation" title="Quality control default stock location"/>
|
||||
<many-to-one name="rawMaterialsDefaultStockLocation" ref="com.axelor.apps.stock.db.StockLocation" title="Raw materials default stock location"/>
|
||||
|
||||
<many-to-one name="customerVirtualStockLocation" ref="com.axelor.apps.stock.db.StockLocation" title="Customer virtual stock location"/>
|
||||
<many-to-one name="supplierVirtualStockLocation" ref="com.axelor.apps.stock.db.StockLocation" title="Supplier virtual stock location"/>
|
||||
|
||||
@@ -6,12 +6,30 @@
|
||||
<module name="stock" package="com.axelor.apps.stock.db"/>
|
||||
|
||||
<entity name="StockHistoryLine" persistable="false">
|
||||
<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="Tracking number"/>
|
||||
<many-to-one name="parentStockLocation" ref="com.axelor.apps.stock.db.StockLocation" title="Parent stock location"/>
|
||||
<integer name="countIncMvtStockPeriod" readonly="true" title="Nbr of incoming moves"/>
|
||||
<decimal name="sumIncQtyPeriod" readonly="true" title="Incoming quantity"/>
|
||||
<decimal name="priceIncStockMovePeriod" readonly="true" title="Incoming amount"/>
|
||||
<integer name="countOutMvtStockPeriod" readonly="true" title="Nbr of outgoing moves"/>
|
||||
<decimal name="sumOutQtyPeriod" readonly="true" title="Outgoing quantity"/>
|
||||
<decimal name="priceOutStockMovePeriod" readonly="true" title="Outgoing amount"/>
|
||||
<decimal name="realQty" readonly="true" title="Real qty"/>
|
||||
<string name="label" readonly="true"/>
|
||||
<integer name="searchTypeSelect" title="Product Search Type" selection="product.search.type.select" default="0" />
|
||||
|
||||
|
||||
<extra-code><![CDATA[
|
||||
|
||||
// OPERATION TYPE SELECT
|
||||
public static final int OPERATION_TYPE_ALL = 1;
|
||||
public static final int OPERATION_TYPE_STOCK_LOCATION = 2;
|
||||
public static final int OPERATION_TYPE_CATEGORY_PRODUCT = 3;
|
||||
public static final int OPERATION_TYPE_SUB_CATEGORY_PRODUCT = 4;
|
||||
|
||||
]]></extra-code>
|
||||
|
||||
|
||||
</entity>
|
||||
</domain-models>
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
<many-to-one name="address" ref="com.axelor.apps.base.db.Address" title="Address" />
|
||||
<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"/>
|
||||
|
||||
<finder-method name="findByCompany" using="company"/>
|
||||
<finder-method name="findByPartner" using="partner"/>
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<many-to-one name="toStockLocation" ref="com.axelor.apps.stock.db.StockLocation" required="true" title="To stock location"/>
|
||||
|
||||
<date name="estimatedDate" title="Estimated date"/>
|
||||
<date name="realDate" title="Move date" readonly="true"/>
|
||||
<datetime name="realDate" title="Move date" readonly="true"/>
|
||||
|
||||
<date name="supplierShipmentDate" title="Supplier Shipment Date"/>
|
||||
<string name="supplierShipmentRef" title="Supplier Shipment Ref"/>
|
||||
@@ -34,6 +34,7 @@
|
||||
<many-to-one name="payerPartner" ref="com.axelor.apps.base.db.Partner" title="Payer Supplier"/>
|
||||
<many-to-one name="deliveryPartner" ref="com.axelor.apps.base.db.Partner" title="Delivery Supplier"/>
|
||||
|
||||
<many-to-one name="manufacturer" ref="com.axelor.apps.base.db.Partner" title="Manufacturer"/>
|
||||
|
||||
<one-to-many name="stockMoveLineList" ref="com.axelor.apps.stock.db.StockMoveLine" mappedBy="stockMove" orderBy="sequence" title="Stock move content"/>
|
||||
<one-to-many name="plannedStockMoveLineList" ref="com.axelor.apps.stock.db.StockMoveLine" mappedBy="plannedStockMove" orderBy="sequence"/>
|
||||
@@ -60,6 +61,7 @@
|
||||
<boolean name="fullySpreadOverLogisticalFormsFlag" default="false" title="Fully spread over logistical forms" />
|
||||
|
||||
<many-to-one name="cancelReason" title="Cancel reason" ref="com.axelor.apps.base.db.CancelReason"/>
|
||||
<string name="cancelReasonStr" large="true" title="Cancel Reason str"/>
|
||||
<boolean name="plannedStockMoveAutomaticMail" title="Send email when planning stock move" default="false"/>
|
||||
<many-to-one name="plannedStockMoveMessageTemplate" title="Message template" ref="com.axelor.apps.message.db.Template"/>
|
||||
<boolean name="realStockMoveAutomaticMail" title="Send email on stock move realization" default="false"/>
|
||||
@@ -100,6 +102,8 @@
|
||||
<decimal name="stamp" title="stamp" scale="2" precision="20" />
|
||||
<decimal name="fixTax" title="fix Tax" scale="2" precision="20" />
|
||||
|
||||
<boolean name="isVentilated" title="Is Ventilated" default="false"/>
|
||||
|
||||
<unique-constraint columns="stockMoveSeq,company"/>
|
||||
|
||||
<extra-code><![CDATA[
|
||||
@@ -139,6 +143,7 @@
|
||||
|
||||
public static final String ORIGIN_INVENTORY = "com.axelor.apps.stock.db.Inventory";
|
||||
public static final String ORIGIN_STOCK_CORRECTION = "com.axelor.apps.stock.db.StockCorrection";
|
||||
public static final String ORIGIN_STOCK_PRODUCTION_REQUEST = "com.axelor.apps.stock.db.StockProductionRequest";
|
||||
]]></extra-code>
|
||||
|
||||
<track>
|
||||
@@ -150,6 +155,7 @@
|
||||
<field name="toStockLocation" />
|
||||
<field name="estimatedDate" />
|
||||
<field name="cancelReason" />
|
||||
<field name="cancelReasonStr" />
|
||||
<field name="realDate" if="statusSelect == 3" />
|
||||
<field name="pickingIsEdited" />
|
||||
<field name="availabilityRequest" />
|
||||
|
||||
@@ -23,8 +23,11 @@
|
||||
<many-to-one name="unit" ref="com.axelor.apps.base.db.Unit" title="Unit"/>
|
||||
<decimal name="netMass" title="Net mass" precision="20" scale="10" />
|
||||
<decimal name="totalNetMass" title="Total net mass"/>
|
||||
<decimal name="volume" title="Volume"/>
|
||||
|
||||
<many-to-one name="trackingNumber" ref="com.axelor.apps.stock.db.TrackingNumber" title="Tracking Nbr."/>
|
||||
|
||||
<many-to-one name="internalTrackingNumber" ref="com.axelor.apps.stock.db.InternalTrackingNumber" title="Internal tracking Nbr."/>
|
||||
|
||||
<integer name="conformitySelect" title="Conformity" selection="stock.move.line.conformity.select"/>
|
||||
|
||||
@@ -75,6 +78,23 @@
|
||||
<decimal name="stklim" title="Stklim" precision="20" scale="10" />
|
||||
<decimal name="shp" title="SHP" precision="20" scale="10" />
|
||||
|
||||
<boolean name="isWapUpdated" title="Is wap upadted"/>
|
||||
|
||||
<boolean name="justifiedGap" title="Justified gap"/>
|
||||
|
||||
<boolean name="isService" title="Is Service"/>
|
||||
|
||||
<boolean name="isWithoutPayment" title="Is Without Payment"/>
|
||||
|
||||
|
||||
<decimal name="totalQty" min="0" title="Total Qty"/>
|
||||
|
||||
<decimal name="currencyRate" title="Currency Rate" scale="6" precision="20" />
|
||||
<decimal name="freight" title="Freight" scale="6" precision="20" />
|
||||
|
||||
<decimal name="convertedExTaxTotal" title="Converted ExTaxTotal" scale="6" precision="20" />
|
||||
<decimal name="convertedInTaxTotal" title="Converted InTaxTotal" scale="6" precision="20" />
|
||||
|
||||
<extra-code><![CDATA[
|
||||
// CONFORMITY SELECT
|
||||
public static final int CONFORMITY_NONE = 1;
|
||||
@@ -96,6 +116,7 @@
|
||||
|
||||
<track>
|
||||
<field name="realQty"/>
|
||||
<field name="unitPriceUntaxed"/>
|
||||
</track>
|
||||
</entity>
|
||||
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
<?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="StockProductionRequest" lang="java">
|
||||
|
||||
<string name="stockProductionRequestSeq" namecolumn="true" title="Ref." readonly="true"/>
|
||||
<string name="name" title="Name"/>
|
||||
<integer name="statusSelect" title="Status" selection="stock.production.request.status.select" required="true" readonly="true" default="1"/>
|
||||
<integer name="typeSelect" title="Type Status" required="true" selection="stock.production.request.type.select"/>
|
||||
<many-to-one name="company" ref="com.axelor.apps.base.db.Company" title="Company" required="true"/>
|
||||
<many-to-one name="partner" ref="com.axelor.apps.base.db.Partner" title="Partner"/>
|
||||
<one-to-many name="stockProductionRequestLineList" ref="com.axelor.apps.stock.db.StockProductionRequestLine" mappedBy="stockProductionRequest" orderBy="sequence" title="StockProduction RequestLine content"/>
|
||||
<decimal name="exTaxTotal" title="Total W.T." precision="20" scale="2"/>
|
||||
<many-to-one name="cancelReason" title="Cancel reason" ref="com.axelor.apps.base.db.CancelReason"/>
|
||||
<string name="cancelReasonStr" large="true" title="Cancel Reason str"/>
|
||||
<string name="note" title="Notes" large="true"/>
|
||||
<many-to-one name="printingSettings" ref="com.axelor.apps.base.db.PrintingSettings"/>
|
||||
<many-to-one name="stocklocation" ref="com.axelor.apps.stock.db.StockLocation" required="true" title="Stock location"/>
|
||||
<datetime name="realDate" title="Real date" />
|
||||
<string name="trackingNumber" title="Tracking number" />
|
||||
<!-- final product -->
|
||||
<many-to-one name="product" ref="com.axelor.apps.base.db.Product" title="Product"/>
|
||||
<many-to-one name="familleProduit" ref="com.axelor.apps.base.db.FamilleProduit" title="Famille produit"/>
|
||||
<datetime name="estimatedDate" title="Estimated date" />
|
||||
|
||||
|
||||
<unique-constraint columns="stockProductionRequestSeq,company"/>
|
||||
|
||||
<extra-code><![CDATA[
|
||||
|
||||
// STATUS SELECT
|
||||
public static final int STATUS_DRAFT = 1;
|
||||
public static final int STATUS_PLANNED = 2;
|
||||
public static final int STATUS_REALIZED = 3;
|
||||
public static final int STATUS_CANCELED = 4;
|
||||
|
||||
]]></extra-code>
|
||||
|
||||
<track>
|
||||
<field name="statusSelect" />
|
||||
<message if="true" on="CREATE">Move created</message>
|
||||
<message if="statusSelect == 1" tag="important">Draft move</message>
|
||||
<message if="statusSelect == 2" tag="info">Planned move</message>
|
||||
<message if="statusSelect == 3" tag="success">Request realized</message>
|
||||
<message if="statusSelect == 4" tag="warning">Request canceled</message>
|
||||
</track>
|
||||
|
||||
</entity>
|
||||
</domain-models>
|
||||
@@ -0,0 +1,56 @@
|
||||
<?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="StockProductionRequestLine" lang="java">
|
||||
<many-to-one name="stockProductionRequest" readonly="true" ref="com.axelor.apps.stock.db.StockProductionRequest" title="Stock Production Request"/>
|
||||
<many-to-one name="product" ref="com.axelor.apps.base.db.Product" title="Product"/>
|
||||
<decimal name="realQty" min="0" title="Real Qty"/>
|
||||
<many-to-one name="unit" ref="com.axelor.apps.base.db.Unit" title="Unit"/>
|
||||
<string name="productName" title="Title" required="true" namecolumn="true" />
|
||||
<string name="description" title="Description" large="true"/>
|
||||
<decimal name="unitPriceUntaxed" precision="20" scale="10" title="Unit price"/>
|
||||
<decimal name="unitPriceTaxed" precision="20" scale="10" title="Unit price"/>
|
||||
<decimal name="companyUnitPriceUntaxed" precision="20" scale="10" title="Company Unit price W.T."/>
|
||||
<decimal name="wapPrice" precision="20" scale="10" readonly="true" nullable="true" title="Price used for WAP"/>
|
||||
<integer name="sequence" title="Seq."/>
|
||||
<boolean name="isWapUpdated" title="Is wap upadted"/>
|
||||
<boolean name="justifiedGap" title="Justified gap"/>
|
||||
<decimal name="totalQty" min="0" title="Total Qty"/>
|
||||
<decimal name="currencyRate" title="Currency Rate" scale="6" precision="20" />
|
||||
<decimal name="convertedExTaxTotal" title="Converted ExTaxTotal" scale="6" precision="20" />
|
||||
<decimal name="convertedInTaxTotal" title="Converted InTaxTotal" scale="6" precision="20" />
|
||||
|
||||
<integer name="deliveryState" title="Delivery State" selection="sale.order.delivery.state" readonly="true" default="1"/>
|
||||
<boolean name="isWithBackorder" title="Manage backorder" default="true"/>
|
||||
|
||||
|
||||
<extra-code><![CDATA[
|
||||
// CONFORMITY SELECT
|
||||
public static final int CONFORMITY_NONE = 1;
|
||||
public static final int CONFORMITY_COMPLIANT = 2;
|
||||
public static final int CONFORMITY_NON_COMPLIANT = 3;
|
||||
|
||||
// AVAILABLE STATUS SELECT
|
||||
public static final int STATUS_AVAILABLE = 1;
|
||||
public static final int STATUS_AVAILABLE_FOR_PRODUCT = 2;
|
||||
public static final int STATUS_MISSING = 3;
|
||||
|
||||
|
||||
// DELIVERY STATE SELECT
|
||||
public static final int DELIVERY_STATE_NOT_DELIVERED = 1;
|
||||
public static final int DELIVERY_STATE_PARTIALLY_DELIVERED = 2;
|
||||
public static final int DELIVERY_STATE_DELIVERED = 3;
|
||||
|
||||
]]></extra-code>
|
||||
|
||||
<track>
|
||||
<field name="realQty"/>
|
||||
<field name="unitPriceUntaxed"/>
|
||||
</track>
|
||||
</entity>
|
||||
|
||||
</domain-models>
|
||||
@@ -8,6 +8,7 @@
|
||||
<entity name="TrackingNumber" lang="java">
|
||||
|
||||
<many-to-one name="product" ref="com.axelor.apps.base.db.Product" title="Product"/>
|
||||
<date name="fabricationDate" title="Fabrication date"/>
|
||||
<date name="warrantyExpirationDate" title="Warranty expiration date" readonly="true"/>
|
||||
<date name="perishableExpirationDate" title="Perishable expiration date" readonly="true"/>
|
||||
<string name="trackingNumberSeq" namecolumn="true" title="Tracking Nbr." required="true"/>
|
||||
@@ -17,6 +18,13 @@
|
||||
|
||||
<finder-method name="findBySeq" using="trackingNumberSeq"/>
|
||||
|
||||
|
||||
<track>
|
||||
<field name="perishableExpirationDate"/>
|
||||
<field name="product"/>
|
||||
<field name="trackingNumberSeq" />
|
||||
</track>
|
||||
|
||||
</entity>
|
||||
|
||||
</domain-models>
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -11,8 +11,8 @@
|
||||
<property name="javax.persistence.jdbc.driver" value="org.postgresql.Driver"/>
|
||||
<property name="javax.persistence.jdbc.url" value="jdbc:postgresql://localhost:5432/axelor-test" />
|
||||
|
||||
<property name="javax.persistence.jdbc.user" value="axelor" />
|
||||
<property name="javax.persistence.jdbc.password" value="" />
|
||||
<property name="javax.persistence.jdbc.user" value="postgres" />
|
||||
<property name="javax.persistence.jdbc.password" value="Ijlv=bB^hSG@PV$,9jkhHzO*74" />
|
||||
|
||||
<!--
|
||||
value="create" to build a new database on each run;
|
||||
|
||||
Reference in New Issue
Block a user