@php use App\Services\ProformaGstService; $partyName = $debitNote->client_type === 'Project' ? ($debitNote->project->project_name ?? '') : ($debitNote->client->company_name ?? ''); $gstType = $debitNote->gst_type ?: (((float) ($debitNote->igst ?? 0)) > 0 ? 'inter' : 'intra'); $intraRate = $gstType === 'intra' && isset(ProformaGstService::INTRA_RATES[$debitNote->gst_rate]) ? ProformaGstService::INTRA_RATES[$debitNote->gst_rate] : ['cgst' => 9, 'sgst' => 9]; $interRate = $gstType === 'inter' && isset(ProformaGstService::INTER_RATES[$debitNote->gst_rate]) ? ProformaGstService::INTER_RATES[$debitNote->gst_rate] : 18; $fmtPct = fn ($v) => rtrim(rtrim(number_format((float) $v, 2), '0'), '.'); $gstRateLabel = $gstType === 'intra' ? $fmtPct($intraRate['cgst'] + $intraRate['sgst']) . '%' : $fmtPct($interRate) . '%'; // Indian digit grouping, like the reference (1,42,46,820.00) $fmtInr = function ($v) { $v = number_format((float) $v, 2, '.', ''); [$int, $dec] = explode('.', $v); $sign = str_starts_with($int, '-') ? '-' : ''; $int = ltrim($int, '-'); if (strlen($int) > 3) { $last3 = substr($int, -3); $rest = substr($int, 0, -3); $int = preg_replace('/\B(?=(\d{2})+(?!\d))/', ',', $rest) . ',' . $last3; } return $sign . $int . '.' . $dec; }; $amount = (float) ($debitNote->amount ?? 0); $grandTotal = (float) ($debitNote->grand_total ?? 0); $paysheetInvoiceNo = $debitNote->paysheet->invoice_number ?? ($debitNote->paysheet->paysheet_no ?? '-'); // Address as readable lines inside the client block $addressLines = array_values(array_filter(array_map('trim', preg_split('/\r\n|\r|\n|,/', (string) $debitNote->address) ), fn ($l) => $l !== '')); $wrapped = []; $line = ''; foreach ($addressLines as $part) { if ($line !== '' && mb_strlen($line . ', ' . $part) > 48) { $wrapped[] = $line . ','; $line = $part; } else { $line = $line === '' ? $part : $line . ', ' . $part; } } if ($line !== '') { $wrapped[] = $line . '.'; } /* * Dynamic A4 layout. * Size tier: scale font/padding down (within readable limits) as the * description grows; filler: stretch the item row so the signature and * bank sections sit near the bottom when data is sparse. Very long * content simply flows onto further A4 pages (the item row may split). */ $descLen = mb_strlen((string) $debitNote->description); if ($descLen > 2200) { // heavy content: compact but readable $fontSize = 11; $headSize = 10; $titleSize = 14; $cellPad = '3px 5px'; $lineHeight = 1.3; } elseif ($descLen > 1000) { // above average $fontSize = 12; $headSize = 10.5; $titleSize = 15; $cellPad = '4px 6px'; $lineHeight = 1.35; } else { // few records: default comfortable sizing $fontSize = 13; $headSize = 11; $titleSize = 16; $cellPad = '5px 7px'; $lineHeight = 1.45; } // Rough content height estimate (mm) to size the stretch filler. $lineMm = round($fontSize * $lineHeight * 0.2646, 2); // px -> mm $descCol = 30; // approx chars per line in the 27% column $descLines = max(1, (int) ceil($descLen / $descCol)); $usableMm = 277; // A4 297mm minus 10mm top/bottom margins $usedMm = 11 // title row + max(6 * $lineMm + 6, 3 * ($lineMm + 4)) // seller block vs 3 info rows + $lineMm + 4 // BILL TO + (count($wrapped) + 2) * $lineMm + 4 // buyer block (name + GST line) + 2 * $lineMm + 6 // column header + $descLines * $lineMm + 4 // item row + ($gstType === 'intra' ? 2 : 1) * ($lineMm + 4) // GST rows + $lineMm + 4 // total row + $lineMm + 4 // words/for-company header row + max(2 * $lineMm, 24) + 6 // words + signature row (18mm sign space) + 3 * $lineMm + 6; // bank details row // Stretch the item row to use the free page height (6mm safety buffer) $fillerMm = (int) max(0, floor($usableMm - $usedMm - 6)); @endphp
| DEBIT NOTE | ||||||
|
CUMANS MANPOWER SOLUTIONS PVT LTD No.31/4, Kamaraj Nagar, Gandhi Nagar, Karamadai, Mettupalayam, Coimbatore – 641104. Tamilnadu, Code - 33. GST /UIN : 33AAJCC3390F1ZT |
Date: {{ $debitNote->invoice_date ? date('d.m.Y', strtotime($debitNote->invoice_date)) : '-' }} | |||||
| Debit Note No: {{ $debitNote->invoice_number }} | ||||||
| Original Invoice No: {{ $paysheetInvoiceNo }} | ||||||
| BILL TO | ||||||
|
@if($partyName){{ $partyName }} @endif {!! implode(' ', array_map('e', $wrapped)) !!} @if(filled($debitNote->gst_no)) GST /UIN : {{ $debitNote->gst_no }} @endif |
||||||
| S.no | Description of Goods | HSN/SAC | GST Rate | Man days | Rate | Amount |
|---|---|---|---|---|---|---|
| 4) style="height: {{ $fillerMm }}mm;" @endif>1 | {{ $debitNote->description ?: 'Debit Note' }} | {{ $debitNote->hsn_code ?: '–' }} | {{ $gstRateLabel }} | – | – | {{ $fmtInr($amount) }} |
| Output CGST@ | {{ $fmtPct($intraRate['cgst']) }}% | {{ $fmtInr($debitNote->cgst ?? 0) }} | ||||
| Output SGST@ | {{ $fmtPct($intraRate['sgst']) }}% | {{ $fmtInr($debitNote->sgst ?? 0) }} | ||||
| Output IGST@ | {{ $fmtPct($interRate) }}% | {{ $fmtInr($debitNote->igst ?? 0) }} | ||||
| Total (Round up) | {{ $fmtInr($grandTotal) }} | |||||
| Debit Note Amount In Words : | For CuManS Manpower Solutions Pvt Ltd | |||||
| {{ ProformaGstService::amountInIndianWords($grandTotal) }} | Authorized Signatory | |||||
|
Company Bank Details : Bank Name: SBI Bank | A/c No. 40143018676 | IFSC: SBIN0000990 GST : {{ config('setting.company_gstin') }} |
||||||