Compare commits

..

No commits in common. "fc9a8b1f0ef2836d72467819013118f1e589e982" and "70531b443dfe5536420ab087259d77f56b2ad4c0" have entirely different histories.

4 changed files with 18 additions and 44 deletions

View File

@ -984,7 +984,7 @@ public function quickCreateProduct(array $validated): array
null,
$maxVariantImages,
required: false,
errorKey: "variants.{$index}.s3_keys",
errorKey: "variants.{$index}.images",
s3Keys: $variantData['s3_keys'] ?? null,
);

View File

@ -815,7 +815,7 @@ private function syncVariantImages(
$variantData['remove_media_ids'] ?? null,
self::MAX_VARIANT_IMAGES,
required: true,
errorKey: "variants.{$index}.s3_keys",
errorKey: "variants.{$index}.images",
s3Keys: $variantData['s3_keys'] ?? null,
);
}
@ -835,7 +835,7 @@ private function syncRequestVariantImages(
$variantData['remove_media_ids'] ?? null,
self::MAX_VARIANT_IMAGES,
required: $required,
errorKey: "variants.{$index}.s3_keys",
errorKey: "variants.{$index}.images",
s3Keys: $variantData['s3_keys'] ?? null,
);
}

View File

@ -515,7 +515,7 @@ private function syncPriceImages(RawMaterialPrice $price, array $priceData, int
$priceData['remove_media_ids'] ?? null,
self::MAX_VARIANT_IMAGES,
required: true,
errorKey: "prices.{$index}.s3_keys",
errorKey: "prices.{$index}.images",
s3Keys: $priceData['s3_keys'] ?? null,
);
}
@ -535,7 +535,7 @@ private function syncRequestPriceImages(
$priceData['remove_media_ids'] ?? null,
self::MAX_VARIANT_IMAGES,
required: $required,
errorKey: "prices.{$index}.s3_keys",
errorKey: "prices.{$index}.images",
s3Keys: $priceData['s3_keys'] ?? null,
);
}

View File

@ -48,37 +48,15 @@ function rowNumber(index: number): number {
return groupedTableRowNumber(props.firstItem, index);
}
interface ProductInfo {
name: string;
unitLabel?: string;
}
function productInfos(items: PurchaseItemDetail[]): ProductInfo[] {
const map = new Map<number, ProductInfo>();
items.forEach((item) => {
const id = item.raw_material_id ?? 0;
if (id && !map.has(id)) {
map.set(id, {
name: item.raw_material_name || 'Bahan Baku Tidak Diketahui',
unitLabel: item.raw_material_unit_label,
});
}
});
return [...map.values()];
}
interface GroupedPurchaseItems {
rawMaterialId: number;
rawMaterialName: string;
unitLabel?: string;
items: (PurchaseItemDetail & { item_number: number })[];
items: PurchaseItemDetail[];
}
function getGroupedItems(items: PurchaseItemDetail[]): GroupedPurchaseItems[] {
const groups: Record<number, GroupedPurchaseItems> = {};
let itemCounter = 0;
items.forEach((item) => {
const rawMaterialId = item.raw_material_id ?? 0;
@ -94,8 +72,7 @@ function getGroupedItems(items: PurchaseItemDetail[]): GroupedPurchaseItems[] {
};
}
itemCounter++;
groups[rawMaterialId].items.push({ ...item, item_number: itemCounter });
groups[rawMaterialId].items.push(item);
});
return Object.values(groups);
@ -125,16 +102,9 @@ function openVerificationDetail(requestId: number | undefined) {
{{ rowNumber(index) }}
</span>
<div class="min-w-0 space-y-2">
<h3 class="font-medium leading-tight flex flex-wrap items-center gap-x-1">
<template v-for="(product, pIdx) in productInfos(purchase.items)" :key="pIdx">
<span>{{ product.name }}</span>
<Badge v-if="product.unitLabel" variant="secondary" class="font-normal">{{ product.unitLabel }}</Badge>
<span v-if="pIdx < productInfos(purchase.items).length - 1" class="text-muted-foreground">,&nbsp;</span>
</template>
<h3 class="font-medium leading-tight">
{{ purchase.supplier?.name }}
</h3>
<p class="text-muted-foreground text-sm">
Supplier: {{ purchase.supplier?.name }}
</p>
<p v-if="purchase.has_pending_request" class="text-sm text-amber-600">
{{ purchase.pending_request_submitted_by_name }} mengajukan {{ purchase.pending_request_action_label?.toLowerCase() }} belanja ini
<button type="button" class="underline-offset-2 hover:underline" @click="openVerificationDetail(purchase.pending_request_id)">lihat</button>
@ -168,7 +138,6 @@ function openVerificationDetail(requestId: number | undefined) {
<Table>
<TableHeader>
<TableRow>
<TableHead class="w-8">#</TableHead>
<TableHead>Varian</TableHead>
<TableHead>Jumlah</TableHead>
<TableHead>Harga Satuan</TableHead>
@ -177,15 +146,20 @@ function openVerificationDetail(requestId: number | undefined) {
</TableHeader>
<TableBody>
<TableRow v-if="!purchase.items.length" :key="`${purchase.id}-empty`">
<TableCell colspan="5" class="text-muted-foreground">
<TableCell colspan="4" class="text-muted-foreground">
Belum ada item
</TableCell>
</TableRow>
<template v-else v-for="group in getGroupedItems(purchase.items)" :key="group.rawMaterialId">
<TableRow v-for="item in group.items" :key="item.id">
<TableCell class="pl-6 text-center text-muted-foreground tabular-nums">
{{ item.item_number }}
<TableRow class="bg-muted/20 hover:bg-muted/20">
<TableCell colspan="4" class="font-semibold text-foreground">
{{ group.rawMaterialName }}
<Badge v-if="group.unitLabel" variant="secondary" class="ml-2 font-normal">
{{ group.unitLabel }}
</Badge>
</TableCell>
</TableRow>
<TableRow v-for="item in group.items" :key="item.id">
<TableCell class="pl-6 font-medium">
{{ item.variant }}
</TableCell>