<!DOCTYPE html>
<html lang="ja">

<head>
    <meta charset="UTF-8">
    <style>
        body {
            font-family: 'noto_sans_jp';
            font-size: 12px;
        }

        .border {
            border: 2px solid #222;
            margin: 0;
            padding: 24px;
            position: relative;
        }

        .title {
            text-align: center;
            margin: 24px 0 12px 0;
        }

        .right {
            text-align: right;
        }

        .table {
            width: 100%;
            border-collapse: collapse;
            margin: 16px 0;
        }

        .table th,
        .table td {
            border: 1px solid #222;
            padding: 6px 8px;
        }

        .table td.left {
            text-align: left;
        }

        .table td.right {
            text-align: right;
        }

        .stamp {
            float: right;
            margin-top: 8px;
            width: 80px;
        }

        .company {
            position: absolute;
            right: 0;
            bottom: 0;
            font-size: 12px;
        }

        .reissue-label {
            display: inline-block;
            border: 2px solid #222;
            border-radius: 36px;
            padding: 14px 48px;
            font-weight: bold;
            font-size: 1.6em;
            color: #222;
            background: #fff;
            letter-spacing: 0.05em;
            box-sizing: border-box;
            margin: 12px 0 0 0;
        }
    </style>
</head>

<body>
    <div class="border">
        @if($is_reissue)
        <span class="reissue-label">再発行</span>
        @endif
        <div class="right">
            No. {{ $inv->seq ?? '' }}<br>
            発行日: {{ !empty($inv->published_at) ? \Carbon\Carbon::parse($inv->published_at)->format('Y年m月d日') : '' }}
        </div>
        <div class="title" style="font-size:20px; font-weight:bold;">領収書</div>
        <div>ID: {{ $contract->contract_id ?? '' }}</div>
        <div><span style="border-bottom:1px solid #222;">{{ $inv->inv_name ?? '' }}</span></div>
        <table class="table">
            <tr>
                <td class="left">契約駐輪場名</td>
                <td class="right">{{ $contract->park_name ?? '' }}</td>
            </tr>
            <tr>
                <td class="left">小計（10％対象）</td>
                <td class="right">
                    {{ isset($contract->contract_money) ? number_format(floor($contract->contract_money / 1.1)) : '' }} 円
                </td>
            </tr>
            <tr>
                <td class="left">消費税額（10％）</td>
                <td class="right">
                    {{ isset($contract->contract_money) ? number_format($contract->contract_money - floor($contract->contract_money / 1.1)) : '' }} 円
                </td>
            </tr>
            <tr>
                <td class="left">合計</td>
                <td class="right">{{ number_format($contract->contract_money ?? 0) }} 円</td>
            </tr>
        </table>
        <div>
            但し、<span style="border-bottom:1px solid #222;">駐輪場利用料（
                {{ !empty($contract->contract_periods) ? \Carbon\Carbon::parse($contract->contract_periods)->format('Y年m月d日') : '' }}
                ～
                {{ !empty($contract->contract_periode) ? \Carbon\Carbon::parse($contract->contract_periode)->format('Y年m月d日') : '' }}
                ）</span>として<br>
            {{ !empty($contract->contract_payment_day) ? \Carbon\Carbon::parse($contract->contract_payment_day)->format('Y年m月d日') : '' }}に上記金額を正に領収いたしました。
        </div>
        <table style="width:100%; margin-top:40px;">
            <tr>
                <td style="width:55%"></td>
                <td>
                    <div class="company">
                        <span style="font-size:20px; font-weight:bold;">{{ $inv_setting->t_name ?? '' }}</span><br>
                        〒{{ $inv_setting->zipcode }}<br>
                        {{ $inv_setting->adrs }}@if(!empty($inv_setting->bldg)){{ $inv_setting->bldg }}@endif
                        <br>適格事業者番号:{{ $inv_setting->t_number ?? '' }}<br>
                        @if(!empty($inv_setting->tel_num))
                        TEL:{{ $inv_setting->tel_num}}<br>
                        @endif
                        @if(!empty($inv_setting->fax_num))
                        FAX:{{ $inv_setting->fax_num}}<br>
                        @endif
                    </div>
                </td>
                @php
                $stamp_file = null;
                if (!empty($inv_setting->company_image_path)) {
                // company_image_path: storage/app/public/xxx.png → other-storage/xxx.png
                $stamp_file = str_replace('storage/app/public/', 'other-storage/', $inv_setting->company_image_path);
                }
                @endphp
                @if($stamp_file)
                <td><img src="{{ asset($stamp_file) }}" class="stamp"></td>
                @endif
            </tr>
        </table>
    </div>
</body>

</html>