diff --git a/src/components/pages/production/transfer-to-laying/TransferToLayingDetailModal.tsx b/src/components/pages/production/transfer-to-laying/TransferToLayingDetailModal.tsx
index f73ab265..8f7fb3d9 100644
--- a/src/components/pages/production/transfer-to-laying/TransferToLayingDetailModal.tsx
+++ b/src/components/pages/production/transfer-to-laying/TransferToLayingDetailModal.tsx
@@ -40,6 +40,9 @@ const TransferToLayingDetailModal = () => {
? transferToLayingResponse.data
: undefined;
+ const isTransferToLayingApproved =
+ transferToLaying?.approval.step_number === 2;
+
const { data: transferToLayingApprovalResponse } = useSWR(
transferToLayingId
? ['approval-transfer-to-laying', transferToLayingId]
@@ -55,9 +58,9 @@ const TransferToLayingDetailModal = () => {
const detailModal = useModal();
- const totalEnteredChickenForTransfer =
+ const maxSourceQuantity =
transferToLaying?.sources.reduce(
- (acc, item) => acc + Number(item.qty),
+ (acc, item) => acc + Number(item.product_warehouse.quantity),
0
) ?? 0;
@@ -67,8 +70,9 @@ const TransferToLayingDetailModal = () => {
0
) ?? 0;
+ // Sisa transfer = Max available dari kandang asal - Total yang sudah diisi di kandang tujuan
const totalAvailableChickenForTransfer =
- totalEnteredChickenForTransfer - totalTransferedChicken;
+ maxSourceQuantity - totalTransferedChicken;
const closeModalHandler = (shouldPushToRoute: boolean = true) => {
if (shouldPushToRoute) {
@@ -161,11 +165,34 @@ const TransferToLayingDetailModal = () => {
{/* Source Kandang */}
-
- Kandang Asal{' '}
-
- *
+
+
+ Kandang Asal{' '}
+
+ *
+
+
+ {!isTransferToLayingApproved && (
+ <>
+
+
+
+ >
+ )}
{transferToLaying?.sources.length === 0 && (
@@ -225,21 +252,6 @@ const TransferToLayingDetailModal = () => {
*
-
-
-
-
{transferToLaying?.targets.length === 0 && (
@@ -304,7 +316,7 @@ const TransferToLayingDetailModal = () => {
readOnly
errorMessage={
totalAvailableChickenForTransfer < 0
- ? `Jumlah transfer melebihi ketersediaan (${formatNumber(totalEnteredChickenForTransfer, 'en-US')} ayam)`
+ ? `Jumlah transfer melebihi ketersediaan (${formatNumber(maxSourceQuantity, 'en-US')} ayam)`
: ''
}
/>
diff --git a/src/components/pages/production/transfer-to-laying/TransferToLayingFormModal.tsx b/src/components/pages/production/transfer-to-laying/TransferToLayingFormModal.tsx
index a1d30d5a..bbfe64f4 100644
--- a/src/components/pages/production/transfer-to-laying/TransferToLayingFormModal.tsx
+++ b/src/components/pages/production/transfer-to-laying/TransferToLayingFormModal.tsx
@@ -822,11 +822,33 @@ const TransferToLayingFormModal = () => {
{/* Source Kandang */}
-
- Kandang Asal{' '}
-
- *
+
+
+ Kandang Asal{' '}
+
+ *
+
+
+
+
+
{formik.values.flockSourceKandangs.length === 0 && (
@@ -906,23 +928,6 @@ const TransferToLayingFormModal = () => {
*
-
-
-
-
{formik.values.flockDestinationKandangs.length === 0 && (
diff --git a/src/types/api/production/transfer-to-laying.d.ts b/src/types/api/production/transfer-to-laying.d.ts
index 8123e9e6..c1fef888 100644
--- a/src/types/api/production/transfer-to-laying.d.ts
+++ b/src/types/api/production/transfer-to-laying.d.ts
@@ -1,4 +1,8 @@
-import { BaseMetadata, CreatedUser } from '@/types/api/api-general';
+import {
+ BaseApproval,
+ BaseMetadata,
+ CreatedUser,
+} from '@/types/api/api-general';
import { BaseKandang } from '@/types/api/master-data/kandang';
import { WarehouseType } from '@/types/api/master-data/warehouse';
@@ -27,6 +31,10 @@ export type BaseTransferToLaying = {
};
qty: number;
product_warehouse: {
+ id: number;
+ product_id: number;
+ warehouse_id: number;
+ quantity: number;
product: {
id: number;
name: string;