[WIP] Claims
This commit is contained in:
@@ -65,7 +65,7 @@ class ClaimController extends Controller
|
|||||||
|
|
||||||
// Store Claim
|
// Store Claim
|
||||||
if ($validation['isEligible']) {
|
if ($validation['isEligible']) {
|
||||||
$claim = ClaimService::storeClaim($member, $diagnosis, $request->total_claim, $benefit);
|
$claim = ClaimService::storeClaim($member, $diagnosis, $request->total_claim, $benefit, 'requested');
|
||||||
} else {
|
} else {
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'data' => $validation,
|
'data' => $validation,
|
||||||
@@ -83,7 +83,11 @@ class ClaimController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function show($id)
|
public function show($id)
|
||||||
{
|
{
|
||||||
return view('internal::show');
|
$claim = Claim::query()
|
||||||
|
->with(['member', 'member.currentPlan'])
|
||||||
|
->findOrFail($id);
|
||||||
|
|
||||||
|
return response()->json($claim);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -120,7 +120,14 @@ class CorporateController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function show($id)
|
public function show($id)
|
||||||
{
|
{
|
||||||
return view('internal::show');
|
$corporate = Corporate::query()
|
||||||
|
->with(['currentPolicy'])
|
||||||
|
->withCount('corporatePlans')
|
||||||
|
->withCount('employees')
|
||||||
|
// ->withCount('employees.claims')
|
||||||
|
->findOrFail($id);
|
||||||
|
|
||||||
|
return response()->json($corporate);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -3,6 +3,8 @@
|
|||||||
namespace Modules\Internal\Http\Controllers\Api;
|
namespace Modules\Internal\Http\Controllers\Api;
|
||||||
|
|
||||||
use App\Exceptions\ImportRowException;
|
use App\Exceptions\ImportRowException;
|
||||||
|
use App\Helpers\Helper;
|
||||||
|
use App\Http\Resources\MemberDataTableResource;
|
||||||
use App\Models\Corporate;
|
use App\Models\Corporate;
|
||||||
use App\Models\Member;
|
use App\Models\Member;
|
||||||
use Box\Spout\Reader\Common\Creator\ReaderEntityFactory;
|
use Box\Spout\Reader\Common\Creator\ReaderEntityFactory;
|
||||||
@@ -35,15 +37,18 @@ class CorporateMemberController extends Controller
|
|||||||
->with([
|
->with([
|
||||||
'employeds',
|
'employeds',
|
||||||
'currentPolicy',
|
'currentPolicy',
|
||||||
|
// 'claims',
|
||||||
'claims' => function ($claim) {
|
'claims' => function ($claim) {
|
||||||
return $claim->used();
|
return $claim->whereBetween('requested_at', [now()->startOfYear(), now()->endOfYear()]);
|
||||||
|
// return $claim->used(now()->startOfYear(), now()->endOfYear());
|
||||||
}
|
}
|
||||||
])
|
])
|
||||||
->with('currentPlan')
|
->with('currentPlan')
|
||||||
|
// ->with
|
||||||
->paginate()
|
->paginate()
|
||||||
->appends($request->all());
|
->appends($request->all());
|
||||||
|
|
||||||
return $members;
|
return Helper::paginateResources(MemberDataTableResource::collection($members));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -100,6 +100,7 @@ Route::prefix('internal')->group(function () {
|
|||||||
|
|
||||||
Route::get('claims', [ClaimController::class, 'index']);
|
Route::get('claims', [ClaimController::class, 'index']);
|
||||||
Route::post('claims', [ClaimController::class, 'store']);
|
Route::post('claims', [ClaimController::class, 'store']);
|
||||||
|
Route::get('claims/{id}', [ClaimController::class, 'show']);
|
||||||
Route::post('check-limit', [ClaimController::class, 'checkLimit']);
|
Route::post('check-limit', [ClaimController::class, 'checkLimit']);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -81,19 +81,24 @@ class ClaimService
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function storeClaim($member, $diagnosis, $totalClaim, $benefit)
|
public static function storeClaim($member, $diagnosis, $totalClaim, $benefit, $status)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
DB::beginTransaction();
|
DB::beginTransaction();
|
||||||
|
|
||||||
$claim = Claim::create([
|
$claimData = [
|
||||||
'member_id' => $member->id,
|
'member_id' => $member->id,
|
||||||
'diagnosis_id' => $diagnosis->id,
|
'diagnosis_id' => $diagnosis->id,
|
||||||
'total_claim' => $totalClaim,
|
'total_claim' => $totalClaim,
|
||||||
'currency' => 'IDR',
|
'currency' => 'IDR',
|
||||||
'plan_id' => $member->currentPlan->id,
|
'plan_id' => $member->currentPlan->id,
|
||||||
'benefit_id' => $benefit->id,
|
'benefit_id' => $benefit->id,
|
||||||
]);
|
'status' => $status
|
||||||
|
];
|
||||||
|
$claimData[$status.'_at'] = now();
|
||||||
|
$claimData[$status.'_by'] = auth()->user()->id ?? null;
|
||||||
|
|
||||||
|
$claim = Claim::create($claimData);
|
||||||
|
|
||||||
$policy = $member->currentPolicy;
|
$policy = $member->currentPolicy;
|
||||||
$policy->limitJournals()->create([
|
$policy->limitJournals()->create([
|
||||||
@@ -109,7 +114,7 @@ class ClaimService
|
|||||||
} catch (\Exception $error) {
|
} catch (\Exception $error) {
|
||||||
DB::rollBack();
|
DB::rollBack();
|
||||||
|
|
||||||
return false;
|
throw new \Exception($error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
32
app/Http/Resources/MemberDataTableResource.php
Normal file
32
app/Http/Resources/MemberDataTableResource.php
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Resources;
|
||||||
|
|
||||||
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
|
|
||||||
|
class MemberDataTableResource extends JsonResource
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Transform the resource into an array.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||||
|
*/
|
||||||
|
public function toArray($request)
|
||||||
|
{
|
||||||
|
$data = parent::toArray($request);
|
||||||
|
$data['claim_grouped_by_status'] = $this->claims->groupBy('status');
|
||||||
|
$data['total_claims'] = [
|
||||||
|
'draft' => count($data['claim_grouped_by_status']['draft'] ?? []),
|
||||||
|
'requested' => count($data['claim_grouped_by_status']['requested'] ?? []),
|
||||||
|
'received' => count($data['claim_grouped_by_status']['received'] ?? []),
|
||||||
|
'approved' => count($data['claim_grouped_by_status']['approved'] ?? []),
|
||||||
|
'paid' => count($data['claim_grouped_by_status']['paid'] ?? []),
|
||||||
|
'declined' => count($data['claim_grouped_by_status']['declined'] ?? [])
|
||||||
|
];
|
||||||
|
|
||||||
|
// $data = ['fuck' => 'you'];
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -18,6 +18,17 @@ class Claim extends Model
|
|||||||
'currency',
|
'currency',
|
||||||
'plan_id',
|
'plan_id',
|
||||||
'benefit_id',
|
'benefit_id',
|
||||||
|
'status',
|
||||||
|
'requested_at',
|
||||||
|
'requested_by',
|
||||||
|
'received_at',
|
||||||
|
'received_by',
|
||||||
|
'approved_at',
|
||||||
|
'approved_by',
|
||||||
|
'declined',
|
||||||
|
'declined_by',
|
||||||
|
'paid_at',
|
||||||
|
'paid_by',
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $hidden = [
|
protected $hidden = [
|
||||||
@@ -75,7 +86,7 @@ class Claim extends Model
|
|||||||
{
|
{
|
||||||
return $query
|
return $query
|
||||||
->whereIn('status', ['approved', 'paid'])
|
->whereIn('status', ['approved', 'paid'])
|
||||||
->whereBetween('requested_at', $startDate, $endDate);
|
->whereBetween('requested_at', [$startDate, $endDate]);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,6 +77,8 @@ class Corporate extends Model
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// public function
|
||||||
|
|
||||||
public function importLogs()
|
public function importLogs()
|
||||||
{
|
{
|
||||||
return $this->morphMany(ImportLog::class, 'importable');
|
return $this->morphMany(ImportLog::class, 'importable');
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ class ClaimService{
|
|||||||
|
|
||||||
$corporate = $member->asd;
|
$corporate = $member->asd;
|
||||||
|
|
||||||
return $claim;
|
return $claim;asldkmalskdmalksmdalksmd
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getMemberTotalUsage(Member $member, $startDate = null, $endDate = null)
|
public static function getMemberTotalUsage(Member $member, $startDate = null, $endDate = null)
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ return new class extends Migration
|
|||||||
$table->string('currency');
|
$table->string('currency');
|
||||||
$table->foreignId('plan_id')->index();
|
$table->foreignId('plan_id')->index();
|
||||||
$table->foreignId('benefit_id')->index();
|
$table->foreignId('benefit_id')->index();
|
||||||
|
$table->string('status');
|
||||||
|
|
||||||
$table->dateTime('requested_at')->nullable();
|
$table->dateTime('requested_at')->nullable();
|
||||||
$table->unsignedBigInteger('requested_by')->nullable()->index();
|
$table->unsignedBigInteger('requested_by')->nullable()->index();
|
||||||
|
|||||||
@@ -16,11 +16,14 @@ import { LoadingButton } from '@mui/lab';
|
|||||||
import { fCurrency } from '../../utils/formatNumber';
|
import { fCurrency } from '../../utils/formatNumber';
|
||||||
import Iconify from '../../components/Iconify';
|
import Iconify from '../../components/Iconify';
|
||||||
|
|
||||||
export default function ClaimsCreate() {
|
export default function ClaimsCreateUpdate() {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
|
||||||
const [member, setMember] = useState();
|
const [member, setMember] = useState();
|
||||||
const selectedMemberDisplay = useRef<HTMLInputElement>(null);
|
const selectedMemberDisplay = useRef<HTMLInputElement>(null);
|
||||||
|
const { id } = useParams();
|
||||||
|
|
||||||
|
const isEdit = !!id;
|
||||||
|
|
||||||
const NewClaimSchema = Yup.object().shape({
|
const NewClaimSchema = Yup.object().shape({
|
||||||
member_id: Yup.string().required('Please select Member'),
|
member_id: Yup.string().required('Please select Member'),
|
||||||
@@ -104,13 +107,25 @@ export default function ClaimsCreate() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => { // Trigger First Search
|
useEffect(() => { // Trigger First Search
|
||||||
axios.get('master/diagnosis/search')
|
|
||||||
.then(function(res) {
|
|
||||||
setDiagnosis(res.data);
|
|
||||||
})
|
|
||||||
|
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (isEdit) {
|
||||||
|
axios.get(`/claims/${id}`)
|
||||||
|
.then((res) => {
|
||||||
|
// console.log('fuck', res.data)
|
||||||
|
// setCurrentCorporatePlan(res.data);
|
||||||
|
set
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
// if (err.response.status === 404) {
|
||||||
|
// navigate('/404');
|
||||||
|
// }
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}, [id]);
|
||||||
|
|
||||||
const [isEligible, setIsEligible] = useState<boolean|null>(null)
|
const [isEligible, setIsEligible] = useState<boolean|null>(null)
|
||||||
|
|
||||||
const [isCheckingLimit, setIsCheckingLimit] = useState(false)
|
const [isCheckingLimit, setIsCheckingLimit] = useState(false)
|
||||||
0
frontend/dashboard/src/pages/Claims/Form.tsx
Normal file
0
frontend/dashboard/src/pages/Claims/Form.tsx
Normal file
@@ -7,16 +7,18 @@ import UploadIcon from '@mui/icons-material/Upload';
|
|||||||
import CancelIcon from '@mui/icons-material/Cancel';
|
import CancelIcon from '@mui/icons-material/Cancel';
|
||||||
// hooks
|
// hooks
|
||||||
import React, { ChangeEvent, useEffect, useRef, useState } from 'react';
|
import React, { ChangeEvent, useEffect, useRef, useState } from 'react';
|
||||||
import { useSearchParams } from 'react-router-dom';
|
import { Navigate, useNavigate, useSearchParams } from 'react-router-dom';
|
||||||
// components
|
// components
|
||||||
import axios from '../../utils/axios';
|
import axios from '../../utils/axios';
|
||||||
import { LaravelPaginatedData, LaravelPaginatedDataDefault } from '../../@types/paginated-data';
|
import { LaravelPaginatedData, LaravelPaginatedDataDefault } from '../../@types/paginated-data';
|
||||||
import DataTable from '../../components/LaravelTable';
|
import DataTable from '../../components/LaravelTable';
|
||||||
import { fCurrency } from '../../utils/formatNumber';
|
import { fCurrency } from '../../utils/formatNumber';
|
||||||
|
import EditRoundedIcon from '@mui/icons-material/EditRounded';
|
||||||
|
|
||||||
export default function List() {
|
export default function List() {
|
||||||
const [searchParams, setSearchParams] = useSearchParams();
|
const [searchParams, setSearchParams] = useSearchParams();
|
||||||
const [importResult, setImportResult] = useState(null);
|
const [importResult, setImportResult] = useState(null);
|
||||||
|
const navigate = useNavigate();
|
||||||
|
|
||||||
function SearchInput(props: any) {
|
function SearchInput(props: any) {
|
||||||
// SEARCH
|
// SEARCH
|
||||||
@@ -182,7 +184,7 @@ export default function List() {
|
|||||||
<TableCell align="left">({row.diagnosis?.code}) {row.diagnosis?.name}</TableCell>
|
<TableCell align="left">({row.diagnosis?.code}) {row.diagnosis?.name}</TableCell>
|
||||||
<TableCell align="left">{fCurrency(row.total_claim)}</TableCell>
|
<TableCell align="left">{fCurrency(row.total_claim)}</TableCell>
|
||||||
|
|
||||||
{/* <TableCell align="right"><Button variant="outlined" color="error" size="small">Disable</Button></TableCell> */}
|
<TableCell align="right"><EditRoundedIcon onClick={(e) => {navigate('/claims/'+row.id)}}/></TableCell>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
{/* COLLAPSIBLE ROW */}
|
{/* COLLAPSIBLE ROW */}
|
||||||
<TableRow>
|
<TableRow>
|
||||||
@@ -214,7 +216,7 @@ export default function List() {
|
|||||||
<TableCell style={headStyle} align="left">Benefit</TableCell>
|
<TableCell style={headStyle} align="left">Benefit</TableCell>
|
||||||
<TableCell style={headStyle} align="left">Diagnosis</TableCell>
|
<TableCell style={headStyle} align="left">Diagnosis</TableCell>
|
||||||
<TableCell style={headStyle} align="left">Total Claim</TableCell>
|
<TableCell style={headStyle} align="left">Total Claim</TableCell>
|
||||||
{/* <TableCell style={headStyle} align="right">Action</TableCell> */}
|
<TableCell style={headStyle} align="right">Action</TableCell>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
</TableBody>
|
</TableBody>
|
||||||
{/* ------------------ END TABLE HEADER ------------------ */}
|
{/* ------------------ END TABLE HEADER ------------------ */}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// @mui
|
// @mui
|
||||||
import { Box, Button, Card, Collapse, IconButton, InputLabel, MenuItem, OutlinedInput, Paper, Select, SelectChangeEvent, Table, TableBody, TableCell, TableContainer, TableHead, TableRow, TextField, Typography, Badge, Tab, Tabs, CardHeader, Stack, Menu, ButtonGroup } from '@mui/material';
|
import { Box, Button, Card, Collapse, IconButton, InputLabel, MenuItem, OutlinedInput, Paper, Select, SelectChangeEvent, Table, TableBody, TableCell, TableContainer, TableHead, TableRow, TextField, Typography, Badge, Tab, Tabs, CardHeader, Stack, Menu, ButtonGroup, Grid } from '@mui/material';
|
||||||
import KeyboardArrowDownIcon from '@mui/icons-material/KeyboardArrowDown';
|
import KeyboardArrowDownIcon from '@mui/icons-material/KeyboardArrowDown';
|
||||||
import KeyboardArrowRightIcon from '@mui/icons-material/KeyboardArrowRight';
|
import KeyboardArrowRightIcon from '@mui/icons-material/KeyboardArrowRight';
|
||||||
import AddIcon from '@mui/icons-material/Add';
|
import AddIcon from '@mui/icons-material/Add';
|
||||||
@@ -43,7 +43,11 @@ export default function CorporatePlanList() {
|
|||||||
const loadDataTableData = async (appliedFilter = null) => {
|
const loadDataTableData = async (appliedFilter = null) => {
|
||||||
setDataTableLoading(true);
|
setDataTableLoading(true);
|
||||||
const filter = appliedFilter ? appliedFilter : Object.fromEntries([...searchParams.entries()]);
|
const filter = appliedFilter ? appliedFilter : Object.fromEntries([...searchParams.entries()]);
|
||||||
const response = await axios.get('/corporates/'+corporate_id+'/members', { params: filter });
|
const response = await axios
|
||||||
|
.get('/corporates/'+corporate_id+'/members', { params: filter })
|
||||||
|
.catch((response) => {
|
||||||
|
enqueueSnackbar('Failed getting data. ' + response.message, { variant: 'error' })
|
||||||
|
});
|
||||||
// console.log(response.data);
|
// console.log(response.data);
|
||||||
setDataTableLoading(false);
|
setDataTableLoading(false);
|
||||||
|
|
||||||
@@ -278,14 +282,70 @@ export default function CorporatePlanList() {
|
|||||||
</TableRow>
|
</TableRow>
|
||||||
{/* COLLAPSIBLE ROW */}
|
{/* COLLAPSIBLE ROW */}
|
||||||
<TableRow>
|
<TableRow>
|
||||||
<TableCell style={{ paddingBottom: 0, paddingTop: 0 }} colSpan={10}>
|
<TableCell></TableCell>
|
||||||
|
<TableCell style={{ paddingBottom: 0, paddingTop: 0 }} colSpan={30}>
|
||||||
<Collapse in={open} timeout="auto" unmountOnExit>
|
<Collapse in={open} timeout="auto" unmountOnExit>
|
||||||
<Box sx={{ borderBottom: 1 }}>
|
<Box sx={{ margin: 1, borderBottom: 1, pb: 2 }}>
|
||||||
<Typography variant="body2" gutterBottom component="div">
|
<Typography sx={{ fontWeight: '600', mb: 1 }}>Claim History</Typography>
|
||||||
No Extra Data
|
<Grid container>
|
||||||
</Typography>
|
<Grid item xs={6}>
|
||||||
|
<Grid container>
|
||||||
|
<Grid item xs={6}>
|
||||||
|
Requested
|
||||||
|
</Grid>
|
||||||
|
<Grid item xs={6}>
|
||||||
|
: {row.total_claims.requested}
|
||||||
|
</Grid>
|
||||||
|
|
||||||
|
|
||||||
|
<Grid item xs={6}>
|
||||||
|
Pending
|
||||||
|
</Grid>
|
||||||
|
<Grid item xs={6}>
|
||||||
|
: {row.total_claims.received}
|
||||||
|
</Grid>
|
||||||
|
|
||||||
|
|
||||||
|
<Grid item xs={6}>
|
||||||
|
Approved
|
||||||
|
</Grid>
|
||||||
|
<Grid item xs={6}>
|
||||||
|
: {row.total_claims.approved}
|
||||||
|
</Grid>
|
||||||
|
|
||||||
|
|
||||||
|
<Grid item xs={6}>
|
||||||
|
Declined
|
||||||
|
</Grid>
|
||||||
|
<Grid item xs={6}>
|
||||||
|
: {row.total_claims.declined}
|
||||||
|
</Grid>
|
||||||
|
|
||||||
|
<Grid item xs={6}>
|
||||||
|
Paid
|
||||||
|
</Grid>
|
||||||
|
<Grid item xs={6}>
|
||||||
|
: {row.total_claims.paid}
|
||||||
|
</Grid>
|
||||||
|
|
||||||
|
</Grid>
|
||||||
|
</Grid>
|
||||||
|
</Grid>
|
||||||
|
|
||||||
|
{/* <Typography sx={{ fontWeight: '600', mb: 1, mt: 2 }}>Sub Corporate</Typography>
|
||||||
|
<Grid container>
|
||||||
|
<Grid item xs={12}>
|
||||||
|
<Grid container>
|
||||||
|
<Grid item xs={6}>
|
||||||
|
Sub Corporates (asdasdasdasd)
|
||||||
|
</Grid>
|
||||||
|
<Grid item xs={6}>
|
||||||
|
: qweqweqweqwe
|
||||||
|
</Grid>
|
||||||
|
</Grid>
|
||||||
|
</Grid>
|
||||||
|
</Grid> */}
|
||||||
</Box>
|
</Box>
|
||||||
{false && <Box sx={{ margin: 1 }} />}
|
|
||||||
</Collapse>
|
</Collapse>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
|
|||||||
@@ -11,188 +11,30 @@ import Page from '../../components/Page';
|
|||||||
import axios from '../../utils/axios';
|
import axios from '../../utils/axios';
|
||||||
import useAuth from '../../hooks/useAuth';
|
import useAuth from '../../hooks/useAuth';
|
||||||
import { Link , NavLink as RouterLink, useParams } from 'react-router-dom';
|
import { Link , NavLink as RouterLink, useParams } from 'react-router-dom';
|
||||||
import React, { useEffect, useRef } from 'react';
|
import React, { useEffect, useRef, useState } from 'react';
|
||||||
import { Theme, useTheme } from '@mui/material/styles';
|
import { Theme, useTheme } from '@mui/material/styles';
|
||||||
import { Corporate } from '../../@types/corporates';
|
import { Corporate } from '../../@types/corporates';
|
||||||
import { LaravelPaginatedData } from '../../@types/paginated-data';
|
import { LaravelPaginatedData, LaravelPaginatedDataDefault } from '../../@types/paginated-data';
|
||||||
import HeaderBreadcrumbs from '../../components/HeaderBreadcrumbs';
|
import HeaderBreadcrumbs from '../../components/HeaderBreadcrumbs';
|
||||||
import CorporateTabNavigations from './CorporateTabNavigations';
|
import CorporateTabNavigations from './CorporateTabNavigations';
|
||||||
|
import { fCurrency } from '../../utils/formatNumber';
|
||||||
|
|
||||||
export default function Corporates() {
|
export default function Corporates() {
|
||||||
const { themeStretch } = useSettings();
|
const { themeStretch } = useSettings();
|
||||||
|
const { corporate_id } = useParams();
|
||||||
// Called on every row to map the data to the columns
|
const [corporate, setCorporate] = useState<Corporate>();
|
||||||
function createData( corporate: Corporate ): Corporate {
|
|
||||||
return {
|
|
||||||
...corporate,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Generate the every row of the table
|
|
||||||
function Row(props: { row: ReturnType<typeof createData> }) {
|
|
||||||
const { row } = props;
|
|
||||||
const [open, setOpen] = React.useState(false);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<React.Fragment>
|
|
||||||
<TableRow sx={{ '& > *': { borderBottom: 'unset' } }}>
|
|
||||||
<TableCell>
|
|
||||||
<IconButton
|
|
||||||
aria-label="expand row"
|
|
||||||
size="small"
|
|
||||||
onClick={() => setOpen(!open)}
|
|
||||||
>
|
|
||||||
{open ? <KeyboardArrowDownIcon /> : <KeyboardArrowRightIcon />}
|
|
||||||
</IconButton>
|
|
||||||
</TableCell>
|
|
||||||
<TableCell align="left">{row.code}</TableCell>
|
|
||||||
<TableCell align="left">{row.name}</TableCell>
|
|
||||||
<TableCell align="right"><Button variant="outlined" color="success" size="small">Active</Button></TableCell>
|
|
||||||
</TableRow>
|
|
||||||
{/* COLLAPSIBLE ROW */}
|
|
||||||
<TableRow>
|
|
||||||
<TableCell style={{ paddingBottom: 0, paddingTop: 0 }} colSpan={6}>
|
|
||||||
<Collapse in={open} timeout="auto" unmountOnExit>
|
|
||||||
<Box sx={{ margin: 1 }}>
|
|
||||||
<Typography variant="h6" gutterBottom component="div">
|
|
||||||
History
|
|
||||||
</Typography>
|
|
||||||
<Table size="small" aria-label="purchases">
|
|
||||||
<TableHead>
|
|
||||||
<TableRow>
|
|
||||||
<TableCell>Date</TableCell>
|
|
||||||
<TableCell>Customer</TableCell>
|
|
||||||
<TableCell align="right">Amount</TableCell>
|
|
||||||
<TableCell align="right">Total price ($)</TableCell>
|
|
||||||
</TableRow>
|
|
||||||
</TableHead>
|
|
||||||
<TableBody>
|
|
||||||
{row.history ? row.history.map((historyRow) => (
|
|
||||||
<TableRow key={historyRow?.date}>
|
|
||||||
<TableCell component="th" scope="row">
|
|
||||||
{historyRow?.date}
|
|
||||||
</TableCell>
|
|
||||||
<TableCell>{historyRow?.customerId}</TableCell>
|
|
||||||
<TableCell align="right">{historyRow?.amount}</TableCell>
|
|
||||||
<TableCell align="right">
|
|
||||||
{Math.round(historyRow?.amount * 1000 * 100) / 100}
|
|
||||||
</TableCell>
|
|
||||||
</TableRow>
|
|
||||||
))
|
|
||||||
: (
|
|
||||||
<TableRow>
|
|
||||||
<TableCell colSpan={8}>No Data</TableCell>
|
|
||||||
</TableRow>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
</TableBody>
|
|
||||||
</Table>
|
|
||||||
</Box>
|
|
||||||
</Collapse>
|
|
||||||
</TableCell>
|
|
||||||
</TableRow>
|
|
||||||
</React.Fragment>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Dummy Default Data
|
|
||||||
const [dataTableIsLoading, setDataTableLoading] = React.useState(true);
|
|
||||||
const [dataTableData, setDataTableData] = React.useState<LaravelPaginatedData>({
|
|
||||||
current_page: 1,
|
|
||||||
data: [],
|
|
||||||
path: "",
|
|
||||||
first_page_url: "",
|
|
||||||
last_page: 1,
|
|
||||||
last_page_url: "",
|
|
||||||
next_page_url: "",
|
|
||||||
prev_page_url: "",
|
|
||||||
per_page: 10,
|
|
||||||
from: 0,
|
|
||||||
to: 0,
|
|
||||||
total: 0
|
|
||||||
});
|
|
||||||
|
|
||||||
const loadDataTableData = async () => {
|
|
||||||
setDataTableLoading(true);
|
|
||||||
const response = await axios.get('/corporates');
|
|
||||||
// console.log(response.data);
|
|
||||||
setDataTableLoading(false);
|
|
||||||
|
|
||||||
setDataTableData(response.data);
|
|
||||||
}
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
loadDataTableData();
|
// TODO Use Hooks
|
||||||
|
axios.get(`corporates/${corporate_id}`)
|
||||||
|
.then((res) => {
|
||||||
|
setCorporate(res.data)
|
||||||
|
})
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
const headStyle = {
|
const headStyle = {
|
||||||
fontWeight: 'bold',
|
fontWeight: 'bold',
|
||||||
};
|
};
|
||||||
|
|
||||||
// FILTER SELECT
|
|
||||||
const ITEM_HEIGHT = 48;
|
|
||||||
const ITEM_PADDING_TOP = 8;
|
|
||||||
const MenuProps = {
|
|
||||||
PaperProps: {
|
|
||||||
style: {
|
|
||||||
maxHeight: ITEM_HEIGHT * 4.5 + ITEM_PADDING_TOP,
|
|
||||||
width: 250,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
const names = [
|
|
||||||
'PLAN001',
|
|
||||||
'PLAN002',
|
|
||||||
'PLAN003',
|
|
||||||
'PLAN004',
|
|
||||||
'PLAN005',
|
|
||||||
];
|
|
||||||
function getStyles(name: string, personName: string[], theme: Theme) {
|
|
||||||
return {
|
|
||||||
fontWeight:
|
|
||||||
personName.indexOf(name) === -1
|
|
||||||
? theme.typography.fontWeightRegular
|
|
||||||
: theme.typography.fontWeightMedium,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
const theme = useTheme();
|
|
||||||
const [planIdFilter, setPlanIdFilter] = React.useState<string[]>([]);
|
|
||||||
|
|
||||||
const handleChangePlanID = (event: SelectChangeEvent<typeof planIdFilter>) => {
|
|
||||||
const {
|
|
||||||
target: { value },
|
|
||||||
} = event;
|
|
||||||
setPlanIdFilter(
|
|
||||||
// On autofill we get a stringified value.
|
|
||||||
typeof value === 'string' ? value.split(',') : value,
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
const [statusFilter, setStatusFilter] = React.useState<string[]>([]);
|
|
||||||
const handleChangeStatus = (event: SelectChangeEvent<typeof statusFilter>) => {
|
|
||||||
const {
|
|
||||||
target: { value },
|
|
||||||
} = event;
|
|
||||||
setStatusFilter(
|
|
||||||
// On autofill we get a stringified value.
|
|
||||||
typeof value === 'string' ? value.split(',') : value,
|
|
||||||
);
|
|
||||||
};
|
|
||||||
// END FILTER SELECT
|
|
||||||
|
|
||||||
// IMPORT
|
|
||||||
const importMember = React.useRef(null);
|
|
||||||
const handleImportButton = (event: any) => {
|
|
||||||
if (importMember?.current)
|
|
||||||
importMember.current ? importMember.current.click() : console.log('fuck');
|
|
||||||
else
|
|
||||||
alert('No file selected')
|
|
||||||
}
|
|
||||||
|
|
||||||
const { id } = useParams();
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Page title="Dashboard">
|
<Page title="Dashboard">
|
||||||
|
|
||||||
@@ -204,8 +46,8 @@ export default function Corporates() {
|
|||||||
href: '/corporates',
|
href: '/corporates',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Corporate Name',
|
name: corporate?.name ?? '-',
|
||||||
href: '/corporates/'+id,
|
href: '/corporates/'+corporate_id,
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
@@ -217,10 +59,58 @@ export default function Corporates() {
|
|||||||
<CorporateTabNavigations position=""/>
|
<CorporateTabNavigations position=""/>
|
||||||
<Grid container spacing={3}>
|
<Grid container spacing={3}>
|
||||||
|
|
||||||
<Grid item xs={12} sx={{ p:2 }}>
|
<Grid item md={6} sx={{ p:2 }}>
|
||||||
Corporate Dashboard / Report Goes Here
|
<Typography sx={{...headStyle, px:3, fontSize:'24px'}}>Current Policy </Typography>
|
||||||
|
|
||||||
|
<Table>
|
||||||
|
<TableBody>
|
||||||
|
|
||||||
|
<TableRow>
|
||||||
|
<TableCell sx={headStyle}>Policy Name</TableCell>
|
||||||
|
<TableCell>{corporate?.current_policy?.code}</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
|
||||||
|
<TableRow>
|
||||||
|
<TableCell sx={headStyle}>Total Premi</TableCell>
|
||||||
|
<TableCell>{fCurrency(corporate?.current_policy?.total_premi)}</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
|
||||||
|
<TableRow>
|
||||||
|
<TableCell sx={headStyle}>Stop Service</TableCell>
|
||||||
|
<TableCell>{fCurrency(corporate?.current_policy?.minimal_stop_service_net)}</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
|
||||||
|
<TableRow>
|
||||||
|
<TableCell sx={headStyle}>Balance</TableCell>
|
||||||
|
<TableCell>{fCurrency(corporate?.current_policy?.limit_balance)}</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
|
||||||
|
</TableBody>
|
||||||
|
</Table>
|
||||||
|
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
|
<Grid item md={6} sx={{ p:2 }}>
|
||||||
|
<Typography sx={{...headStyle, px:3, fontSize:'24px'}}>Claims</Typography>
|
||||||
|
|
||||||
|
<Table>
|
||||||
|
<TableBody>
|
||||||
|
|
||||||
|
<TableRow>
|
||||||
|
<TableCell sx={headStyle}>Number Of Claim</TableCell>
|
||||||
|
<TableCell>{corporate?.current_policy?.code}</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
|
||||||
|
<TableRow>
|
||||||
|
<TableCell sx={headStyle}>Total Usage This Year</TableCell>
|
||||||
|
<TableCell>{fCurrency((corporate?.current_policy?.total_premi ?? 0) - (corporate?.current_policy?.limit_balance ?? 0))}</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
|
||||||
|
</TableBody>
|
||||||
|
</Table>
|
||||||
|
|
||||||
|
</Grid>
|
||||||
|
|
||||||
</Grid>
|
</Grid>
|
||||||
</Stack>
|
</Stack>
|
||||||
</Card>
|
</Card>
|
||||||
|
|||||||
@@ -303,4 +303,4 @@ const CorporateHospitals = Loadable(lazy(() => import('../pages/Corporates/Hospi
|
|||||||
const CorporateClaimHistories = Loadable(lazy(() => import('../pages/Corporates/ClaimHistory/Index')));
|
const CorporateClaimHistories = Loadable(lazy(() => import('../pages/Corporates/ClaimHistory/Index')));
|
||||||
|
|
||||||
const Claims = Loadable(lazy(() => import('../pages/Claims/Index')));
|
const Claims = Loadable(lazy(() => import('../pages/Claims/Index')));
|
||||||
const ClaimsCreate = Loadable(lazy(() => import('../pages/Claims/Create')));
|
const ClaimsCreate = Loadable(lazy(() => import('../pages/Claims/CreateUpdate')));
|
||||||
Reference in New Issue
Block a user