| 1 | 
                    Nama Penerima Pembiayaan | 
                    : | 
                    
                        {{ $creditApplicationBusiness->businessType . ' ' . $creditApplicationBusiness->businessName }}
                     | 
                
                
                     | 
                    Alamat perusahaan saat ini dan sesuai NIB | 
                    : | 
                    {{ $creditApplicationBusiness->businessAddress }},
                        Kel.{{ $creditApplicationBusiness->businessVillage }},
                        Kec.{{ $creditApplicationBusiness->businessSubdistrict }},
                        {{ $creditApplicationBusiness->businessCity }},
                        {{ $creditApplicationBusiness->businessProvince }}. | 
                
                
                    | 2 | 
                    Nilai Limit | 
                    : | 
                    Rp {{ getPriceNumber($creditApplicationBusiness->totalPlafond) }}
                     | 
                
                
                    | 3 | 
                    Tenor | 
                    : | 
                    
                        {{ $invoice->period > 0 ? getPriceNumber($invoice->period) . ' bulan' : getPriceNumber($invoice->periodDay) . ' hari' }}
                     | 
                
                
                    | 4 | 
                    Nama Pengurus dan Pemegang Saham | 
                    : | 
                    
                        
                            
                                @php
                                    $commissioners = json_decode($creditApplicationBusinessManagement);
                                    $noCommissioner = 1;
                                @endphp
                                @foreach (json_decode($commissioners->commissionerName, true) as $key => $value)
                                    
                                        | {{ $noCommissioner }}. | 
                                        
                                            {{ ucwords($value) . ' ' . '(' . $constant::MANAGEMENT_COMMISSIONER_ALIAS[json_decode($commissioners->commissionerPosition, true)[$key]] . ')' }}
                                         | 
                                        
                                            
                                                Rp 
                                                
                                                    {{ number_format(json_decode($commissioners->commissionerShareValue, true)[$key], 0, ',', '.') }}
                                                 
                                             
                                         | 
                                        
                                            {{ json_decode($commissioners->commissionerSharePercent, true)[$key] }}%
                                         | 
                                     
                                    @php
                                        $noCommissioner++;
                                    @endphp
                                @endforeach
                                @php
                                    $directors = json_decode($creditApplicationBusinessManagement);
                                    $noDirector = $noCommissioner;
                                @endphp
                                @foreach (json_decode($directors->directorName, true) as $key => $value)
                                    
                                        | {{ $noDirector }}. | 
                                        
                                            {{ ucwords($value) . ' ' . '(' . $constant::MANAGEMENT_DIRECTOR_ALIAS[json_decode($directors->directorPosition, true)[$key]] . ')' }}
                                         | 
                                        
                                            
                                                Rp 
                                                
                                                    {{ number_format(json_decode($directors->directorShareValue, true)[$key], 0, ',', '.') }}
                                                 
                                             
                                         | 
                                        
                                            {{ json_decode($directors->directorSharePercent, true)[$key] }}% | 
                                     
                                    @php
                                        $noDirector++;
                                    @endphp
                                @endforeach
                                @php
                                    $shareHolders = json_decode($creditApplicationBusinessManagement);
                                    $combinedData = [];
                                    foreach (json_decode($shareHolders->shareHolderName, true) as $key => $value) {
                                        $combinedData[] = [
                                            'shareHolderName' => ucwords($value),
                                            'shareValue' => json_decode($shareHolders->shareHolderShareValue, true)[
                                                $key
                                            ],
                                            'sharePercent' => json_decode($shareHolders->shareHolderSharePercent, true)[
                                                $key
                                            ],
                                        ];
                                    }
                                    // MENGURUTKAN DATA PEMEGANG SAHAM DARI SHAREHOLDERSHAREVALUE TERTINGGI
                                    usort($combinedData, function ($a, $b) {
                                        return $b['shareValue'] - $a['shareValue'];
                                    });
                                    $noShareHolder = $noDirector;
                                @endphp
                                @foreach ($combinedData as $data)
                                    
                                        | {{ $noShareHolder }}. | 
                                        {{ $data['shareHolderName'] }} | 
                                        
                                            
                                                Rp 
                                                
                                                    {{ number_format($data['shareValue'], 0, ',', '.') }}
                                                 
                                             
                                         | 
                                        {{ $data['sharePercent'] }}% | 
                                     
                                    @php
                                        $noShareHolder++;
                                    @endphp
                                @endforeach
                            
                         
                     | 
                
                
                    | 5 | 
                    Laporan Keuangan | 
                    : | 
                    
                        
                            
                                | 
                                     Laporan Keuangan (dalam juta Rp.) 
                                 | 
                                @php
                                    $reportDate = empty($creditApplicationBusinessFinancialPerformance->reportDate)
                                        ? ''
                                        : parseDateToIndonesian($carbon::parse($creditApplicationBusinessFinancialPerformance->reportDate)->format('M-Y'));
                                    $reportDate2 = empty($creditApplicationBusinessFinancialPerformance->reportDate2)
                                        ? ''
                                        : parseDateToIndonesian($carbon::parse($creditApplicationBusinessFinancialPerformance->reportDate2)->format('M-Y'));
                                    try {
                                        $reportDate =
                                            substr(explode('-', $reportDate)[0], 0, 3) .
                                            '-' .
                                            explode('-', $reportDate)[1];
                                        $reportDate2 =
                                            substr(explode('-', $reportDate2)[0], 0, 3) .
                                            '-' .
                                            explode('-', $reportDate2)[1];
                                    } catch (\Throwable $th) {
                                        $reportDate = '';
                                        $reportDate2 = '';
                                    }
                                @endphp
                                
                                     {{ $reportDate }} 
                                 | 
                                
                                     {{ $reportDate2 }} 
                                 | 
                             
                            
                                | 
                                     Neraca 
                                 | 
                                
                                     in-House 
                                 | 
                                
                                     in-House 
                                 | 
                             
                            
                                | 
                                     Total Current Aset 
                                 | 
                                
                                     
                                        {{ getBillionMillionNumber($creditApplicationBusinessFinancialPerformance->totalCurrentAsset) }}
                                     
                                 | 
                                
                                     
                                        {{ getBillionMillionNumber($creditApplicationBusinessFinancialPerformance->totalCurrentAsset2) }}
                                     
                                 | 
                             
                            
                                | 
                                     Total Aset 
                                 | 
                                
                                     
                                        {{ getBillionMillionNumber($creditApplicationBusinessFinancialPerformance->totalAsset) }}
                                     
                                 | 
                                
                                     
                                        {{ getBillionMillionNumber($creditApplicationBusinessFinancialPerformance->totalAsset2) }}
                                     
                                 | 
                             
                            
                                | 
                                     Total Current Liabilities 
                                 | 
                                
                                     
                                        {{ getBillionMillionNumber($creditApplicationBusinessFinancialPerformance->totalCurrentLiabilities) }}
                                     
                                 | 
                                
                                     
                                        {{ getBillionMillionNumber($creditApplicationBusinessFinancialPerformance->totalCurrentLiabilities2) }}
                                     
                                 | 
                             
                            
                                | 
                                     Total Liabilities 
                                 | 
                                
                                     
                                        {{ getBillionMillionNumber($creditApplicationBusinessFinancialPerformance->totalLiabilities) }}
                                     
                                 | 
                                
                                     
                                        {{ getBillionMillionNumber($creditApplicationBusinessFinancialPerformance->totalLiabilities2) }}
                                     
                                 | 
                             
                            
                                | 
                                     Ekuitas 
                                 | 
                                
                                     
                                        {{ getBillionMillionNumber($creditApplicationBusinessFinancialPerformance->ekuitas) }}
                                     
                                 | 
                                
                                     
                                        {{ getBillionMillionNumber($creditApplicationBusinessFinancialPerformance->ekuitas2) }}
                                     
                                 | 
                             
                            
                                | 
                                     Laba / (Rugi) 
                                 | 
                                
                                       
                                 | 
                                
                                       
                                 | 
                             
                            
                                | 
                                     Pendapatan Usaha 
                                 | 
                                
                                     
                                        {{ getBillionMillionNumber($creditApplicationBusinessFinancialPerformance->operatingRevenues) }}
                                     
                                 | 
                                
                                     
                                        {{ getBillionMillionNumber($creditApplicationBusinessFinancialPerformance->operatingRevenues2) }}
                                     
                                 | 
                             
                            
                                | 
                                     Laba Kotor 
                                 | 
                                
                                     
                                        {{ getBillionMillionNumber($creditApplicationBusinessFinancialPerformance->grossProfit) }}
                                     
                                 | 
                                
                                     
                                        {{ getBillionMillionNumber($creditApplicationBusinessFinancialPerformance->grossProfit2) }}
                                     
                                 | 
                             
                            
                                | 
                                     Laba Usaha Sebelum Pajak 
                                 | 
                                
                                     
                                        {{ getBillionMillionNumber($creditApplicationBusinessFinancialPerformance->profitBeforeTax) }}
                                     
                                 | 
                                
                                     
                                        {{ getBillionMillionNumber($creditApplicationBusinessFinancialPerformance->profitBeforeTax2) }}
                                     
                                 | 
                             
                            
                                | 
                                     Laba Bersih Setelah Pajak 
                                 | 
                                
                                     
                                        {{ getBillionMillionNumber($creditApplicationBusinessFinancialPerformance->nettProfitAfterTax) }}
                                     
                                 | 
                                
                                     
                                        {{ getBillionMillionNumber($creditApplicationBusinessFinancialPerformance->nettProfitAfterTax2) }}
                                     
                                 | 
                             
                            
                                | 
                                     Rasio Keuangan [%] 
                                 | 
                                
                                       
                                 | 
                                
                                       
                                 | 
                             
                            
                                | 
                                     Return On Assets (ROA) 
                                 | 
                                
                                     
                                        {{ getFormattedNumber($creditApplicationBusinessFinancialPerformance->roa, 2) }}%
                                     
                                 | 
                                
                                     
                                        {{ getFormattedNumber($creditApplicationBusinessFinancialPerformance->roa2, 2) }}%
                                     
                                 | 
                             
                            
                                | 
                                     Return On Equity (ROE) 
                                 | 
                                
                                     
                                        {{ getFormattedNumber($creditApplicationBusinessFinancialPerformance->roe, 2) }}%
                                     
                                 | 
                                
                                     
                                        {{ getFormattedNumber($creditApplicationBusinessFinancialPerformance->roe2, 2) }}%
                                     
                                 | 
                             
                            
                                | 
                                     Debt To Equity (DER) 
                                 | 
                                
                                     
                                        {{ getFormattedNumber($creditApplicationBusinessFinancialPerformance->der, 2) }}
                                     
                                 | 
                                
                                     
                                        {{ getFormattedNumber($creditApplicationBusinessFinancialPerformance->der2, 2) }}
                                     
                                 | 
                             
                            
                                | 
                                     Net Profit Margin (NPM) 
                                 | 
                                
                                     
                                        {{ getFormattedNumber($creditApplicationBusinessFinancialPerformance->npm, 2) }}%
                                     
                                 | 
                                
                                     
                                        {{ getFormattedNumber($creditApplicationBusinessFinancialPerformance->npm2, 2) }}%
                                     
                                 | 
                             
                            
                                | 
                                     Current Ratio 
                                 | 
                                
                                     
                                        {{ getFormattedNumber($creditApplicationBusinessFinancialPerformance->currentRatio, 2) }}
                                     
                                 | 
                                
                                     
                                        {{ getFormattedNumber($creditApplicationBusinessFinancialPerformance->currentRatio2, 2) }}
                                     
                                 | 
                             
                         
                     | 
                
                
                    | 6 | 
                    Analisa Laporan Keuangan | 
                    : | 
                     | 
                
                
                     | 
                    {!! nl2br($invoice->proposalInvoicer->analisa_risk_note) !!} | 
                
                {{-- 
                    | 7 | 
                    Aging Piutang | 
                    : | 
                    255 Hari | 
                
 --}}
                
                    | 7 | 
                    Pefindo Score | 
                    : | 
                    {{ $invoice->proposalInvoicer->kredit_skor_pefindo }} | 
                
                
                    | 8 | 
                    FDC | 
                    : | 
                    {{ $invoice->proposalInvoicer->kredit_skor_fdc }} | 
                
                
                    | 9 | 
                    Informasi Usaha | 
                    : | 
                     | 
                
                
                     | 
                    {!! nl2br($creditApplication->description) !!} | 
                
                
                    | 10 | 
                    Mutasi Rekening | 
                    : | 
                     | 
                
                
                     | 
                    
                        @php
                            $accountMutationHtml = '';
                            $numberOfMonths[] = [];
                            foreach ($creditApplicationBusinessAccountMutation as $key => $accountMutation) {
                                $mutationData = json_decode($accountMutation->mutationData, true);
                                $accountMutationHtml =
                                    '
                            
                                
                                    
                                        | ' .
                                    $accountMutation->bank->name .
                                    ' (' .
                                    $accountMutation->bankAccountNumber .
                                    ') A.N. ' .
                                    strtoupper($accountMutation->bankAccountOwnerName) .
                                    ' | 
                                     
                                    
                                        | Periode | 
                                        Debit | 
                                        Kredit | 
                                        Saldo | 
                                     
                                
                                ';
                                $totalDebit = 0;
                                $totalCredit = 0;
                                $totalSaldo = 0;
                                $numberOfMonths[$key] = 0;
                                foreach ($mutationData as $mutation) {
                                    $totalDebit += intval(str_replace(',', '', $mutation['mutationAmount']['debit']));
                                    $totalCredit += intval(str_replace(',', '', $mutation['mutationAmount']['credit']));
                                    $mutationMonth = isset($mutation['mutationMonth'])
                                        ? $mutation['mutationMonth']
                                        : '';
                                    $mutationYear = isset($mutation['mutationYear']) ? $mutation['mutationYear'] : '';
                                    $numberOfMonths[$key]++;
                                    $accountMutationHtml .=
                                        '
                                        
                                            | ' .
                                        Constant::MONTH_LABELS[$mutationMonth] .
                                        ' ' .
                                        $mutationYear .
                                        ' | 
                                        Rp' .
                                        number_format(
                                            intval(str_replace(',', '', $mutation['mutationAmount']['debit'])), 0, ',', '.'
                                        ) .
                                        ' | 
                                        Rp' .
                                        number_format(
                                            intval(str_replace(',', '', $mutation['mutationAmount']['credit'])), 0, ',', '.'
                                        ) .
                                        ' | 
                                            Rp' .
                                        number_format(intval(str_replace(',', '', $mutation['balance'])), 0, ',', '.') .
                                        ' | 
                                         
                                    ';
                                }
                                $accountMutationHtml .=
                                    '
                                        
                                            | Total | 
                                            Rp' .
                                    number_format($totalDebit, 0, ',', '.') .
                                    ' | 
                                            Rp' .
                                    number_format($totalCredit, 0, ',', '.') .
                                    ' | 
                                             | 
                                         
                                    
                                 
                                 
                                ';
                                echo $accountMutationHtml;
                            }
                        @endphp
                     | 
                
                
                    | 11 | 
                    Info Mutasi Rekening | 
                    : | 
                    
                        @php
                            $grandTotalAvgTotalDebit = 0;
                            $grandTotalAvgTotalCredit = 0;
                            $grandTotalAvgTotalBalance = 0;
                            $summaryAccountMutationHtml = '
                            
                                
                                    
                                        | Bank | 
                                        Avg. Saldo Akhir | 
                                        Avg. Kredit | 
                                     
                                
                                ';
                            foreach ($creditApplicationBusinessAccountMutation as $key => $accountMutation) {
                                $mutationData = json_decode($accountMutation->mutationData, true);
                                $totalDebit = 0;
                                $totalCredit = 0;
                                $totalBalance = 0;
                                foreach ($mutationData as $mutation) {
                                    $totalDebit += intval(str_replace(',', '', $mutation['mutationAmount']['debit']));
                                    $totalCredit += intval(str_replace(',', '', $mutation['mutationAmount']['credit']));
                                    $totalBalance += intval(str_replace(',', '', $mutation['balance']));
                                }
                                $avgTotalDebit = $totalDebit / $numberOfMonths[$key];
                                $avgTotalCredit = $totalCredit / $numberOfMonths[$key];
                                $avgTotalBalance = $totalBalance / $numberOfMonths[$key];
                                $grandTotalAvgTotalDebit += $avgTotalDebit;
                                $grandTotalAvgTotalCredit += $avgTotalCredit;
                                $grandTotalAvgTotalBalance += $avgTotalBalance;
                                $summaryAccountMutationHtml .=
                                    '
                                        
                                            | ' .
                                    $accountMutation->bank->name .
                                    ' ****' .
                                    substr($accountMutation->bankAccountNumber, -3) .
                                    ' | 
                                            Rp' .
                                    number_format(round($avgTotalBalance, PHP_ROUND_HALF_UP), 0, ',', '.') .
                                    ' | 
                                            Rp' .
                                    number_format(round($avgTotalCredit, PHP_ROUND_HALF_UP), 0, ',', '.') .
                                    ' | 
                                         
                                    ';
                            }
                            $summaryAccountMutationHtml .=
                                '
                                    
                                    
                                        
                                            | Total | 
                                            Rp' .
                                number_format(round($grandTotalAvgTotalBalance, PHP_ROUND_HALF_UP), 0, ',', '.') .
                                ' | 
                                            Rp' .
                                number_format(round($grandTotalAvgTotalCredit, PHP_ROUND_HALF_UP), 0, ',', '.') .
                                ' | 
                                         
                                    
                                 ';
                            echo $summaryAccountMutationHtml;
                        @endphp
                     | 
                
                
                    | 12 | 
                    Resume Analisa Rek Koran | 
                    : | 
                     | 
                
                
                     | 
                    
                        {!! nl2br($invoice->proposalInvoicer->analisa_rek_koran) !!}
                     | 
                
                
                    | 13 | 
                    Informasi Payor | 
                    : | 
                    {!! nl2br($invoice->proposalInvoicer->informasi_payor) !!} | 
                
                
                    | 14 | 
                    Analisis SWOT | 
                    : | 
                    
                        STRENGTHS (S)
                        {{ $invoice->proposalInvoicer->strengths }}
                        
  
                        WEAKNESSES (W)
                        {{ $invoice->proposalInvoicer->weaknesses }}
                        
  
                        OPPORTUNITIES (O)
                        {{ $invoice->proposalInvoicer->opportunities }}
                        
  
                        THREATS (T)
                        {{ $invoice->proposalInvoicer->threats }}
                         
                     | 
                
                
                    | 15 | 
                    Resume | 
                    : | 
                     | 
                
                
                     | 
                    
                        {!! nl2br($invoice->proposalInvoicer->mup_resume) !!}
                     | 
                
                
                    | 16 | 
                    Dokumentasi | 
                    : | 
                     | 
                
                
                     | 
                    
                        
                            {{--   --}}
                            @foreach (json_decode($creditApplicationBusiness->visitDocumentationImage) as $key => $visitImage)
                                {{--  
                     | 
                
                
                    | 17 | 
                    Form Scoring | 
                    : | 
                     | 
                
                
                    
                        
                            
                                
                                    
                                        PARAMETER CREDIT SCORING PT DMS
                                     | 
                                 
                            
                            
                                
                                    | Group Parameter
                                     | 
                                    Bobot | 
                                    Score | 
                                 
                            
                            
                                @php
                                    $noUrutGroupFormScoring = 1;
                                    $totalScore = 0;
                                    foreach ($creditApplicationBusinessFormScoring as $formScoring) {
                                        $arrParentScore = json_decode($formScoring->score, true);
                                        $sumParentScore = array_sum($arrParentScore);
                                        echo "
                                        | " .
                                            $noUrutGroupFormScoring .
                                            " | 
                                        " .
                                            $formScoring->parameterGroupParent->title .
                                            " | 
                                        " .
                                            $formScoring->parameterGroupParent->weight .
                                            "% | 
                                        " .
                                            $sumParentScore .
                                            " | 
                                     ";
                                        $noUrutGroupFormScoring++;
                                        $totalScore += $sumParentScore;
                                    }
                                @endphp
                            
                         
                         
                        @php
                            $gradeText = '';
                            $gradeColor = '';
                            $riskRating = '';
                            $totalScore = (float) $totalScore;
                            if ($totalScore >= 0 && $totalScore <= 2.99) {
                                $gradeText = 'High Risk (Reject)';
                                $gradeColor = '#C00000';
                                $riskRating = 'DD';
                            } elseif ($totalScore >= 3.0 && $totalScore <= 3.65) {
                                $gradeText = 'Medium Risk';
                                $gradeColor = '#FFFF00';
                                $riskRating = 'CC';
                            } elseif ($totalScore >= 3.66 && $totalScore <= 3.99) {
                                $gradeText = 'Low Risk';
                                $gradeColor = '#A9D08E';
                                $riskRating = 'BB';
                            } elseif ($totalScore >= 4.0 && $totalScore <= 5.0) {
                                $gradeText = 'Very Low Risk';
                                $gradeColor = '#00B050';
                                $riskRating = 'AA';
                            }
                        @endphp
                        
                            
                                
                                    | Score | 
                                    
                                        {{ number_format($totalScore, 2, ',', '.') }} | 
                                 
                                
                                    | Grade | 
                                    
                                        {{ $gradeText }} | 
                                 
                                
                                    | Risk Rating | 
                                    {{ $riskRating }} | 
                                 
                            
                         
                     |