Subversion Repositories SmartDukaan

Rev

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

Rev 34236 Rev 34256
Line 20... Line 20...
20
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
20
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
21
import com.spice.profitmandi.dao.repository.cs.CsService;
21
import com.spice.profitmandi.dao.repository.cs.CsService;
22
import com.spice.profitmandi.dao.repository.cs.PositionRepository;
22
import com.spice.profitmandi.dao.repository.cs.PositionRepository;
23
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
23
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
24
import com.spice.profitmandi.dao.repository.dtr.RoleRepository;
24
import com.spice.profitmandi.dao.repository.dtr.RoleRepository;
25
import com.spice.profitmandi.dao.repository.fofo.FofoOrderRepository;
-
 
26
import com.spice.profitmandi.dao.repository.fofo.PendingOrderItemRepository;
-
 
27
import com.spice.profitmandi.dao.repository.fofo.PendingOrderService;
25
import com.spice.profitmandi.dao.repository.fofo.*;
28
import com.spice.profitmandi.dao.repository.transaction.*;
26
import com.spice.profitmandi.dao.repository.transaction.*;
29
import com.spice.profitmandi.service.authentication.RoleManager;
27
import com.spice.profitmandi.service.authentication.RoleManager;
30
import com.spice.profitmandi.service.order.OrderService;
28
import com.spice.profitmandi.service.order.OrderService;
31
import com.spice.profitmandi.service.transaction.CreditNoteService;
29
import com.spice.profitmandi.service.transaction.CreditNoteService;
-
 
30
import com.spice.profitmandi.service.transaction.InventoryMarginModel;
32
import com.spice.profitmandi.service.transaction.TransactionService;
31
import com.spice.profitmandi.service.transaction.TransactionService;
33
import com.spice.profitmandi.service.user.RetailerService;
32
import com.spice.profitmandi.service.user.RetailerService;
34
import com.spice.profitmandi.service.wallet.WalletService;
33
import com.spice.profitmandi.service.wallet.WalletService;
35
import com.spice.profitmandi.web.model.LoginDetails;
34
import com.spice.profitmandi.web.model.LoginDetails;
36
import com.spice.profitmandi.web.util.CookiesProcessor;
35
import com.spice.profitmandi.web.util.CookiesProcessor;
Line 106... Line 105...
106
 
105
 
107
    @Autowired
106
    @Autowired
108
    CreditNoteService creditNoteService;
107
    CreditNoteService creditNoteService;
109
 
108
 
110
    @Autowired
109
    @Autowired
-
 
110
    PriceDropIMEIRepository priceDropIMEIRepository;
-
 
111
 
-
 
112
    @Autowired
-
 
113
    SchemeInOutRepository schemeInOutRepository;
-
 
114
 
-
 
115
    @Autowired
-
 
116
    OfferPayoutRepository offerPayoutRepository;
-
 
117
 
-
 
118
    @Autowired
111
    UserWalletRepository userWalletRepository;
119
    UserWalletRepository userWalletRepository;
112
    @PostMapping(value = "/reports/{projectName}/{fileName}")
120
    @PostMapping(value = "/reports/{projectName}/{fileName}")
113
    public ResponseEntity<?> fetchReport(HttpServletRequest request, @PathVariable String fileName,
121
    public ResponseEntity<?> fetchReport(HttpServletRequest request, @PathVariable String fileName,
114
                                         @PathVariable ReporticoProject projectName, @RequestBody Map<String, String> paramsMap)
122
                                         @PathVariable ReporticoProject projectName, @RequestBody Map<String, String> paramsMap)
115
            throws ProfitMandiBusinessException, UnsupportedOperationException, IOException {
123
            throws ProfitMandiBusinessException, UnsupportedOperationException, IOException {
Line 1669... Line 1677...
1669
            e.printStackTrace();
1677
            e.printStackTrace();
1670
            return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Error generating PDF: " + e.getMessage());
1678
            return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Error generating PDF: " + e.getMessage());
1671
        }
1679
        }
1672
    }
1680
    }
1673
 
1681
 
-
 
1682
    @RequestMapping(value = "/credit-note/attachements", method = RequestMethod.GET)
-
 
1683
    public ResponseEntity<?> getCnAttachements(@RequestParam("cnNumber") String cnNumber) throws Exception {
-
 
1684
        CreditNote creditNote = creditNoteRepository.selectByCreditNoteNumber(cnNumber);
-
 
1685
        YearMonth yearMonth = YearMonth.from(creditNote.getCnDate());
-
 
1686
        int fofoId = creditNote.getFofoId();
-
 
1687
 
-
 
1688
        List<InventoryMarginModel> allOffers = offerPayoutRepository.getPaidOffers(yearMonth, fofoId);
-
 
1689
        List<InventoryMarginModel> allPriceDrops = priceDropIMEIRepository.selectPaidPriceDrops(yearMonth, fofoId);
-
 
1690
        List<InventoryMarginModel> schemeMarginsInventoryModel = schemeInOutRepository.getPaidMargins(yearMonth, fofoId);
-
 
1691
 
-
 
1692
        List<InventoryMarginModel> allInventoryMarginModels = new ArrayList<>();
-
 
1693
        allInventoryMarginModels.addAll(schemeMarginsInventoryModel);
-
 
1694
        allInventoryMarginModels.addAll(allPriceDrops);
-
 
1695
        allInventoryMarginModels.addAll(allOffers);
-
 
1696
 
-
 
1697
        List<List<?>> rows = allInventoryMarginModels.stream().map(InventoryMarginModel::toRow).collect(Collectors.toList());
-
 
1698
 
-
 
1699
        // Add CN Number Header Row
-
 
1700
        List<List<?>> finalRows = new ArrayList<>();
-
 
1701
        finalRows.add(Arrays.asList("CN Number:", cnNumber));  // First row with CN Number
-
 
1702
        finalRows.add(Collections.emptyList());  // Blank row for separation
-
 
1703
        finalRows.addAll(rows);  // Add actual data
-
 
1704
 
-
 
1705
        // Generate CSV
-
 
1706
        org.apache.commons.io.output.ByteArrayOutputStream byteArrayOutputStream = FileUtil.getCSVByteStream(
-
 
1707
                Arrays.asList("FofoId", "InvoiceNo", "SerialNumber", "Margin", "Description", "CGST", "IGST", "SGST", "Credited On"),
-
 
1708
                finalRows
-
 
1709
        );
-
 
1710
 
-
 
1711
        return orderService.downloadReportInCsv(byteArrayOutputStream, finalRows, "CN Detail Report");
-
 
1712
    }
-
 
1713
 
-
 
1714
 
-
 
1715
 
1674
}
1716
}