pembayaran hutang done
parent
bdf9ea7a49
commit
394e4bb40b
@ -0,0 +1,172 @@
|
||||
import React from 'react'
|
||||
import { Link, router } from '@inertiajs/react'
|
||||
import { Head } from '@inertiajs/react'
|
||||
import { HiEye } from 'react-icons/hi2'
|
||||
|
||||
import AuthenticatedLayout from '@/Layouts/AuthenticatedLayout'
|
||||
import Pagination from '@/Components/Pagination'
|
||||
import { formatIDR } from '@/utils'
|
||||
import Button from '@/Components/Button'
|
||||
import { HiRefresh } from 'react-icons/hi'
|
||||
|
||||
export default function PaylaterHistory(props) {
|
||||
const {
|
||||
query: { links, data },
|
||||
customer,
|
||||
} = props
|
||||
|
||||
return (
|
||||
<AuthenticatedLayout
|
||||
page={'Mitra WBB'}
|
||||
action={[customer.name, 'Riwayat Pembayaran Hutang']}
|
||||
parent={route('mitra.edit', customer)}
|
||||
>
|
||||
<Head title="Pembayaran Hutang" />
|
||||
|
||||
<div>
|
||||
<div className="mx-auto sm:px-6 lg:px-8 ">
|
||||
<div className="p-6 overflow-hidden shadow-sm sm:rounded-lg bg-gray-200 dark:bg-gray-800 space-y-4">
|
||||
<div className="w-full flex flex-row justify-end">
|
||||
<Button
|
||||
onClick={() =>
|
||||
router.visit(
|
||||
route(route().current(), customer)
|
||||
)
|
||||
}
|
||||
>
|
||||
<HiRefresh className="w-5 h-5" />
|
||||
</Button>
|
||||
</div>
|
||||
<div className="overflow-auto">
|
||||
<div>
|
||||
<table className="w-full text-sm text-left text-gray-500 dark:text-gray-400 mb-4">
|
||||
<thead className="text-xs text-gray-700 uppercase bg-gray-50 dark:bg-gray-700 dark:text-gray-400">
|
||||
<tr>
|
||||
<th
|
||||
scope="col"
|
||||
className="py-3 px-6"
|
||||
>
|
||||
#
|
||||
</th>
|
||||
<th
|
||||
scope="col"
|
||||
className="py-3 px-6"
|
||||
>
|
||||
Customer
|
||||
</th>
|
||||
<th
|
||||
scope="col"
|
||||
className="py-3 px-3"
|
||||
>
|
||||
Debit
|
||||
</th>
|
||||
<th
|
||||
scope="col"
|
||||
className="py-3 px-3"
|
||||
>
|
||||
Credit
|
||||
</th>
|
||||
<th
|
||||
scope="col"
|
||||
className="py-3 px-6"
|
||||
>
|
||||
Tanggal
|
||||
</th>
|
||||
<th
|
||||
scope="col"
|
||||
className="py-3 px-6"
|
||||
>
|
||||
Note
|
||||
</th>
|
||||
<th
|
||||
scope="col"
|
||||
className="py-3 px-6"
|
||||
>
|
||||
Status
|
||||
</th>
|
||||
<th
|
||||
scope="col"
|
||||
className="py-3 px-6"
|
||||
>
|
||||
Approver
|
||||
</th>
|
||||
<th
|
||||
scope="col"
|
||||
className="py-3 px-6"
|
||||
/>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{data.map((paylater) => (
|
||||
<tr
|
||||
className="bg-white border-b dark:bg-gray-800 dark:border-gray-700"
|
||||
key={paylater.id}
|
||||
>
|
||||
<td
|
||||
scope="row"
|
||||
className="py-4 px-6 font-medium text-gray-900 whitespace-nowrap dark:text-white"
|
||||
>
|
||||
{paylater.description}
|
||||
</td>
|
||||
<td className="py-4 px-6">
|
||||
<Link
|
||||
className="hover:underline"
|
||||
href={route(
|
||||
'mitra.edit',
|
||||
customer.id
|
||||
)}
|
||||
>
|
||||
{customer.name}
|
||||
</Link>
|
||||
</td>
|
||||
<td className="py-4 px-3">
|
||||
{`Rp ${formatIDR(
|
||||
paylater.credit
|
||||
)}`}
|
||||
</td>
|
||||
<td className="py-4 px-3">
|
||||
{`Rp ${formatIDR(
|
||||
paylater.debit
|
||||
)}`}
|
||||
</td>
|
||||
<td className="py-4 px-6">
|
||||
{paylater.format_created_at}
|
||||
</td>
|
||||
<td className="py-4 px-6">
|
||||
{paylater.note}
|
||||
</td>
|
||||
<td
|
||||
className={`py-4 px-6 ${paylater.status_text.text_color}`}
|
||||
>
|
||||
{paylater.status_text.text}
|
||||
</td>
|
||||
<td className="py-4 px-6">
|
||||
{paylater.editor?.name}
|
||||
</td>
|
||||
<td className="py-4 px-6 flex justify-center">
|
||||
<Link
|
||||
href={route(
|
||||
'paylater.show',
|
||||
paylater
|
||||
)}
|
||||
className="flex space-x-1 items-center hover:underline"
|
||||
>
|
||||
<HiEye />
|
||||
<div>Lihat</div>
|
||||
</Link>
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div className="w-full flex items-center justify-center">
|
||||
<Pagination links={links} />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</AuthenticatedLayout>
|
||||
)
|
||||
}
|
@ -0,0 +1,67 @@
|
||||
import React from 'react'
|
||||
import { Head, Link } from '@inertiajs/react'
|
||||
|
||||
import AuthenticatedLayout from '@/Layouts/AuthenticatedLayout'
|
||||
|
||||
export default function Detail(props) {
|
||||
const { paylater } = props
|
||||
|
||||
return (
|
||||
<AuthenticatedLayout
|
||||
page={'Pembayaran Hutang'}
|
||||
action={paylater.description}
|
||||
parent={route('paylater.index')}
|
||||
>
|
||||
<Head title="Pembayaran Hutang" />
|
||||
|
||||
<div>
|
||||
<div className="mx-auto sm:px-6 lg:px-8">
|
||||
<div className="overflow-hidden p-4 shadow-sm sm:rounded-lg bg-white dark:bg-gray-800 flex flex-col ">
|
||||
<div className="text-xl font-bold mb-4">
|
||||
{paylater.description}
|
||||
</div>
|
||||
<table className="relative w-full overflow-x-auto p-2 rounded">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td className="font-bold">Customer</td>
|
||||
<td>:</td>
|
||||
<td>
|
||||
<Link
|
||||
href={route('customer.edit', {
|
||||
customer: paylater.customer,
|
||||
})}
|
||||
className="hover:underline"
|
||||
>
|
||||
{paylater.customer.name}
|
||||
</Link>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td className="font-bold">Jumlah</td>
|
||||
<td>:</td>
|
||||
<td>{paylater.amount}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td className="font-bold">Status</td>
|
||||
<td>:</td>
|
||||
<td
|
||||
className={
|
||||
paylater.status_text.text_color
|
||||
}
|
||||
>
|
||||
{paylater.status_text.text}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td className="font-bold">Tanggal</td>
|
||||
<td>:</td>
|
||||
<td>{paylater.format_created_at}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</AuthenticatedLayout>
|
||||
)
|
||||
}
|
@ -0,0 +1,230 @@
|
||||
import React, { useEffect } from 'react'
|
||||
import { Head, Link, useForm } from '@inertiajs/react'
|
||||
import { isEmpty } from 'lodash'
|
||||
|
||||
import {
|
||||
STATUS_APPROVE,
|
||||
STATUS_REJECT,
|
||||
STATUS_WAIT_APPROVE,
|
||||
STATUS_WAIT_UPLOAD,
|
||||
} from '@/constant'
|
||||
import AuthenticatedLayout from '@/Layouts/AuthenticatedLayout'
|
||||
import FormInput from '@/Components/FormInput'
|
||||
import Button from '@/Components/Button'
|
||||
import FormInputNumeric from '@/Components/FormInputNumeric'
|
||||
import { formatIDR } from '@/utils'
|
||||
|
||||
export default function Form(props) {
|
||||
const { deposit } = props
|
||||
|
||||
const { data, setData, post, processing, errors } = useForm({
|
||||
debit: 0,
|
||||
is_valid: 0,
|
||||
reject_reason: '',
|
||||
})
|
||||
|
||||
const handleOnChange = (event) => {
|
||||
setData(
|
||||
event.target.name,
|
||||
event.target.type === 'checkbox'
|
||||
? event.target.checked
|
||||
? 1
|
||||
: 0
|
||||
: event.target.value
|
||||
)
|
||||
}
|
||||
|
||||
const showForm =
|
||||
+deposit.is_valid === STATUS_WAIT_APPROVE ||
|
||||
+deposit.is_valid === STATUS_WAIT_UPLOAD
|
||||
|
||||
const handleSubmit = () => {
|
||||
post(route('paylater.update', deposit))
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
if (isEmpty(deposit) === false) {
|
||||
setData({
|
||||
debit: deposit.debit,
|
||||
is_valid: deposit.is_valid,
|
||||
reject_reason: deposit.reject_reason,
|
||||
})
|
||||
return
|
||||
}
|
||||
}, [deposit])
|
||||
|
||||
return (
|
||||
<AuthenticatedLayout
|
||||
page={'Pembayaran Hutang'}
|
||||
action={deposit.description}
|
||||
parent={route('paylater.index')}
|
||||
>
|
||||
<Head title="Pembayaran Hutang" />
|
||||
|
||||
<div>
|
||||
<div className="mx-auto sm:px-6 lg:px-8">
|
||||
<div className="overflow-hidden p-4 shadow-sm sm:rounded-lg bg-white dark:bg-gray-800 flex flex-col ">
|
||||
<div className="text-xl font-bold mb-4">
|
||||
{deposit.description}
|
||||
</div>
|
||||
<table className="relative w-full overflow-x-auto p-2 rounded">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td className="font-bold">Customer</td>
|
||||
<td>:</td>
|
||||
<td>
|
||||
<Link
|
||||
href={route('customer.edit', {
|
||||
customer: deposit.customer,
|
||||
})}
|
||||
className="hover:underline"
|
||||
>
|
||||
{deposit.customer.name}
|
||||
</Link>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td className="font-bold">
|
||||
Metode Pembayaran
|
||||
</td>
|
||||
<td>:</td>
|
||||
<td>{deposit.payment_channel}</td>
|
||||
</tr>
|
||||
{deposit.account !== null && (
|
||||
<tr>
|
||||
<td className="font-bold">Bank Akun</td>
|
||||
<td>:</td>
|
||||
<td>
|
||||
{deposit.account.name} (
|
||||
{deposit.account.bank_name})
|
||||
</td>
|
||||
</tr>
|
||||
)}
|
||||
{deposit.deposit_location !== null && (
|
||||
<tr>
|
||||
<td className="font-bold">
|
||||
Lokasi Cash / Setor Tunai
|
||||
</td>
|
||||
<td>:</td>
|
||||
<td>{deposit.deposit_location.name}</td>
|
||||
</tr>
|
||||
)}
|
||||
<tr>
|
||||
<td className="font-bold">Jumlah</td>
|
||||
<td>:</td>
|
||||
<td>{deposit.amount}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td className="font-bold">Admin Fee</td>
|
||||
<td>:</td>
|
||||
<td>Rp {formatIDR(+deposit.admin_fee)}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td className="font-bold">Status</td>
|
||||
<td>:</td>
|
||||
<td className={deposit.status.text_color}>
|
||||
{deposit.status.text}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td className="font-bold">
|
||||
Alasan Penolakan
|
||||
</td>
|
||||
<td>:</td>
|
||||
<td>{deposit.reject_reason}</td>
|
||||
</tr>
|
||||
{isEmpty(deposit.editor) === false && (
|
||||
<tr>
|
||||
<td className="font-bold">Approver</td>
|
||||
<td>:</td>
|
||||
<td>{deposit.editor.name}</td>
|
||||
</tr>
|
||||
)}
|
||||
<tr>
|
||||
<td className="font-bold">Tanggal</td>
|
||||
<td>:</td>
|
||||
<td>{deposit.format_created_at}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
{isEmpty(deposit.image_prove_url) === false && (
|
||||
<div>
|
||||
<a
|
||||
href={deposit.image_prove_url}
|
||||
target="_blank"
|
||||
>
|
||||
<img
|
||||
src={deposit.image_prove_url}
|
||||
className="w-full object-fill h-96"
|
||||
loading="lazy"
|
||||
/>
|
||||
</a>
|
||||
</div>
|
||||
)}
|
||||
{showForm && (
|
||||
<>
|
||||
<div className="my-4">
|
||||
<FormInputNumeric
|
||||
type="number"
|
||||
label="Jumlah Deposit"
|
||||
name="debit"
|
||||
onChange={handleOnChange}
|
||||
value={data.debit}
|
||||
error={errors.debit}
|
||||
/>
|
||||
<div className="mb-1 text-sm">Status</div>
|
||||
<select
|
||||
className="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"
|
||||
onChange={handleOnChange}
|
||||
value={+data.is_valid}
|
||||
name="is_valid"
|
||||
>
|
||||
<option value="">
|
||||
{' '}
|
||||
-- pilih status --{' '}
|
||||
</option>
|
||||
<option value={STATUS_APPROVE}>
|
||||
Approve
|
||||
</option>
|
||||
<option value={STATUS_REJECT}>
|
||||
Reject
|
||||
</option>
|
||||
</select>
|
||||
{errors.status && (
|
||||
<div className="text-sm text-red-500">
|
||||
{errors.status}
|
||||
</div>
|
||||
)}
|
||||
{errors.reject_reason && (
|
||||
<div className="text-sm text-red-500">
|
||||
{errors.reject_reason}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
{+data.is_valid === STATUS_REJECT && (
|
||||
<FormInput
|
||||
label="Alasan penolakan"
|
||||
name="reject_reason"
|
||||
value={data.reject_reason}
|
||||
onChange={handleOnChange}
|
||||
error={errors.reject_reason}
|
||||
/>
|
||||
)}
|
||||
|
||||
<div className="mt-8">
|
||||
<Button
|
||||
onClick={handleSubmit}
|
||||
processing={processing}
|
||||
>
|
||||
Simpan
|
||||
</Button>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</AuthenticatedLayout>
|
||||
)
|
||||
}
|
@ -0,0 +1,218 @@
|
||||
import React, { useEffect, useState } from 'react'
|
||||
import { Head, Link, router } from '@inertiajs/react'
|
||||
import { usePrevious } from 'react-use'
|
||||
import { HiEye } from 'react-icons/hi2'
|
||||
|
||||
import { formatIDR, hasPermission } from '@/utils'
|
||||
import { DEPOSIT_STATUSES } from '@/constant'
|
||||
import AuthenticatedLayout from '@/Layouts/AuthenticatedLayout'
|
||||
import Pagination from '@/Components/Pagination'
|
||||
import SearchInput from '@/Components/SearchInput'
|
||||
import ThSort from '@/Components/ThSortComponent'
|
||||
|
||||
export default function Index(props) {
|
||||
const {
|
||||
deposits: { links, data },
|
||||
auth,
|
||||
_search,
|
||||
_sortBy,
|
||||
_sortRule,
|
||||
} = props
|
||||
|
||||
const [search, setSearch] = useState({
|
||||
q: _search,
|
||||
sortBy: _sortBy,
|
||||
sortRule: _sortRule,
|
||||
})
|
||||
const [status, setStatus] = useState('')
|
||||
const preValue = usePrevious(`${search}${status}`)
|
||||
|
||||
const handleChangeSearch = (e) => {
|
||||
setSearch({
|
||||
...search,
|
||||
q: e.target.value,
|
||||
})
|
||||
}
|
||||
|
||||
const sort = (key, sort = null) => {
|
||||
if (sort !== null) {
|
||||
setSearch({
|
||||
...search,
|
||||
sortBy: key,
|
||||
sortRule: sort,
|
||||
})
|
||||
return
|
||||
}
|
||||
setSearch({
|
||||
...search,
|
||||
sortBy: key,
|
||||
sortRule: search.sortRule == 'asc' ? 'desc' : 'asc',
|
||||
})
|
||||
}
|
||||
|
||||
const params = { ...search, status: status }
|
||||
useEffect(() => {
|
||||
if (preValue) {
|
||||
router.get(
|
||||
route(route().current()),
|
||||
{ ...search, status: status },
|
||||
{
|
||||
replace: true,
|
||||
preserveState: true,
|
||||
}
|
||||
)
|
||||
}
|
||||
}, [search, status])
|
||||
|
||||
const canUpdate = hasPermission(auth, 'update-paylater-repayment')
|
||||
|
||||
return (
|
||||
<AuthenticatedLayout page={'Pembayaran Hutang'} action={''}>
|
||||
<Head title="Pembayaran Hutang" />
|
||||
|
||||
<div>
|
||||
<div className="mx-auto sm:px-6 lg:px-8 ">
|
||||
<div className="p-6 overflow-hidden shadow-sm sm:rounded-lg bg-gray-200 dark:bg-gray-800 space-y-4">
|
||||
<div className="flex flex-col lg:flex-row gap-1 justify-between">
|
||||
<div className="flex flex-row space-x-2">
|
||||
<SearchInput
|
||||
onChange={handleChangeSearch}
|
||||
value={search.q}
|
||||
/>
|
||||
</div>
|
||||
<div className="flex flex-row space-x-2">
|
||||
<select
|
||||
className="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"
|
||||
onChange={(e) => setStatus(e.target.value)}
|
||||
>
|
||||
<option value="">Semua Status</option>
|
||||
{DEPOSIT_STATUSES.map((status) => (
|
||||
<option
|
||||
value={status.value}
|
||||
key={status.value}
|
||||
>
|
||||
{status.key}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div className="overflow-auto">
|
||||
<div>
|
||||
<table className="w-full text-sm text-left text-gray-500 dark:text-gray-400 mb-4">
|
||||
<thead className="text-xs text-gray-700 uppercase bg-gray-50 dark:bg-gray-700 dark:text-gray-400">
|
||||
<tr>
|
||||
<ThSort
|
||||
sort={sort}
|
||||
label={'description'}
|
||||
search={search}
|
||||
>
|
||||
#
|
||||
</ThSort>
|
||||
<ThSort
|
||||
sort={sort}
|
||||
label={'customer_id'}
|
||||
search={search}
|
||||
>
|
||||
Customer
|
||||
</ThSort>
|
||||
<ThSort
|
||||
sort={sort}
|
||||
label={'debit'}
|
||||
search={search}
|
||||
>
|
||||
Deposit
|
||||
</ThSort>
|
||||
<ThSort
|
||||
sort={sort}
|
||||
label={'updated_at'}
|
||||
search={search}
|
||||
>
|
||||
Tanggal
|
||||
</ThSort>
|
||||
<ThSort
|
||||
sort={sort}
|
||||
label={'is_valid'}
|
||||
search={search}
|
||||
>
|
||||
Status
|
||||
</ThSort>
|
||||
<ThSort
|
||||
sort={sort}
|
||||
label={'updated_by'}
|
||||
search={search}
|
||||
>
|
||||
Approver
|
||||
</ThSort>
|
||||
<th
|
||||
scope="col"
|
||||
className="py-3 px-6"
|
||||
/>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{data.map((deposit) => (
|
||||
<tr
|
||||
className="bg-white border-b dark:bg-gray-800 dark:border-gray-700"
|
||||
key={deposit.id}
|
||||
>
|
||||
<td
|
||||
scope="row"
|
||||
className="py-4 px-6 font-medium text-gray-900 whitespace-nowrap dark:text-white"
|
||||
>
|
||||
{deposit.description}
|
||||
</td>
|
||||
<td className="py-4 px-6">
|
||||
<Link
|
||||
className="hover:underline"
|
||||
href={route(
|
||||
'mitra.edit',
|
||||
deposit.customer.id
|
||||
)}
|
||||
>
|
||||
{deposit.customer.name}
|
||||
</Link>
|
||||
</td>
|
||||
<td className="py-4 px-6">
|
||||
{deposit.amount}
|
||||
</td>
|
||||
<td className="py-4 px-6">
|
||||
{deposit.format_created_at}
|
||||
</td>
|
||||
<td
|
||||
className={`py-4 px-6 ${deposit.status.text_color}`}
|
||||
>
|
||||
{deposit.status.text}
|
||||
</td>
|
||||
<td className="py-4 px-6">
|
||||
{deposit.editor?.name}
|
||||
</td>
|
||||
<td className="py-4 px-6 flex justify-center">
|
||||
{canUpdate && (
|
||||
<Link
|
||||
href={route(
|
||||
'paylater.edit',
|
||||
deposit
|
||||
)}
|
||||
className="flex space-x-1 items-center hover:underline"
|
||||
>
|
||||
<HiEye />
|
||||
<div>Lihat</div>
|
||||
</Link>
|
||||
)}
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div className="w-full flex items-center justify-center">
|
||||
<Pagination links={links} params={params} />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</AuthenticatedLayout>
|
||||
)
|
||||
}
|
Loading…
Reference in New Issue