Browse Source

entrate - aggiunto campo anno per progressivo ricevuta

ferrari 1 week ago
parent
commit
592110fa53

+ 8 - 3
app/Http/Livewire/RecordIN.php

@@ -285,6 +285,7 @@ class RecordIN extends Component
         $this->commercial = 0;
         $this->corrispettivo_fiscale = false;
         $this->date = date("Y-m-d");
+        $this->year = date("Y");
         $this->type = 'IN';
         $this->deleted = false;
         $this->financial_movement = false;
@@ -668,6 +669,7 @@ class RecordIN extends Component
                         'commercial' => $this->commercial,
                         'corrispettivo_fiscale' => $this->corrispettivo_fiscale,
                         'date' => $this->date,
+                        'year' => $this->year,
                         'type' => $this->type,
                         'amount' => $price,
                         'financial_movement' => $this->financial_movement,
@@ -780,6 +782,7 @@ class RecordIN extends Component
                 'commercial' => $this->commercial,
                 'corrispettivo_fiscale' => $this->corrispettivo_fiscale,
                 'date' => $this->date,
+                'year' => $this->year,
                 'type' => $this->type,
                 'amount' => $totalNet,
                 'prediscount_amount' => $totalGross,
@@ -935,6 +938,7 @@ class RecordIN extends Component
                 $this->commercial = $record->commercial;
                 $this->corrispettivo_fiscale = $record->corrispettivo_fiscale;
                 $this->date = date("Y-m-d", strtotime($record->date));
+                $this->year = $record->year;
                 $this->type = $record->type;
                 $this->deleted = $record->deleted;
                 $this->financial_movement = $record->financial_movement;
@@ -1119,6 +1123,7 @@ class RecordIN extends Component
                 'commercial' => $this->commercial,
                 'corrispettivo_fiscale' => $this->corrispettivo_fiscale,
                 'date' => date("Y-m-d", strtotime($this->date)),
+                'year' => $this->year,
                 'type' => $this->type,
                 'financial_movement' => $this->financial_movement,
                 'deleted' => $this->deleted,
@@ -1376,7 +1381,7 @@ class RecordIN extends Component
 
             if ($create) {
                 $number = 1;
-                $exist = \App\Models\Receipt::where('year', date("Y"))->orderBy('number', 'DESC')->first();
+                $exist = \App\Models\Receipt::where('year', $this->year)->orderBy('number', 'DESC')->first();
                 if ($exist != null)
                     $number = $exist->number + 1;
 
@@ -1399,7 +1404,7 @@ class RecordIN extends Component
                     'payment_method_id' => $this->payment_method_id,
                     'number' => $number,
                     'date' => $this->date,
-                    'year' => date("Y"),
+                    'year' => $this->year,
                     'type' => $this->type,
                     'parent' => $this->parent,
                     'status' => 1,
@@ -1431,7 +1436,7 @@ class RecordIN extends Component
 
                 sendReceiptEmail($receipt);
 
-                session()->flash('receipt', "Ricevuta " . $number . "/" . date("Y") . " creata correttamente");
+                session()->flash('receipt', "Ricevuta " . $number . "/" . $this->year . " creata correttamente");
 
                 $this->emit('showReceipt', $this->currentReceip->id);
             }

+ 1 - 0
app/Models/Record.php

@@ -17,6 +17,7 @@ class Record extends Model
         'destination_id',
         'origin_id',
         'date',
+        'year',
         'data_pagamento',
         //'month',
         //'year',

+ 32 - 0
database/migrations/2026_01_20_101338_add_year_to_records.php

@@ -0,0 +1,32 @@
+<?php
+
+use App\Database\Migrations\TenantMigration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+return new class extends TenantMigration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('records', function (Blueprint $table) {
+            $table->integer('year')->nullable()->after('date');
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('records', function (Blueprint $table) {
+            $table->dropColumn('year');
+        });
+    }
+};

+ 8 - 3
resources/views/livewire/records_in.blade.php

@@ -265,7 +265,12 @@
                                     <input id="date" type="date" class="form-control"  wire:model="date" {{$this->dataId > 0 && !$isDuplicate ? 'disabled' : ''}}>
                                 </div>
                             </div>
-                            <div class="col-md-6">&nbsp;</div>
+                            <div class="col-md-6 mt-3">
+                                <span class="title-form d-block w-100">Anno</span>
+                                <div class="input-group mb-3">
+                                    <input id="year" type="year" class="form-control" wire:model="year" {{$this->dataId > 0 && !$isDuplicate ? 'disabled' : ''}}>
+                                </div>
+                            </div>
 
 
                             <div class="col-md-6">
@@ -699,7 +704,7 @@
                                                 <span style="color:red">Devi selezionare un genitore</span>
                                             @else
 
-                                                    <button class="btn--ui primary sendInvoice d-flex ms-auto" wire:click.prevent="store(true)" onclick='window.location.href = "#top";'><i class="ico--ui sendingBtn"></i><span>inserisci {{!$commercial ? 'genera ricevuta' : ''}}</span></button>
+                                                    <button class="btn--ui primary sendInvoice d-flex ms-auto" wire:click.prevent="store(true)" onclick='window.location.href = "#top";'><i class="ico--ui sendingBtn"></i><span>inserisci {{!$commercial ? ' e genera ricevuta' : ''}}</span></button>
 
                                             @endif
 
@@ -711,7 +716,7 @@
                                             <span style="color:red">Devi selezionare un genitore</span>
                                         @else
 
-                                                <button class="btn--ui primary sendInvoice d-flex ms-auto" wire:click.prevent="update({{!$commercial}})"><i class="ico--ui sendingBtn"></i><span>inserisci {{!$commercial ? 'genera ricevuta' : ''}}</span></button>
+                                                <button class="btn--ui primary sendInvoice d-flex ms-auto" wire:click.prevent="update({{!$commercial}})"><i class="ico--ui sendingBtn"></i><span>inserisci {{!$commercial ? ' e genera ricevuta' : ''}}</span></button>
 
                                         @endif
                                     @endif