Procházet zdrojové kódy

Updated import, export, products table (removed columns)

Alexander Musikhin před 7 měsíci
rodič
revize
626cabe354

+ 2 - 4
app/Http/Controllers/ProductController.php

@@ -20,18 +20,16 @@ class ProductController extends Controller
         'header'    => [
             'id'                        => 'ID',
             'year'                      => 'Год',
-            'nomenclature_number'       => 'Номер номенклатуры',
             'article'                   => 'Артикул',
+            'nomenclature_number'       => 'Номер номенклатуры',
             'manufacturer'              => 'Производитель',
             'name_tz'                   => 'Наименование ТЗ',
             'type_tz'                   => 'Тип по ТЗ',
             'type'                      => 'Тип',
             'manufacturer_name'         => 'Наименование производителя',
             'sizes'                     => 'Размеры',
-            'price_status'              => 'Статус цены',
             'product_price_txt'         => 'Цена товара',
             'installation_price_txt'    => 'Цена установки',
-            'service_price_txt'         => 'Цена обслуживания',
             'total_price_txt'           => 'Итоговая цена',
             'note'                      => 'Примечания',
             'created_at'                => 'Дата создания',
@@ -50,7 +48,7 @@ class ProductController extends Controller
         $model = new Product;
         // fill filters
         $this->createFilters($model, 'type_tz', 'type');
-        $this->createRangeFilters($model, 'nomenclature_number', 'product_price', 'installation_price', 'service_price', 'total_price');
+        $this->createRangeFilters($model, 'nomenclature_number', 'product_price', 'installation_price', 'total_price');
         $this->createDateFilters($model, 'created_at');
 
         // create request

+ 3 - 11
app/Models/Product.php

@@ -17,6 +17,7 @@ class Product extends Model
 
     protected $fillable = [
         'year',
+        'article',
         'name_tz',
         'type_tz',
         'nomenclature_number',
@@ -24,18 +25,15 @@ class Product extends Model
         'manufacturer',
         'unit',
         'type',
-        'price_status',
         'product_price',
         'installation_price',
-        'service_price',
         'total_price',
         'manufacturer_name',
-        'article',
         'note',
     ];
 
-    protected $appends = ['product_price', 'installation_price', 'service_price', 'total_price',
-                          'product_price_txt', 'installation_price_txt', 'service_price_txt', 'total_price_txt',];
+    protected $appends = ['product_price', 'installation_price', 'total_price',
+                          'product_price_txt', 'installation_price_txt', 'total_price_txt',];
     protected function productPrice(): Attribute
     {
         return Attribute::make(
@@ -82,12 +80,6 @@ class Product extends Model
         );
     }
 
-    protected function servicePriceTxt(): Attribute
-    {
-        return Attribute::make(
-            get: fn($value) => Price::format($this->service_price),
-        );
-    }
 
     protected function totalPriceTxt(): Attribute
     {

+ 12 - 16
app/Services/ExportService.php

@@ -64,24 +64,20 @@ class ExportService
         $sum_format = '#,##0.00\ "₽";[Red]\-#,##0.00\ "₽"';
 
         foreach ($products as $product) {
-            $sheet->setCellValue('B' . $i, $product->name_tz);
-            $sheet->setCellValue('C' . $i, $product->type_tz);
-            $sheet->setCellValue('D' . $i, $product->nomenclature_number);
-            $sheet->setCellValue('E' . $i, $product->sizes);
-            $sheet->setCellValue('F' . $i, $product->manufacturer);
-            $sheet->setCellValue('G' . $i, $product->unit);
-            $sheet->setCellValue('H' . $i, $product->type);
-            $sheet->setCellValue('I' . $i, $product->price_status);
+            $sheet->setCellValue('B' . $i, $product->article);
+            $sheet->setCellValue('C' . $i, $product->name_tz);
+            $sheet->setCellValue('D' . $i, $product->type_tz);
+            $sheet->setCellValue('E' . $i, $product->nomenclature_number);
+            $sheet->setCellValue('F' . $i, $product->sizes);
+            $sheet->setCellValue('G' . $i, $product->manufacturer);
+            $sheet->setCellValue('H' . $i, $product->unit);
+            $sheet->setCellValue('I' . $i, $product->type);
             $sheet->setCellValue('J' . $i, $product->product_price);
             $sheet->setCellValue('K' . $i, $product->installation_price);
-            $sheet->setCellValue('L' . $i, $product->service_price);
-            $sheet->setCellValue('M' . $i, $product->total_price);
-            $sheet->setCellValue('N' . $i, $product->manufacturer_name);
-            $sheet->setCellValue('O' . $i, $product->article);
-            $sheet->setCellValue('P' . $i, $product->note);
-
-            $sheet->getStyle("J{$i}:M{$i}")->getNumberFormat()->setFormatCode($sum_format);
-
+            $sheet->setCellValue('L' . $i, $product->total_price);
+            $sheet->setCellValue('M' . $i, $product->manufacturer_name);
+            $sheet->setCellValue('N' . $i, $product->note);
+            $sheet->getStyle("J{$i}:L{$i}")->getNumberFormat()->setFormatCode($sum_format);
             $i++;
         }
 

+ 13 - 17
app/Services/ImportService.php

@@ -11,6 +11,7 @@ class ImportService
 {
     const HEADERS_TO_FIELDS = [
         "Фото" => '',
+        "Артикул образца"               => 'article',
         "Наименование по ТЗ"            => 'name_tz',
         "Тип по ТЗ"                     => 'type_tz',
         "№ по номенкл."                 => 'nomenclature_number',
@@ -18,13 +19,10 @@ class ImportService
         "Производитель"                 => 'manufacturer',
         "ед. изм."                      => 'unit',
         "Тип оборудования"              => 'type',
-        "Статус цены"                   => 'price_status',
         "Цена поставки"                 => 'product_price',
         "Цена установки"                => 'installation_price',
-        "Цена обслуживания"             => 'service_price',
         "Итого цена"                    => 'total_price',
-        "Наименование производителя"    => 'manufacturer_name',
-        "Артикул образца"               => 'article',
+        "Наименование по паспорту"      => 'manufacturer_name',
         "Примечание"                    => 'note',
     ];
 
@@ -55,22 +53,20 @@ class ImportService
                 if($record[0] === 'Фото') continue;
 
                 Product::query()
-                    ->updateOrCreate(['year' => $year, 'nomenclature_number' => $record[3]],
+                    ->updateOrCreate(['year' => $year, 'nomenclature_number' => $record[4]],
                     [
-                        'name_tz'           => $record[1],
-                        'type_tz'           => $record[2],
-                        'sizes'             => $record[4],
-                        'manufacturer'      => $record[5],
-                        'unit'              => $record[6],
-                        'type'              => $record[7],
-                        'price_status'      => $record[8],
+                        'article'           => $record[1],
+                        'name_tz'           => $record[2],
+                        'type_tz'           => $record[3],
+                        'sizes'             => $record[5],
+                        'manufacturer'      => $record[6],
+                        'unit'              => $record[7],
+                        'type'              => $record[8],
                         'product_price'     => $record[9],
                         'installation_price'=> $record[10],
-                        'service_price'     => $record[11],
-                        'total_price'       => $record[12],
-                        'manufacturer_name' => $record[13],
-                        'article'           => $record[14],
-                        'note'              => $record[15],
+                        'total_price'       => $record[11],
+                        'manufacturer_name' => $record[12],
+                        'note'              => $record[13],
                     ]);
             }
         } else {

+ 0 - 2
database/migrations/2024_12_19_143844_create_products_table.php

@@ -22,10 +22,8 @@ return new class extends Migration
             $table->string('manufacturer');
             $table->string('unit');
             $table->string('type');
-            $table->string('price_status');
             $table->unsignedBigInteger('product_price');
             $table->unsignedBigInteger('installation_price');
-            $table->unsignedBigInteger('service_price');
             $table->unsignedBigInteger('total_price');
             $table->text('manufacturer_name');
             $table->string('article');

binární
templates/ExportCatalogTemplate.xlsx