Andrew Wallo 5 달 전
부모
커밋
e6762fb80a

+ 13
- 4
app/DTO/DocumentDTO.php 파일 보기

@@ -26,7 +26,7 @@ readonly class DocumentDTO
26 26
         public string $date,
27 27
         public string $dueDate,
28 28
         public string $currencyCode,
29
-        public string $subtotal,
29
+        public ?string $subtotal,
30 30
         public ?string $discount,
31 31
         public ?string $tax,
32 32
         public string $total,
@@ -50,6 +50,15 @@ readonly class DocumentDTO
50 50
 
51 51
         $currencyCode = $document->currency_code ?? CurrencyAccessor::getDefaultCurrency();
52 52
 
53
+        $discount = $document->discount_total > 0 ? self::formatToMoney($document->discount_total, $currencyCode) : null;
54
+        $tax = $document->tax_total > 0 ? self::formatToMoney($document->tax_total, $currencyCode) : null;
55
+
56
+        if (! $discount && ! $tax) {
57
+            $subtotal = null;
58
+        } else {
59
+            $subtotal = self::formatToMoney($document->subtotal, $currencyCode);
60
+        }
61
+
53 62
         return new self(
54 63
             header: $document->header,
55 64
             subheader: $document->subheader,
@@ -61,9 +70,9 @@ readonly class DocumentDTO
61 70
             date: $document->documentDate(),
62 71
             dueDate: $document->dueDate(),
63 72
             currencyCode: $currencyCode,
64
-            subtotal: self::formatToMoney($document->subtotal, $currencyCode),
65
-            discount: self::formatToMoney($document->discount_total, $currencyCode),
66
-            tax: self::formatToMoney($document->tax_total, $currencyCode),
73
+            subtotal: $subtotal,
74
+            discount: $discount,
75
+            tax: $tax,
67 76
             total: self::formatToMoney($document->total, $currencyCode),
68 77
             amountDue: self::formatToMoney($document->amountDue(), $currencyCode),
69 78
             company: CompanyDTO::fromModel($document->company),

+ 2
- 0
app/Filament/Forms/Components/CustomTableRepeater.php 파일 보기

@@ -40,6 +40,8 @@ class CustomTableRepeater extends TableRepeater
40 40
     {
41 41
         parent::setUp();
42 42
 
43
+        $this->minItems(1);
44
+
43 45
         $this->extraAttributes(function (): array {
44 46
             $attributes = [];
45 47
 

+ 5
- 1
app/Utilities/RateCalculator.php 파일 보기

@@ -28,8 +28,12 @@ class RateCalculator
28 28
         return (int) round($decimalRate * self::PERCENTAGE_SCALING_FACTOR);
29 29
     }
30 30
 
31
-    public static function parseLocalizedRate(string $value): int
31
+    public static function parseLocalizedRate(?string $value): int
32 32
     {
33
+        if (! $value) {
34
+            return 0;
35
+        }
36
+
33 37
         $format = Localization::firstOrFail()->number_format->value;
34 38
         [$decimalMark, $thousandsSeparator] = NumberFormat::from($format)->getFormattingParameters();
35 39
 

+ 1
- 1
resources/views/components/company/document-template/container.blade.php 파일 보기

@@ -6,7 +6,7 @@
6 6
     <div
7 7
         @class([
8 8
             'doc-template-paper bg-[#ffffff] dark:bg-gray-800 rounded-sm shadow-xl',
9
-            'w-full max-w-[820px] max-h-[1024px] overflow-y-auto' => $preview === false,
9
+            'w-full max-w-[820px] min-h-[1066px] max-h-[1200px] overflow-y-auto' => $preview === false,
10 10
             'w-[38.25rem] h-[49.5rem] overflow-hidden' => $preview === true,
11 11
         ])
12 12
         @style([

+ 1
- 1
resources/views/filament/company/components/document-templates/default.blade.php 파일 보기

@@ -128,7 +128,7 @@
128 128
     </x-company.document-template.line-items>
129 129
 
130 130
     <!-- Footer Notes -->
131
-    <x-company.document-template.footer class="classic-template-footer min-h-48 flex flex-col text-xs p-6">
131
+    <x-company.document-template.footer class="default-template-footer min-h-48 flex flex-col text-xs p-6">
132 132
         <div>
133 133
             <h4 class="font-semibold mb-2">Terms & Conditions</h4>
134 134
             <p class="break-words line-clamp-4">{{ $document->terms }}</p>

+ 7
- 5
resources/views/filament/infolists/components/document-templates/classic.blade.php 파일 보기

@@ -107,10 +107,12 @@
107 107
             <div class="w-[40%]">
108 108
                 <table class="w-full table-fixed whitespace-nowrap">
109 109
                     <tbody class="text-sm">
110
-                    <tr>
111
-                        <td class="text-right font-semibold py-2">Subtotal:</td>
112
-                        <td class="text-right py-2">{{ $document->subtotal }}</td>
113
-                    </tr>
110
+                    @if($document->subtotal)
111
+                        <tr>
112
+                            <td class="text-right font-semibold py-2">Subtotal:</td>
113
+                            <td class="text-right py-2">{{ $document->subtotal }}</td>
114
+                        </tr>
115
+                    @endif
114 116
                     @if($document->discount)
115 117
                         <tr class="text-success-800 dark:text-success-600">
116 118
                             <td class="text-right py-2">Discount:</td>
@@ -144,7 +146,7 @@
144 146
     </x-company.document-template.line-items>
145 147
 
146 148
     <!-- Footer -->
147
-    <x-company.document-template.footer class="classic-template-footer min-h-48 p-6 text-sm">
149
+    <x-company.document-template.footer class="default-template-footer min-h-48 p-6 text-sm">
148 150
         <h4 class="font-semibold mb-2">Terms & Conditions</h4>
149 151
         <p class="break-words line-clamp-4">{{ $document->terms }}</p>
150 152
     </x-company.document-template.footer>

+ 7
- 5
resources/views/filament/infolists/components/document-templates/default.blade.php 파일 보기

@@ -90,11 +90,13 @@
90 90
             @endforeach
91 91
             </tbody>
92 92
             <tfoot class="text-sm summary-section">
93
-            <tr>
94
-                <td class="pl-6 py-2" colspan="2"></td>
95
-                <td class="text-right font-semibold py-2">Subtotal:</td>
96
-                <td class="text-right pr-6 py-2">{{ $document->subtotal }}</td>
97
-            </tr>
93
+            @if($document->subtotal)
94
+                <tr>
95
+                    <td class="pl-6 py-2" colspan="2"></td>
96
+                    <td class="text-right font-semibold py-2">Subtotal:</td>
97
+                    <td class="text-right pr-6 py-2">{{ $document->subtotal }}</td>
98
+                </tr>
99
+            @endif
98 100
             @if($document->discount)
99 101
                 <tr class="text-success-800 dark:text-success-600">
100 102
                     <td class="pl-6 py-2" colspan="2"></td>

+ 7
- 5
resources/views/filament/infolists/components/document-templates/modern.blade.php 파일 보기

@@ -92,11 +92,13 @@
92 92
             @endforeach
93 93
             </tbody>
94 94
             <tfoot class="text-sm summary-section">
95
-            <tr>
96
-                <td class="pl-6 py-2" colspan="2"></td>
97
-                <td class="text-right font-semibold py-2">Subtotal:</td>
98
-                <td class="text-right pr-6 py-2">{{ $document->subtotal }}</td>
99
-            </tr>
95
+            @if($document->subtotal)
96
+                <tr>
97
+                    <td class="pl-6 py-2" colspan="2"></td>
98
+                    <td class="text-right font-semibold py-2">Subtotal:</td>
99
+                    <td class="text-right pr-6 py-2">{{ $document->subtotal }}</td>
100
+                </tr>
101
+            @endif
100 102
             @if($document->discount)
101 103
                 <tr class="text-success-800 dark:text-success-600">
102 104
                     <td class="pl-6 py-2" colspan="2"></td>

Loading…
취소
저장