From 70d7dc45b64c21b5eae9bed5f7ec0536d2431344 Mon Sep 17 00:00:00 2001 From: Yoga Pangestu Date: Mon, 17 Nov 2025 15:55:22 +0700 Subject: [PATCH] fix(gods): menyesuaikan cogs saat yang create datanya adalah leader --- .../Forms/Studio/Catalog/BottleForm.php | 4 +-- .../Forms/Studio/Catalog/PerfumeForm.php | 4 +-- .../Forms/Studio/Catalog/ProductForm.php | 4 +-- .../studio/catalog/bottle/form.blade.php | 28 ++++++++++--------- .../studio/catalog/perfume/form.blade.php | 27 ++++++++++-------- .../studio/catalog/product/form.blade.php | 28 ++++++++++--------- 6 files changed, 51 insertions(+), 44 deletions(-) diff --git a/app/Livewire/Forms/Studio/Catalog/BottleForm.php b/app/Livewire/Forms/Studio/Catalog/BottleForm.php index 3df2c7f..c31d1c2 100644 --- a/app/Livewire/Forms/Studio/Catalog/BottleForm.php +++ b/app/Livewire/Forms/Studio/Catalog/BottleForm.php @@ -34,7 +34,7 @@ public function rules(): array return [ 'name' => ['required', 'string', 'max:50'], 'size' => ['required', new UnsignedInteger], - 'cost_price' => ['required', new UnsignedInteger], + 'cost_price' => [Rule::requiredIf(auth()->user()->can('view cogs')), new UnsignedInteger], 'sale_price' => ['required', new UnsignedInteger], 'description' => ['nullable', 'string'], 'outlet_ids' => ['required', 'array', 'min:1'], @@ -102,7 +102,7 @@ private function prepareSavedData(): array return [ 'name' => $this->name, 'size' => $this->size, - 'cost_price' => replaceCurrency($this->cost_price), + 'cost_price' => replaceCurrency($this->cost_price == '' ? '0' : $this->cost_price), 'sale_price' => replaceCurrency($this->sale_price), 'point_per_pcs' => round($this->sale_price / 100), 'description' => $this->description, diff --git a/app/Livewire/Forms/Studio/Catalog/PerfumeForm.php b/app/Livewire/Forms/Studio/Catalog/PerfumeForm.php index b0eaf13..9983cb3 100644 --- a/app/Livewire/Forms/Studio/Catalog/PerfumeForm.php +++ b/app/Livewire/Forms/Studio/Catalog/PerfumeForm.php @@ -53,7 +53,7 @@ public function rules(): array Rule::unique('perfumes', 'sku')->ignore($this->perfume), ], 'brand_id' => ['nullable', Rule::exists('brands', 'id')], - 'cost_price' => ['required', new UnsignedInteger], + 'cost_price' => [Rule::requiredIf(auth()->user()->can('view cogs')), new UnsignedInteger], 'sale_price' => ['required', new UnsignedInteger], 'base_notes' => ['nullable', 'string', 'max:255'], 'middle_notes' => ['nullable', 'string', 'max:255'], @@ -145,7 +145,7 @@ private function prepareSavedData() return [ 'name' => $this->name, 'sku' => $this->sku, - 'cost_price' => replaceCurrency($this->cost_price), + 'cost_price' => replaceCurrency($this->cost_price == '' ? '0' : $this->cost_price), 'sale_price' => replaceCurrency($this->sale_price), 'point_per_ml' => round($this->sale_price / 100), 'base_notes' => $this->base_notes, diff --git a/app/Livewire/Forms/Studio/Catalog/ProductForm.php b/app/Livewire/Forms/Studio/Catalog/ProductForm.php index c8f39ad..e7c27e1 100644 --- a/app/Livewire/Forms/Studio/Catalog/ProductForm.php +++ b/app/Livewire/Forms/Studio/Catalog/ProductForm.php @@ -39,7 +39,7 @@ public function rules(): array 'max:20', Rule::unique('products', 'sku')->ignore($this->product), ], - 'cost_price' => ['required', new UnsignedInteger], + 'cost_price' => [Rule::requiredIf(auth()->user()->can('view cogs')), new UnsignedInteger], 'sale_price' => ['required', new UnsignedInteger], 'description' => ['nullable', 'string'], 'outlet_ids' => ['required', 'array', 'min:1'], @@ -112,7 +112,7 @@ private function prepareSavedData() return [ 'name' => $this->name, 'sku' => $this->sku, - 'cost_price' => replaceCurrency($this->cost_price), + 'cost_price' => replaceCurrency($this->cost_price == '' ? '0' : $this->cost_price), 'sale_price' => replaceCurrency($this->sale_price), 'point_per_pcs' => round($this->sale_price / 100), 'description' => $this->description, diff --git a/resources/views/livewire/studio/catalog/bottle/form.blade.php b/resources/views/livewire/studio/catalog/bottle/form.blade.php index 0194c78..f2fa58e 100644 --- a/resources/views/livewire/studio/catalog/bottle/form.blade.php +++ b/resources/views/livewire/studio/catalog/bottle/form.blade.php @@ -20,8 +20,8 @@
Nama * - + @@ -32,18 +32,20 @@ - - Harga Beli * - - Rp - - - - + @can('view cogs') + + Harga Beli * + + Rp + + + + + @endcan - + Harga Jual * Rp diff --git a/resources/views/livewire/studio/catalog/perfume/form.blade.php b/resources/views/livewire/studio/catalog/perfume/form.blade.php index 051fc9c..5ab484d 100644 --- a/resources/views/livewire/studio/catalog/perfume/form.blade.php +++ b/resources/views/livewire/studio/catalog/perfume/form.blade.php @@ -33,7 +33,8 @@
-
+
@foreach ($brands as $key => $value) @@ -42,17 +43,19 @@ @endforeach - - Harga Beli * - - - Rp - - - - + @can('view cogs') + + Harga Beli * + + + Rp + + + + + @endcan Harga Jual * diff --git a/resources/views/livewire/studio/catalog/product/form.blade.php b/resources/views/livewire/studio/catalog/product/form.blade.php index 360b441..e48ee2c 100644 --- a/resources/views/livewire/studio/catalog/product/form.blade.php +++ b/resources/views/livewire/studio/catalog/product/form.blade.php @@ -20,8 +20,8 @@
Nama * - + @@ -32,18 +32,20 @@ - - Harga Beli * - - Rp - - - - + @can('view cogs') + + Harga Beli * + + Rp + + + + + @endcan - + Harga Jual * Rp