fix(gods): menyesuaikan cogs saat yang create datanya adalah leader

This commit is contained in:
Yoga Pangestu 2025-11-17 15:55:22 +07:00
parent 72b8a922b4
commit 70d7dc45b6
6 changed files with 51 additions and 44 deletions

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -20,8 +20,8 @@
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
<flux:field>
<flux:label>Nama <span class="text-red-500 ms-1">*</span></flux:label>
<flux:input placeholder="Le Labo"
wire:model.live.debounce.500ms="form.name" autofocus autocomplete="off" />
<flux:input placeholder="Le Labo" wire:model.live.debounce.500ms="form.name"
autofocus autocomplete="off" />
<flux:error name="form.name" />
</flux:field>
@ -32,18 +32,20 @@
<flux:error name="form.size" />
</flux:field>
<flux:field>
<flux:label>Harga Beli <span class="text-red-500 ms-1">*</span></flux:label>
<flux:input.group>
<flux:input.group.prefix>Rp</flux:input.group.prefix>
<flux:input placeholder="Masukkan harga beli"
x-mask:dynamic="$money($input, ',')"
wire:model.live.debounce.500ms="form.cost_price" autocomplete="off" />
</flux:input.group>
<flux:error name="form.cost_price" />
</flux:field>
@can('view cogs')
<flux:field>
<flux:label>Harga Beli <span class="text-red-500 ms-1">*</span></flux:label>
<flux:input.group>
<flux:input.group.prefix>Rp</flux:input.group.prefix>
<flux:input placeholder="Masukkan harga beli"
x-mask:dynamic="$money($input, ',')"
wire:model.live.debounce.500ms="form.cost_price" autocomplete="off" />
</flux:input.group>
<flux:error name="form.cost_price" />
</flux:field>
@endcan
<flux:field>
<flux:field class="col-span-{{ auth()->user()->can('view cogs') ? '1' : '2' }}">
<flux:label>Harga Jual <span class="text-red-500 ms-1">*</span></flux:label>
<flux:input.group>
<flux:input.group.prefix>Rp</flux:input.group.prefix>

View File

@ -33,7 +33,8 @@
</flux:field>
<div class="lg:col-span-2">
<div class="grid grid-cols-1 md:grid-cols-3 gap-6">
<div
class="grid grid-cols-1 md:grid-cols-{{ auth()->user()->can('view cogs') ? '3' : '2' }} gap-6">
<flux:select variant="listbox" searchable placeholder="Pilih Merek"
label="Merek" wire:model.live.debounce.500ms="form.brand_id">
@foreach ($brands as $key => $value)
@ -42,17 +43,19 @@
@endforeach
</flux:select>
<flux:field>
<flux:label>Harga Beli <span class="text-red-500 ms-1">*</span>
</flux:label>
<flux:input.group>
<flux:input.group.prefix>Rp</flux:input.group.prefix>
<flux:input placeholder="xxx" x-mask:dynamic="$money($input, ',')"
wire:model.live.debounce.500ms="form.cost_price"
autocomplete="off" />
</flux:input.group>
<flux:error name="form.cost_price" />
</flux:field>
@can('view cogs')
<flux:field>
<flux:label>Harga Beli <span class="text-red-500 ms-1">*</span>
</flux:label>
<flux:input.group>
<flux:input.group.prefix>Rp</flux:input.group.prefix>
<flux:input placeholder="xxx" x-mask:dynamic="$money($input, ',')"
wire:model.live.debounce.500ms="form.cost_price"
autocomplete="off" />
</flux:input.group>
<flux:error name="form.cost_price" />
</flux:field>
@endcan
<flux:field>
<flux:label>Harga Jual <span class="text-red-500 ms-1">*</span>

View File

@ -20,8 +20,8 @@
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
<flux:field>
<flux:label>Nama <span class="text-red-500 ms-1">*</span></flux:label>
<flux:input placeholder="Air Zam Zam"
wire:model.live.debounce.500ms="form.name" autofocus autocomplete="off" />
<flux:input placeholder="Air Zam Zam" wire:model.live.debounce.500ms="form.name"
autofocus autocomplete="off" />
<flux:error name="form.name" />
</flux:field>
@ -32,18 +32,20 @@
<flux:error name="form.sku" />
</flux:field>
<flux:field>
<flux:label>Harga Beli <span class="text-red-500 ms-1">*</span></flux:label>
<flux:input.group>
<flux:input.group.prefix>Rp</flux:input.group.prefix>
<flux:input placeholder="Masukkan harga beli"
x-mask:dynamic="$money($input, ',')"
wire:model.live.debounce.500ms="form.cost_price" autocomplete="off" />
</flux:input.group>
<flux:error name="form.cost_price" />
</flux:field>
@can('view cogs')
<flux:field>
<flux:label>Harga Beli <span class="text-red-500 ms-1">*</span></flux:label>
<flux:input.group>
<flux:input.group.prefix>Rp</flux:input.group.prefix>
<flux:input placeholder="Masukkan harga beli"
x-mask:dynamic="$money($input, ',')"
wire:model.live.debounce.500ms="form.cost_price" autocomplete="off" />
</flux:input.group>
<flux:error name="form.cost_price" />
</flux:field>
@endcan
<flux:field>
<flux:field class="col-span-{{ auth()->user()->can('view cogs') ? '1' : '2' }}">
<flux:label>Harga Jual <span class="text-red-500 ms-1">*</span></flux:label>
<flux:input.group>
<flux:input.group.prefix>Rp</flux:input.group.prefix>