|
@@ -75,9 +75,8 @@ public class SaleBatchService {
|
|
|
return saleBatches;
|
|
return saleBatches;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public SaleBatchDto create1(SaleBatchDto record) {
|
|
|
|
|
- List<SalesBatchExtension> extensions = record.getExtensions();
|
|
|
|
|
- SaleBatch batch = record.getSaleBatch();
|
|
|
|
|
|
|
+ public SaleBatch create1(SaleBatch batch) {
|
|
|
|
|
+ List<SalesBatchExtension> extensions = batch.getExtensions();
|
|
|
BigDecimal maxPrice = extensions.stream()
|
|
BigDecimal maxPrice = extensions.stream()
|
|
|
.map(SalesBatchExtension::getMaxPrice)
|
|
.map(SalesBatchExtension::getMaxPrice)
|
|
|
.max(BigDecimal::compareTo)
|
|
.max(BigDecimal::compareTo)
|
|
@@ -88,14 +87,14 @@ public class SaleBatchService {
|
|
|
extensionRepo.saveAllAndFlush(extensions);
|
|
extensionRepo.saveAllAndFlush(extensions);
|
|
|
schedule();
|
|
schedule();
|
|
|
cacheService.clearBatch();
|
|
cacheService.clearBatch();
|
|
|
- return new SaleBatchDto(saleBatch, extensions);
|
|
|
|
|
|
|
+ return batch;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public SaleBatchDto update1(SaleBatchDto record) {
|
|
|
|
|
- List<SalesBatchExtension> extensions = record.getExtensions();
|
|
|
|
|
- SaleBatch orig = saleBatchRepo.findById(record.getSaleBatch().getId())
|
|
|
|
|
|
|
+ public SaleBatch update1(SaleBatch batch) {
|
|
|
|
|
+ List<SalesBatchExtension> extensions = batch.getExtensions();
|
|
|
|
|
+ SaleBatch orig = saleBatchRepo.findById(batch.getId())
|
|
|
.orElseThrow(new BusinessException(Translator.toLocale("record.not_found")));
|
|
.orElseThrow(new BusinessException(Translator.toLocale("record.not_found")));
|
|
|
- ObjUtils.merge(orig, record.getSaleBatch());
|
|
|
|
|
|
|
+ ObjUtils.merge(orig, batch);
|
|
|
SaleBatch saleBatch = saleBatchRepo.saveAndFlush(orig);
|
|
SaleBatch saleBatch = saleBatchRepo.saveAndFlush(orig);
|
|
|
List<SalesBatchExtension> list = extensionRepo.findAllByBatchId(orig.getId());
|
|
List<SalesBatchExtension> list = extensionRepo.findAllByBatchId(orig.getId());
|
|
|
if (list.size() > 0) {
|
|
if (list.size() > 0) {
|
|
@@ -105,7 +104,7 @@ public class SaleBatchService {
|
|
|
extensionRepo.saveAll(extensions);
|
|
extensionRepo.saveAll(extensions);
|
|
|
schedule();
|
|
schedule();
|
|
|
cacheService.clearBatch();
|
|
cacheService.clearBatch();
|
|
|
- return new SaleBatchDto(saleBatch, extensions);
|
|
|
|
|
|
|
+ return batch;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public SaleBatchDto addExtensions(List<SalesBatchExtension> extensions) {
|
|
public SaleBatchDto addExtensions(List<SalesBatchExtension> extensions) {
|