refactor: remove verified cuttings display and related logic from StockController and StockPendingSection for improved clarity and focus on pending cuttings
This commit is contained in:
parent
e76a117abb
commit
07e9a4ab18
@ -26,7 +26,6 @@ public function index(Request $request): Response
|
||||
|
||||
return Inertia::render('admin/manage/stocks/Index', [
|
||||
'pendingCuttings' => $this->stockService->getPendingVerificationCuttings($user),
|
||||
'verifiedCuttings' => $this->stockService->getVerifiedCuttings(),
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@ -1,15 +1,11 @@
|
||||
<script setup lang="ts">
|
||||
import { Head } from '@inertiajs/vue3';
|
||||
import { Package } from '@lucide/vue';
|
||||
import StockPendingSection from './table/StockPendingSection.vue';
|
||||
import StockVerifiedSection from './table/StockVerifiedSection.vue';
|
||||
import { Card, CardContent } from '@/components/ui/card';
|
||||
import AdminLayout from '@/layouts/AdminLayout.vue';
|
||||
import type { CuttingListItem } from '@/types/cutting';
|
||||
|
||||
defineProps<{
|
||||
pendingCuttings: CuttingListItem[];
|
||||
verifiedCuttings: CuttingListItem[];
|
||||
}>();
|
||||
</script>
|
||||
|
||||
@ -29,11 +25,5 @@ defineProps<{
|
||||
</div>
|
||||
|
||||
<StockPendingSection :cuttings="pendingCuttings" />
|
||||
|
||||
<Card class="min-w-0">
|
||||
<CardContent class="min-w-0">
|
||||
<StockVerifiedSection :cuttings="verifiedCuttings" />
|
||||
</CardContent>
|
||||
</Card>
|
||||
</AdminLayout>
|
||||
</template>
|
||||
|
||||
@ -3,62 +3,6 @@ import { Card } from '@/components/ui/card';
|
||||
import type { CuttingListItem } from '@/types/cutting';
|
||||
import StockDataTableActions from './data-table-actions.vue';
|
||||
|
||||
const CM_PER_YARD = 91.44;
|
||||
const CM_PER_METER = 100;
|
||||
|
||||
function formatTotalMaterialUsage(totalUsage: number | null | undefined, materials: any[]): string {
|
||||
if (!totalUsage || !materials.length) {
|
||||
return '0';
|
||||
}
|
||||
|
||||
const unit = materials[0]?.raw_material_price?.raw_material?.unit;
|
||||
|
||||
if (unit === 'yard') {
|
||||
return (totalUsage * CM_PER_YARD).toFixed(2);
|
||||
}
|
||||
|
||||
if (unit === 'meter') {
|
||||
return (totalUsage * CM_PER_METER).toFixed(2);
|
||||
}
|
||||
|
||||
return totalUsage.toFixed(2);
|
||||
}
|
||||
|
||||
function getTotalMaterialUsageUnit(materials: any[]): string {
|
||||
const unit = materials[0]?.raw_material_price?.raw_material?.unit;
|
||||
|
||||
if (unit === 'yard' || unit === 'meter') {
|
||||
return 'cm';
|
||||
}
|
||||
|
||||
return materials[0]?.raw_material_price?.raw_material?.unit_abbreviation ?? '';
|
||||
}
|
||||
|
||||
function formatMaterialUsage(mat: any): string {
|
||||
const usage = mat.material_usage ?? 0;
|
||||
const unit = mat.raw_material_price?.raw_material?.unit;
|
||||
|
||||
if (unit === 'yard') {
|
||||
return (usage * CM_PER_YARD).toFixed(2);
|
||||
}
|
||||
|
||||
if (unit === 'meter') {
|
||||
return (usage * CM_PER_METER).toFixed(2);
|
||||
}
|
||||
|
||||
return usage.toFixed(2);
|
||||
}
|
||||
|
||||
function getMaterialUnit(mat: any): string {
|
||||
const unit = mat.raw_material_price?.raw_material?.unit;
|
||||
|
||||
if (unit === 'yard' || unit === 'meter') {
|
||||
return 'cm';
|
||||
}
|
||||
|
||||
return mat.raw_material_price?.raw_material?.unit_abbreviation ?? '';
|
||||
}
|
||||
|
||||
defineProps<{
|
||||
cuttings: CuttingListItem[];
|
||||
}>();
|
||||
@ -93,21 +37,6 @@ defineProps<{
|
||||
</div>
|
||||
|
||||
<div class="p-4 space-y-3 flex-1 text-xs">
|
||||
<div v-if="cutting.description" class="text-muted-foreground pb-2 border-b">
|
||||
<span class="font-medium text-foreground">Catatan:</span> {{ cutting.description }}
|
||||
</div>
|
||||
|
||||
<div class="space-y-1">
|
||||
<span class="font-medium text-foreground">Bahan Baku:</span>
|
||||
<ul class="list-disc pl-4 space-y-0.5 text-muted-foreground">
|
||||
<li v-for="mat in cutting.materials" :key="mat.id">
|
||||
{{ mat.raw_material_price?.raw_material?.name }} ({{
|
||||
mat.raw_material_price?.variant }}) - {{ formatMaterialUsage(mat) }} {{ getMaterialUnit(mat) }}
|
||||
</li>
|
||||
<li v-if="!cutting.materials.length">Belum ada bahan baku</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="space-y-1">
|
||||
<span class="font-medium text-foreground">Hasil Produk:</span>
|
||||
<ul class="list-disc pl-4 space-y-0.5 text-muted-foreground">
|
||||
@ -122,27 +51,11 @@ defineProps<{
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div v-if="cutting.results.length" class="space-y-1.5 pt-2 border-t">
|
||||
<div v-if="cutting.results.length" class="pt-2 border-t">
|
||||
<div class="flex items-center justify-between text-[11px]">
|
||||
<span class="text-muted-foreground">Total Hasil Cutting:</span>
|
||||
<span class="font-semibold tabular-nums">{{ cutting.total_result_pieces ?? 0 }}
|
||||
pcs</span>
|
||||
<span class="font-semibold tabular-nums">{{ cutting.total_result_pieces ?? 0 }} pcs</span>
|
||||
</div>
|
||||
<div class="flex items-center justify-between text-[11px]">
|
||||
<span class="text-muted-foreground">Total Pemakaian Bahan:</span>
|
||||
<span class="font-semibold tabular-nums">{{ formatTotalMaterialUsage(cutting.total_material_usage, cutting.materials) }} {{ getTotalMaterialUsageUnit(cutting.materials) }}</span>
|
||||
</div>
|
||||
<div class="flex items-center justify-between text-[11px]">
|
||||
<span class="text-muted-foreground">Biaya Produksi:</span>
|
||||
<span class="font-semibold tabular-nums">{{ cutting.total_production_cost_formatted ?? 'Rp 0' }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="text-[11px] text-muted-foreground pt-2 border-t flex items-center justify-between">
|
||||
<span>Pembuat:</span>
|
||||
<span class="font-medium text-foreground">
|
||||
{{ cutting.created_by?.profile?.full_name ?? cutting.created_by?.username }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</Card>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user