Invoice Payment
This commit is contained in:
@@ -127,6 +127,69 @@ class ClaimController extends Controller
|
||||
return response()->json(Helper::paginateResources($results));
|
||||
}
|
||||
|
||||
public function getClaimDetails(Request $request)
|
||||
{
|
||||
// Get the 'ids' array from the request
|
||||
$ids = $request->input('ids');
|
||||
|
||||
// Ensure the 'ids' array is not empty
|
||||
if (empty($ids)) {
|
||||
return response()->json(['error' => 'No IDs provided'], 400);
|
||||
}
|
||||
|
||||
// Use the SQL Query Builder with whereIn to fetch data
|
||||
$claimDetails = DB::table('claim_requests')
|
||||
->leftJoin('request_logs', 'claim_requests.request_log_id','=', 'request_logs.id')
|
||||
->leftJoin('members', 'request_logs.member_id', '=', 'members.id')
|
||||
->whereIn('claim_requests.id', $ids)
|
||||
->select(
|
||||
'claim_requests.id',
|
||||
'request_logs.invoice_no',
|
||||
'request_logs.id AS id_log',
|
||||
'request_logs.code AS code_log',
|
||||
'claim_requests.code as code',
|
||||
'members.name',
|
||||
DB::raw('
|
||||
(SELECT members.member_id FROM members WHERE members.id = claim_requests.member_id LIMIT 1) AS member_id
|
||||
'),
|
||||
'request_logs.created_at as submission_date',
|
||||
'request_logs.submission_date as addmission_date',
|
||||
'request_logs.discharge_date',
|
||||
// DB::raw('
|
||||
// (SELECT plans.code FROM plans WHERE plans.id = member_plans.plan_id LIMIT 1) AS plan_code
|
||||
// '),
|
||||
DB::raw('
|
||||
(SELECT plans.code
|
||||
FROM plans
|
||||
WHERE plans.id IN (
|
||||
SELECT member_plans.plan_id
|
||||
FROM member_plans
|
||||
WHERE member_plans.member_id = claim_requests.member_id
|
||||
)
|
||||
AND plans.service_code = claim_requests.service_code) AS plan_code
|
||||
'),
|
||||
DB::raw('
|
||||
(SELECT services.description FROM services WHERE services.code = claim_requests.service_code LIMIT 1) AS service_code
|
||||
'),
|
||||
DB::raw('
|
||||
(SELECT corporate_policies.code FROM corporate_policies WHERE corporate_policies.id = claim_requests.policy_id LIMIT 1) AS corporate_policies
|
||||
'),
|
||||
DB::raw('
|
||||
(SELECT organizations.name FROM organizations WHERE organizations.id = request_logs.organization_id LIMIT 1) AS provider
|
||||
'),
|
||||
DB::raw('
|
||||
(Select SUM(request_log_benefits.amount_approved) as tot_bill FROM request_log_benefits
|
||||
WHERE request_log_benefits.request_log_id = request_logs.id LIMIT 1) AS tot_bill
|
||||
'),
|
||||
'claim_requests.status_claim_management as status',
|
||||
)
|
||||
->get();
|
||||
|
||||
// Return the fetched claim details as a JSON response
|
||||
return response()->json($claimDetails);
|
||||
}
|
||||
|
||||
|
||||
public function filesProvider(Request $request)
|
||||
{
|
||||
$limit = $request->has('per_page') ? $request->input('per_page') : 50;
|
||||
|
||||
@@ -0,0 +1,627 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Internal\Http\Controllers\Api;
|
||||
|
||||
|
||||
use Illuminate\Routing\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use App\Models\File;
|
||||
use App\Helpers\Helper;
|
||||
use Box\Spout\Writer\Common\Creator\WriterEntityFactory;
|
||||
use Box\Spout\Writer\Common\Creator\Style\StyleBuilder;
|
||||
use Box\Spout\Common\Entity\Style\CellAlignment;
|
||||
|
||||
class InvoicePaymentController extends Controller
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
$limit = $request->has('per_page') ? $request->input('per_page') : 10;
|
||||
$results = DB::table('invoice_payments')
|
||||
->when($request->input('search'), function ($query, $search) {
|
||||
$query->where(function ($query) use ($search) {
|
||||
$query->orWhere('invoice_payments.invoice_number', 'like', "%" . $search . "%");
|
||||
});
|
||||
})
|
||||
->when($request->has('orderBy'), function ($query) use ($request) {
|
||||
$orderBy = $request->orderBy;
|
||||
$direction = $request->order ?? 'asc';
|
||||
|
||||
$query->orderBy($orderBy, $direction);
|
||||
})
|
||||
->when($request->input('start_date') , function ($query, $start_date) {
|
||||
$query->where(function ($query) use ($start_date) {
|
||||
$query->where('invoice_payments.created_at', '>=', $start_date);
|
||||
});
|
||||
})
|
||||
->when($request->input('end_date') , function ($query, $end_date) {
|
||||
$query->where(function ($query) use ($end_date) {
|
||||
$query->where('invoice_payments.created_at', '<=', $end_date);
|
||||
});
|
||||
})
|
||||
->when($request->input('status') , function ($query, $status) {
|
||||
$query->where(function ($query) use ($status) {
|
||||
$query->where('invoice_payments.status', '=', $status);
|
||||
});
|
||||
})
|
||||
// ->where('claim_management', '=', 1)
|
||||
->select(
|
||||
'invoice_payments.id',
|
||||
'invoice_payments.invoice_number',
|
||||
'invoice_payments.start_date',
|
||||
'invoice_payments.end_date',
|
||||
'invoice_payments.created_at',
|
||||
'invoice_payments.status',
|
||||
)
|
||||
->groupBy('invoice_payments.invoice_number')
|
||||
->paginate($limit);
|
||||
|
||||
|
||||
|
||||
return response()->json(Helper::paginateResources($results));
|
||||
}
|
||||
public function claim(Request $request)
|
||||
{
|
||||
$limit = $request->has('per_page') ? $request->input('per_page') : 10;
|
||||
$results = DB::table('claim_requests')
|
||||
->leftJoin('request_logs', 'claim_requests.request_log_id','=', 'request_logs.id')
|
||||
->leftJoin('members', 'request_logs.member_id', '=', 'members.id')
|
||||
->leftJoin('invoice_payment_details', function ($join) {
|
||||
$join->on('invoice_payment_details.claim_request_id', '=', 'claim_requests.id')
|
||||
->whereNull('invoice_payment_details.deleted_by')
|
||||
->orWhere('invoice_payment_details.deleted_by', 0);
|
||||
})
|
||||
// ->leftJoin('member_plans', 'member_plans.member_id', '=', 'members.id')
|
||||
->when($request->input('search'), function ($query, $search) {
|
||||
$query->where(function ($query) use ($search) {
|
||||
$query->orWhere('members.name', 'like', "%" . $search . "%");
|
||||
$query->orWhere('claim_requests.code', 'like', "%" . $search . "%");
|
||||
$query->orWhere('request_logs.code', 'like', "%" . $search . "%");
|
||||
$query->orWhere('members.member_id', 'like', "%" . $search . "%");
|
||||
});
|
||||
})
|
||||
->when($request->has('orderBy'), function ($query) use ($request) {
|
||||
$orderBy = $request->orderBy;
|
||||
$direction = $request->order ?? 'asc';
|
||||
|
||||
$query->orderBy($orderBy, $direction);
|
||||
})
|
||||
->when($request->input('start_date') , function ($query, $start_date) {
|
||||
$query->where(function ($query) use ($start_date) {
|
||||
$query->where('claim_requests.created_at', '>=', $start_date);
|
||||
});
|
||||
})
|
||||
->when($request->input('end_date') , function ($query, $end_date) {
|
||||
$query->where(function ($query) use ($end_date) {
|
||||
$query->where('claim_requests.created_at', '<=', $end_date);
|
||||
});
|
||||
})
|
||||
->when($request->input('provider') , function ($query, $provider) {
|
||||
$query->where(function ($query) use ($provider) {
|
||||
$query->where('request_logs.organization_id', '=', $provider);
|
||||
});
|
||||
})
|
||||
->where('claim_management', '=', 1)
|
||||
->when($request->input('param') !== 'Edit', function ($query) {
|
||||
$query->whereNotIn('claim_requests.id', function ($query) {
|
||||
$query->select('claim_request_id')
|
||||
->from('invoice_payment_details');
|
||||
});
|
||||
})
|
||||
->when($request->input('param') === 'Edit', function ($query) use ($request) {
|
||||
$query->where(function ($q) use ($request) {
|
||||
$q->whereNotIn('claim_requests.id', function ($subquery) {
|
||||
$subquery->select('claim_request_id')
|
||||
->from('invoice_payment_details')
|
||||
->whereNull('invoice_payment_details.deleted_by')
|
||||
->orWhere('invoice_payment_details.deleted_by', 0);
|
||||
})
|
||||
->orWhereIn('claim_requests.id', function ($subquery) use ($request) {
|
||||
$subquery->select('claim_request_id')
|
||||
->from('invoice_payment_details')
|
||||
->where('invoice_payment_details.invoice_payment_id', $request->input('invoiceID'))
|
||||
->whereNull('invoice_payment_details.deleted_by')
|
||||
->orWhere('invoice_payment_details.deleted_by', 0);
|
||||
});
|
||||
});
|
||||
})
|
||||
->select(
|
||||
'claim_requests.id',
|
||||
'request_logs.id AS id_log',
|
||||
'request_logs.code AS code_log',
|
||||
'claim_requests.code as code',
|
||||
'members.name',
|
||||
DB::raw('
|
||||
(SELECT members.member_id FROM members WHERE members.id = claim_requests.member_id LIMIT 1) AS member_id
|
||||
'),
|
||||
'claim_requests.created_at',
|
||||
// DB::raw('
|
||||
// (SELECT plans.code FROM plans WHERE plans.id = member_plans.plan_id LIMIT 1) AS plan_code
|
||||
// '),
|
||||
DB::raw('
|
||||
(SELECT plans.code
|
||||
FROM plans
|
||||
WHERE plans.id IN (
|
||||
SELECT member_plans.plan_id
|
||||
FROM member_plans
|
||||
WHERE member_plans.member_id = claim_requests.member_id
|
||||
)
|
||||
AND plans.service_code = claim_requests.service_code) AS plan_code
|
||||
'),
|
||||
DB::raw('
|
||||
(SELECT services.description FROM services WHERE services.code = claim_requests.service_code LIMIT 1) AS service_code
|
||||
'),
|
||||
DB::raw('
|
||||
(SELECT corporate_policies.code FROM corporate_policies WHERE corporate_policies.id = claim_requests.policy_id LIMIT 1) AS corporate_policies
|
||||
'),
|
||||
DB::raw('
|
||||
(SELECT organizations.name FROM organizations WHERE organizations.id = request_logs.organization_id LIMIT 1) AS provider
|
||||
'),
|
||||
DB::raw('
|
||||
(Select SUM(request_log_benefits.amount_approved) as tot_bill FROM request_log_benefits
|
||||
WHERE request_log_benefits.request_log_id = request_logs.id LIMIT 1) AS tot_bill
|
||||
'),
|
||||
'claim_requests.status_claim_management as status',
|
||||
)
|
||||
->groupBy('claim_requests.id')
|
||||
->paginate($limit);
|
||||
|
||||
|
||||
|
||||
return response()->json(Helper::paginateResources($results));
|
||||
}
|
||||
public function detail($id)
|
||||
{
|
||||
$invoice['invoice_payments'] = DB::table('invoice_payments')
|
||||
->where('invoice_payments.id', $id)
|
||||
->select('invoice_payments.*')
|
||||
->get();
|
||||
|
||||
$invoice['invoice_payment_details'] = DB::table('invoice_payment_details')
|
||||
->leftJoin('claim_requests', 'claim_requests.id', '=', 'invoice_payment_details.claim_request_id')
|
||||
->leftJoin('request_logs', 'claim_requests.request_log_id','=', 'request_logs.id')
|
||||
->leftJoin('members', 'request_logs.member_id', '=', 'members.id')
|
||||
->where('invoice_payment_details.invoice_payment_id', $id)
|
||||
->whereNull('invoice_payment_details.deleted_by')
|
||||
->orWhere('invoice_payment_details.deleted_by', 0)
|
||||
->select(
|
||||
'claim_requests.id',
|
||||
'request_logs.invoice_no',
|
||||
'request_logs.id AS id_log',
|
||||
'request_logs.code AS code_log',
|
||||
'claim_requests.code as code',
|
||||
'members.name',
|
||||
DB::raw('
|
||||
(SELECT members.member_id FROM members WHERE members.id = claim_requests.member_id LIMIT 1) AS member_id
|
||||
'),
|
||||
'request_logs.created_at as submission_date',
|
||||
'request_logs.submission_date as addmission_date',
|
||||
'request_logs.discharge_date',
|
||||
// DB::raw('
|
||||
// (SELECT plans.code FROM plans WHERE plans.id = member_plans.plan_id LIMIT 1) AS plan_code
|
||||
// '),
|
||||
DB::raw('
|
||||
(SELECT plans.code
|
||||
FROM plans
|
||||
WHERE plans.id IN (
|
||||
SELECT member_plans.plan_id
|
||||
FROM member_plans
|
||||
WHERE member_plans.member_id = claim_requests.member_id
|
||||
)
|
||||
AND plans.service_code = claim_requests.service_code) AS plan_code
|
||||
'),
|
||||
DB::raw('
|
||||
(SELECT services.description FROM services WHERE services.code = claim_requests.service_code LIMIT 1) AS service_code
|
||||
'),
|
||||
DB::raw('
|
||||
(SELECT corporate_policies.code FROM corporate_policies WHERE corporate_policies.id = claim_requests.policy_id LIMIT 1) AS corporate_policies
|
||||
'),
|
||||
DB::raw('
|
||||
(SELECT organizations.name FROM organizations WHERE organizations.id = request_logs.organization_id LIMIT 1) AS provider
|
||||
'),
|
||||
DB::raw('
|
||||
(Select SUM(request_log_benefits.amount_approved) as tot_bill FROM request_log_benefits
|
||||
WHERE request_log_benefits.request_log_id = request_logs.id LIMIT 1) AS tot_bill
|
||||
'),
|
||||
'claim_requests.status_claim_management as status',
|
||||
)
|
||||
->groupBy('claim_requests.id')
|
||||
->get();
|
||||
$payments = DB::table('invoice_payments')
|
||||
->leftJoin('files', function ($join) {
|
||||
$join->on('files.fileable_id', '=', 'invoice_payments.id')
|
||||
->where('files.type', 'files-proof-payment')
|
||||
->whereNull('files.deleted_by')
|
||||
->orWhere('files.deleted_by', 0);
|
||||
})
|
||||
->where('invoice_payments.invoice_number', $invoice['invoice_payments'][0]->invoice_number)
|
||||
->select(
|
||||
'invoice_payments.id',
|
||||
'files.id as file_id',
|
||||
'invoice_payments.amount_paid',
|
||||
'invoice_payments.payment_number',
|
||||
DB::raw("CONCAT('" . env('APP_URL') . "/storage/', files.path) as path"),
|
||||
'files.original_name'
|
||||
)
|
||||
->orderBy('invoice_payments.payment_number', 'asc')
|
||||
->get();
|
||||
|
||||
$invoice['files'] = $payments->groupBy('payment_number')->map(function ($group) {
|
||||
return [
|
||||
'id' => $group->first()->id,
|
||||
'amount_paid' => $group->first()->amount_paid,
|
||||
'payment_number' => $group->first()->payment_number,
|
||||
'files' => $group->map(function ($file) {
|
||||
return [
|
||||
'file_id' => $file->file_id,
|
||||
'path' => $file->path,
|
||||
'original_name' => $file->original_name
|
||||
];
|
||||
})->toArray()
|
||||
];
|
||||
})->values()->toArray();
|
||||
|
||||
if ($invoice['invoice_payments']->isEmpty()) {
|
||||
return response()->json(['message' => 'Invoice tidak ditemukan'], 404);
|
||||
}
|
||||
|
||||
return response()->json($invoice);
|
||||
}
|
||||
|
||||
public function create(Request $request)
|
||||
{
|
||||
$data = [
|
||||
'invoice_number' => $request->invoice_number,
|
||||
'invoice_date' => $request->invoice_date,
|
||||
'start_date' => $request->start_date,
|
||||
'end_date' => $request->end_date,
|
||||
'payments' => $request->payments
|
||||
];
|
||||
$validator = Validator::make($request->all(), [
|
||||
'invoice_number' => 'required',
|
||||
'invoice_date' => 'required',
|
||||
'start_date' => 'required',
|
||||
'end_date' => 'required',
|
||||
'payments' => 'required',
|
||||
'invoice_payment_details' => 'required',
|
||||
], [
|
||||
'invoice_number.required' => trans('Validation.required',['attribute' => 'Nomor Invoice']),
|
||||
'invoice_date.required' => trans('Validation.required',['attribute' => 'Tanggal Invoice']),
|
||||
'start_date.required' => trans('Validation.required',['attribute' => 'Tanggal Mulai']),
|
||||
'end_date.required' => trans('Validation.required',['attribute' => 'Tanggal Akhir']),
|
||||
'payments.required' => trans('Validation.required',['attribute' => 'Jumlah Bayar']),
|
||||
'invoice_payment_details.required' => trans('Validation.required',['attribute' => 'Nomor Claim']),
|
||||
]);
|
||||
if ($validator->fails())
|
||||
{
|
||||
return response()->json(['message' => $validator->errors()], 400);
|
||||
}
|
||||
else
|
||||
{
|
||||
try {
|
||||
DB::beginTransaction();
|
||||
$invoiceNumber = $request->invoice_number;
|
||||
foreach ($request->payments as $valuePayments) {
|
||||
if($request->param === 'Edit')
|
||||
{
|
||||
$invoiceNumber = DB::table('invoice_payments')
|
||||
->where('id', $valuePayments['id'])
|
||||
->value('invoice_number');
|
||||
}
|
||||
// **Cek apakah invoice_number sudah ada di database**
|
||||
$existingInvoice = DB::table('invoice_payments')
|
||||
->where('invoice_number', $invoiceNumber)
|
||||
->where('payment_number', $valuePayments['paymentNumber'])
|
||||
// ->where('amount_paid', $this->normalizeCurrency($valuePayments['amount']))
|
||||
->exists();
|
||||
|
||||
//Insert
|
||||
if (!$existingInvoice) {
|
||||
$lastInsertedId = DB::table('invoice_payments')
|
||||
->insertGetId([
|
||||
'invoice_number' => $request->invoice_number,
|
||||
'payment_number' => $valuePayments['paymentNumber'],
|
||||
'invoice_date' => $request->invoice_date,
|
||||
'start_date' => $request->start_date,
|
||||
'end_date' => $request->start_date,
|
||||
'amount_paid' => $this->normalizeCurrency($valuePayments['amount']),
|
||||
'status' => 'submitted',
|
||||
'created_by' => auth()->user()->id,
|
||||
'created_at' => date('Y-m-d H:i:s'),
|
||||
]);
|
||||
|
||||
foreach ($request->invoice_payment_details as $value)
|
||||
{
|
||||
// **Cek apakah claim_request_id sudah ada untuk invoice_payment_id ini**
|
||||
$existingClaim = DB::table('invoice_payment_details')
|
||||
->where('claim_request_id', $value)
|
||||
->exists();
|
||||
|
||||
if (!$existingClaim) {
|
||||
DB::table('invoice_payment_details')
|
||||
->insert([
|
||||
'invoice_payment_id' => $lastInsertedId,
|
||||
'claim_request_id' => $value,
|
||||
'created_by' => auth()->user()->id,
|
||||
'created_at' => date('Y-m-d H:i:s'),
|
||||
]);
|
||||
}
|
||||
}
|
||||
if (!empty($valuePayments['files']) && is_array($valuePayments['files'])) {
|
||||
foreach ($valuePayments['files'] as $file) {
|
||||
$pathFile = File::storeFile('files-proof-payment', $lastInsertedId, $file);
|
||||
File::updateOrCreate([
|
||||
'fileable_type' => 'App\Models\InvoicePayment',
|
||||
'fileable_id' => $lastInsertedId,
|
||||
'type' => 'files-proof-payment',
|
||||
'name' => File::getFileName('files-proof-payment', $lastInsertedId, $file),
|
||||
'original_name' => $file->getClientOriginalName(),
|
||||
'extension' => $file->getClientOriginalExtension(),
|
||||
'path' => $pathFile,
|
||||
'created_by' => auth()->user()->id,
|
||||
'updated_by' => auth()->user()->id,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Edit
|
||||
$invoicePaymentId = DB::table('invoice_payments')
|
||||
->where('invoice_number', $invoiceNumber)
|
||||
->where('payment_number', $valuePayments['paymentNumber'])
|
||||
->value('id');
|
||||
|
||||
DB::table('invoice_payments')
|
||||
->where('id', $invoicePaymentId)
|
||||
->update([
|
||||
'invoice_number' => $request->invoice_number,
|
||||
'invoice_date' => $request->invoice_date,
|
||||
'start_date' => $request->start_date,
|
||||
'end_date' => $request->end_date,
|
||||
'amount_paid' => $this->normalizeCurrency($valuePayments['amount']),
|
||||
'updated_by' => auth()->user()->id,
|
||||
'updated_at' => date('Y-m-d H:i:s'),
|
||||
]);
|
||||
|
||||
$existingClaims = DB::table('invoice_payment_details')
|
||||
->where('invoice_payment_id', $invoicePaymentId)
|
||||
->pluck('claim_request_id')
|
||||
->toArray();
|
||||
|
||||
$newClaims = $request->invoice_payment_details;
|
||||
|
||||
// Data yang mau di-insert
|
||||
$claimsToInsert = array_diff($newClaims, $existingClaims);
|
||||
foreach ($claimsToInsert as $claim) {
|
||||
DB::table('invoice_payment_details')->insert([
|
||||
'invoice_payment_id' => $invoicePaymentId,
|
||||
'claim_request_id' => $claim,
|
||||
'updated_by' => auth()->user()->id,
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
}
|
||||
|
||||
// Data yang mau di-delete (tidak ada di data baru)
|
||||
$claimsToDelete = array_diff($existingClaims, $newClaims);
|
||||
if (!empty($claimsToDelete)) {
|
||||
DB::table('invoice_payment_details')
|
||||
->where('invoice_payment_id', $invoicePaymentId)
|
||||
->whereIn('claim_request_id', $claimsToDelete)
|
||||
->update([
|
||||
'deleted_by' => auth()->user()->id,
|
||||
'deleted_at' => now(),
|
||||
]);
|
||||
}
|
||||
|
||||
// Handle existing files
|
||||
$existingFiles = DB::table('files')
|
||||
->where('files.fileable_id', $invoicePaymentId)
|
||||
|
||||
->where('files.type', 'files-proof-payment')
|
||||
->pluck('id')
|
||||
->toArray();
|
||||
|
||||
$newFiles = [];
|
||||
if (!empty($valuePayments['existingFiles']) && is_array($valuePayments['existingFiles'])) {
|
||||
$newFiles = array_column($valuePayments['existingFiles'], 'file_id');
|
||||
}
|
||||
|
||||
|
||||
$filesToDelete = array_diff($existingFiles, $newFiles);
|
||||
|
||||
if (!empty($filesToDelete)) {
|
||||
DB::table('files')
|
||||
->whereIn('id', $filesToDelete)
|
||||
->update([
|
||||
'deleted_by' => auth()->user()->id,
|
||||
'deleted_at' => now(),
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
//File New
|
||||
if (!empty($valuePayments['files']) && is_array($valuePayments['files'])) {
|
||||
foreach ($valuePayments['files'] as $file) {
|
||||
$pathFile = File::storeFile('files-proof-payment', $invoicePaymentId, $file);
|
||||
File::updateOrCreate([
|
||||
'fileable_type' => 'App\Models\InvoicePayment',
|
||||
'fileable_id' => $invoicePaymentId,
|
||||
'type' => 'files-proof-payment',
|
||||
'name' => File::getFileName('files-proof-payment', $invoicePaymentId, $file),
|
||||
'original_name' => $file->getClientOriginalName(),
|
||||
'extension' => $file->getClientOriginalExtension(),
|
||||
'path' => $pathFile,
|
||||
'created_by' => auth()->user()->id,
|
||||
'updated_by' => auth()->user()->id,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
DB::commit();
|
||||
|
||||
return response()->json(['message' => 'Data berhasil disimpan'], 200);
|
||||
}
|
||||
catch (\Exception $e) {
|
||||
DB::rollback();
|
||||
return response()->json(['message' => $e->getMessage()], 500);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function normalizeCurrency($amount) {
|
||||
return (int) preg_replace('/\D/', '', $amount);
|
||||
}
|
||||
|
||||
public function submitStatus(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'valueStatus' => 'required|in:submitted,accepted,partial_paid,paid,decline',
|
||||
'valueID' => 'required|integer|exists:invoice_payments,id',
|
||||
]);
|
||||
|
||||
$update = DB::table('invoice_payments')
|
||||
->where('id', $request->valueID)
|
||||
->update([
|
||||
'status' => $request->valueStatus,
|
||||
'updated_at' => now(),
|
||||
'updated_by' => auth()->user()->id,
|
||||
]);
|
||||
|
||||
if (!$update) {
|
||||
return response()->json(['message' => 'Data tidak ditemukan atau tidak diperbarui'], 404);
|
||||
}
|
||||
|
||||
return response()->json(['message' => 'Status berhasil diperbarui']);
|
||||
}
|
||||
|
||||
public function export(Request $request)
|
||||
{
|
||||
$start_date = $request->input('start_date') ? $request->input('start_date') : 'all';
|
||||
$end_date = $request->input('end_date') ? $request->input('end_date') : 'all';
|
||||
$writer = WriterEntityFactory::createXLSXWriter();
|
||||
$writer->openToFile(public_path('files/Report-Data-Invoice-Management-'.$start_date.'-'.$end_date.'.xlsx'));
|
||||
$header = [
|
||||
'No',
|
||||
'Nomor Invoice',
|
||||
'Pembayaran Ke',
|
||||
'Tanggal Invoice',
|
||||
'Start Date',
|
||||
'End Date',
|
||||
'Nominal Pembayaran',
|
||||
'Created At',
|
||||
'Updated At',
|
||||
];
|
||||
$style = (new StyleBuilder())
|
||||
->setFontBold()
|
||||
// ->setFontSize(15)
|
||||
// ->setFontColor(Color::BLUE)
|
||||
// ->setShouldWrapText()
|
||||
->setCellAlignment(CellAlignment::LEFT)
|
||||
// ->setBackgroundColor(Color::YELLOW)
|
||||
->build();
|
||||
|
||||
$headerRow = WriterEntityFactory::createRowFromArray($header, $style);
|
||||
$writer->addRow($headerRow);
|
||||
// ============================
|
||||
$results = DB::table('invoice_payments')
|
||||
// ->leftJoin('member_plans', 'member_plans.member_id', '=', 'members.id')
|
||||
->when($request->input('search'), function ($query, $search) {
|
||||
$query->where(function ($query) use ($search) {
|
||||
$query->orWhere('invoice_payments.invoice_number', 'like', "%" . $search . "%");
|
||||
});
|
||||
})
|
||||
->when($request->has('orderBy'), function ($query) use ($request) {
|
||||
$orderBy = $request->orderBy;
|
||||
$direction = $request->order ?? 'asc';
|
||||
|
||||
$query->orderBy($orderBy, $direction);
|
||||
})
|
||||
->when($request->input('start_date') , function ($query, $start_date) {
|
||||
$query->where(function ($query) use ($start_date) {
|
||||
$query->where('claim_requests.created_at', '>=', $start_date);
|
||||
});
|
||||
})
|
||||
->when($request->input('end_date') , function ($query, $end_date) {
|
||||
$query->where(function ($query) use ($end_date) {
|
||||
$query->where('claim_requests.created_at', '<=', $end_date);
|
||||
});
|
||||
})
|
||||
->select(
|
||||
'invoice_payments.*')
|
||||
->get();
|
||||
$no=0;
|
||||
$gr_total = 0;
|
||||
$header = [
|
||||
'No',
|
||||
'Nomor Invoice',
|
||||
'Pembayaran Ke',
|
||||
'Tanggal Invoice',
|
||||
'Start Date',
|
||||
'End Date',
|
||||
'Nominal Pembayaran',
|
||||
'Created At',
|
||||
'Updated At',
|
||||
];
|
||||
foreach($results as $item)
|
||||
{
|
||||
$gr_total += $item->amount_paid;
|
||||
$no++;
|
||||
$rowData = [
|
||||
$no,
|
||||
$item->invoice_number,
|
||||
$item->payment_number,
|
||||
$item->invoice_date,
|
||||
$item->start_date,
|
||||
$item->end_date,
|
||||
$item->amount_paid,
|
||||
$item->created_at,
|
||||
$item->updated_at
|
||||
];
|
||||
$style = (new StyleBuilder())
|
||||
//->setFontBold()
|
||||
// ->setFontSize(15)
|
||||
// ->setFontColor(Color::BLUE)
|
||||
// ->setShouldWrapText()
|
||||
->setCellAlignment(CellAlignment::LEFT)
|
||||
// ->setBackgroundColor(Color::YELLOW)
|
||||
->build();
|
||||
$row = WriterEntityFactory::createRowFromArray($rowData, $style);
|
||||
$writer->addRow($row);
|
||||
}
|
||||
$footer = [
|
||||
'Grand Total',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
$gr_total,
|
||||
'',
|
||||
'',
|
||||
];
|
||||
$style = (new StyleBuilder())
|
||||
->setFontBold()
|
||||
// ->setFontSize(15)
|
||||
// ->setFontColor(Color::BLUE)
|
||||
// ->setShouldWrapText()
|
||||
->setCellAlignment(CellAlignment::LEFT)
|
||||
// ->setBackgroundColor(Color::YELLOW)
|
||||
->build();
|
||||
|
||||
$footerRow = WriterEntityFactory::createRowFromArray($footer, $style);
|
||||
$writer->addRow($footerRow);
|
||||
|
||||
$writer->close();
|
||||
|
||||
return Helper::responseJson([
|
||||
'file_name' => 'Report-Data-Invoice-Management-'. $start_date.'-'.$end_date,
|
||||
"file_url" => url('files/Report-Data-Invoice-Management-'. $start_date.'-'.$end_date.'.xlsx')
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -8,6 +8,7 @@ use Modules\Internal\Http\Controllers\Api\BenefitController;
|
||||
use Modules\Internal\Http\Controllers\Api\CityController;
|
||||
use Modules\Internal\Http\Controllers\Api\ClaimController;
|
||||
use Modules\Internal\Http\Controllers\Api\ClaimRequestController;
|
||||
use Modules\Internal\Http\Controllers\Api\InvoicePaymentController;
|
||||
use Modules\Internal\Http\Controllers\Api\KatalogDokterController;
|
||||
use Modules\Internal\Http\Controllers\Api\RequestLogController;
|
||||
use Modules\Internal\Http\Controllers\Api\RequestLogBenefitController;
|
||||
@@ -86,7 +87,7 @@ Route::prefix('internal')->group(function () {
|
||||
Route::get('drugs', [AutocompleteController::class, 'drugList']);
|
||||
Route::get('units', [AutocompleteController::class, 'unitList']);
|
||||
|
||||
|
||||
|
||||
Route::get('signa', [AutocompleteController::class, 'signaList']);
|
||||
Route::post('signa-add', [AutocompleteController::class, 'signaAdd']);
|
||||
|
||||
@@ -268,7 +269,15 @@ Route::prefix('internal')->group(function () {
|
||||
Route::post('claims/{claim_id}/encounters/{encounter_id}/update', [ClaimEncounterController::class, 'update']);
|
||||
Route::post('claims/{claim_id}/set-final-encounter', [ClaimEncounterController::class, 'setFinalEncounter']);
|
||||
|
||||
Route::post('invoice_payments/create', [InvoicePaymentController::class, 'create']);
|
||||
Route::get('invoice_payments/list', [InvoicePaymentController::class, 'index']);
|
||||
Route::post('invoice-payment/submit-status', [InvoicePaymentController::class, 'submitStatus']);
|
||||
Route::get('invoice-payment/detail/{id}', [InvoicePaymentController::class, 'detail']);
|
||||
Route::get('invoice-payment/claim', [InvoicePaymentController::class, 'claim']);
|
||||
Route::get('invoice-payment/export', [InvoicePaymentController::class, 'export']);
|
||||
|
||||
Route::get('claims', [ClaimController::class, 'index']);
|
||||
Route::post('claim-details', [ClaimController::class, 'getClaimDetails']);
|
||||
Route::get('claims-files-provider', [ClaimController::class, 'filesProvider']);
|
||||
Route::post('download-zip', [ClaimController::class, 'downloadZip']);
|
||||
Route::get('claims/download-template', [ClaimController::class, 'downloadTemplate']);
|
||||
|
||||
@@ -53,6 +53,7 @@ class File extends Model
|
||||
'docs' => 'docs/',
|
||||
'additional-files' => 'additional-files/',
|
||||
'chat' => 'chat/',
|
||||
'files-proof-payment' => 'files-proof-payment/',
|
||||
];
|
||||
|
||||
public function fileable()
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('invoice_payments', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('invoice_number');
|
||||
$table->string('payment_number');
|
||||
$table->date('invoice_date');
|
||||
$table->date('start_date');
|
||||
$table->date('end_date');
|
||||
$table->decimal('amount_paid', 15, 2);
|
||||
$table->string('status')->comment('submitted = Pengajuan, accepted = Belum Dibayar, partial_paid = Bayar Sebagian, paid = Sudah Dibayar');
|
||||
$table->bigInteger('created_by');
|
||||
$table->bigInteger('updated_by');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('invoice_payments');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('invoice_payment_details', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('invoice_payment_id')->constrained('invoice_payments')->onDelete('cascade');
|
||||
$table->foreignId('claim_request_id')->constrained('claim_requests')->onDelete('cascade');
|
||||
$table->bigInteger('created_by');
|
||||
$table->bigInteger('updated_by');
|
||||
$table->bigInteger('deleted_by');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('invoice_payment_details');
|
||||
}
|
||||
};
|
||||
1573
frontend/dashboard/src/pages/InvoicePayment/CreateInvoice.tsx
Normal file
1573
frontend/dashboard/src/pages/InvoicePayment/CreateInvoice.tsx
Normal file
File diff suppressed because it is too large
Load Diff
323
frontend/dashboard/src/pages/InvoicePayment/Detail.tsx
Normal file
323
frontend/dashboard/src/pages/InvoicePayment/Detail.tsx
Normal file
@@ -0,0 +1,323 @@
|
||||
import {
|
||||
Container,
|
||||
Grid,
|
||||
Stack,
|
||||
Typography,
|
||||
Card,
|
||||
TableRow,
|
||||
Tab,
|
||||
TableCell,
|
||||
Collapse,
|
||||
AccordionSummary,
|
||||
AccordionDetails,
|
||||
IconButton,
|
||||
TextField
|
||||
} from '@mui/material';
|
||||
import { fCurrency } from '../../utils/formatNumber';
|
||||
import { Table, TableBody, TableContainer, TableHead, Paper } from '@mui/material';
|
||||
// components
|
||||
import Page from '@/components/Page';
|
||||
// utils
|
||||
import useSettings from '@/hooks/useSettings';
|
||||
// react
|
||||
import { useNavigate, useParams, useLocation } from 'react-router-dom';
|
||||
import { useEffect, useState, useRef, useMemo } from 'react';
|
||||
import axios from '@/utils/axios';
|
||||
// pages
|
||||
import ArrowBackIosIcon from '@mui/icons-material/ArrowBackIos';
|
||||
import { fDate, fDateTimesecond, fDateTime } from '@/utils/formatTime';
|
||||
import { Button } from '@mui/material';
|
||||
import Label from '@/components/Label';
|
||||
import { Box } from '@mui/system';
|
||||
import { Accordion } from '@mui/material';
|
||||
import { Delete, EditOutlined, ExpandMore } from '@mui/icons-material';
|
||||
import AddIcon from '@mui/icons-material/Add';
|
||||
|
||||
import MoreMenu from '@/components/MoreMenu';
|
||||
import { MenuItem } from '@mui/material';
|
||||
import { fNumber } from '@/utils/formatNumber';
|
||||
import palette from '@/theme/palette';
|
||||
|
||||
import CloseIcon from '@mui/icons-material/Close';
|
||||
import { enqueueSnackbar } from 'notistack';
|
||||
import { Dialog, DialogTitle, DialogContent, DialogActions } from '@mui/material';
|
||||
import { List, ListItem, Link, Divider } from '@mui/material';
|
||||
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
export default function Detail() {
|
||||
const location = useLocation();
|
||||
const queryParams = new URLSearchParams(location.search);
|
||||
|
||||
const navigate = useNavigate();
|
||||
const { themeStretch } = useSettings();
|
||||
const [invoicePayment, setInvoicePayment] = useState([]);
|
||||
const [invoicePaymentDetail, setInvoicePaymentDetail] = useState([]);
|
||||
const [invoicePaymentFile, setInvoicePaymentFile] = useState([]);
|
||||
const [statusClaim, setStatusClaim] = useState('');
|
||||
const [dataMember, setDataMember] = useState('');
|
||||
|
||||
|
||||
const { id } = useParams();
|
||||
|
||||
useEffect(() => {
|
||||
axios
|
||||
.get('invoice-payment/detail/'+id)
|
||||
.then((response) => {
|
||||
setInvoicePayment(response.data.invoice_payments);
|
||||
setInvoicePaymentDetail(response.data.invoice_payment_details);
|
||||
setInvoicePaymentFile(response.data.files);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error(error);
|
||||
});
|
||||
}, [id]);
|
||||
|
||||
console.log(invoicePayment);
|
||||
console.log(invoicePaymentDetail);
|
||||
console.log(invoicePaymentFile);
|
||||
|
||||
const style1 = {
|
||||
color: '#919EAB',
|
||||
width: '30%'
|
||||
}
|
||||
const style3 = {
|
||||
color: '#919EAB',
|
||||
width: '35%'
|
||||
}
|
||||
const style2 = {
|
||||
width: '70%'
|
||||
}
|
||||
const marginBottom1 = {
|
||||
marginBottom: 1,
|
||||
}
|
||||
const marginBottom2 = {
|
||||
marginBottom: 2,
|
||||
}
|
||||
|
||||
const handleCloseDialogSubmit = () => {
|
||||
setOpenDialogSubmit(false);
|
||||
}
|
||||
|
||||
const [decline, setDeclaine] = useState('');
|
||||
|
||||
// const handleSubmitData = () => {
|
||||
// //approve or decline
|
||||
// if(!reasonDecline && approve == 'decline')
|
||||
// {
|
||||
// enqueueSnackbar('Mohon isi alasan', { variant: 'warning' });
|
||||
// return false;
|
||||
// }
|
||||
// axios
|
||||
// .post('claims/'+id_claim+'/'+approve, {reasonDecline:reasonDecline})
|
||||
// .then((response) => {
|
||||
// enqueueSnackbar('Success '+toTitleCase(approve)+' Claim Request', { variant: 'success' });
|
||||
// setOpenDialogSubmit(false);
|
||||
// // window.location.reload();
|
||||
|
||||
// })
|
||||
// .catch(({ response }) => {
|
||||
// enqueueSnackbar(response.data.message ?? 'Something went wrong!', { variant: 'error' });
|
||||
// });
|
||||
|
||||
// setTimeout(() =>
|
||||
// {
|
||||
// window.location.reload();
|
||||
// }, 5000);
|
||||
|
||||
// };
|
||||
|
||||
function toTitleCase(str: string | null) {
|
||||
return str.replace(/\w\S*/g, function(txt) {
|
||||
return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
|
||||
});
|
||||
}
|
||||
|
||||
const [reasonDecline, setReasonDecline] = useState('');
|
||||
|
||||
const handleReasonDeclineChange = (event) => {
|
||||
setReasonDecline(event.target.value);
|
||||
// Tambahkan logika yang diperlukan di sini
|
||||
};
|
||||
|
||||
const [openDialogSubmit, setOpenDialogSubmit] = useState(false);
|
||||
const [openDialogEditDetail, setDialogDEditDetail] = useState(false);
|
||||
const [openDialogBenefit, setDialogBenefit] = useState(false);
|
||||
const [openDialogMedicine, setDialogMedicine] = useState(false);
|
||||
|
||||
// Handel Delete Detail Benefit
|
||||
const [idBenefitData, setIdBenefitData] = useState<number>();
|
||||
const [openDialogDeleteBenefit, setDialogDeleteBenefit] = useState(false)
|
||||
|
||||
const [idMedicineData, setIdMedicineData] = useState<number>();
|
||||
const [openDialogDeleteMedicine, setDialogDeleteMedicine] = useState(false)
|
||||
|
||||
const [approve, setApprove] = useState('')
|
||||
|
||||
// Handle Edit Detail Benefit
|
||||
const [openDialogEditBenefit, setDialogEditBenefit] = useState(false)
|
||||
const [BenefitConfigurationData, setBenefitConfigurationData] = useState<BenefitData>();
|
||||
|
||||
// Buat total data
|
||||
|
||||
|
||||
// Handle Delete File LOG
|
||||
const [pathFile, setPathFile] = useState('')
|
||||
const [dialogDeleteFIleLog, setDialogDeleteFileLog] = useState(false)
|
||||
|
||||
// Handle Upload File LOG
|
||||
const [dialogUploadFileLog, setDialogUploadFileLog] = useState(false)
|
||||
|
||||
const totalAmount = invoicePaymentFile.reduce((sum, payment) => {
|
||||
const num = parseFloat(payment.amount_paid) || 0;
|
||||
return parseFloat(sum) + parseFloat(num);
|
||||
}, 0);
|
||||
const grandTotal = invoicePaymentDetail.reduce((sum, item) => sum + parseFloat(item.tot_bill ? item.tot_bill : 0), 0);
|
||||
|
||||
return (
|
||||
<Page title='Detail'>
|
||||
<Container maxWidth={themeStretch ? false : 'xl'}>
|
||||
<Stack direction="row" alignItems="center" sx={{ marginBottom: 3 }}>
|
||||
<ArrowBackIosIcon onClick={() => navigate(-1)} sx={{cursor:'pointer'}}/>
|
||||
<Typography variant="h5" sx={{ marginLeft: 2 }}>
|
||||
{/* {invoicePayment.length > 0 ? invoicePayment[0].invoice_number : 'Detail'} */}
|
||||
Detail Invoice
|
||||
</Typography>
|
||||
</Stack>
|
||||
<Grid container spacing={2}>
|
||||
{/* Detail */}
|
||||
<Grid item xs={12} md={12}>
|
||||
<Card sx={{padding:2}} >
|
||||
<Grid container spacing={2}>
|
||||
<Grid item xs={6}>
|
||||
<Typography variant='subtitle1' sx={{ color: '#19BBBB', marginBottom: 4 }} gutterBottom>
|
||||
Detail
|
||||
</Typography>
|
||||
</Grid>
|
||||
</Grid>
|
||||
<Stack direction='row' spacing={2} sx={marginBottom1}>
|
||||
<Typography variant='subtitle2' sx={style1} gutterBottom>Tanggal Invoice</Typography>
|
||||
<Typography variant='subtitle2' sx={style2} gutterBottom>{invoicePayment.length > 0 ? fDate(invoicePayment[0].invoice_date) : '-'}</Typography>
|
||||
</Stack>
|
||||
<Stack direction='row' spacing={2} sx={marginBottom1}>
|
||||
<Typography variant='subtitle2' sx={style1} gutterBottom>Nomor Invoice </Typography>
|
||||
<Typography variant='subtitle2' sx={style2} gutterBottom>{invoicePayment.length > 0 ? invoicePayment[0].invoice_number : '-'}</Typography>
|
||||
</Stack>
|
||||
<Stack direction='row' spacing={2} sx={marginBottom1}>
|
||||
<Typography variant='subtitle2' sx={style1} gutterBottom>Periode Pembayaran</Typography>
|
||||
<Typography variant='subtitle2' sx={style2} gutterBottom>{invoicePayment.length > 0 ? fDate(invoicePayment[0].start_date) : '-'}-{invoicePayment.length > 0 ? fDate(invoicePayment[0].end_date) : '-'}</Typography>
|
||||
</Stack>
|
||||
|
||||
</Card>
|
||||
</Grid>
|
||||
|
||||
{/* Benefit */}
|
||||
<Grid item xs={12} md={12}>
|
||||
<Card sx={{padding:2}} >
|
||||
<Stack direction="row" alignItems="center" sx={{marginBottom: 4}}>
|
||||
<Typography variant='subtitle1' sx={{color: '#19BBBB'}} gutterBottom>Claim</Typography>
|
||||
</Stack>
|
||||
<TableContainer component={Paper}>
|
||||
<Table>
|
||||
<TableHead>
|
||||
<TableRow>
|
||||
<TableCell>Code Claim/Code Log</TableCell>
|
||||
<TableCell>Invoice No</TableCell>
|
||||
<TableCell>Name</TableCell>
|
||||
<TableCell>Member ID</TableCell>
|
||||
<TableCell>Policy Number</TableCell>
|
||||
<TableCell>Provider</TableCell>
|
||||
<TableCell>Total Bill</TableCell>
|
||||
</TableRow>
|
||||
</TableHead>
|
||||
<TableBody>
|
||||
{invoicePaymentDetail.map((detail) => (
|
||||
<TableRow key={detail.id}>
|
||||
<TableCell>{detail.code} / {detail.code_log}</TableCell>
|
||||
<TableCell>{detail.invoice_no || '-'}</TableCell>
|
||||
<TableCell>{detail.name}</TableCell>
|
||||
<TableCell>{detail.member_id}</TableCell>
|
||||
<TableCell>{detail.corporate_policies}</TableCell>
|
||||
<TableCell>{detail.provider}</TableCell>
|
||||
<TableCell>{fCurrency(detail.tot_bill)}</TableCell>
|
||||
</TableRow>
|
||||
))}
|
||||
</TableBody>
|
||||
</Table>
|
||||
</TableContainer>
|
||||
</Card>
|
||||
|
||||
|
||||
|
||||
</Grid>
|
||||
|
||||
{/* Catatan Pembayaran */}
|
||||
<Grid item xs={12} md={12}>
|
||||
<Card sx={{padding:2}} >
|
||||
<Stack direction="row" alignItems="center" sx={{marginBottom: 4}}>
|
||||
<Typography variant='subtitle1' sx={{color: '#19BBBB'}} gutterBottom>Catatan Pembayaran</Typography>
|
||||
|
||||
</Stack>
|
||||
{invoicePaymentFile.map((file, index) => (
|
||||
<Stack key={index.id} spacing={2} width="100%" sx={{ border: "1px solid #ddd", p: 2, borderRadius: 2, mt: 2, pt: 2 }}>
|
||||
<Stack direction="row" justifyContent="space-between" alignItems="center">
|
||||
<Typography variant="subtitle1">Pembayaran {file.payment_number}</Typography>
|
||||
</Stack>
|
||||
|
||||
{/* Input Jumlah Bayar */}
|
||||
<Stack direction="row" spacing={2} width="100%">
|
||||
<Stack spacing={2} sx={{ width: "50%" }}>
|
||||
<Typography variant='subtitle2' sx={style1} gutterBottom>Nominal Pembayaran</Typography>
|
||||
<Typography variant='subtitle2' sx={style2} gutterBottom>{fCurrency(parseFloat(file.amount_paid))}</Typography>
|
||||
</Stack>
|
||||
|
||||
{/* Input File Bukti */}
|
||||
<Stack spacing={2} sx={{ width: "50%" }}>
|
||||
<Typography variant='subtitle2' sx={style1} gutterBottom>Bukti Pembayaran</Typography>
|
||||
<Stack>
|
||||
<Stack divider={<Divider orientation="horizontal" flexItem />} spacing={1}>
|
||||
{file.files.map((file1, fileIndex) => (
|
||||
<Stack direction="row" justifyContent="space-between" key={fileIndex}>
|
||||
<a
|
||||
href={file1.path}
|
||||
style={{ cursor: 'pointer', textDecoration: 'none', color: '#19BBBB' }}
|
||||
target="_blank"
|
||||
>
|
||||
<Typography variant="body2" gutterBottom>{file1.original_name ? file1.original_name : '-'}</Typography>
|
||||
</a>
|
||||
</Stack>
|
||||
))}
|
||||
</Stack>
|
||||
</Stack>
|
||||
</Stack>
|
||||
</Stack>
|
||||
</Stack>
|
||||
))}
|
||||
<Stack direction="row" justifyContent="space-between" alignContent="center" sx={{ mt: 2, pt: 2}}>
|
||||
<Typography variant='subtitle1' fontWeight="bold">Jumlah Tagihan</Typography>
|
||||
<Typography variant='subtitle1' fontWeight="bold">
|
||||
{fCurrency(grandTotal)}
|
||||
</Typography>
|
||||
</Stack>
|
||||
{/* Total Jumlah Bayar */}
|
||||
<Stack direction="row" justifyContent="space-between" alignItems="center" sx={{ mt: 2, borderTop: "2px solid #ddd", pt: 2 }}>
|
||||
<Typography variant="subtitle2" fontWeight="bold" sx={{ color: "#19BBBB" }}>Total Dibayar</Typography>
|
||||
<Typography variant="subtitle2" fontWeight="bold" sx={{ color: "#19BBBB" }}>
|
||||
{fCurrency(totalAmount.toString())}
|
||||
</Typography>
|
||||
</Stack>
|
||||
<Stack direction="row" justifyContent="space-between" alignItems="center" sx={{ mt: 1, pt: 1 }}>
|
||||
<Typography variant="subtitle2" fontWeight="bold" sx={{ color: "#FF4842" }}>Sisa Pembayaran</Typography>
|
||||
<Typography variant="subtitle2" fontWeight="bold" sx={{ color: "#FF4842" }}>
|
||||
{fCurrency((grandTotal - totalAmount))}
|
||||
</Typography>
|
||||
</Stack>
|
||||
</Card>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Container>
|
||||
</Page>
|
||||
);
|
||||
}
|
||||
30
frontend/dashboard/src/pages/InvoicePayment/Index.tsx
Normal file
30
frontend/dashboard/src/pages/InvoicePayment/Index.tsx
Normal file
@@ -0,0 +1,30 @@
|
||||
import { Card, Stack } from "@mui/material";
|
||||
import HeaderBreadcrumbs from "../../components/HeaderBreadcrumbs";
|
||||
import Page from "../../components/Page";
|
||||
import List from "./List";
|
||||
|
||||
|
||||
|
||||
export default function Invoice() {
|
||||
|
||||
const pageTitle = 'Invoice Management';
|
||||
return (
|
||||
<Page title={ pageTitle } sx={{ mx: 2}}>
|
||||
|
||||
<HeaderBreadcrumbs
|
||||
heading={ pageTitle }
|
||||
links={[
|
||||
{ name: 'Dashboard', href: '/dashboard' },
|
||||
{
|
||||
name: 'Invoice Payment',
|
||||
href: '/invoice-payment',
|
||||
},
|
||||
]}
|
||||
/>
|
||||
|
||||
{/* <Stack> */}
|
||||
<List />
|
||||
{/* </Stack> */}
|
||||
</Page>
|
||||
);
|
||||
}
|
||||
1063
frontend/dashboard/src/pages/InvoicePayment/List.tsx
Normal file
1063
frontend/dashboard/src/pages/InvoicePayment/List.tsx
Normal file
File diff suppressed because it is too large
Load Diff
@@ -480,6 +480,22 @@ export default function Router() {
|
||||
path: 'report/rujukan',
|
||||
element: <RujukanPasien/>,
|
||||
},
|
||||
{
|
||||
path: 'invoice-payment',
|
||||
element: <InvoicePayments />,
|
||||
},
|
||||
{
|
||||
path: 'invoice-payment/create',
|
||||
element: <CreateInvoicePayments />,
|
||||
},
|
||||
{
|
||||
path: 'invoice-payment/detail/:id',
|
||||
element: <InvoicePaymentsDetail />,
|
||||
},
|
||||
{
|
||||
path: 'invoice-payment/edit/:invoiceID',
|
||||
element: <InvoicePaymentsEdit />,
|
||||
},
|
||||
{
|
||||
path: 'claims',
|
||||
element: <Claims />,
|
||||
@@ -780,6 +796,13 @@ const CorporateHistories = Loadable(
|
||||
|
||||
const Profile = Loadable(lazy(() => import('../pages/Profile/Index')));
|
||||
|
||||
//Invoice_Payments
|
||||
const InvoicePayments = Loadable(lazy(() => import('../pages/InvoicePayment/Index')));
|
||||
const CreateInvoicePayments = Loadable(lazy(() => import('../pages/InvoicePayment/CreateInvoice')));
|
||||
const InvoicePaymentsDetail = Loadable(lazy(() => import('../pages/InvoicePayment/Detail')));
|
||||
const InvoicePaymentsEdit = Loadable(lazy(() => import('../pages/InvoicePayment/CreateInvoice')));
|
||||
|
||||
|
||||
const Claims = Loadable(lazy(() => import('../pages/Claims/Index')));
|
||||
const ClaimsCreate = Loadable(lazy(() => import('../pages/Claims/CreateUpdate')));
|
||||
const ClaimsDetail = Loadable(lazy(() => import('../pages/Claims/Detail')));
|
||||
|
||||
Reference in New Issue
Block a user