소스 검색

fix prima nota

FabioFratini 7 달 전
부모
커밋
639051edfb
1개의 변경된 파일55개의 추가작업 그리고 9개의 파일을 삭제
  1. 55 9
      app/Http/Livewire/Record.php

+ 55 - 9
app/Http/Livewire/Record.php

@@ -58,6 +58,7 @@ class Record extends Component
         $this->payments = \App\Models\PaymentMethod::select('id', 'name', 'type')->where('enabled', true)->where('money', false)->get();
     }
 
+
     private function generateExportData($fromDate, $toDate)
     {
         $exportRecords = array();
@@ -66,7 +67,25 @@ class Record extends Component
         $exclude_from_records = \App\Models\Member::where('exclude_from_records', true)->pluck('id')->toArray();
 
         $datas = \App\Models\Record::with('member', 'supplier', 'payment_method')
-            ->select('records.*', 'records_rows.*')
+            ->select(
+                'records.*',
+                'records_rows.id as row_id',
+                'records_rows.record_id',
+                'records_rows.causal_id',
+                'records_rows.amount',
+                'records_rows.note',
+                'records_rows.when',
+                'records_rows.vat_id',
+                'records_rows.imponibile',
+                'records_rows.aliquota_iva',
+                'records_rows.imposta',
+                'records_rows.divisa',
+                'records_rows.numero_linea',
+                'records_rows.prezzo_unitario',
+                'records_rows.quantita',
+                'records_rows.created_at as row_created_at',
+                'records_rows.updated_at as row_updated_at'
+            )
             ->join('records_rows', 'records.id', '=', 'records_rows.record_id')
             ->whereBetween('date', [$fromDate, $toDate])
             ->where(function ($query) {
@@ -121,7 +140,8 @@ class Record extends Component
                     $amount = $data->amount;
                 }
 
-                $typeLabel = $data->commercial ? 'Commerciale' : 'Non Commerciale';
+                $isCommercial = ($data->commercial == 1 || $data->commercial === '1' || $data->commercial === true);
+                $typeLabel = $isCommercial ? 'Commerciale' : 'Non Commerciale';
 
                 $nominativo = '';
                 if ($data->type == "IN") {
@@ -202,7 +222,19 @@ class Record extends Component
         $exclude_from_records = \App\Models\Member::where('exclude_from_records', true)->pluck('id')->toArray();
 
         $datas = \App\Models\Record::with('member', 'supplier', 'payment_method')
-            ->select('records.*', 'records_rows.*')
+            ->select(
+                'records.*',
+                'records_rows.id as row_id',
+                'records_rows.record_id',
+                'records_rows.causal_id',
+                'records_rows.amount',
+                'records_rows.note',
+                'records_rows.when',
+                'records_rows.vat_id',
+                'records_rows.imponibile',
+                'records_rows.aliquota_iva',
+                'records_rows.imposta'
+            )
             ->join('records_rows', 'records.id', '=', 'records_rows.record_id')
             ->whereBetween('date', [$fromDate, $toDate])
             ->where(function ($query) {
@@ -325,13 +357,13 @@ class Record extends Component
                 break;
 
             case 'ULTIMO TRIMESTRE':
-                $this->fromDate = $today->copy()->subMonths(3)->startOfMonth()->format('Y-m-d');
-                $this->toDate = $today->copy()->subMonth()->endOfMonth()->format('Y-m-d');
+                $this->fromDate = $today->copy()->subMonths(3)->format('Y-m-d');
+                $this->toDate = $today->format('Y-m-d');
                 break;
 
             case 'ULTIMO QUADRIMESTRE':
-                $this->fromDate = $today->copy()->subMonths(4)->startOfMonth()->format('Y-m-d');
-                $this->toDate = $today->copy()->subMonth()->endOfMonth()->format('Y-m-d');
+                $this->fromDate = $today->copy()->subMonths(4)->format('Y-m-d');
+                $this->toDate = $today->format('Y-m-d');
                 break;
         }
     }
@@ -392,6 +424,7 @@ class Record extends Component
         return $ret;
     }
 
+
     public function render()
     {
         $month = 0;
@@ -403,7 +436,19 @@ class Record extends Component
         $exclude_from_records = \App\Models\Member::where('exclude_from_records', true)->pluck('id')->toArray();
 
         $datas = \App\Models\Record::with('member', 'supplier', 'payment_method')
-            ->select('records.*', 'records_rows.*')
+            ->select(
+                'records.*',
+                'records_rows.id as row_id',
+                'records_rows.record_id',
+                'records_rows.causal_id',
+                'records_rows.amount',
+                'records_rows.note',
+                'records_rows.when',
+                'records_rows.vat_id',
+                'records_rows.imponibile',
+                'records_rows.aliquota_iva',
+                'records_rows.imposta'
+            )
             ->join('records_rows', 'records.id', '=', 'records_rows.record_id')
             ->whereBetween('date', [$this->appliedFromDate, $this->appliedToDate])
             ->where(function ($query) {
@@ -461,7 +506,8 @@ class Record extends Component
                     $amount = $data->amount;
                 }
 
-                $typeLabel = $data->commercial ? 'Commerciale' : 'Non Commerciale';
+                $isCommercial = ($data->commercial == 1 || $data->commercial === '1' || $data->commercial === true);
+                $typeLabel = $isCommercial ? 'Commerciale' : 'Non Commerciale';
 
                 $nominativo = '';
                 if ($data->type == "IN") {