Sales Bill List table Update
This commit is contained in:
parent
7077bf8d87
commit
420df71452
@ -188,7 +188,6 @@ const ExpenseListTable = () => {
|
|||||||
return filteredData.reduce((sum, expense) => sum + expense.total, 0)
|
return filteredData.reduce((sum, expense) => sum + expense.total, 0)
|
||||||
}, [filteredData])
|
}, [filteredData])
|
||||||
|
|
||||||
// For demonstration, adding tax/additional fees to show difference between subtotal and total
|
|
||||||
const taxAmount = subtotalTotal * 0.1 // 10% tax example
|
const taxAmount = subtotalTotal * 0.1 // 10% tax example
|
||||||
const finalTotal = subtotalTotal + taxAmount
|
const finalTotal = subtotalTotal + taxAmount
|
||||||
|
|
||||||
|
|||||||
@ -42,6 +42,8 @@ import Loading from '@/components/layout/shared/Loading'
|
|||||||
import { getLocalizedUrl } from '@/utils/i18n'
|
import { getLocalizedUrl } from '@/utils/i18n'
|
||||||
import { SalesBillType } from '@/types/apps/salesTypes'
|
import { SalesBillType } from '@/types/apps/salesTypes'
|
||||||
import { salesBillData } from '@/data/dummy/sales'
|
import { salesBillData } from '@/data/dummy/sales'
|
||||||
|
import DateRangePicker from '@/components/RangeDatePicker'
|
||||||
|
import StatusFilterTabs from '@/components/StatusFilterTab'
|
||||||
|
|
||||||
declare module '@tanstack/table-core' {
|
declare module '@tanstack/table-core' {
|
||||||
interface FilterFns {
|
interface FilterFns {
|
||||||
@ -144,6 +146,8 @@ const SalesBillListTable = () => {
|
|||||||
const [search, setSearch] = useState('')
|
const [search, setSearch] = useState('')
|
||||||
const [statusFilter, setStatusFilter] = useState<string>('Semua')
|
const [statusFilter, setStatusFilter] = useState<string>('Semua')
|
||||||
const [filteredData, setFilteredData] = useState<SalesBillType[]>(salesBillData)
|
const [filteredData, setFilteredData] = useState<SalesBillType[]>(salesBillData)
|
||||||
|
const [startDate, setStartDate] = useState<Date | null>(new Date())
|
||||||
|
const [endDate, setEndDate] = useState<Date | null>(new Date())
|
||||||
|
|
||||||
// Hooks
|
// Hooks
|
||||||
const { lang: locale } = useParams()
|
const { lang: locale } = useParams()
|
||||||
@ -178,6 +182,17 @@ const SalesBillListTable = () => {
|
|||||||
return filteredData.slice(startIndex, startIndex + pageSize)
|
return filteredData.slice(startIndex, startIndex + pageSize)
|
||||||
}, [filteredData, currentPage, pageSize])
|
}, [filteredData, currentPage, pageSize])
|
||||||
|
|
||||||
|
const subtotalremainingBill = useMemo(() => {
|
||||||
|
return filteredData.reduce((sum, expense) => sum + expense.remainingBill, 0)
|
||||||
|
}, [filteredData])
|
||||||
|
|
||||||
|
const subtotalTotal = useMemo(() => {
|
||||||
|
return filteredData.reduce((sum, expense) => sum + expense.total, 0)
|
||||||
|
}, [filteredData])
|
||||||
|
|
||||||
|
const taxAmount = subtotalTotal * 0.1 // 10% tax example
|
||||||
|
const finalTotal = subtotalTotal + taxAmount
|
||||||
|
|
||||||
const handlePageChange = useCallback((event: unknown, newPage: number) => {
|
const handlePageChange = useCallback((event: unknown, newPage: number) => {
|
||||||
setCurrentPage(newPage)
|
setCurrentPage(newPage)
|
||||||
}, [])
|
}, [])
|
||||||
@ -323,30 +338,29 @@ const SalesBillListTable = () => {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Card>
|
<Card>
|
||||||
{/* Filter Status Tabs */}
|
{/* Filter Status Tabs and Range Date */}
|
||||||
<div className='p-6 border-bs'>
|
<div className='p-6 border-bs'>
|
||||||
<div className='flex flex-wrap gap-2'>
|
<div className='flex items-center justify-between'>
|
||||||
{['Semua', 'Belum Dibayar', 'Dibayar Sebagian', 'Lunas', 'Void', 'Retur'].map(status => (
|
<StatusFilterTabs
|
||||||
<Button
|
statusOptions={[
|
||||||
key={status}
|
'Semua',
|
||||||
variant={statusFilter === status ? 'contained' : 'outlined'}
|
'Belum Dibayar',
|
||||||
color={statusFilter === status ? 'primary' : 'inherit'}
|
'Dibayar Sebagian',
|
||||||
onClick={() => handleStatusFilter(status)}
|
'Lunas',
|
||||||
size='small'
|
'Void',
|
||||||
className='rounded-lg'
|
'Jatuh Tempo',
|
||||||
sx={{
|
'Retur',
|
||||||
textTransform: 'none',
|
'Transaksi Berulang'
|
||||||
fontWeight: statusFilter === status ? 600 : 400,
|
]}
|
||||||
borderRadius: '8px',
|
selectedStatus={statusFilter}
|
||||||
...(statusFilter !== status && {
|
onStatusChange={handleStatusFilter}
|
||||||
borderColor: '#e0e0e0',
|
/>
|
||||||
color: '#666'
|
<DateRangePicker
|
||||||
})
|
startDate={startDate}
|
||||||
}}
|
endDate={endDate}
|
||||||
>
|
onStartDateChange={setStartDate}
|
||||||
{status}
|
onEndDateChange={setEndDate}
|
||||||
</Button>
|
/>
|
||||||
))}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -435,6 +449,56 @@ const SalesBillListTable = () => {
|
|||||||
</tr>
|
</tr>
|
||||||
)
|
)
|
||||||
})}
|
})}
|
||||||
|
|
||||||
|
{/* Subtotal Row */}
|
||||||
|
<tr className='border-t-2 bg-gray-50'>
|
||||||
|
<td className='font-semibold text-lg py-4'>
|
||||||
|
<Typography variant='h6' className='font-semibold'>
|
||||||
|
Subtotal
|
||||||
|
</Typography>
|
||||||
|
</td>
|
||||||
|
<td></td>
|
||||||
|
<td></td>
|
||||||
|
<td></td>
|
||||||
|
<td></td>
|
||||||
|
<td></td>
|
||||||
|
<td></td>
|
||||||
|
<td className='font-semibold text-lg py-4'>
|
||||||
|
<Typography variant='h6' className='font-semibol'>
|
||||||
|
{formatCurrency(subtotalremainingBill)}
|
||||||
|
</Typography>
|
||||||
|
</td>
|
||||||
|
<td className='font-semibold text-lg py-4'>
|
||||||
|
<Typography variant='h6' className='font-semibold'>
|
||||||
|
{formatCurrency(subtotalTotal)}
|
||||||
|
</Typography>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
{/* Total Row */}
|
||||||
|
<tr className='border-t bg-gray-100'>
|
||||||
|
<td className='font-bold text-xl py-4'>
|
||||||
|
<Typography variant='h6' className='font-bold'>
|
||||||
|
Total
|
||||||
|
</Typography>
|
||||||
|
</td>
|
||||||
|
<td></td>
|
||||||
|
<td></td>
|
||||||
|
<td></td>
|
||||||
|
<td></td>
|
||||||
|
<td></td>
|
||||||
|
<td></td>
|
||||||
|
<td className='font-bold text-xl py-4'>
|
||||||
|
<Typography variant='h6' className='font-bold'>
|
||||||
|
{formatCurrency(subtotalremainingBill + taxAmount)}
|
||||||
|
</Typography>
|
||||||
|
</td>
|
||||||
|
<td className='font-bold text-xl py-4'>
|
||||||
|
<Typography variant='h6' className='font-bold'>
|
||||||
|
{formatCurrency(finalTotal)}
|
||||||
|
</Typography>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
)}
|
)}
|
||||||
</table>
|
</table>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user