Ver código fonte

numero fattura

FabioFratini 8 meses atrás
pai
commit
07be5a0375

+ 9 - 4
app/Http/Livewire/RecordOUT.php

@@ -88,6 +88,8 @@ class RecordOUT extends Component
 
     public $vats = array();
 
+    public $numero_fattura;
+
 
     protected $rules = [
         'supplier_id' => 'required',
@@ -129,6 +131,7 @@ class RecordOUT extends Component
         $this->date = date("Y-m-d");
         $this->data_pagamento = date("Y-m-d");
         //$this->attachment = null;
+        $this->numero_fattura = null;
         $this->type = 'OUT';
         $this->commercial = 1;
         $this->rows = array();
@@ -370,9 +373,9 @@ class RecordOUT extends Component
             $this->attachment->storeAs('public', $name);
         } */
 
-        $invoiceNumber = null;
-
-        $invoiceNumber = 'USC-' . date('YmdHis');
+        if($this->numero_fattura == null || $this->numero_fattura == '') {
+            $this->numero_fattura = 'USC-' . date('Ymd');
+        }
 
 
         if (empty($this->data_pagamento) || $this->data_pagamento == '1970-01-01') {
@@ -396,7 +399,7 @@ class RecordOUT extends Component
                 'type' => $this->type,
                 'amount' => $this->currencyToDouble($this->amount),
                 'commercial' => $this->commercial,
-                'numero_fattura' => $invoiceNumber,
+                'numero_fattura' => $this->numero_fattura,
                 'is_paid' => $is_paid,
             ]);
             Log::info("Record data being inserted: " . json_encode($record));
@@ -470,6 +473,7 @@ class RecordOUT extends Component
                 $this->date = date("Y-m-d", strtotime($record->date));
                 $this->data_pagamento =  $record->data_pagamento;
                 $this->type = $record->type;
+                $this->numero_fattura = $record->numero_fattura;
                 //$attachment = $record->attachment;
                 $this->commercial = $record->commercial;
                 $this->dataId = $record->id;
@@ -554,6 +558,7 @@ class RecordOUT extends Component
                 'type' => $this->type,
                 'commercial' => $this->commercial,
                 'is_paid' => $is_paid,
+                'numero_fattura' => $this->numero_fattura,
                 //'attachment' => $this->attachment,
             ]);
 

+ 12 - 2
resources/views/livewire/records_out.blade.php

@@ -175,6 +175,7 @@
             <table class="table tablesaw tableHead tablesaw-stack table--lista_entrate tableHead" id="tablesaw-350" width="100%">
                 <thead>
                     <tr>
+                        <th scope="col">N° Fattura</th>
                         <th scope="col">Data</th>
                         <th scope="col">Importo</th>
                         <th scope="col">Fornitore</th>
@@ -258,7 +259,7 @@
                         <div class="row gx-2 mt-5">
                             <span class="title-form d-block w-100">Metodo di pagamento</span>
 
-                            <div class="col-md-12">
+                            <div class="col-md-6">
                                 <select name="payment_method_id" class="form-select paymentClass @error('payment_method_id') is-invalid @enderror" aria-label="Seleziona un metodo di pagamento" wire:model="payment_method_id">
                                     <option value="">--Seleziona--
                                     @foreach($payments as $payment)
@@ -271,6 +272,14 @@
                             </div>
                         </div>
 
+                        <div class="row gx-2 mt-5">
+                            <span class="title-form d-block w-100">N° Fattura</span>
+                            <div class="col-md-12">
+                                <input class="form-control " type="text" placeholder="Numero fattura" wire:model="numero_fattura">
+                            </div>
+                        </div>
+
+
                         @foreach($rows as $idx => $row)
 
                             <div class="row gx-2 mt-5" wire:ignore.self>
@@ -577,7 +586,7 @@
                                     <td id="recordSupplier"></td>
                                 </tr>
                                 <tr>
-                                    <th>Metodo di Pagamento:</th>
+                                    <th>Metodo di pagamento:</th>
                                     <td id="recordPaymentMethod"></td>
                                 </tr>
                             </table>
@@ -941,6 +950,7 @@
                     }
                 },
                 columns: [
+                    { data: 'numero_fattura' },
                     {
                         data: "date",
                         render: function (data, type){

+ 1 - 0
routes/web.php

@@ -772,6 +772,7 @@ Route::get('/get_record_out', function () {
         $datas[] = array(
             'date' => $r->date,
             'total' => formatPrice($r->getTotal()),
+            'numero_fattura' => $r->numero_fattura,
             'supplier' => $r->supplier->name,
             'causals' => $causals,
             'payment' => $r->payment_method->name,