diff --git a/src/pages/AssetDetail.tsx b/src/pages/AssetDetail.tsx index 16ce0de..680127d 100644 --- a/src/pages/AssetDetail.tsx +++ b/src/pages/AssetDetail.tsx @@ -26,6 +26,15 @@ const AssetDetail: React.FC = () => { const { asset, loading, error } = useAssetDetails( isDuplicating ? duplicateFromAsset : (isNewAsset ? null : assetName || null) ); + + // Add this after the hook call + useEffect(() => { + if (asset) { + console.log('Full asset object:', asset); + console.log('Finance books:', asset.finance_books); + } + }, [asset]); + const { createAsset, updateAsset, loading: saving } = useAssetMutations(); const [isEditing, setIsEditing] = useState(isNewAsset); @@ -53,17 +62,10 @@ const AssetDetail: React.FC = () => { custom_site_contractor: '', custom_total_amount: 0, calculate_depreciation: false, - available_for_use_date: isNewAsset ? new Date().toISOString().split('T')[0] : undefined + available_for_use_date: isNewAsset ? new Date().toISOString().split('T')[0] : undefined, + finance_books:[] }); - const emptyFinanceRow = { - finance_book: "", - depreciation_method: "", - total_number_of_depreciations: 0, - frequency_of_depreciation: "", - depreciation_start_date: "", - }; - // Load user details on mount useEffect(() => { @@ -171,7 +173,8 @@ const AssetDetail: React.FC = () => { custom_total_amount: asset.custom_total_amount || 0, gross_purchase_amount:asset.gross_purchase_amount || 0, available_for_use_date: asset.available_for_use_date || '', - calculate_depreciation: asset.calculate_depreciation || false + calculate_depreciation: asset.calculate_depreciation || false, + finance_books: asset.finance_books || [] }); } }, [asset, isDuplicating]); diff --git a/src/services/assetService.ts b/src/services/assetService.ts index a56833d..bef3190 100644 --- a/src/services/assetService.ts +++ b/src/services/assetService.ts @@ -30,6 +30,7 @@ export interface Asset { calculate_depreciation?: boolean; gross_purchase_amount?: number; available_for_use_date?:string; + finance_books?: AssetFinanceBookRow[]; } export interface AssetListResponse { @@ -72,7 +73,7 @@ export interface AssetFinanceBookRow { finance_book?: string; depreciation_method?: string; total_number_of_depreciations?: number; - frequency_of_depreciation?: string; + frequency_of_depreciation?: number; depreciation_start_date?: string; // YYYY-MM-DD }