bug fixes
This commit is contained in:
@@ -240,7 +240,18 @@ public class RecipientGroupService {
|
||||
item.setAmount(productDto.getDefaultAmount());
|
||||
}
|
||||
updatedItems.add(groupBatchItemRepository.save(item));
|
||||
|
||||
// Recalculate batch totals
|
||||
BigDecimal newTotalValue = updatedItems.stream()
|
||||
.map(GroupBatchItem::getAmount)
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
GroupBatch batch = groupBatchRepository.findById(batchId)
|
||||
.orElseThrow(() -> new ApiException("Batch not found"));
|
||||
batch.setValue(newTotalValue);
|
||||
batch.setCount(updatedItems.size());
|
||||
groupBatchRepository.save(batch);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
providerErrors.add(GroupCreateFromFileResult.RowError.builder()
|
||||
.lineNumber(update.row.lineNumber)
|
||||
.account(update.row.account)
|
||||
@@ -250,19 +261,6 @@ public class RecipientGroupService {
|
||||
}
|
||||
}
|
||||
|
||||
// Recalculate batch totals
|
||||
if (!updatedItems.isEmpty()) {
|
||||
List<GroupBatchItem> allItems = groupBatchItemRepository.findAllByGroupBatchId(batchId);
|
||||
BigDecimal newTotalValue = allItems.stream()
|
||||
.map(GroupBatchItem::getAmount)
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
GroupBatch batch = groupBatchRepository.findById(batchId)
|
||||
.orElseThrow(() -> new ApiException("Batch not found"));
|
||||
batch.setValue(newTotalValue);
|
||||
batch.setCount(allItems.size());
|
||||
groupBatchRepository.save(batch);
|
||||
}
|
||||
|
||||
return providerErrors;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user