Subversion Repositories SmartDukaan

Rev

Rev 35393 | Rev 35442 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 35393 Rev 35424
Line 4458... Line 4458...
4458
 
4458
 
4459
    @Autowired
4459
    @Autowired
4460
    SaholicReservationSnapshotRepository saholicReservationSnapshotRepository;
4460
    SaholicReservationSnapshotRepository saholicReservationSnapshotRepository;
4461
 
4461
 
4462
    public void removePartialBillingForTransaction(int transactionId) throws ProfitMandiBusinessException {
4462
    public void removePartialBillingForTransaction(int transactionId) throws ProfitMandiBusinessException {
-
 
4463
        // Fetch with pessimistic lock to prevent concurrent modifications
4463
        List<Order> orderList = orderRepository.selectAllByTransactionId(transactionId);
4464
        List<Order> orderList = orderRepository.selectAllByTransactionIdForUpdate(transactionId);
4464
        Map<Integer, Order> orderMap = orderList.stream().collect(Collectors.toMap(x -> x.getId(), x -> x));
4465
        Map<Integer, Order> orderMap = orderList.stream().collect(Collectors.toMap(x -> x.getId(), x -> x));
4465
        //Delete scanRecords
4466
        //Delete scanRecords
4466
        List<WarehouseScan> warehouseScans = warehouseScanRepository.selectAllByOrderIds(new ArrayList<>(orderMap.keySet()));
4467
        List<WarehouseScan> warehouseScans = warehouseScanRepository.selectAllByOrderIds(new ArrayList<>(orderMap.keySet()));
4467
        for (WarehouseScan warehouseScan : warehouseScans) {
4468
        for (WarehouseScan warehouseScan : warehouseScans) {
4468
            warehouseScanRepository.delete(warehouseScan);
4469
            warehouseScanRepository.delete(warehouseScan);