Andrew Wallo 5 个月前
父节点
当前提交
e6762fb80a

+ 13
- 4
app/DTO/DocumentDTO.php 查看文件

26
         public string $date,
26
         public string $date,
27
         public string $dueDate,
27
         public string $dueDate,
28
         public string $currencyCode,
28
         public string $currencyCode,
29
-        public string $subtotal,
29
+        public ?string $subtotal,
30
         public ?string $discount,
30
         public ?string $discount,
31
         public ?string $tax,
31
         public ?string $tax,
32
         public string $total,
32
         public string $total,
50
 
50
 
51
         $currencyCode = $document->currency_code ?? CurrencyAccessor::getDefaultCurrency();
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
         return new self(
62
         return new self(
54
             header: $document->header,
63
             header: $document->header,
55
             subheader: $document->subheader,
64
             subheader: $document->subheader,
61
             date: $document->documentDate(),
70
             date: $document->documentDate(),
62
             dueDate: $document->dueDate(),
71
             dueDate: $document->dueDate(),
63
             currencyCode: $currencyCode,
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
             total: self::formatToMoney($document->total, $currencyCode),
76
             total: self::formatToMoney($document->total, $currencyCode),
68
             amountDue: self::formatToMoney($document->amountDue(), $currencyCode),
77
             amountDue: self::formatToMoney($document->amountDue(), $currencyCode),
69
             company: CompanyDTO::fromModel($document->company),
78
             company: CompanyDTO::fromModel($document->company),

+ 2
- 0
app/Filament/Forms/Components/CustomTableRepeater.php 查看文件

40
     {
40
     {
41
         parent::setUp();
41
         parent::setUp();
42
 
42
 
43
+        $this->minItems(1);
44
+
43
         $this->extraAttributes(function (): array {
45
         $this->extraAttributes(function (): array {
44
             $attributes = [];
46
             $attributes = [];
45
 
47
 

+ 5
- 1
app/Utilities/RateCalculator.php 查看文件

28
         return (int) round($decimalRate * self::PERCENTAGE_SCALING_FACTOR);
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
         $format = Localization::firstOrFail()->number_format->value;
37
         $format = Localization::firstOrFail()->number_format->value;
34
         [$decimalMark, $thousandsSeparator] = NumberFormat::from($format)->getFormattingParameters();
38
         [$decimalMark, $thousandsSeparator] = NumberFormat::from($format)->getFormattingParameters();
35
 
39
 

+ 1
- 1
resources/views/components/company/document-template/container.blade.php 查看文件

6
     <div
6
     <div
7
         @class([
7
         @class([
8
             'doc-template-paper bg-[#ffffff] dark:bg-gray-800 rounded-sm shadow-xl',
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
             'w-[38.25rem] h-[49.5rem] overflow-hidden' => $preview === true,
10
             'w-[38.25rem] h-[49.5rem] overflow-hidden' => $preview === true,
11
         ])
11
         ])
12
         @style([
12
         @style([

+ 1
- 1
resources/views/filament/company/components/document-templates/default.blade.php 查看文件

128
     </x-company.document-template.line-items>
128
     </x-company.document-template.line-items>
129
 
129
 
130
     <!-- Footer Notes -->
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
         <div>
132
         <div>
133
             <h4 class="font-semibold mb-2">Terms & Conditions</h4>
133
             <h4 class="font-semibold mb-2">Terms & Conditions</h4>
134
             <p class="break-words line-clamp-4">{{ $document->terms }}</p>
134
             <p class="break-words line-clamp-4">{{ $document->terms }}</p>

+ 7
- 5
resources/views/filament/infolists/components/document-templates/classic.blade.php 查看文件

107
             <div class="w-[40%]">
107
             <div class="w-[40%]">
108
                 <table class="w-full table-fixed whitespace-nowrap">
108
                 <table class="w-full table-fixed whitespace-nowrap">
109
                     <tbody class="text-sm">
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
                     @if($document->discount)
116
                     @if($document->discount)
115
                         <tr class="text-success-800 dark:text-success-600">
117
                         <tr class="text-success-800 dark:text-success-600">
116
                             <td class="text-right py-2">Discount:</td>
118
                             <td class="text-right py-2">Discount:</td>
144
     </x-company.document-template.line-items>
146
     </x-company.document-template.line-items>
145
 
147
 
146
     <!-- Footer -->
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
         <h4 class="font-semibold mb-2">Terms & Conditions</h4>
150
         <h4 class="font-semibold mb-2">Terms & Conditions</h4>
149
         <p class="break-words line-clamp-4">{{ $document->terms }}</p>
151
         <p class="break-words line-clamp-4">{{ $document->terms }}</p>
150
     </x-company.document-template.footer>
152
     </x-company.document-template.footer>

+ 7
- 5
resources/views/filament/infolists/components/document-templates/default.blade.php 查看文件

90
             @endforeach
90
             @endforeach
91
             </tbody>
91
             </tbody>
92
             <tfoot class="text-sm summary-section">
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
             @if($document->discount)
100
             @if($document->discount)
99
                 <tr class="text-success-800 dark:text-success-600">
101
                 <tr class="text-success-800 dark:text-success-600">
100
                     <td class="pl-6 py-2" colspan="2"></td>
102
                     <td class="pl-6 py-2" colspan="2"></td>

+ 7
- 5
resources/views/filament/infolists/components/document-templates/modern.blade.php 查看文件

92
             @endforeach
92
             @endforeach
93
             </tbody>
93
             </tbody>
94
             <tfoot class="text-sm summary-section">
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
             @if($document->discount)
102
             @if($document->discount)
101
                 <tr class="text-success-800 dark:text-success-600">
103
                 <tr class="text-success-800 dark:text-success-600">
102
                     <td class="pl-6 py-2" colspan="2"></td>
104
                     <td class="pl-6 py-2" colspan="2"></td>

正在加载...
取消
保存