Browse Source

fatture in cloud

Roberto Santini 3 weeks ago
parent
commit
37ff3e5eda

+ 2
- 0
app/Http/Controllers/FatturazioneController.php View File

@@ -118,6 +118,7 @@ class FatturazioneController extends Controller implements HasMiddleware
118 118
       'data_scadenza' => 'nullable|date',
119 119
       'periodo_da' => 'nullable|date',
120 120
       'periodo_a' => 'nullable|date',
121
+      'oggetto' => 'nullable|string|max:200',
121 122
       'ragione_sociale' => 'nullable|string|max:255',
122 123
       'piva' => 'nullable|string|max:255',
123 124
       'cod_fiscale' => 'nullable|string|max:255',
@@ -150,6 +151,7 @@ class FatturazioneController extends Controller implements HasMiddleware
150 151
       $fattura->data_scadenza = $validated['data_scadenza'] ?? null;
151 152
       $fattura->periodo_da = $validated['periodo_da'] ?? null;
152 153
       $fattura->periodo_a = $validated['periodo_a'] ?? null;
154
+      $fattura->oggetto = trim((string) ($validated['oggetto'] ?? '')) ?: null;
153 155
       $fattura->ragione_sociale = $validated['ragione_sociale'] ?? null;
154 156
       $fattura->piva = $validated['piva'] ?? null;
155 157
       $fattura->cod_fiscale = $validated['cod_fiscale'] ?? null;

+ 23
- 0
app/Models/Fattura.php View File

@@ -5,6 +5,29 @@ use Carbon\Carbon;
5 5
 
6 6
 class Fattura extends \App\Models\AbstractModels\AbstractFattura
7 7
 {
8
+    public function getFillable()
9
+    {
10
+        return array_merge(parent::getFillable(), [
11
+            'oggetto',
12
+        ]);
13
+    }
14
+
15
+    public function oggettoFic(): string
16
+    {
17
+        $oggetto = trim((string) $this->oggetto);
18
+        if ($oggetto !== '') {
19
+            return $oggetto;
20
+        }
21
+        if ($this->periodo_da && $this->periodo_a) {
22
+            return 'Periodo '
23
+                .Carbon::parse($this->periodo_da)->format('d/m/Y')
24
+                .' – '
25
+                .Carbon::parse($this->periodo_a)->format('d/m/Y');
26
+        }
27
+
28
+        return '';
29
+    }
30
+
8 31
     public const STATO_BOZZA = 'bozza';
9 32
     public const STATO_EMESSA = 'emessa';
10 33
     public const STATO_PAGATA = 'pagata';

+ 3
- 5
app/Services/FatturaFicService.php View File

@@ -179,11 +179,9 @@ class FatturaFicService
179 179
             ],
180 180
         ];
181 181
 
182
-        if ($fattura->periodo_da && $fattura->periodo_a) {
183
-            $payload['visible_subject'] = 'Periodo '
184
-                .Carbon::parse($fattura->periodo_da)->format('d/m/Y')
185
-                .' – '
186
-                .Carbon::parse($fattura->periodo_a)->format('d/m/Y');
182
+        $oggetto = trim($fattura->oggettoFic());
183
+        if ($oggetto !== '') {
184
+            $payload['visible_subject'] = mb_substr($oggetto, 0, 200);
187 185
         }
188 186
 
189 187
         return $payload;

+ 1
- 0
app/Services/FatturazioneGeneraService.php View File

@@ -148,6 +148,7 @@ class FatturazioneGeneraService
148 148
             $fattura->data_scadenza = Carbon::today()->addDays(30)->toDateString();
149 149
             $fattura->periodo_da = $from->toDateString();
150 150
             $fattura->periodo_a = $to->toDateString();
151
+            $fattura->oggetto = 'Periodo '.$from->format('d/m/Y').' – '.$to->format('d/m/Y');
151 152
             $fattura->iva_percentuale = Config::ivaPercentualeDefault();
152 153
             $fattura->snapshotDaUser($user);
153 154
             $fattura->meta = [

+ 22
- 0
database/migrations/2026_10_12_231200_add_oggetto_to_fattura_table.php View File

@@ -0,0 +1,22 @@
1
+<?php
2
+
3
+use Illuminate\Database\Migrations\Migration;
4
+use Illuminate\Database\Schema\Blueprint;
5
+use Illuminate\Support\Facades\Schema;
6
+
7
+return new class extends Migration
8
+{
9
+    public function up(): void
10
+    {
11
+        Schema::table('fattura', function (Blueprint $table) {
12
+            $table->string('oggetto', 200)->nullable()->after('periodo_a');
13
+        });
14
+    }
15
+
16
+    public function down(): void
17
+    {
18
+        Schema::table('fattura', function (Blueprint $table) {
19
+            $table->dropColumn('oggetto');
20
+        });
21
+    }
22
+};

+ 8
- 0
resources/views/fatturazione/show.blade.php View File

@@ -162,6 +162,11 @@
162 162
           <label class="form-label" for="periodo_a">Periodo a</label>
163 163
           <input type="date" name="periodo_a" id="periodo_a" class="form-control" value="{{ old('periodo_a', $dataInput($fattura->periodo_a)) }}">
164 164
         </div>
165
+        <div class="col-12">
166
+          <label class="form-label" for="oggetto">Oggetto</label>
167
+          <input type="text" name="oggetto" id="oggetto" class="form-control" maxlength="200" value="{{ old('oggetto', $fattura->oggettoFic()) }}">
168
+          <div class="form-text">Compare sulla fattura in Fatture in Cloud.</div>
169
+        </div>
165 170
 
166 171
         <div class="col-md-6">
167 172
           <label class="form-label" for="ragione_sociale">Ragione sociale / cliente</label>
@@ -340,6 +345,9 @@
340 345
         <hr>
341 346
         <p class="mb-1"><strong>Data:</strong> {{ $fattura->data ? \Carbon\Carbon::parse($fattura->data)->format('d/m/Y') : '—' }}</p>
342 347
         <p class="mb-1"><strong>Scadenza:</strong> {{ $fattura->data_scadenza ? \Carbon\Carbon::parse($fattura->data_scadenza)->format('d/m/Y') : '—' }}</p>
348
+        @if($fattura->oggettoFic() !== '')
349
+        <p class="mb-1"><strong>Oggetto:</strong> {{ $fattura->oggettoFic() }}</p>
350
+        @endif
343 351
         <p class="mb-0"><strong>Periodo:</strong>
344 352
           {{ $fattura->periodo_da ? \Carbon\Carbon::parse($fattura->periodo_da)->format('d/m/Y') : '—' }}
345 353
           –

Loading…
Cancel
Save