Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2786b3be0c | |||
| aac29bc199 | |||
| 9e73f6ad32 | |||
| ff21d82af5 |
@@ -3,6 +3,7 @@
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Marhun;
|
||||
use App\Gadai;
|
||||
use App\Jemas;
|
||||
use App\Cawangan;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -160,39 +161,53 @@ class MarhunController extends Controller
|
||||
|
||||
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first();
|
||||
|
||||
$old_data = Marhun::on($cawangan['mysql'])->where([['recno','=',$request->recno],['norujukan','=',$norujukan]])->first();
|
||||
// Lock the parent first so concurrent edits to this SAG are serialized.
|
||||
(new Marhun)->setConnection($cawangan['mysql'])->getConnection()->transaction(function () use ($cawangan, $norujukan, $request, $harga, $nilai_marhun, $kodcaw, $current) {
|
||||
Gadai::on($cawangan['mysql'])->where('norujukan', $norujukan)->lockForUpdate()->firstOrFail();
|
||||
$old_data = Marhun::on($cawangan['mysql'])->where([['recno','=',$request->recno],['norujukan','=',$norujukan]])->firstOrFail();
|
||||
|
||||
$marhunToUpdate = [
|
||||
'karat' => $request->karat,
|
||||
'marhun' => $request->marhun,
|
||||
'nota' => $request->nota,
|
||||
'tag_permata' => $request->tag_permata,
|
||||
'berat_batu_permata' => $request->berat_batu_permata,
|
||||
'berat' => $request->berat,
|
||||
'harga' => $harga['harga'],
|
||||
'n_marhun' => $nilai_marhun,
|
||||
'bil' => $request->kuantiti,
|
||||
];
|
||||
$marhunToUpdate = [
|
||||
'karat' => $request->karat,
|
||||
'marhun' => $request->marhun,
|
||||
'nota' => $request->nota,
|
||||
'tag_permata' => $request->tag_permata,
|
||||
'berat_batu_permata' => $request->berat_batu_permata,
|
||||
'berat' => $request->berat,
|
||||
'harga' => $harga['harga'],
|
||||
'n_marhun' => $nilai_marhun,
|
||||
'bil' => $request->kuantiti,
|
||||
];
|
||||
|
||||
// Set value berat_batu_permata to null if value passed is null
|
||||
if($marhunToUpdate['berat_batu_permata'] == '') {
|
||||
$marhunToUpdate['berat_batu_permata'] = null;
|
||||
};
|
||||
// Set value berat_batu_permata to null if value passed is null
|
||||
if($marhunToUpdate['berat_batu_permata'] == '') {
|
||||
$marhunToUpdate['berat_batu_permata'] = null;
|
||||
};
|
||||
|
||||
$jemas = Marhun::on($cawangan['mysql'])->where([['recno','=',$request->recno],['norujukan','=',$norujukan]])->update($marhunToUpdate);
|
||||
$jemas = Marhun::on($cawangan['mysql'])->where([['recno','=',$request->recno],['norujukan','=',$norujukan]])->update($marhunToUpdate);
|
||||
|
||||
$new_data = Marhun::on($cawangan['mysql'])->where([['recno','=',$request->recno],['norujukan','=',$norujukan]])->first();
|
||||
// Recalculate from every item belonging to this SAG, after the edit.
|
||||
$totals = Marhun::on($cawangan['mysql'])->where('norujukan', $norujukan)
|
||||
->selectRaw('COALESCE(SUM(berat), 0) AS total_berat, COALESCE(SUM(n_marhun), 0) AS total_nilai, COALESCE(SUM(bil), 0) AS total_kuantiti')
|
||||
->first();
|
||||
Gadai::on($cawangan['mysql'])->where('norujukan', $norujukan)->update([
|
||||
'berat' => $totals->total_berat,
|
||||
'nilaimarhun' => $totals->total_nilai,
|
||||
'kuantiti' => $totals->total_kuantiti,
|
||||
]);
|
||||
|
||||
$audit = new Audit();
|
||||
$audit->users = $request->teller;
|
||||
$audit->actions = 'Ubah Marhun';
|
||||
$audit->norujukan = $norujukan;
|
||||
$audit->old_data = $old_data;
|
||||
$audit->new_data = $new_data;
|
||||
$audit->kodcaw = $kodcaw;
|
||||
$audit->created_at = $current;
|
||||
$audit->updated_at = $current;
|
||||
$audit->save();
|
||||
$new_data = Marhun::on($cawangan['mysql'])->where([['recno','=',$request->recno],['norujukan','=',$norujukan]])->first();
|
||||
|
||||
$audit = new Audit();
|
||||
$audit->users = $request->teller;
|
||||
$audit->actions = 'Ubah Marhun';
|
||||
$audit->norujukan = $norujukan;
|
||||
$audit->old_data = $old_data;
|
||||
$audit->new_data = $new_data;
|
||||
$audit->kodcaw = $kodcaw;
|
||||
$audit->created_at = $current;
|
||||
$audit->updated_at = $current;
|
||||
$audit->save();
|
||||
});
|
||||
|
||||
return response('Edit Successfully', 200);
|
||||
}
|
||||
|
||||
@@ -62,6 +62,7 @@ class PembiayaanOnlineController extends Controller
|
||||
'kodbank', 'noakaun', 'nama_bank', 'nama_akaun', 'nota',
|
||||
'bukti_akaun_file_id', 'borang_file_id', 'update_customer_bank',
|
||||
'bukti_akaun_data', 'bukti_akaun_filename', 'bukti_akaun_type',
|
||||
'borang_data', 'borang_filename', 'borang_type',
|
||||
] as $key) {
|
||||
if ($request->has($key)) {
|
||||
$input[$key] = $request->input($key);
|
||||
@@ -214,6 +215,14 @@ class PembiayaanOnlineController extends Controller
|
||||
return $this->respond($this->service->getBuktiAkaun($kodcaw, $id));
|
||||
}
|
||||
|
||||
/**
|
||||
* GET /api/pembiayaan-online/{kodcaw}/lines/{id}/borang
|
||||
*/
|
||||
public function getBorang($kodcaw, $id)
|
||||
{
|
||||
return $this->respond($this->service->getBorang($kodcaw, $id));
|
||||
}
|
||||
|
||||
/**
|
||||
* GET /api/pembiayaan-online/{kodcaw}/paid?blast_sent=0
|
||||
*/
|
||||
|
||||
@@ -415,6 +415,19 @@ class PembiayaanOnlineService
|
||||
$fields['bukti_akaun_file_id'] = $saved['payload']['id'];
|
||||
}
|
||||
|
||||
if (!empty($input['borang_data'])) {
|
||||
$saved = $this->storeBuktiFile([
|
||||
'data' => $input['borang_data'],
|
||||
'filename' => $input['borang_filename'] ?? null,
|
||||
'type' => $input['borang_type'] ?? null,
|
||||
]);
|
||||
if (!$saved['ok']) {
|
||||
$saved['payload']['message'] = 'Borang pengesahan diperlukan: fail, nama fail dan jenis fail.';
|
||||
return $saved;
|
||||
}
|
||||
$fields['borang_file_id'] = $saved['payload']['id'];
|
||||
}
|
||||
|
||||
if (empty($fields)) {
|
||||
return [
|
||||
'ok' => false,
|
||||
@@ -694,6 +707,26 @@ class PembiayaanOnlineService
|
||||
->orderBy('id', 'asc')
|
||||
->get();
|
||||
|
||||
// Fetch customer phone numbers in one query for the batch approval form.
|
||||
$identityNumbers = $lines->pluck('nokp')->filter()->unique()->values()->all();
|
||||
$phones = [];
|
||||
if ($identityNumbers) {
|
||||
$customers = Customer::on('mysql7')->select('kpbaru', 'kplama', 'telefon')
|
||||
->where(function ($query) use ($identityNumbers) {
|
||||
$query->whereIn('kpbaru', $identityNumbers)->orWhereIn('kplama', $identityNumbers);
|
||||
})->get();
|
||||
foreach ($customers as $customer) {
|
||||
foreach ([$customer->kpbaru, $customer->kplama] as $identity) {
|
||||
if ($identity !== null && $identity !== '') {
|
||||
$phones[(string) $identity] = $customer->telefon;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach ($lines as $line) {
|
||||
$line->setAttribute('telefon', $phones[(string) $line->nokp] ?? null);
|
||||
}
|
||||
|
||||
return [
|
||||
'ok' => true,
|
||||
'status' => 200,
|
||||
@@ -1739,6 +1772,65 @@ class PembiayaanOnlineService
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get attached signed online-financing confirmation form (borang_file_id).
|
||||
*
|
||||
* @return array{ok:bool,status:int,payload:mixed}
|
||||
*/
|
||||
public function getBorang($kodcaw, $id)
|
||||
{
|
||||
$resolved = $this->resolveMysql($kodcaw);
|
||||
if (!$resolved['ok']) {
|
||||
return $resolved;
|
||||
}
|
||||
|
||||
$line = PembiayaanOnline::on($resolved['mysql'])
|
||||
->where('kodcaw', $kodcaw)
|
||||
->where('id', $id)
|
||||
->first();
|
||||
|
||||
if (!$line) {
|
||||
return [
|
||||
'ok' => false,
|
||||
'status' => 404,
|
||||
'payload' => ['message' => 'Pembiayaan online tidak dijumpai'],
|
||||
];
|
||||
}
|
||||
|
||||
if (empty($line->borang_file_id)) {
|
||||
return [
|
||||
'ok' => false,
|
||||
'status' => 404,
|
||||
'payload' => ['message' => 'Borang pengesahan belum dimuat naik'],
|
||||
];
|
||||
}
|
||||
|
||||
$file = ARFiles::on('mysql7')->where('id', $line->borang_file_id)->first();
|
||||
if (!$file) {
|
||||
return [
|
||||
'ok' => false,
|
||||
'status' => 404,
|
||||
'payload' => ['message' => 'Fail borang pengesahan tidak dijumpai'],
|
||||
];
|
||||
}
|
||||
|
||||
return [
|
||||
'ok' => true,
|
||||
'status' => 200,
|
||||
'payload' => [
|
||||
'pembiayaan_online_id' => $line->id,
|
||||
'norujukan' => $line->norujukan,
|
||||
'file' => [
|
||||
'id' => $file->id,
|
||||
'filename' => $file->filename,
|
||||
'type' => $file->type,
|
||||
'tarikhmasa' => $file->tarikhmasa,
|
||||
'data' => $file->data,
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* PC list of PAID lines awaiting blast / tally.
|
||||
*
|
||||
|
||||
+3
-10
@@ -5,6 +5,8 @@ services:
|
||||
dockerfile: docker/php/Dockerfile
|
||||
target: development
|
||||
working_dir: /var/www/html
|
||||
ports:
|
||||
- "8080:8000"
|
||||
volumes:
|
||||
- ./:/var/www/html:cached
|
||||
environment:
|
||||
@@ -12,16 +14,7 @@ services:
|
||||
APP_DEBUG: "true"
|
||||
depends_on:
|
||||
- mysql
|
||||
|
||||
web:
|
||||
image: nginx:1.25-alpine
|
||||
ports:
|
||||
- "8080:80"
|
||||
volumes:
|
||||
- ./:/var/www/html:cached
|
||||
- ./docker/nginx/default.conf:/etc/nginx/conf.d/default.conf:ro
|
||||
depends_on:
|
||||
- app
|
||||
command: ["php", "-S", "0.0.0.0:8000", "-t", "public"]
|
||||
|
||||
mysql:
|
||||
image: mysql:8.0
|
||||
|
||||
@@ -723,6 +723,7 @@ $router->group(['prefix'=>'api'], function () use ($router){
|
||||
$router->post('pembiayaan-online/{kodcaw}/lines/{id}/unverify', ['uses' => 'PembiayaanOnlineController@unverifyLine']);
|
||||
$router->get('pembiayaan-online/{kodcaw}/lines/{id}/bukti', ['uses' => 'PembiayaanOnlineController@getBukti']);
|
||||
$router->get('pembiayaan-online/{kodcaw}/lines/{id}/bukti-akaun', ['uses' => 'PembiayaanOnlineController@getBuktiAkaun']);
|
||||
$router->get('pembiayaan-online/{kodcaw}/lines/{id}/borang', ['uses' => 'PembiayaanOnlineController@getBorang']);
|
||||
$router->get('pembiayaan-online/{kodcaw}/lines/{id}', ['uses' => 'PembiayaanOnlineController@showLine']);
|
||||
$router->get('pembiayaan-online/{kodcaw}/batches', ['uses' => 'PembiayaanOnlineController@listBatches']);
|
||||
$router->get('pembiayaan-online/{kodcaw}/batches/{batchId}', ['uses' => 'PembiayaanOnlineController@showBatch']);
|
||||
|
||||
Reference in New Issue
Block a user