Fix/gadai online details (#30)
Build Docker Image / build-frontend (push) Successful in 46s
Deploy to Staging / deploy (push) Successful in 20s

Co-authored-by: afrina <afrina@koppkb.com>
Reviewed-on: #30
This commit was merged in pull request #30.
This commit is contained in:
2026-10-22 11:51:55 +08:00
parent 464d3e8dbb
commit 1138e193ae
6 changed files with 117 additions and 23 deletions
@@ -156,7 +156,6 @@ class PembiayaanOnlineController extends Controller
'kodbank' => $request->input('kodbank'),
'noakaun' => $request->input('noakaun'),
'nama_bank' => $request->input('nama_bank'),
'nama_akaun' => $request->input('nama_akaun'),
'nota' => $request->input('nota'),
'update_customer_bank' => true,
];
@@ -174,6 +173,19 @@ class PembiayaanOnlineController extends Controller
$payload['bukti_akaun_type'] = $file->getMimeType() ?: 'application/octet-stream';
}
if ($request->hasFile('borang')) {
$file = $request->file('borang');
if (!$file->isValid()) {
return redirect()->back()->with('error', 'Fail borang pengesahan tidak sah.');
}
if ($file->getSize() > 4 * 1024 * 1024) {
return redirect()->back()->with('error', 'Saiz fail maksimum 4MB.');
}
$payload['borang_data'] = base64_encode(file_get_contents($file->getRealPath()));
$payload['borang_filename'] = $file->getClientOriginalName();
$payload['borang_type'] = $file->getMimeType() ?: 'application/octet-stream';
}
$res = $this->api()
->asForm()
->put($api_url . '/api/pembiayaan-online/' . $kodcaw . '/lines/' . $id, $payload);
@@ -394,6 +406,22 @@ class PembiayaanOnlineController extends Controller
return $this->streamBase64File($file, 'slip-bank-' . $id);
}
/**
* PC: view uploaded Borang Pengesahan Penerimaan Pembiayaan Secara Atas Talian.
*/
public function viewBorang($id)
{
$this->abortUnlessPembiayaanOnline();
return $this->streamLineFile(
$this->kodcaw(),
$id,
'/borang',
'Borang pengesahan tidak dijumpai.',
'Fail borang pengesahan kosong.',
'borang-pengesahan-' . $id
);
}
/**
* PC: view SAG for a queue line (does not mark SAG as printed).
*/
@@ -426,6 +454,21 @@ class PembiayaanOnlineController extends Controller
return $this->streamBase64File($file, 'slip-bank-' . $id);
}
/**
* Operasi: view uploaded Borang Pengesahan Penerimaan Pembiayaan Secara Atas Talian.
*/
public function operasiViewBorang($kodcaw, $id)
{
return $this->streamLineFile(
$kodcaw,
$id,
'/borang',
'Borang pengesahan tidak dijumpai.',
'Fail borang pengesahan kosong.',
'borang-pengesahan-' . $id
);
}
/**
* Operasi: view SAG for a batch line.
*/
@@ -434,6 +477,26 @@ class PembiayaanOnlineController extends Controller
return $this->renderLineSag($kodcaw, $id);
}
protected function streamLineFile($kodcaw, $id, $path, $missingMessage, $emptyMessage, $fallbackName)
{
$res = $this->api()
->get(config('api.url') . '/api/pembiayaan-online/' . $kodcaw . '/lines/' . $id . $path);
if (!$res->successful()) {
$body = $res->json();
$msg = is_array($body) && isset($body['message']) ? $body['message'] : $missingMessage;
return redirect()->back()->with('error', $msg);
}
$payload = $res->json();
$file = $payload['file'] ?? null;
if (!$file || empty($file['data'])) {
return redirect()->back()->with('error', $emptyMessage);
}
return $this->streamBase64File($file, $fallbackName);
}
protected function streamBase64File(array $file, $fallbackName)
{
$raw = $file['data'];