Compare commits

...

3 Commits

Author SHA1 Message Date
efrilm
9c1b1fc1db Fixed Asset Add 2025-09-11 14:47:57 +07:00
efrilm
42b95bb212 Fixed Asset Table 2025-09-11 13:37:52 +07:00
efrilm
63eea38d48 update 2025-09-11 00:44:07 +07:00
12 changed files with 1218 additions and 4 deletions

View File

@ -0,0 +1,18 @@
import FixedAssetAddForm from '@/views/apps/fixed-assets/add/FixedAssetAddForm'
import FixedAssetAddHeader from '@/views/apps/fixed-assets/add/FixedAssetAddHeader'
import Grid from '@mui/material/Grid2'
const FixedAssetPage = () => {
return (
<Grid container spacing={6}>
<Grid size={{ xs: 12 }}>
<FixedAssetAddHeader />
</Grid>
<Grid size={{ xs: 12 }}>
<FixedAssetAddForm />
</Grid>
</Grid>
)
}
export default FixedAssetPage

View File

@ -0,0 +1,7 @@
import FixedAssetList from '@/views/apps/fixed-assets'
const FixedAssetPage = () => {
return <FixedAssetList />
}
export default FixedAssetPage

View File

@ -137,6 +137,14 @@ const VerticalMenu = ({ dictionary, scrollMenu }: Props) => {
> >
{dictionary['navigation'].account} {dictionary['navigation'].account}
</MenuItem> </MenuItem>
<MenuItem
href={`/${locale}/apps/fixed-assets`}
icon={<i className='tabler-apps' />}
exactMatch={false}
activeUrl='/apps/fixed-assets'
>
{dictionary['navigation'].fixed_assets}
</MenuItem>
<SubMenu label={dictionary['navigation'].inventory} icon={<i className='tabler-salad' />}> <SubMenu label={dictionary['navigation'].inventory} icon={<i className='tabler-salad' />}>
<SubMenu label={dictionary['navigation'].products}> <SubMenu label={dictionary['navigation'].products}>
<MenuItem href={`/${locale}/apps/inventory/products/list`}>{dictionary['navigation'].list}</MenuItem> <MenuItem href={`/${locale}/apps/inventory/products/list`}>{dictionary['navigation'].list}</MenuItem>

View File

@ -125,6 +125,7 @@
"quotes": "Quotes", "quotes": "Quotes",
"expenses": "Expenses", "expenses": "Expenses",
"cash_and_bank": "Cash & Bank", "cash_and_bank": "Cash & Bank",
"account": "Account" "account": "Account",
"fixed_assets": "Fixed Assets"
} }
} }

View File

@ -125,6 +125,7 @@
"quotes": "Penawaran", "quotes": "Penawaran",
"expenses": "Biaya", "expenses": "Biaya",
"cash_and_bank": "Kas & Bank", "cash_and_bank": "Kas & Bank",
"account": "Akun" "account": "Akun",
"fixed_assets": "Aset Tetap"
} }
} }

View File

@ -0,0 +1,8 @@
export type FixedAssetType = {
id: number
assetName: string
puchaseBill: string // Code Purchase
reference: string
date: string
price: number
}

View File

@ -372,8 +372,6 @@ const AccountListTable = () => {
variant='text' variant='text'
color='primary' color='primary'
className='p-0 min-w-0 font-medium normal-case justify-start' className='p-0 min-w-0 font-medium normal-case justify-start'
component={Link}
href={getLocalizedUrl(`/apps/accounting/accounts/${row.original.id}/detail`, locale as Locale)}
sx={{ sx={{
textTransform: 'none', textTransform: 'none',
fontWeight: 500, fontWeight: 500,

View File

@ -0,0 +1,63 @@
// MUI Imports
import Grid from '@mui/material/Grid2'
// Type Imports
import type { UserDataType } from '@components/card-statistics/HorizontalWithSubtitle'
// Component Imports
import HorizontalWithSubtitle from '@components/card-statistics/HorizontalWithSubtitle'
// Vars
const data: UserDataType[] = [
// Fixed Assets Data (from the image)
{
title: 'Nilai Aset',
stats: 'Rp 17.900.000',
avatarIcon: 'tabler-building-store',
avatarColor: 'success',
trend: 'positive',
trendNumber: '100%',
subtitle: 'Hari ini vs 365 hari lalu'
},
{
title: 'Depresiasi Aset',
stats: 'Rp 0',
avatarIcon: 'tabler-trending-down',
avatarColor: 'secondary',
trend: 'neutral',
trendNumber: '0%',
subtitle: 'Tahun ini vs tanggal sama tahun lalu'
},
{
title: 'Laba/Rugi Pelepasan Aset',
stats: 'Rp 0',
avatarIcon: 'tabler-exchange',
avatarColor: 'secondary',
trend: 'neutral',
trendNumber: '0%',
subtitle: 'Tahun ini vs tanggal sama tahun lalu'
},
{
title: 'Aset Baru',
stats: 'Rp 17.900.000',
avatarIcon: 'tabler-plus-circle',
avatarColor: 'success',
trend: 'positive',
trendNumber: '100%',
subtitle: 'Tahun ini vs tanggal sama tahun lalu'
}
]
const FixedAssetCards = () => {
return (
<Grid container spacing={6}>
{data.map((item, i) => (
<Grid key={i} size={{ xs: 12, sm: 6, md: 3 }}>
<HorizontalWithSubtitle {...item} />
</Grid>
))}
</Grid>
)
}
export default FixedAssetCards

View File

@ -0,0 +1,512 @@
'use client'
// React Imports
import { useCallback, useEffect, useMemo, useState } from 'react'
// Next Imports
import Link from 'next/link'
import { useParams } from 'next/navigation'
// MUI Imports
import Button from '@mui/material/Button'
import Card from '@mui/material/Card'
import CardHeader from '@mui/material/CardHeader'
import Checkbox from '@mui/material/Checkbox'
import Chip from '@mui/material/Chip'
import IconButton from '@mui/material/IconButton'
import MenuItem from '@mui/material/MenuItem'
import { styled } from '@mui/material/styles'
import type { TextFieldProps } from '@mui/material/TextField'
import Typography from '@mui/material/Typography'
// Third-party Imports
import type { RankingInfo } from '@tanstack/match-sorter-utils'
import { rankItem } from '@tanstack/match-sorter-utils'
import type { ColumnDef, FilterFn } from '@tanstack/react-table'
import { createColumnHelper, flexRender, getCoreRowModel, useReactTable } from '@tanstack/react-table'
import classnames from 'classnames'
// Type Imports
import type { Locale } from '@configs/i18n'
// Component Imports
import CustomTextField from '@core/components/mui/TextField'
import OptionMenu from '@core/components/option-menu'
// Style Imports
import tableStyles from '@core/styles/table.module.css'
import { Box, CircularProgress, TablePagination } from '@mui/material'
import { useDispatch } from 'react-redux'
import TablePaginationComponent from '@/components/TablePaginationComponent'
import Loading from '@/components/layout/shared/Loading'
import { getLocalizedUrl } from '@/utils/i18n'
import StatusFilterTabs from '@/components/StatusFilterTab'
// Fixed Asset Type
export type FixedAssetType = {
id: number
assetName: string
puchaseBill: string // Code Purchase
reference: string
date: string
price: number
}
declare module '@tanstack/table-core' {
interface FilterFns {
fuzzy: FilterFn<unknown>
}
interface FilterMeta {
itemRank: RankingInfo
}
}
type FixedAssetTypeWithAction = FixedAssetType & {
actions?: string
}
// Dummy data for fixed assets
const fixedAssetData: FixedAssetType[] = [
{
id: 1,
assetName: 'Laptop Dell XPS 13',
puchaseBill: 'PB-2024-001',
reference: 'REF-001',
date: '2024-01-15',
price: 15000000
},
{
id: 2,
assetName: 'Office Furniture Set',
puchaseBill: 'PB-2024-002',
reference: 'REF-002',
date: '2024-02-10',
price: 8500000
},
{
id: 3,
assetName: 'Printer Canon ImageClass',
puchaseBill: 'PB-2024-003',
reference: 'REF-003',
date: '2024-02-20',
price: 3200000
},
{
id: 4,
assetName: 'Air Conditioning Unit',
puchaseBill: 'PB-2024-004',
reference: 'REF-004',
date: '2024-03-05',
price: 12000000
},
{
id: 5,
assetName: 'Conference Room TV',
puchaseBill: 'PB-2024-005',
reference: 'REF-005',
date: '2024-03-15',
price: 7500000
},
{
id: 6,
assetName: 'MacBook Pro 16"',
puchaseBill: 'PB-2024-006',
reference: 'REF-006',
date: '2024-04-01',
price: 28000000
},
{
id: 7,
assetName: 'Standing Desk Electric',
puchaseBill: 'PB-2024-007',
reference: 'REF-007',
date: '2024-04-15',
price: 4500000
},
{
id: 8,
assetName: 'Server HP ProLiant',
puchaseBill: 'PB-2024-008',
reference: 'REF-008',
date: '2024-05-01',
price: 45000000
}
]
// Styled Components
const Icon = styled('i')({})
const fuzzyFilter: FilterFn<any> = (row, columnId, value, addMeta) => {
// Rank the item
const itemRank = rankItem(row.getValue(columnId), value)
// Store the itemRank info
addMeta({
itemRank
})
// Return if the item should be filtered in/out
return itemRank.passed
}
const DebouncedInput = ({
value: initialValue,
onChange,
debounce = 500,
...props
}: {
value: string | number
onChange: (value: string | number) => void
debounce?: number
} & Omit<TextFieldProps, 'onChange'>) => {
// States
const [value, setValue] = useState(initialValue)
useEffect(() => {
setValue(initialValue)
}, [initialValue])
useEffect(() => {
const timeout = setTimeout(() => {
onChange(value)
}, debounce)
return () => clearTimeout(timeout)
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [value])
return <CustomTextField {...props} value={value} onChange={e => setValue(e.target.value)} />
}
// Format currency
const formatCurrency = (amount: number) => {
return new Intl.NumberFormat('id-ID', {
style: 'currency',
currency: 'IDR',
minimumFractionDigits: 0
}).format(amount)
}
// Format date
const formatDate = (dateString: string) => {
return new Date(dateString).toLocaleDateString('id-ID', {
day: '2-digit',
month: '2-digit',
year: 'numeric'
})
}
// Column Definitions
const columnHelper = createColumnHelper<FixedAssetTypeWithAction>()
const FixedAssetTable = () => {
const dispatch = useDispatch()
// States
const [addAssetOpen, setAddAssetOpen] = useState(false)
const [rowSelection, setRowSelection] = useState({})
const [currentPage, setCurrentPage] = useState(0)
const [pageSize, setPageSize] = useState(10)
const [openConfirm, setOpenConfirm] = useState(false)
const [assetId, setAssetId] = useState('')
const [search, setSearch] = useState('')
const [filteredData, setFilteredData] = useState<FixedAssetType[]>([])
const [statusFilter, setStatusFilter] = useState<string>('Draft')
// Hooks
const { lang: locale } = useParams()
// Initialize data on component mount
useEffect(() => {
console.log('Initial fixedAssetData:', fixedAssetData)
setFilteredData(fixedAssetData)
}, [])
// Filter data based on search
useEffect(() => {
let filtered = [...fixedAssetData]
// Filter by search
if (search) {
filtered = filtered.filter(
asset =>
asset.assetName.toLowerCase().includes(search.toLowerCase()) ||
asset.puchaseBill.toLowerCase().includes(search.toLowerCase()) ||
asset.reference.toLowerCase().includes(search.toLowerCase())
)
}
console.log('Filtered data:', filtered) // Debug log
setFilteredData(filtered)
setCurrentPage(0)
}, [search])
const totalCount = filteredData.length
const paginatedData = useMemo(() => {
const startIndex = currentPage * pageSize
return filteredData.slice(startIndex, startIndex + pageSize)
}, [filteredData, currentPage, pageSize])
// Calculate total value from filtered data
const totalValue = useMemo(() => {
return filteredData.reduce((sum, asset) => sum + asset.price, 0)
}, [filteredData])
const handlePageChange = useCallback((event: unknown, newPage: number) => {
setCurrentPage(newPage)
}, [])
const handlePageSizeChange = useCallback((event: React.ChangeEvent<HTMLInputElement>) => {
const newPageSize = parseInt(event.target.value, 10)
setPageSize(newPageSize)
setCurrentPage(0)
}, [])
const handleDelete = () => {
setOpenConfirm(false)
}
const handleAssetClick = (assetId: string) => {
console.log('Navigasi ke detail Asset:', assetId)
}
const handleStatusFilter = (status: string) => {
setStatusFilter(status)
}
const columns = useMemo<ColumnDef<FixedAssetTypeWithAction, any>[]>(
() => [
{
id: 'select',
header: ({ table }) => (
<Checkbox
{...{
checked: table.getIsAllRowsSelected(),
indeterminate: table.getIsSomeRowsSelected(),
onChange: table.getToggleAllRowsSelectedHandler()
}}
/>
),
cell: ({ row }) => (
<Checkbox
{...{
checked: row.getIsSelected(),
disabled: !row.getCanSelect(),
indeterminate: row.getIsSomeSelected(),
onChange: row.getToggleSelectedHandler()
}}
/>
)
},
columnHelper.accessor('puchaseBill', {
header: 'Kode Pembelian',
cell: ({ row }) => (
<Button
variant='text'
color='primary'
className='p-0 min-w-0 font-medium normal-case justify-start'
component={Link}
href={getLocalizedUrl(`/apps/fixed-asset/${row.original.id}/detail`, locale as Locale)}
sx={{
textTransform: 'none',
fontWeight: 500,
'&:hover': {
textDecoration: 'underline',
backgroundColor: 'transparent'
}
}}
>
{row.original.puchaseBill}
</Button>
)
}),
columnHelper.accessor('assetName', {
header: 'Nama Aset',
cell: ({ row }) => (
<Typography color='text.primary' className='font-medium'>
{row.original.assetName}
</Typography>
)
}),
columnHelper.accessor('reference', {
header: 'Referensi',
cell: ({ row }) => <Typography color='text.secondary'>{row.original.reference || '-'}</Typography>
}),
columnHelper.accessor('date', {
header: 'Tanggal Pembelian',
cell: ({ row }) => <Typography>{formatDate(row.original.date)}</Typography>
}),
columnHelper.accessor('price', {
header: 'Harga',
cell: ({ row }) => (
<Typography className='font-medium text-primary'>{formatCurrency(row.original.price)}</Typography>
)
})
],
[locale]
)
const table = useReactTable({
data: paginatedData as FixedAssetType[],
columns,
filterFns: {
fuzzy: fuzzyFilter
},
state: {
rowSelection,
pagination: {
pageIndex: currentPage,
pageSize
}
},
enableRowSelection: true,
onRowSelectionChange: setRowSelection,
getCoreRowModel: getCoreRowModel(),
manualPagination: true,
pageCount: Math.ceil(totalCount / pageSize)
})
return (
<>
<Card>
{/* Header */}
<div className='p-6 border-bs'>
<StatusFilterTabs
statusOptions={['Draft', 'Terdaftar', 'Terjual/Dilepaskan']}
selectedStatus={statusFilter}
onStatusChange={handleStatusFilter}
/>
</div>
<div className='flex justify-between flex-col items-start md:flex-row md:items-center p-6 border-bs gap-4'>
<DebouncedInput
value={search}
onChange={value => setSearch(value as string)}
placeholder='Cari Aset Tetap'
className='max-sm:is-full'
/>
<div className='flex flex-col sm:flex-row max-sm:is-full items-start sm:items-center gap-4'>
<CustomTextField
select
value={pageSize}
onChange={handlePageSizeChange}
className='max-sm:is-full sm:is-[70px]'
>
<MenuItem value={10}>10</MenuItem>
<MenuItem value={25}>25</MenuItem>
<MenuItem value={50}>50</MenuItem>
</CustomTextField>
<Button
color='secondary'
variant='tonal'
startIcon={<i className='tabler-upload' />}
className='max-sm:is-full'
>
Ekspor
</Button>
<Button
variant='contained'
component={Link}
className='max-sm:is-full is-auto'
startIcon={<i className='tabler-plus' />}
href={getLocalizedUrl('/apps/fixed-assets/add', locale as Locale)}
>
Tambah Aset
</Button>
</div>
</div>
<div className='overflow-x-auto'>
<table className={tableStyles.table}>
<thead>
{table.getHeaderGroups().map(headerGroup => (
<tr key={headerGroup.id}>
{headerGroup.headers.map(header => (
<th key={header.id}>
{header.isPlaceholder ? null : (
<>
<div
className={classnames({
'flex items-center': header.column.getIsSorted(),
'cursor-pointer select-none': header.column.getCanSort()
})}
onClick={header.column.getToggleSortingHandler()}
>
{flexRender(header.column.columnDef.header, header.getContext())}
{{
asc: <i className='tabler-chevron-up text-xl' />,
desc: <i className='tabler-chevron-down text-xl' />
}[header.column.getIsSorted() as 'asc' | 'desc'] ?? null}
</div>
</>
)}
</th>
))}
</tr>
))}
</thead>
{filteredData.length === 0 ? (
<tbody>
<tr>
<td colSpan={table.getVisibleFlatColumns().length} className='text-center'>
Tidak ada data tersedia
</td>
</tr>
</tbody>
) : (
<tbody>
{table.getRowModel().rows.map(row => {
return (
<tr key={row.id} className={classnames({ selected: row.getIsSelected() })}>
{row.getVisibleCells().map(cell => (
<td key={cell.id}>{flexRender(cell.column.columnDef.cell, cell.getContext())}</td>
))}
</tr>
)
})}
{/* Total Row */}
<tr className='border-t-2 bg-gray-50'>
<td className='font-bold text-lg py-4'>
<Typography variant='h6' className='font-bold'>
Total Nilai Aset
</Typography>
</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td className='font-bold text-lg py-4'>
<Typography variant='h6' className='font-bold text-primary'>
{formatCurrency(totalValue)}
</Typography>
</td>
<td></td>
</tr>
</tbody>
)}
</table>
</div>
<TablePagination
component={() => (
<TablePaginationComponent
pageIndex={currentPage}
pageSize={pageSize}
totalCount={totalCount}
onPageChange={handlePageChange}
/>
)}
count={totalCount}
rowsPerPage={pageSize}
page={currentPage}
onPageChange={handlePageChange}
onRowsPerPageChange={handlePageSizeChange}
rowsPerPageOptions={[10, 25, 50]}
/>
</Card>
</>
)
}
export default FixedAssetTable

View File

@ -0,0 +1,561 @@
'use client'
import React, { useState } from 'react'
import { Card, CardContent, Typography, Button, Switch, FormControlLabel, Box, Radio } from '@mui/material'
import Grid from '@mui/material/Grid2'
import CustomTextField from '@/@core/components/mui/TextField'
import CustomAutocomplete from '@/@core/components/mui/Autocomplete'
interface FormData {
namaAset: string
nomor: string
tanggalPembelian: string
hargaBeli: string
akunAsetTetap: any
dikreditkanDariAkun: any
deskripsi: string
referensi: string
tanpaPenyusutan: boolean
akunAkumulasiPenyusutan: any
akunPenyusutan: any
nilaiPenyusuanPerTahun: string
masaManfaatTahun: string
masaManfaatBulan: string
depreciationType: 'percentage' | 'useful-life'
showAdditionalOptions: boolean
metodePenyusutan: any
tanggalMulaiPenyusutan: string
akumulasiPenyusutan: string
batasBiaya: string
nilaiResidu: string
showImageUpload: boolean
uploadedImage: string | null
}
// Simple ImageUpload component
const ImageUpload = ({ onUpload, maxFileSize, showUrlOption, dragDropText, browseButtonText }: any) => {
const [dragOver, setDragOver] = useState(false)
const handleFileSelect = (file: File) => {
if (file.size > maxFileSize) {
alert(`File size exceeds ${maxFileSize / (1024 * 1024)}MB limit`)
return
}
const url = URL.createObjectURL(file)
onUpload(file, url)
}
const handleDrop = (e: React.DragEvent) => {
e.preventDefault()
setDragOver(false)
const files = Array.from(e.dataTransfer.files)
if (files[0]) {
handleFileSelect(files[0])
}
}
const handleFileInput = (e: React.ChangeEvent<HTMLInputElement>) => {
const files = Array.from(e.target.files || [])
if (files[0]) {
handleFileSelect(files[0])
}
}
return (
<Box
sx={{
border: dragOver ? '2px dashed #1976d2' : '2px dashed #ccc',
borderRadius: 2,
p: 3,
textAlign: 'center',
backgroundColor: dragOver ? '#f5f5f5' : 'transparent',
transition: 'all 0.3s ease'
}}
onDrop={handleDrop}
onDragOver={e => {
e.preventDefault()
setDragOver(true)
}}
onDragLeave={() => setDragOver(false)}
>
<Typography variant='body1' sx={{ mb: 2 }}>
{dragDropText}
</Typography>
<input
type='file'
accept='image/*'
style={{ display: 'none' }}
id='image-upload-input'
onChange={handleFileInput}
/>
<label htmlFor='image-upload-input'>
<Button variant='outlined' component='span'>
{browseButtonText}
</Button>
</label>
</Box>
)
}
const FixedAssetAddForm = () => {
const [formData, setFormData] = useState<FormData>({
namaAset: '',
nomor: 'FA/00003',
tanggalPembelian: '11/09/2025',
hargaBeli: '0',
akunAsetTetap: null,
dikreditkanDariAkun: null,
deskripsi: '',
referensi: '',
tanpaPenyusutan: true,
akunAkumulasiPenyusutan: null,
akunPenyusutan: null,
nilaiPenyusuanPerTahun: '',
masaManfaatTahun: '',
masaManfaatBulan: '',
depreciationType: 'percentage',
showAdditionalOptions: false,
metodePenyusutan: null,
tanggalMulaiPenyusutan: '11/09/2025',
akumulasiPenyusutan: '0',
batasBiaya: '0',
nilaiResidu: '0',
showImageUpload: false,
uploadedImage: null
})
const handleInputChange = (field: keyof FormData, value: any) => {
setFormData(prev => ({
...prev,
[field]: value
}))
}
// Sample options - replace with your actual data
const akunAsetTetapOptions = [{ label: '1-10705 Aset Tetap - Perlengkapan Kantor', value: '1-10705' }]
const dikreditkanDariAkunOptions = [{ label: 'Silakan pilih dikreditkan dari akun', value: '' }]
const akunAkumulasiPenyusutanOptions = [{ label: 'Silakan pilih akun akumulasi penyusutan', value: '' }]
const akunPenyusutanOptions = [{ label: 'Silakan pilih akbun penyusutan', value: '' }]
const metodePenyusutanOptions = [
{ label: 'Straight Line', value: 'straight-line' },
{ label: 'Declining Balance', value: 'declining-balance' },
{ label: 'Sum of Years Digits', value: 'sum-of-years' }
]
const handleUpload = (file: File, url: string) => {
handleInputChange('uploadedImage', url)
console.log('Image uploaded:', { file, url })
}
const handleSubmit = () => {
console.log('Form Data:', formData)
// Handle form submission here
}
return (
<Card>
<CardContent>
<Typography variant='h6' gutterBottom>
Detil
</Typography>
<Box sx={{ mb: 2 }}>
<Button
variant='text'
color='primary'
sx={{ textTransform: 'none', p: 0, minWidth: 'auto' }}
onClick={() => handleInputChange('showImageUpload', !formData.showImageUpload)}
>
{formData.showImageUpload ? '- Sembunyikan gambar aset tetap' : '+ Tampilkan gambar aset tetap'}
</Button>
</Box>
{/* Image Upload Section */}
{formData.showImageUpload && (
<Box sx={{ mb: 3 }}>
<ImageUpload
onUpload={handleUpload}
maxFileSize={1 * 1024 * 1024} // 1MB
showUrlOption={false}
dragDropText='Drop your image here'
browseButtonText='Choose Image'
/>
{formData.uploadedImage && (
<Box sx={{ mt: 2, textAlign: 'center' }}>
<img
src={formData.uploadedImage}
alt='Uploaded asset'
style={{ maxWidth: '200px', maxHeight: '200px', borderRadius: '8px' }}
/>
</Box>
)}
</Box>
)}
<Grid container spacing={3}>
{/* Left Column */}
<Grid size={{ xs: 12, md: 6 }}>
<CustomTextField
fullWidth
label='Nama Aset'
placeholder='Nama Aset'
value={formData.namaAset}
onChange={(e: React.ChangeEvent<HTMLInputElement>) => handleInputChange('namaAset', e.target.value)}
required
sx={{ mb: 3 }}
/>
<CustomTextField
fullWidth
label='Tanggal Pembelian'
type='date'
value={formData.tanggalPembelian}
onChange={(e: React.ChangeEvent<HTMLInputElement>) =>
handleInputChange('tanggalPembelian', e.target.value)
}
InputLabelProps={{
shrink: true
}}
required
sx={{ mb: 3 }}
/>
<CustomAutocomplete
fullWidth
options={akunAsetTetapOptions}
value={formData.akunAsetTetap}
onChange={(event, newValue) => handleInputChange('akunAsetTetap', newValue)}
renderInput={params => (
<CustomTextField
{...params}
label='Akun Aset Tetap'
placeholder='1-10705 Aset Tetap - Perlengkapan Kantor'
fullWidth
required
/>
)}
sx={{ mb: 3 }}
/>
<CustomTextField
fullWidth
label='Deskripsi'
placeholder='Deskripsi'
multiline
rows={4}
value={formData.deskripsi}
onChange={(e: React.ChangeEvent<HTMLInputElement>) => handleInputChange('deskripsi', e.target.value)}
sx={{ mb: 3 }}
/>
<CustomTextField
fullWidth
label='Referensi'
placeholder='Referensi'
value={formData.referensi}
onChange={(e: React.ChangeEvent<HTMLInputElement>) => handleInputChange('referensi', e.target.value)}
/>
</Grid>
{/* Right Column */}
<Grid size={{ xs: 12, md: 6 }}>
<CustomTextField
fullWidth
label='Nomor'
value={formData.nomor}
onChange={(e: React.ChangeEvent<HTMLInputElement>) => handleInputChange('nomor', e.target.value)}
sx={{ mb: 3 }}
/>
<CustomTextField
fullWidth
label='Harga Beli'
type='number'
value={formData.hargaBeli}
onChange={(e: React.ChangeEvent<HTMLInputElement>) => handleInputChange('hargaBeli', e.target.value)}
sx={{ mb: 3 }}
/>
<CustomAutocomplete
fullWidth
options={dikreditkanDariAkunOptions}
value={formData.dikreditkanDariAkun}
onChange={(event, newValue) => handleInputChange('dikreditkanDariAkun', newValue)}
renderInput={params => (
<CustomTextField
{...params}
label='Dikreditkan Dari Akun'
placeholder='Silakan pilih dikreditkan dari akun'
fullWidth
required
/>
)}
sx={{ mb: 3 }}
/>
</Grid>
</Grid>
{/* Penyusutan Section */}
<Box sx={{ mt: 4 }}>
<Typography variant='h6' gutterBottom>
Penyusutan
</Typography>
<FormControlLabel
control={
<Switch
checked={formData.tanpaPenyusutan}
onChange={e => handleInputChange('tanpaPenyusutan', e.target.checked)}
color='primary'
/>
}
label='Tanpa penyusutan'
/>
{/* Show depreciation fields when switch is OFF (false) */}
{!formData.tanpaPenyusutan && (
<Grid container spacing={3} sx={{ mt: 2 }}>
<Grid size={{ xs: 12, md: 6 }}>
<CustomAutocomplete
fullWidth
options={akunAkumulasiPenyusutanOptions}
value={formData.akunAkumulasiPenyusutan}
onChange={(event, newValue) => handleInputChange('akunAkumulasiPenyusutan', newValue)}
renderInput={params => (
<CustomTextField
{...params}
label='Akun Akumulasi Penyusutan'
placeholder='Silakan pilih akun akumulasi penyusutan'
fullWidth
required
/>
)}
sx={{ mb: 3 }}
/>
</Grid>
<Grid size={{ xs: 12, md: 6 }}>
<CustomAutocomplete
fullWidth
options={akunPenyusutanOptions}
value={formData.akunPenyusutan}
onChange={(event, newValue) => handleInputChange('akunPenyusutan', newValue)}
renderInput={params => (
<CustomTextField
{...params}
label='Akun penyusutan'
placeholder='Silakan pilih akbun penyusutan'
fullWidth
required
/>
)}
sx={{ mb: 3 }}
/>
</Grid>
<Grid size={{ xs: 12, md: 6 }}>
<Box sx={{ mb: 3 }}>
<Typography variant='body2' sx={{ mb: 1, fontWeight: 500 }}>
Nilai penyusutan per tahun *
</Typography>
<Box sx={{ display: 'flex', alignItems: 'center', gap: 1 }}>
<Radio
checked={formData.depreciationType === 'percentage'}
onChange={() => handleInputChange('depreciationType', 'percentage')}
value='percentage'
name='depreciation-method'
color='primary'
size='small'
/>
<Box>
<CustomTextField
value={formData.nilaiPenyusuanPerTahun}
onChange={(e: React.ChangeEvent<HTMLInputElement>) =>
handleInputChange('nilaiPenyusuanPerTahun', e.target.value)
}
disabled={formData.depreciationType !== 'percentage'}
sx={{
flex: 1,
'& .MuiOutlinedInput-root': {
border: 'none',
'& fieldset': {
border: 'none'
}
}
}}
/>
</Box>
</Box>
</Box>
</Grid>
<Grid size={{ xs: 12, md: 6 }}>
<Box sx={{ mb: 3 }}>
<Typography variant='body2' sx={{ mb: 1, fontWeight: 500 }}>
Masa Manfaat *
</Typography>
<Box sx={{ display: 'flex', alignItems: 'center', gap: 1 }}>
<Radio
checked={formData.depreciationType === 'useful-life'}
onChange={() => handleInputChange('depreciationType', 'useful-life')}
value='useful-life'
name='depreciation-method'
color='primary'
size='small'
/>
<Box>
<CustomTextField
placeholder='Tahun'
value={formData.masaManfaatTahun}
onChange={(e: React.ChangeEvent<HTMLInputElement>) =>
handleInputChange('masaManfaatTahun', e.target.value)
}
disabled={formData.depreciationType !== 'useful-life'}
sx={{
flex: 1,
'& .MuiOutlinedInput-root': {
borderRadius: 0,
borderRight: '1px solid #e0e0e0',
'& fieldset': {
border: 'none'
}
}
}}
/>
<CustomTextField
placeholder='Bulan'
value={formData.masaManfaatBulan}
onChange={(e: React.ChangeEvent<HTMLInputElement>) =>
handleInputChange('masaManfaatBulan', e.target.value)
}
disabled={formData.depreciationType !== 'useful-life'}
sx={{
flex: 1,
'& .MuiOutlinedInput-root': {
borderRadius: 0,
'& fieldset': {
border: 'none'
}
}
}}
/>
</Box>
</Box>
</Box>
</Grid>
<Grid size={12}>
<Button
variant='text'
color='primary'
sx={{ textTransform: 'none', p: 0, minWidth: 'auto' }}
onClick={() => handleInputChange('showAdditionalOptions', !formData.showAdditionalOptions)}
>
{formData.showAdditionalOptions ? '- Sembunyikan opsi lainnya' : '+ Tampilkan opsi lainnya'}
</Button>
</Grid>
{/* Additional Options */}
{formData.showAdditionalOptions && (
<>
<Grid size={{ xs: 12, md: 6 }}>
<Typography variant='body2' sx={{ mb: 1, fontWeight: 500, color: 'error.main' }}>
Metode Penyusutan *
</Typography>
<CustomAutocomplete
fullWidth
options={metodePenyusutanOptions}
value={formData.metodePenyusutan}
onChange={(event, newValue) => handleInputChange('metodePenyusutan', newValue)}
renderInput={params => (
<CustomTextField {...params} placeholder='Straight Line' fullWidth required />
)}
sx={{ mb: 3 }}
/>
</Grid>
<Grid size={{ xs: 12, md: 6 }}>
<Typography variant='body2' sx={{ mb: 1, fontWeight: 500 }}>
Tanggal Mulai Penyusutan
</Typography>
<CustomTextField
fullWidth
type='date'
value={formData.tanggalMulaiPenyusutan}
onChange={(e: React.ChangeEvent<HTMLInputElement>) =>
handleInputChange('tanggalMulaiPenyusutan', e.target.value)
}
InputLabelProps={{
shrink: true
}}
sx={{ mb: 3 }}
/>
</Grid>
<Grid size={{ xs: 12, md: 4 }}>
<Typography variant='body2' sx={{ mb: 1, fontWeight: 500 }}>
Akumulasi Penyusutan
</Typography>
<CustomTextField
fullWidth
type='number'
value={formData.akumulasiPenyusutan}
onChange={(e: React.ChangeEvent<HTMLInputElement>) =>
handleInputChange('akumulasiPenyusutan', e.target.value)
}
sx={{ mb: 3 }}
/>
</Grid>
<Grid size={{ xs: 12, md: 4 }}>
<Typography variant='body2' sx={{ mb: 1, fontWeight: 500 }}>
Batas Biaya
</Typography>
<CustomTextField
fullWidth
type='number'
value={formData.batasBiaya}
onChange={(e: React.ChangeEvent<HTMLInputElement>) =>
handleInputChange('batasBiaya', e.target.value)
}
sx={{ mb: 3 }}
/>
</Grid>
<Grid size={{ xs: 12, md: 4 }}>
<Typography variant='body2' sx={{ mb: 1, fontWeight: 500 }}>
Nilai Residu
</Typography>
<CustomTextField
fullWidth
type='number'
value={formData.nilaiResidu}
onChange={(e: React.ChangeEvent<HTMLInputElement>) =>
handleInputChange('nilaiResidu', e.target.value)
}
sx={{ mb: 3 }}
/>
</Grid>
</>
)}
</Grid>
)}
</Box>
{/* Submit Button */}
<Box sx={{ mt: 4, display: 'flex', justifyContent: 'flex-end' }}>
<Button variant='contained' color='primary' onClick={handleSubmit} sx={{ minWidth: 120 }}>
Simpan
</Button>
</Box>
</CardContent>
</Card>
)
}
export default FixedAssetAddForm

View File

@ -0,0 +1,19 @@
'use client'
// MUI Imports
import Button from '@mui/material/Button'
import Typography from '@mui/material/Typography'
const FixedAssetAddHeader = () => {
return (
<div className='flex flex-wrap sm:items-center justify-between max-sm:flex-col gap-6'>
<div>
<Typography variant='h4' className='mbe-1'>
Tambah Asset Tetap
</Typography>
</div>
</div>
)
}
export default FixedAssetAddHeader

View File

@ -0,0 +1,18 @@
import Grid from '@mui/material/Grid2'
import FixedAssetCards from './FixedAssetCard'
import FixedAssetTable from './FixedAssetTable'
const FixedAssetList = () => {
return (
<Grid container spacing={6}>
<Grid size={{ xs: 12 }}>
<FixedAssetCards />
</Grid>
<Grid size={{ xs: 12 }}>
<FixedAssetTable />
</Grid>
</Grid>
)
}
export default FixedAssetList