diff --git a/BEST_PRACTICE.md b/BEST_PRACTICE.md index a367ff1..3644a3a 100644 --- a/BEST_PRACTICE.md +++ b/BEST_PRACTICE.md @@ -226,7 +226,7 @@ ### Controller PurchaseDraftItemController.php Stock/ StockController.php - StockRetailController.php + RetailStockController.php StokOpnameController.php ← modul dengan 1 controller tetap di level parent OwnerVerificationController.php ``` diff --git a/app/Enums/OwnerVerificationAction.php b/app/Enums/OwnerVerificationAction.php index c871c11..3ebdf50 100644 --- a/app/Enums/OwnerVerificationAction.php +++ b/app/Enums/OwnerVerificationAction.php @@ -13,7 +13,7 @@ enum OwnerVerificationAction: string case DELETE = 'delete'; case TOGGLE_STATUS = 'toggle_status'; case STOCK_VERIFY = 'stock_verify'; - case STOCK_RETAIL_TRANSFER = 'stock_retail_transfer'; + case RETAIL_STOCK_TRANSFER = 'retail_stock_transfer'; public function label(): string { @@ -23,7 +23,7 @@ public function label(): string self::DELETE => 'Hapus', self::TOGGLE_STATUS => 'Ubah Status', self::STOCK_VERIFY => 'Verifikasi Stok', - self::STOCK_RETAIL_TRANSFER => 'Transfer Stok Ecer', + self::RETAIL_STOCK_TRANSFER => 'Transfer Stok Ecer', }; } } diff --git a/app/Http/Controllers/Admin/Manage/Stock/StockRetailController.php b/app/Http/Controllers/Admin/Manage/Stock/RetailStockController.php similarity index 64% rename from app/Http/Controllers/Admin/Manage/Stock/StockRetailController.php rename to app/Http/Controllers/Admin/Manage/Stock/RetailStockController.php index e943f78..c37c9aa 100644 --- a/app/Http/Controllers/Admin/Manage/Stock/StockRetailController.php +++ b/app/Http/Controllers/Admin/Manage/Stock/RetailStockController.php @@ -3,21 +3,21 @@ namespace App\Http\Controllers\Admin\Manage\Stock; use App\Http\Controllers\Controller; -use App\Http\Requests\Admin\Manage\StockRetailTransferRequest; -use App\Services\Manage\StockRetailService; +use App\Http\Requests\Admin\Manage\RetailStockTransferRequest; +use App\Services\Manage\RetailStockService; use Illuminate\Http\JsonResponse; -class StockRetailController extends Controller +class RetailStockController extends Controller { public function __construct( - private readonly StockRetailService $stockRetailService, + private readonly RetailStockService $retailStockService, ) {} - public function transfer(StockRetailTransferRequest $request): JsonResponse + public function transfer(RetailStockTransferRequest $request): JsonResponse { $validated = $request->validated(); - $this->stockRetailService->transfer( + $this->retailStockService->transfer( $validated['product_variant_id'], $validated['quantity'], $request->user(), diff --git a/app/Http/Requests/Admin/Manage/StockRetailTransferRequest.php b/app/Http/Requests/Admin/Manage/RetailStockTransferRequest.php similarity index 94% rename from app/Http/Requests/Admin/Manage/StockRetailTransferRequest.php rename to app/Http/Requests/Admin/Manage/RetailStockTransferRequest.php index 9f32ade..feb65e2 100644 --- a/app/Http/Requests/Admin/Manage/StockRetailTransferRequest.php +++ b/app/Http/Requests/Admin/Manage/RetailStockTransferRequest.php @@ -6,7 +6,7 @@ use Illuminate\Foundation\Http\FormRequest; use Illuminate\Validation\Rule; -class StockRetailTransferRequest extends FormRequest +class RetailStockTransferRequest extends FormRequest { public function authorize(): bool { diff --git a/app/Http/Requests/Admin/Master/ProductRequest.php b/app/Http/Requests/Admin/Master/ProductRequest.php index c9baf20..85c3b9e 100644 --- a/app/Http/Requests/Admin/Master/ProductRequest.php +++ b/app/Http/Requests/Admin/Master/ProductRequest.php @@ -42,7 +42,7 @@ public function rules(): array ], 'variants.*.name' => ['required', 'string', 'max:200'], 'variants.*.stock' => ['required', 'integer', 'min:0'], - 'variants.*.stock_retail' => ['required', 'integer', 'min:0'], + 'variants.*.retail_stock' => ['required', 'integer', 'min:0'], ...$this->variantImageRules(), ]; } @@ -60,7 +60,7 @@ public function attributes(): array 'variants' => 'Varian', 'variants.*.name' => 'Nama Varian', 'variants.*.stock' => 'Stok', - 'variants.*.stock_retail' => 'Stok Ecer', + 'variants.*.retail_stock' => 'Stok Ecer', ...$this->variantImageAttributes('variants', 'Foto Varian'), ]; } diff --git a/app/Models/Product.php b/app/Models/Product.php index d2dc89c..ec9cd4c 100644 --- a/app/Models/Product.php +++ b/app/Models/Product.php @@ -65,7 +65,7 @@ public function totalRejectStockFormatted(): Attribute public function totalRetailStockFormatted(): Attribute { return Attribute::make( - get: fn () => number_format($this->variants->sum('stock_retail'), 0, ',', '.'), + get: fn () => number_format($this->variants->sum('retail_stock'), 0, ',', '.'), ); } diff --git a/app/Models/ProductVariant.php b/app/Models/ProductVariant.php index ca5b9d1..0d50c2f 100644 --- a/app/Models/ProductVariant.php +++ b/app/Models/ProductVariant.php @@ -15,7 +15,7 @@ use Spatie\MediaLibrary\HasMedia; #[Guarded(['id'])] -#[Appends(['stock_formatted', 'reject_stock_formatted', 'stock_retail_formatted'])] +#[Appends(['stock_formatted', 'reject_stock_formatted', 'retail_stock_formatted'])] class ProductVariant extends Model implements HasMedia { // 1. Use Trait @@ -29,7 +29,7 @@ protected function casts(): array return [ 'reject_stock' => 'integer', 'stock' => 'integer', - 'stock_retail' => 'integer', + 'retail_stock' => 'integer', ]; } @@ -48,10 +48,10 @@ public function stockFormatted(): Attribute ); } - public function stockRetailFormatted(): Attribute + public function retailStockFormatted(): Attribute { return Attribute::make( - get: fn () => number_format($this->stock_retail, 0, ',', '.'), + get: fn () => number_format($this->retail_stock, 0, ',', '.'), ); } diff --git a/app/Models/RawMaterialPrice.php b/app/Models/RawMaterialPrice.php index aeeb738..4379899 100644 --- a/app/Models/RawMaterialPrice.php +++ b/app/Models/RawMaterialPrice.php @@ -50,8 +50,10 @@ public function stockFormatted(): Attribute return Attribute::make( get: function () { $formatted = rtrim(rtrim(number_format((float) $this->stock, 4, ',', '.'), '0'), ','); + $unitAbbreviation = $this->attributes['unit_abbreviation'] + ?? $this->rawMaterial?->unit?->abbreviation(); - return "{$formatted} {$this->rawMaterial->unit->abbreviation()}"; + return "{$formatted} {$unitAbbreviation}"; }, ); } diff --git a/app/Models/StockRetailHistory.php b/app/Models/RetailStockHistory.php similarity index 79% rename from app/Models/StockRetailHistory.php rename to app/Models/RetailStockHistory.php index 536b42f..0e89ca7 100644 --- a/app/Models/StockRetailHistory.php +++ b/app/Models/RetailStockHistory.php @@ -7,9 +7,9 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo; #[Guarded(['id'])] -class StockRetailHistory extends Model +class RetailStockHistory extends Model { - protected $table = 'stock_retail_histories'; + protected $table = 'retail_stock_histories'; public $timestamps = false; @@ -21,8 +21,8 @@ protected function casts(): array 'quantity' => 'integer', 'stock_after' => 'integer', 'stock_before' => 'integer', - 'stock_retail_after' => 'integer', - 'stock_retail_before' => 'integer', + 'retail_stock_after' => 'integer', + 'retail_stock_before' => 'integer', ]; } diff --git a/app/Services/Manage/CuttingService.php b/app/Services/Manage/CuttingService.php index 73fb555..38cebd7 100644 --- a/app/Services/Manage/CuttingService.php +++ b/app/Services/Manage/CuttingService.php @@ -117,7 +117,7 @@ public function rawMaterialCatalog(?Cutting $cutting = null, ?User $user = null) ->with([ 'prices' => fn ($query) => $query ->orderBy('created_at') - ->with(['rawMaterial:id,unit', 'media']), + ->with('media'), ]) ->where(function (Builder $query) use ($selectedPriceIds): void { $query->active(); @@ -132,11 +132,10 @@ public function rawMaterialCatalog(?Cutting $cutting = null, ?User $user = null) ->orderBy('name') ->get() ->each(function (RawMaterial $rawMaterial): void { - $rawMaterial->prices->each(function (RawMaterialPrice $price): void { - $price->setAttribute( - 'images', - MediaPresenter::collection($price, 'images'), - ); + $rawMaterial->prices->each(function (RawMaterialPrice $price) use ($rawMaterial): void { + $price->setAttribute('images', MediaPresenter::collection($price, 'images')); + $price->setAttribute('unit_abbreviation', $rawMaterial->unit->abbreviation()); + $price->unsetRelation('rawMaterial'); }); }); } diff --git a/app/Services/Manage/OrderService.php b/app/Services/Manage/OrderService.php index 6f9f2fc..90a32b3 100644 --- a/app/Services/Manage/OrderService.php +++ b/app/Services/Manage/OrderService.php @@ -52,7 +52,7 @@ public function stockColumn(ProductStockQuality $quality): string return match ($quality) { ProductStockQuality::GOOD => 'stock', ProductStockQuality::REJECT => 'reject_stock', - ProductStockQuality::RETAIL => 'stock_retail', + ProductStockQuality::RETAIL => 'retail_stock', }; } diff --git a/app/Services/Manage/OwnerVerificationService.php b/app/Services/Manage/OwnerVerificationService.php index 96cd6bc..fb3e1a9 100644 --- a/app/Services/Manage/OwnerVerificationService.php +++ b/app/Services/Manage/OwnerVerificationService.php @@ -36,7 +36,7 @@ public function __construct( private readonly PurchaseService $purchaseService, private readonly PushNotificationService $pushNotificationService, private readonly MarketplaceService $marketplaceService, - private readonly StockRetailService $stockRetailService, + private readonly RetailStockService $retailStockService, ) {} public function hasPendingMarketplaceVerification(): bool @@ -283,7 +283,7 @@ private function rejectVerificationRequest(OwnerVerificationRequest $request): v RawMaterial::class => $this->rawMaterialService->rejectVerificationRequest($request), Purchase::class => $this->purchaseService->rejectVerificationRequest($request), MarketplaceSettings::class => null, - ProductVariant::class => $this->stockRetailService->rejectStockRetailTransfer($request), + ProductVariant::class => $this->retailStockService->rejectRetailStockTransfer($request), default => throw ValidationException::withMessages([ 'subject_type' => 'Tipe data verifikasi tidak didukung.', ]), @@ -297,7 +297,7 @@ private function applyVerificationRequest(OwnerVerificationRequest $request): vo RawMaterial::class => $this->rawMaterialService->applyVerificationRequest($request), Purchase::class => $this->purchaseService->applyVerificationRequest($request), MarketplaceSettings::class => $this->marketplaceService->applyVerificationRequest($request), - ProductVariant::class => $this->stockRetailService->applyStockRetailTransfer($request), + ProductVariant::class => $this->retailStockService->applyRetailStockTransfer($request), default => throw ValidationException::withMessages([ 'subject_type' => 'Tipe data verifikasi tidak didukung.', ]), diff --git a/app/Services/Manage/PurchaseService.php b/app/Services/Manage/PurchaseService.php index 186a915..8f8e91c 100644 --- a/app/Services/Manage/PurchaseService.php +++ b/app/Services/Manage/PurchaseService.php @@ -97,7 +97,7 @@ public function catalogItems(?Purchase $purchase = null, ?User $user = null): Co ->with([ 'prices' => fn ($query) => $query ->orderBy('created_at') - ->with(['rawMaterial:id,unit', 'media']), + ->with('media'), ]) ->where(function (Builder $query) use ($purchasePriceIds): void { $query->active(); @@ -112,11 +112,10 @@ public function catalogItems(?Purchase $purchase = null, ?User $user = null): Co ->orderBy('name') ->get() ->each(function (RawMaterial $rawMaterial): void { - $rawMaterial->prices->each(function (RawMaterialPrice $price): void { - $price->setAttribute( - 'images', - MediaPresenter::collection($price, 'images'), - ); + $rawMaterial->prices->each(function (RawMaterialPrice $price) use ($rawMaterial): void { + $price->setAttribute('images', MediaPresenter::collection($price, 'images')); + $price->setAttribute('unit_abbreviation', $rawMaterial->unit->abbreviation()); + $price->unsetRelation('rawMaterial'); }); }); } diff --git a/app/Services/Manage/StockRetailService.php b/app/Services/Manage/RetailStockService.php similarity index 87% rename from app/Services/Manage/StockRetailService.php rename to app/Services/Manage/RetailStockService.php index ffc6c51..a3b23f0 100644 --- a/app/Services/Manage/StockRetailService.php +++ b/app/Services/Manage/RetailStockService.php @@ -7,14 +7,14 @@ use App\Enums\Permission; use App\Models\OwnerVerificationRequest; use App\Models\ProductVariant; -use App\Models\StockRetailHistory; +use App\Models\RetailStockHistory; use App\Models\User; use App\Services\System\PushNotificationService; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Log; use Illuminate\Validation\ValidationException; -class StockRetailService +class RetailStockService { public function __construct( private readonly PushNotificationService $pushNotificationService, @@ -47,7 +47,7 @@ public function transfer(int $variantId, int $quantity, User $user, ?string $not $existingPending = OwnerVerificationRequest::query() ->where('subject_type', ProductVariant::class) ->where('subject_id', $variant->id) - ->where('action', OwnerVerificationAction::STOCK_RETAIL_TRANSFER) + ->where('action', OwnerVerificationAction::RETAIL_STOCK_TRANSFER) ->where('status', OwnerVerificationStatus::PENDING) ->exists(); @@ -59,7 +59,7 @@ public function transfer(int $variantId, int $quantity, User $user, ?string $not try { $request = OwnerVerificationRequest::create([ - 'action' => OwnerVerificationAction::STOCK_RETAIL_TRANSFER, + 'action' => OwnerVerificationAction::RETAIL_STOCK_TRANSFER, 'status' => OwnerVerificationStatus::PENDING, 'subject_type' => ProductVariant::class, 'subject_id' => $variant->id, @@ -67,12 +67,12 @@ public function transfer(int $variantId, int $quantity, User $user, ?string $not 'payload' => [ 'old' => [ 'stock' => $variant->stock, - 'stock_retail' => $variant->stock_retail, + 'retail_stock' => $variant->retail_stock, ], 'new' => [ 'quantity' => $quantity, 'stock' => $variant->stock - $quantity, - 'stock_retail' => $variant->stock_retail + $quantity, + 'retail_stock' => $variant->retail_stock + $quantity, 'notes' => $notes, 'variant_name' => $variant->name, 'product_name' => $variant->product?->name ?? '-', @@ -110,7 +110,7 @@ public function transfer(int $variantId, int $quantity, User $user, ?string $not } } - public function applyStockRetailTransfer(OwnerVerificationRequest $request): void + public function applyRetailStockTransfer(OwnerVerificationRequest $request): void { $payload = $request->payload ?? []; $newData = $payload['new'] ?? []; @@ -138,26 +138,26 @@ private function executeTransfer(ProductVariant $variant, int $quantity, User $u ->firstOrFail(); $stockBefore = $variant->stock; - $stockRetailBefore = $variant->stock_retail; + $retailStockBefore = $variant->retail_stock; $variant->decrement('stock', $quantity); - $variant->increment('stock_retail', $quantity); + $variant->increment('retail_stock', $quantity); - StockRetailHistory::create([ + RetailStockHistory::create([ 'product_variant_id' => $variant->id, 'user_id' => $user->id, 'quantity' => $quantity, 'stock_before' => $stockBefore, - 'stock_retail_before' => $stockRetailBefore, + 'retail_stock_before' => $retailStockBefore, 'stock_after' => $stockBefore - $quantity, - 'stock_retail_after' => $stockRetailBefore + $quantity, + 'retail_stock_after' => $retailStockBefore + $quantity, 'notes' => $notes, 'created_at' => now(), ]); }); } - public function rejectStockRetailTransfer(OwnerVerificationRequest $request): void + public function rejectRetailStockTransfer(OwnerVerificationRequest $request): void { // No-op: nothing was changed yet, so nothing to rollback. } diff --git a/app/Services/Master/ProductService.php b/app/Services/Master/ProductService.php index 10a1c9d..e9af99b 100644 --- a/app/Services/Master/ProductService.php +++ b/app/Services/Master/ProductService.php @@ -74,12 +74,12 @@ public function paginateForIndex(array $tableQuery, string $isActive, string $ca $pendingRequest = $product->pendingOwnerVerificationRequest; - // Also check for pending stock retail transfer on variants + // Also check for pending retail stock transfer on variants if ($pendingRequest === null) { $pendingRequest = OwnerVerificationRequest::query() ->where('subject_type', ProductVariant::class) ->whereIn('subject_id', $product->variants->pluck('id')) - ->where('action', OwnerVerificationAction::STOCK_RETAIL_TRANSFER) + ->where('action', OwnerVerificationAction::RETAIL_STOCK_TRANSFER) ->pending() ->latest() ->first(); @@ -132,7 +132,7 @@ public function create(array $validated, User $user): void $variant = $product->variants()->create([ 'name' => $variantData['name'], 'stock' => $variantData['stock'], - 'stock_retail' => $variantData['stock_retail'], + 'retail_stock' => $variantData['retail_stock'], ]); $this->syncVariantImages($variant, $variantData, $index); @@ -195,7 +195,7 @@ public function update(Product $product, array $validated, User $user): void $variant = $product->variants()->create([ 'name' => $variantData['name'], 'stock' => $variantData['stock'], - 'stock_retail' => $variantData['stock_retail'], + 'retail_stock' => $variantData['retail_stock'], ]); $this->syncVariantImages($variant, $variantData, $index); } @@ -436,7 +436,7 @@ private function applyPayloadToProduct( $variant->update([ 'name' => $variantData['name'], 'stock' => $variantData['stock'], - 'stock_retail' => $variantData['stock_retail'], + 'retail_stock' => $variantData['retail_stock'], ]); if ($verificationRequest !== null) { @@ -449,7 +449,7 @@ private function applyPayloadToProduct( $variant = $product->variants()->create([ 'name' => $variantData['name'], 'stock' => $variantData['stock'], - 'stock_retail' => $variantData['stock_retail'], + 'retail_stock' => $variantData['retail_stock'], ]); if ($verificationRequest !== null) { @@ -595,7 +595,7 @@ private function snapshotProduct(Product $product): array 'id' => $variant->id, 'name' => $variant->name, 'stock' => $variant->stock, - 'stock_retail' => $variant->stock_retail, + 'retail_stock' => $variant->retail_stock, ]) ->all(), ]); @@ -623,7 +623,7 @@ private function buildPayloadFromValidated(array $validated): array 'id' => $variantData['id'] ?? null, 'name' => $variantData['name'], 'stock' => $variantData['stock'], - 'stock_retail' => $variantData['stock_retail'], + 'retail_stock' => $variantData['retail_stock'], 'remove_media_ids' => $variantData['remove_media_ids'] ?? [], ]) ->all(), diff --git a/app/Services/Master/RawMaterialService.php b/app/Services/Master/RawMaterialService.php index 906133e..03e14e5 100644 --- a/app/Services/Master/RawMaterialService.php +++ b/app/Services/Master/RawMaterialService.php @@ -35,7 +35,7 @@ public function paginateForIndex(array $tableQuery, string $isActive, string $st 'pendingOwnerVerificationRequest', 'prices' => fn ($query) => $query ->orderBy('created_at') - ->with(['rawMaterial:id,unit', 'media']), + ->with('media'), ]) ->when($tableQuery['search'] !== '', function (Builder $query) use ($tableQuery): void { $search = $tableQuery['search']; @@ -73,11 +73,10 @@ public function paginateForIndex(array $tableQuery, string $isActive, string $st ->paginate(25) ->withQueryString() ->through(function (RawMaterial $rawMaterial) { - $rawMaterial->prices->each(function (RawMaterialPrice $price): void { - $price->setAttribute( - 'images', - MediaPresenter::collection($price, 'images'), - ); + $rawMaterial->prices->each(function (RawMaterialPrice $price) use ($rawMaterial): void { + $price->setAttribute('images', MediaPresenter::collection($price, 'images')); + $price->setAttribute('unit_abbreviation', $rawMaterial->unit->abbreviation()); + $price->unsetRelation('rawMaterial'); }); $pendingRequest = $rawMaterial->pendingOwnerVerificationRequest; @@ -101,8 +100,10 @@ public function findForEdit(RawMaterial $rawMaterial): RawMaterial 'prices' => fn ($query) => $query->orderBy('created_at')->with('media'), ]); - $rawMaterial->prices->each(function (RawMaterialPrice $price): void { + $rawMaterial->prices->each(function (RawMaterialPrice $price) use ($rawMaterial): void { $price->setAttribute('images', MediaPresenter::collection($price, 'images')); + $price->setAttribute('unit_abbreviation', $rawMaterial->unit->abbreviation()); + $price->unsetRelation('rawMaterial'); }); return $rawMaterial; diff --git a/app/Services/System/AnalysisService.php b/app/Services/System/AnalysisService.php index 263b7c8..c641d55 100644 --- a/app/Services/System/AnalysisService.php +++ b/app/Services/System/AnalysisService.php @@ -499,7 +499,7 @@ public function getProductStock(): array ->selectRaw(' SUM(product_variants.stock) as total_stock, SUM(product_variants.reject_stock) as total_reject, - SUM(product_variants.stock_retail) as total_retail, + SUM(product_variants.retail_stock) as total_retail, COUNT(product_variants.id) as total_variants, COUNT(DISTINCT products.id) as total_products ') diff --git a/app/Support/OwnerVerification/VerificationChangeFormatter.php b/app/Support/OwnerVerification/VerificationChangeFormatter.php index aba59c8..0adcba6 100644 --- a/app/Support/OwnerVerification/VerificationChangeFormatter.php +++ b/app/Support/OwnerVerification/VerificationChangeFormatter.php @@ -77,7 +77,7 @@ private static function label(string $field): string 'prices' => 'Varian Harga', 'quantity' => 'Jumlah Transfer', 'stock' => 'Stok Bagus', - 'stock_retail' => 'Stok Ecer', + 'retail_stock' => 'Stok Ecer', 'variant_name' => 'Varian', 'product_name' => 'Produk', 'tiktok_shop_platform_commission' => 'TikTok Shop - Komisi Platform', @@ -186,7 +186,7 @@ private static function presentValue(string $field, mixed $value): mixed return implode(', ', $value); } - if (in_array($field, ['quantity', 'stock', 'stock_retail'], true)) { + if (in_array($field, ['quantity', 'stock', 'retail_stock'], true)) { return (int) $value; } diff --git a/database/migrations/2026_06_10_100003_create_product_variants_table.php b/database/migrations/2026_06_10_100003_create_product_variants_table.php index a4e3a3d..799485d 100644 --- a/database/migrations/2026_06_10_100003_create_product_variants_table.php +++ b/database/migrations/2026_06_10_100003_create_product_variants_table.php @@ -16,7 +16,7 @@ public function up(): void $table->string('name', 200); $table->unsignedInteger('stock')->default(0); $table->unsignedInteger('reject_stock')->default(0); - $table->unsignedInteger('stock_retail')->default(0); + $table->unsignedInteger('retail_stock')->default(0); $table->timestamp('created_at')->useCurrent(); $table->timestamp('updated_at')->useCurrent()->useCurrentOnUpdate(); diff --git a/database/migrations/2026_06_28_094400_create_stock_retail_histories_table.php b/database/migrations/2026_06_28_094400_create_retail_stock_histories_table.php similarity index 76% rename from database/migrations/2026_06_28_094400_create_stock_retail_histories_table.php rename to database/migrations/2026_06_28_094400_create_retail_stock_histories_table.php index afb7125..b1da23a 100644 --- a/database/migrations/2026_06_28_094400_create_stock_retail_histories_table.php +++ b/database/migrations/2026_06_28_094400_create_retail_stock_histories_table.php @@ -8,7 +8,7 @@ { public function up(): void { - Schema::create('stock_retail_histories', function (Blueprint $table) { + Schema::create('retail_stock_histories', function (Blueprint $table) { $table->id(); $table->foreignId('product_variant_id')->constrained('product_variants')->cascadeOnDelete(); @@ -16,9 +16,9 @@ public function up(): void $table->unsignedInteger('quantity'); $table->unsignedInteger('stock_before'); - $table->unsignedInteger('stock_retail_before'); + $table->unsignedInteger('retail_stock_before'); $table->unsignedInteger('stock_after'); - $table->unsignedInteger('stock_retail_after'); + $table->unsignedInteger('retail_stock_after'); $table->string('notes')->nullable(); $table->timestamp('created_at')->useCurrent(); @@ -27,6 +27,6 @@ public function up(): void public function down(): void { - Schema::dropIfExists('stock_retail_histories'); + Schema::dropIfExists('retail_stock_histories'); } }; diff --git a/resources/js/components/button/RowTransferAction.vue b/resources/js/components/button/RowTransferAction.vue new file mode 100644 index 0000000..28d249f --- /dev/null +++ b/resources/js/components/button/RowTransferAction.vue @@ -0,0 +1,33 @@ + + + diff --git a/resources/js/components/button/index.ts b/resources/js/components/button/index.ts index 875d8d5..26e61c9 100644 --- a/resources/js/components/button/index.ts +++ b/resources/js/components/button/index.ts @@ -7,5 +7,6 @@ export { default as RowAdjustAction } from './RowAdjustAction.vue'; export { default as RowStatusAction } from './RowStatusAction.vue'; export { default as RowPrintAction } from './RowPrintAction.vue'; export { default as RowDetailAction } from './RowDetailAction.vue'; +export { default as RowTransferAction } from './RowTransferAction.vue'; export { default as CreateButton } from './CreateButton.vue'; export { default as BackButton } from './BackButton.vue'; diff --git a/resources/js/components/modal/StockRetailTransferModal.vue b/resources/js/components/modal/RetailStockTransferModal.vue similarity index 64% rename from resources/js/components/modal/StockRetailTransferModal.vue rename to resources/js/components/modal/RetailStockTransferModal.vue index 149a861..ed8b2aa 100644 --- a/resources/js/components/modal/StockRetailTransferModal.vue +++ b/resources/js/components/modal/RetailStockTransferModal.vue @@ -1,6 +1,6 @@ @@ -79,15 +79,15 @@ const emit = defineEmits<{ - + Stok Ecer - + diff --git a/resources/js/pages/admin/master/products/table/ProductGroupedTable.vue b/resources/js/pages/admin/master/products/table/ProductGroupedTable.vue index 92d1c39..35073cb 100644 --- a/resources/js/pages/admin/master/products/table/ProductGroupedTable.vue +++ b/resources/js/pages/admin/master/products/table/ProductGroupedTable.vue @@ -1,13 +1,10 @@ diff --git a/resources/js/pages/admin/master/products/table/data-table-actions.vue b/resources/js/pages/admin/master/products/table/data-table-actions.vue index 4af4655..55ddd45 100644 --- a/resources/js/pages/admin/master/products/table/data-table-actions.vue +++ b/resources/js/pages/admin/master/products/table/data-table-actions.vue @@ -1,5 +1,7 @@ diff --git a/resources/js/types/product.ts b/resources/js/types/product.ts index 198914f..ba4963f 100644 --- a/resources/js/types/product.ts +++ b/resources/js/types/product.ts @@ -43,8 +43,8 @@ export interface Variant { stock_formatted: string; reject_stock: number; reject_stock_formatted: string; - stock_retail: number; - stock_retail_formatted: string; + retail_stock: number; + retail_stock_formatted: string; prices: Price[]; images: MediaItem[]; } @@ -91,7 +91,7 @@ export interface ProductVariantFormItem { id?: number; name: string; stock: string | number; - stock_retail: string | number; + retail_stock: string | number; media: MediaUploadState; [key: string]: unknown; } @@ -104,7 +104,7 @@ export type ProductFormInitialData = { id?: number; name?: string; stock?: number | string; - stock_retail?: number | string; + retail_stock?: number | string; images?: MediaItem[]; }>; }; diff --git a/routes/web.php b/routes/web.php index fd7c9cb..8c204e1 100644 --- a/routes/web.php +++ b/routes/web.php @@ -21,8 +21,8 @@ use App\Http\Controllers\Admin\Manage\OwnerVerificationController; use App\Http\Controllers\Admin\Manage\Purchase\PurchaseController; use App\Http\Controllers\Admin\Manage\Purchase\PurchaseDraftItemController; +use App\Http\Controllers\Admin\Manage\Stock\RetailStockController; use App\Http\Controllers\Admin\Manage\Stock\StockController; -use App\Http\Controllers\Admin\Manage\Stock\StockRetailController; use App\Http\Controllers\Admin\Manage\StokOpnameController; use App\Http\Controllers\Admin\Master\CategoryController; use App\Http\Controllers\Admin\Master\CustomerController; @@ -357,10 +357,10 @@ ->name('verify'); }); - Route::prefix('stock-retail')->name('stock-retail.') + Route::prefix('retail-stock')->name('retail-stock.') ->middleware('permission:'.Permission::STOCKS_VIEW->value) ->group(function () { - Route::post('/transfer', [StockRetailController::class, 'transfer'])->name('transfer'); + Route::post('/transfer', [RetailStockController::class, 'transfer'])->name('transfer'); }); Route::prefix('stok-opnames')->name('stok-opnames.')