Subversion Repositories SmartDukaan

Rev

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

Rev 35066 Rev 35076
Line 769... Line 769...
769
        // Step 2: Load all policy certificate PDFs
769
        // Step 2: Load all policy certificate PDFs
770
        List<byte[]> pdfFiles = new ArrayList<>();
770
        List<byte[]> pdfFiles = new ArrayList<>();
771
        pdfFiles.add(invoicePdf); // first add invoice
771
        pdfFiles.add(invoicePdf); // first add invoice
772
 
772
 
773
        for (InsurancePolicy insurancePolicy : insurancePolicies) {
773
        for (InsurancePolicy insurancePolicy : insurancePolicies) {
-
 
774
            if (insurancePolicy.getProviderId() == 6) {
774
            String policyNumber = insurancePolicy.getPolicyNumber();
775
                String policyNumber = insurancePolicy.getPolicyNumber();
775
            String safePolicyNo = policyNumber.replace("/", "-");
776
                String safePolicyNo = policyNumber.replace("/", "-");
776
            String filePath = "/uploads/policy-certificate-" + safePolicyNo + ".pdf";
777
                String filePath = "/uploads/policy-certificate-" + safePolicyNo + ".pdf";
777
            File file = new File(filePath);
778
                File file = new File(filePath);
778
 
779
 
779
            if (file.exists()) {
780
                if (file.exists()) {
780
                try {
781
                    try {
781
                    byte[] policyPdf = Files.readAllBytes(file.toPath());
782
                        byte[] policyPdf = Files.readAllBytes(file.toPath());
782
                    pdfFiles.add(policyPdf);
783
                        pdfFiles.add(policyPdf);
783
                } catch (IOException e) {
784
                    } catch (IOException e) {
784
                    LOGGER.error("Failed to read policy PDF: {}", filePath, e);
785
                        LOGGER.error("Failed to read policy PDF: {}", filePath, e);
-
 
786
                    }
-
 
787
                } else {
-
 
788
                    LOGGER.warn("Policy PDF not found: {}", filePath);
785
                }
789
                }
786
            } else {
-
 
787
                LOGGER.warn("Policy PDF not found: {}", filePath);
-
 
788
            }
790
            }
-
 
791
 
789
        }
792
        }
790
 
793
 
791
        // Step 3: Merge all PDFs
794
        // Step 3: Merge all PDFs
792
        byte[] mergedPdf;
795
        byte[] mergedPdf;
793
        try {
796
        try {