Sales Invoice Page
This commit is contained in:
parent
f585f23c54
commit
cc3a0c07a9
@ -0,0 +1,7 @@
|
|||||||
|
import SalesBillList from '@/views/apps/sales/sales-bill/list'
|
||||||
|
|
||||||
|
const SalesBillPage = () => {
|
||||||
|
return <SalesBillList />
|
||||||
|
}
|
||||||
|
|
||||||
|
export default SalesBillPage
|
||||||
@ -93,6 +93,7 @@ const VerticalMenu = ({ dictionary, scrollMenu }: Props) => {
|
|||||||
<MenuSection label={dictionary['navigation'].appsPages}>
|
<MenuSection label={dictionary['navigation'].appsPages}>
|
||||||
<SubMenu label={dictionary['navigation'].sales} icon={<i className='tabler-user' />}>
|
<SubMenu label={dictionary['navigation'].sales} icon={<i className='tabler-user' />}>
|
||||||
<MenuItem href={`/${locale}/apps/sales/overview`}>{dictionary['navigation'].overview}</MenuItem>
|
<MenuItem href={`/${locale}/apps/sales/overview`}>{dictionary['navigation'].overview}</MenuItem>
|
||||||
|
<MenuItem href={`/${locale}/apps/sales/sales-bills`}>{dictionary['navigation'].invoices}</MenuItem>
|
||||||
{/* <MenuItem href={`/${locale}/apps/user/view`}>{dictionary['navigation'].view}</MenuItem> */}
|
{/* <MenuItem href={`/${locale}/apps/user/view`}>{dictionary['navigation'].view}</MenuItem> */}
|
||||||
</SubMenu>
|
</SubMenu>
|
||||||
<SubMenu label={dictionary['navigation'].purchase_text} icon={<i className='tabler-user' />}>
|
<SubMenu label={dictionary['navigation'].purchase_text} icon={<i className='tabler-user' />}>
|
||||||
|
|||||||
@ -118,6 +118,7 @@
|
|||||||
"purchase_orders": "Purchase Orders",
|
"purchase_orders": "Purchase Orders",
|
||||||
"purchase_bills": "Purchase Bills",
|
"purchase_bills": "Purchase Bills",
|
||||||
"purchase_delivery": "Purchase Delivery",
|
"purchase_delivery": "Purchase Delivery",
|
||||||
"purchase_quotes": "Purchase Quotes"
|
"purchase_quotes": "Purchase Quotes",
|
||||||
|
"invoices": "Invoices"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -118,6 +118,7 @@
|
|||||||
"purchase_orders": "Pesanan Pembelian",
|
"purchase_orders": "Pesanan Pembelian",
|
||||||
"purchase_bills": "Tagihan Pembelian",
|
"purchase_bills": "Tagihan Pembelian",
|
||||||
"purchase_delivery": "Pengiriman Pembelian",
|
"purchase_delivery": "Pengiriman Pembelian",
|
||||||
"purchase_quotes": "Penawaran Pembelian"
|
"purchase_quotes": "Penawaran Pembelian",
|
||||||
|
"invoices": "Tagihan"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
244
src/data/dummy/sales.ts
Normal file
244
src/data/dummy/sales.ts
Normal file
@ -0,0 +1,244 @@
|
|||||||
|
import { SalesBillType } from '@/types/apps/salesTypes'
|
||||||
|
|
||||||
|
export const salesBillData: SalesBillType[] = [
|
||||||
|
{
|
||||||
|
id: 1,
|
||||||
|
number: 'INV/001',
|
||||||
|
customerName: 'Andi Wijaya',
|
||||||
|
customerCompany: 'PT Nusantara Abadi',
|
||||||
|
reference: 'REF-SB-001',
|
||||||
|
date: '2025-09-01',
|
||||||
|
dueDate: '2025-09-15',
|
||||||
|
status: 'Belum Dibayar',
|
||||||
|
remainingBill: 5000000,
|
||||||
|
total: 5000000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 2,
|
||||||
|
number: 'INV/002',
|
||||||
|
customerName: 'Siti Rahma',
|
||||||
|
customerCompany: 'CV Cahaya Abadi',
|
||||||
|
reference: 'REF-SB-002',
|
||||||
|
date: '2025-09-02',
|
||||||
|
dueDate: '2025-09-16',
|
||||||
|
status: 'Dibayar Sebagian',
|
||||||
|
remainingBill: 2000000,
|
||||||
|
total: 8000000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 3,
|
||||||
|
number: 'INV/003',
|
||||||
|
customerName: 'Budi Santoso',
|
||||||
|
customerCompany: 'UD Sejahtera',
|
||||||
|
reference: 'REF-SB-003',
|
||||||
|
date: '2025-09-03',
|
||||||
|
dueDate: '2025-09-17',
|
||||||
|
status: 'Lunas',
|
||||||
|
remainingBill: 0,
|
||||||
|
total: 3500000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 4,
|
||||||
|
number: 'INV/004',
|
||||||
|
customerName: 'Rina Kartika',
|
||||||
|
customerCompany: 'PT Mitra Jaya',
|
||||||
|
reference: 'REF-SB-004',
|
||||||
|
date: '2025-09-04',
|
||||||
|
dueDate: '2025-09-18',
|
||||||
|
status: 'Void',
|
||||||
|
remainingBill: 0,
|
||||||
|
total: 4200000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 5,
|
||||||
|
number: 'INV/005',
|
||||||
|
customerName: 'Agus Salim',
|
||||||
|
customerCompany: 'CV Bumi Persada',
|
||||||
|
reference: 'REF-SB-005',
|
||||||
|
date: '2025-09-05',
|
||||||
|
dueDate: '2025-09-19',
|
||||||
|
status: 'Retur',
|
||||||
|
remainingBill: 0,
|
||||||
|
total: 6100000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 6,
|
||||||
|
number: 'INV/006',
|
||||||
|
customerName: 'Maya Lestari',
|
||||||
|
customerCompany: 'PT Tunas Baru',
|
||||||
|
reference: 'REF-SB-006',
|
||||||
|
date: '2025-09-06',
|
||||||
|
dueDate: '2025-09-20',
|
||||||
|
status: 'Belum Dibayar',
|
||||||
|
remainingBill: 9000000,
|
||||||
|
total: 9000000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 7,
|
||||||
|
number: 'INV/007',
|
||||||
|
customerName: 'Hendra Gunawan',
|
||||||
|
customerCompany: 'UD Prima Sentosa',
|
||||||
|
reference: 'REF-SB-007',
|
||||||
|
date: '2025-09-07',
|
||||||
|
dueDate: '2025-09-21',
|
||||||
|
status: 'Dibayar Sebagian',
|
||||||
|
remainingBill: 1500000,
|
||||||
|
total: 7500000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 8,
|
||||||
|
number: 'INV/008',
|
||||||
|
customerName: 'Dewi Anggraini',
|
||||||
|
customerCompany: 'CV Inti Mandiri',
|
||||||
|
reference: 'REF-SB-008',
|
||||||
|
date: '2025-09-08',
|
||||||
|
dueDate: '2025-09-22',
|
||||||
|
status: 'Lunas',
|
||||||
|
remainingBill: 0,
|
||||||
|
total: 4500000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 9,
|
||||||
|
number: 'INV/009',
|
||||||
|
customerName: 'Yusuf Arifin',
|
||||||
|
customerCompany: 'PT Surya Kencana',
|
||||||
|
reference: 'REF-SB-009',
|
||||||
|
date: '2025-09-09',
|
||||||
|
dueDate: '2025-09-23',
|
||||||
|
status: 'Void',
|
||||||
|
remainingBill: 0,
|
||||||
|
total: 5000000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 10,
|
||||||
|
number: 'INV/010',
|
||||||
|
customerName: 'Nurhayati',
|
||||||
|
customerCompany: 'UD Cahaya Mulia',
|
||||||
|
reference: 'REF-SB-010',
|
||||||
|
date: '2025-09-10',
|
||||||
|
dueDate: '2025-09-24',
|
||||||
|
status: 'Retur',
|
||||||
|
remainingBill: 0,
|
||||||
|
total: 3000000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 11,
|
||||||
|
number: 'INV/011',
|
||||||
|
customerName: 'Fajar Hidayat',
|
||||||
|
customerCompany: 'PT Bina Karya',
|
||||||
|
reference: 'REF-SB-011',
|
||||||
|
date: '2025-09-11',
|
||||||
|
dueDate: '2025-09-25',
|
||||||
|
status: 'Belum Dibayar',
|
||||||
|
remainingBill: 6000000,
|
||||||
|
total: 6000000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 12,
|
||||||
|
number: 'INV/012',
|
||||||
|
customerName: 'Ratna Sari',
|
||||||
|
customerCompany: 'CV Mega Utama',
|
||||||
|
reference: 'REF-SB-012',
|
||||||
|
date: '2025-09-12',
|
||||||
|
dueDate: '2025-09-26',
|
||||||
|
status: 'Dibayar Sebagian',
|
||||||
|
remainingBill: 2500000,
|
||||||
|
total: 10000000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 13,
|
||||||
|
number: 'INV/013',
|
||||||
|
customerName: 'Tono Prasetyo',
|
||||||
|
customerCompany: 'UD Karya Indah',
|
||||||
|
reference: 'REF-SB-013',
|
||||||
|
date: '2025-09-13',
|
||||||
|
dueDate: '2025-09-27',
|
||||||
|
status: 'Lunas',
|
||||||
|
remainingBill: 0,
|
||||||
|
total: 7000000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 14,
|
||||||
|
number: 'INV/014',
|
||||||
|
customerName: 'Lina Marlina',
|
||||||
|
customerCompany: 'PT Harmoni Sejati',
|
||||||
|
reference: 'REF-SB-014',
|
||||||
|
date: '2025-09-14',
|
||||||
|
dueDate: '2025-09-28',
|
||||||
|
status: 'Void',
|
||||||
|
remainingBill: 0,
|
||||||
|
total: 3200000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 15,
|
||||||
|
number: 'INV/015',
|
||||||
|
customerName: 'Arman Saputra',
|
||||||
|
customerCompany: 'CV Sentra Niaga',
|
||||||
|
reference: 'REF-SB-015',
|
||||||
|
date: '2025-09-15',
|
||||||
|
dueDate: '2025-09-29',
|
||||||
|
status: 'Retur',
|
||||||
|
remainingBill: 0,
|
||||||
|
total: 5400000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 16,
|
||||||
|
number: 'INV/016',
|
||||||
|
customerName: 'Indah Permata',
|
||||||
|
customerCompany: 'PT Citra Abadi',
|
||||||
|
reference: 'REF-SB-016',
|
||||||
|
date: '2025-09-16',
|
||||||
|
dueDate: '2025-09-30',
|
||||||
|
status: 'Belum Dibayar',
|
||||||
|
remainingBill: 8000000,
|
||||||
|
total: 8000000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 17,
|
||||||
|
number: 'INV/017',
|
||||||
|
customerName: 'Adi Putra',
|
||||||
|
customerCompany: 'UD Makmur Bersama',
|
||||||
|
reference: 'REF-SB-017',
|
||||||
|
date: '2025-09-17',
|
||||||
|
dueDate: '2025-10-01',
|
||||||
|
status: 'Dibayar Sebagian',
|
||||||
|
remainingBill: 1200000,
|
||||||
|
total: 6200000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 18,
|
||||||
|
number: 'INV/018',
|
||||||
|
customerName: 'Sri Wahyuni',
|
||||||
|
customerCompany: 'CV Bintang Terang',
|
||||||
|
reference: 'REF-SB-018',
|
||||||
|
date: '2025-09-18',
|
||||||
|
dueDate: '2025-10-02',
|
||||||
|
status: 'Lunas',
|
||||||
|
remainingBill: 0,
|
||||||
|
total: 9200000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 19,
|
||||||
|
number: 'INV/019',
|
||||||
|
customerName: 'Eko Prabowo',
|
||||||
|
customerCompany: 'PT Mandiri Jaya',
|
||||||
|
reference: 'REF-SB-019',
|
||||||
|
date: '2025-09-19',
|
||||||
|
dueDate: '2025-10-03',
|
||||||
|
status: 'Void',
|
||||||
|
remainingBill: 0,
|
||||||
|
total: 2500000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 20,
|
||||||
|
number: 'INV/020',
|
||||||
|
customerName: 'Novi Astuti',
|
||||||
|
customerCompany: 'UD Sinar Harapan',
|
||||||
|
reference: 'REF-SB-020',
|
||||||
|
date: '2025-09-20',
|
||||||
|
dueDate: '2025-10-04',
|
||||||
|
status: 'Retur',
|
||||||
|
remainingBill: 0,
|
||||||
|
total: 4800000
|
||||||
|
}
|
||||||
|
]
|
||||||
12
src/types/apps/salesTypes.ts
Normal file
12
src/types/apps/salesTypes.ts
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
export type SalesBillType = {
|
||||||
|
id: number
|
||||||
|
number: string
|
||||||
|
customerName: string
|
||||||
|
customerCompany: string
|
||||||
|
reference: string
|
||||||
|
date: string
|
||||||
|
dueDate: string
|
||||||
|
status: string
|
||||||
|
remainingBill: number
|
||||||
|
total: number
|
||||||
|
}
|
||||||
464
src/views/apps/sales/sales-bill/list/SalesBillListTable.tsx
Normal file
464
src/views/apps/sales/sales-bill/list/SalesBillListTable.tsx
Normal file
@ -0,0 +1,464 @@
|
|||||||
|
'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 { SalesBillType } from '@/types/apps/salesTypes'
|
||||||
|
import { salesBillData } from '@/data/dummy/sales'
|
||||||
|
|
||||||
|
declare module '@tanstack/table-core' {
|
||||||
|
interface FilterFns {
|
||||||
|
fuzzy: FilterFn<unknown>
|
||||||
|
}
|
||||||
|
interface FilterMeta {
|
||||||
|
itemRank: RankingInfo
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type SalesBillTypeWithAction = SalesBillType & {
|
||||||
|
actions?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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)} />
|
||||||
|
}
|
||||||
|
|
||||||
|
// Status color mapping for Sales Bill
|
||||||
|
const getStatusColor = (status: string) => {
|
||||||
|
switch (status) {
|
||||||
|
case 'Belum Dibayar':
|
||||||
|
return 'error'
|
||||||
|
case 'Dibayar Sebagian':
|
||||||
|
return 'warning'
|
||||||
|
case 'Lunas':
|
||||||
|
return 'success'
|
||||||
|
case 'Void':
|
||||||
|
return 'default'
|
||||||
|
case 'Retur':
|
||||||
|
return 'info'
|
||||||
|
default:
|
||||||
|
return 'default'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Format currency
|
||||||
|
const formatCurrency = (amount: number) => {
|
||||||
|
return new Intl.NumberFormat('id-ID', {
|
||||||
|
style: 'currency',
|
||||||
|
currency: 'IDR',
|
||||||
|
minimumFractionDigits: 0
|
||||||
|
}).format(amount)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Column Definitions
|
||||||
|
const columnHelper = createColumnHelper<SalesBillTypeWithAction>()
|
||||||
|
|
||||||
|
const SalesBillListTable = () => {
|
||||||
|
const dispatch = useDispatch()
|
||||||
|
|
||||||
|
// States
|
||||||
|
const [addBillOpen, setAddBillOpen] = useState(false)
|
||||||
|
const [rowSelection, setRowSelection] = useState({})
|
||||||
|
const [currentPage, setCurrentPage] = useState(0)
|
||||||
|
const [pageSize, setPageSize] = useState(10)
|
||||||
|
const [openConfirm, setOpenConfirm] = useState(false)
|
||||||
|
const [billId, setBillId] = useState('')
|
||||||
|
const [search, setSearch] = useState('')
|
||||||
|
const [statusFilter, setStatusFilter] = useState<string>('Semua')
|
||||||
|
const [filteredData, setFilteredData] = useState<SalesBillType[]>(salesBillData)
|
||||||
|
|
||||||
|
// Hooks
|
||||||
|
const { lang: locale } = useParams()
|
||||||
|
|
||||||
|
// Filter data based on search and status
|
||||||
|
useEffect(() => {
|
||||||
|
let filtered = salesBillData
|
||||||
|
|
||||||
|
// Filter by search
|
||||||
|
if (search) {
|
||||||
|
filtered = filtered.filter(
|
||||||
|
bill =>
|
||||||
|
bill.number.toLowerCase().includes(search.toLowerCase()) ||
|
||||||
|
bill.customerName.toLowerCase().includes(search.toLowerCase()) ||
|
||||||
|
bill.customerCompany.toLowerCase().includes(search.toLowerCase()) ||
|
||||||
|
bill.status.toLowerCase().includes(search.toLowerCase())
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Filter by status
|
||||||
|
if (statusFilter !== 'Semua') {
|
||||||
|
filtered = filtered.filter(bill => bill.status === statusFilter)
|
||||||
|
}
|
||||||
|
|
||||||
|
setFilteredData(filtered)
|
||||||
|
setCurrentPage(0)
|
||||||
|
}, [search, statusFilter])
|
||||||
|
|
||||||
|
const totalCount = filteredData.length
|
||||||
|
const paginatedData = useMemo(() => {
|
||||||
|
const startIndex = currentPage * pageSize
|
||||||
|
return filteredData.slice(startIndex, startIndex + pageSize)
|
||||||
|
}, [filteredData, currentPage, pageSize])
|
||||||
|
|
||||||
|
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 handleBillClick = (billId: string) => {
|
||||||
|
console.log('Navigasi ke detail Sales Bill:', billId)
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleStatusFilter = (status: string) => {
|
||||||
|
setStatusFilter(status)
|
||||||
|
}
|
||||||
|
|
||||||
|
const columns = useMemo<ColumnDef<SalesBillTypeWithAction, 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('number', {
|
||||||
|
header: 'Nomor Bill',
|
||||||
|
cell: ({ row }) => (
|
||||||
|
<Button
|
||||||
|
variant='text'
|
||||||
|
color='primary'
|
||||||
|
className='p-0 min-w-0 font-medium normal-case justify-start'
|
||||||
|
onClick={() => handleBillClick(row.original.id.toString())}
|
||||||
|
sx={{
|
||||||
|
textTransform: 'none',
|
||||||
|
fontWeight: 500,
|
||||||
|
'&:hover': {
|
||||||
|
textDecoration: 'underline',
|
||||||
|
backgroundColor: 'transparent'
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{row.original.number}
|
||||||
|
</Button>
|
||||||
|
)
|
||||||
|
}),
|
||||||
|
columnHelper.accessor('customerName', {
|
||||||
|
header: 'Customer',
|
||||||
|
cell: ({ row }) => (
|
||||||
|
<div className='flex flex-col'>
|
||||||
|
<Typography color='text.primary' className='font-medium'>
|
||||||
|
{row.original.customerName}
|
||||||
|
</Typography>
|
||||||
|
<Typography variant='body2' color='text.secondary'>
|
||||||
|
{row.original.customerCompany}
|
||||||
|
</Typography>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}),
|
||||||
|
columnHelper.accessor('reference', {
|
||||||
|
header: 'Referensi',
|
||||||
|
cell: ({ row }) => <Typography color='text.secondary'>{row.original.reference || '-'}</Typography>
|
||||||
|
}),
|
||||||
|
columnHelper.accessor('date', {
|
||||||
|
header: 'Tanggal',
|
||||||
|
cell: ({ row }) => <Typography>{row.original.date}</Typography>
|
||||||
|
}),
|
||||||
|
columnHelper.accessor('dueDate', {
|
||||||
|
header: 'Tanggal Jatuh Tempo',
|
||||||
|
cell: ({ row }) => <Typography>{row.original.dueDate}</Typography>
|
||||||
|
}),
|
||||||
|
columnHelper.accessor('status', {
|
||||||
|
header: 'Status',
|
||||||
|
cell: ({ row }) => (
|
||||||
|
<div className='flex items-center gap-3'>
|
||||||
|
<Chip
|
||||||
|
variant='tonal'
|
||||||
|
label={row.original.status}
|
||||||
|
size='small'
|
||||||
|
color={getStatusColor(row.original.status) as any}
|
||||||
|
className='capitalize'
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}),
|
||||||
|
columnHelper.accessor('remainingBill', {
|
||||||
|
header: 'Sisa Tagihan',
|
||||||
|
cell: ({ row }) => (
|
||||||
|
<Typography className={`font-medium ${row.original.remainingBill > 0 ? 'text-red-600' : 'text-green-600'}`}>
|
||||||
|
{formatCurrency(row.original.remainingBill)}
|
||||||
|
</Typography>
|
||||||
|
)
|
||||||
|
}),
|
||||||
|
columnHelper.accessor('total', {
|
||||||
|
header: 'Total',
|
||||||
|
cell: ({ row }) => <Typography className='font-medium'>{formatCurrency(row.original.total)}</Typography>
|
||||||
|
})
|
||||||
|
],
|
||||||
|
[]
|
||||||
|
)
|
||||||
|
|
||||||
|
const table = useReactTable({
|
||||||
|
data: paginatedData as SalesBillType[],
|
||||||
|
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>
|
||||||
|
{/* Filter Status Tabs */}
|
||||||
|
<div className='p-6 border-bs'>
|
||||||
|
<div className='flex flex-wrap gap-2'>
|
||||||
|
{['Semua', 'Belum Dibayar', 'Dibayar Sebagian', 'Lunas', 'Void', 'Retur'].map(status => (
|
||||||
|
<Button
|
||||||
|
key={status}
|
||||||
|
variant={statusFilter === status ? 'contained' : 'outlined'}
|
||||||
|
color={statusFilter === status ? 'primary' : 'inherit'}
|
||||||
|
onClick={() => handleStatusFilter(status)}
|
||||||
|
size='small'
|
||||||
|
className='rounded-lg'
|
||||||
|
sx={{
|
||||||
|
textTransform: 'none',
|
||||||
|
fontWeight: statusFilter === status ? 600 : 400,
|
||||||
|
borderRadius: '8px',
|
||||||
|
...(statusFilter !== status && {
|
||||||
|
borderColor: '#e0e0e0',
|
||||||
|
color: '#666'
|
||||||
|
})
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{status}
|
||||||
|
</Button>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</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 Sales Bill'
|
||||||
|
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/sales/sales-bills/add', locale as Locale)}
|
||||||
|
>
|
||||||
|
Tambah
|
||||||
|
</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>
|
||||||
|
)
|
||||||
|
})}
|
||||||
|
</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 SalesBillListTable
|
||||||
19
src/views/apps/sales/sales-bill/list/index.tsx
Normal file
19
src/views/apps/sales/sales-bill/list/index.tsx
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
// MUI Imports
|
||||||
|
import Grid from '@mui/material/Grid2'
|
||||||
|
|
||||||
|
// Type Imports
|
||||||
|
|
||||||
|
// Component Imports
|
||||||
|
import SalesBillListTable from './SalesBillListTable'
|
||||||
|
|
||||||
|
const SalesBillList = () => {
|
||||||
|
return (
|
||||||
|
<Grid container spacing={6}>
|
||||||
|
<Grid size={{ xs: 12 }}>
|
||||||
|
<SalesBillListTable />
|
||||||
|
</Grid>
|
||||||
|
</Grid>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default SalesBillList
|
||||||
Loading…
x
Reference in New Issue
Block a user