finished panjar and tunai, also added migration for recno in requestteller

This commit is contained in:
hafifierahman
2024-11-08 21:49:22 +08:00
parent 24bf497d3d
commit 494408a5cc
5 changed files with 49 additions and 9 deletions
+9
View File
@@ -339,6 +339,15 @@ class TunaiController extends Controller
return response()->json($requestteller);
}
public function getRequestTellerByRecno($kodcaw,Request $request){
$current = Carbon::now();
$current = new Carbon();
$requestteller=RequestTeller::on('mysql7')->where([['kodcaw','=',$kodcaw],['update','=',1],['recno','=',$request->recno],['kodlaluan','=',$request->teller]])->get();
return response()->json($requestteller);
}
public function getRequestTellerLaporanSerahanBerkala($kodcaw,Request $request)
{
+4 -2
View File
@@ -177,7 +177,7 @@ class TellerServices
throw new Exception('Unsuccessful Tunai');
}
AddTunai::on($cawangan['mysql'])->create([
$addtunai = AddTunai::on($cawangan['mysql'])->create([
'tarikh' => $current->toDateString(),
'kodcaw'=> $this->cawangan,
'kodlaluan'=>$request->teller,
@@ -286,6 +286,7 @@ class TellerServices
'txtsen10' => ($request->ambilansen10) ? $request->ambilansen10 : 0,
'txtsen20' => ($request->ambilansen20) ? $request->ambilansen20 : 0,
'txtsen50' => ($request->ambilansen50) ? $request->ambilansen50 : 0,
'recno' => $addtunai['id']
) );
// Commit transactions
@@ -324,7 +325,7 @@ class TellerServices
throw new Exception('Unsuccessful Tunai');
}
AddTunai::on($cawangan['mysql'])->create([
$addtunai = AddTunai::on($cawangan['mysql'])->create([
'tarikh' => $current->toDateString(),
'kodcaw'=> $this->cawangan,
'kodlaluan'=>$request->teller,
@@ -414,6 +415,7 @@ class TellerServices
/* RequestTeller Transaction */
$requestteller = RequestTeller::on('mysql7')->where([['no','=',$request->no],['kodcaw','=',$this->cawangan],['kodlaluan','=',$request->teller],['update','=',0]])->update(array(
'update' => 1,
'recno' => $addtunai['id']
) );
// Commit transactions
@@ -122,14 +122,13 @@ class PanjarServices
$panjar = Panjar::on($cawangan['mysql'])->latest('tarikh')->where('nobaucer', $request->nobaucer)->first();
$vault = Vault::on($cawangan['mysql'])->latest('tarikh')->first();
$deno_panjar = DenoPanjar::on('mysql7')->where('kodcaw', $this->cawangan)->where('recno', $request->recno)->latest('tarikh','masa')->first();
$totalperubatan = floatval($this->getPerubatanAmount($panjar['tuntutoleh'])) + $panjar['bayaran'];
try{
if (!$panjar) throw new \Exception('Custom Exception: Panjar Does Not Exist!');
if (!$denominasi) throw new \Exception('Custom Exception: Denominasi Does Not Exist!');
if (!$vault) throw new \Exception('Custom Exception: Vault Does Not Exist!');
if (!$deno_panjar) throw new \Exception('Custom Exception: Denominasi Panjar Does Not Exist!');
return DB::transaction(function () use ($cawangan,$deno_panjar,$panjar,$denominasi,$current,$vault,$totalperubatan) {
return DB::transaction(function () use ($cawangan,$deno_panjar,$panjar,$denominasi,$current,$vault) {
$return_data = $this->calculation_denominasi($deno_panjar,$denominasi,'masuk');
if($return_data == 'no data') throw new \Exception('Custom Exception: Denominasi Panjar Not Return Data');
@@ -200,10 +199,12 @@ class PanjarServices
DenoPanjar::on('mysql7')->where('kodcaw', $this->cawangan)->where('recno', $panjar['recno'])->latest('tarikh','masa')->delete();
Panjar::on($cawangan['mysql'])->where('recno',$panjar['recno'])->delete();
$totalperubatan = floatval($this->getPerubatanAmount($panjar['tuntutoleh']));
return $array_response = [
'result' => 'success',
'data' => 1,
'bakiperubatan' => $totalperubatan,
'totalperubatan' => $totalperubatan,
'tuntutoleh' => $panjar['tuntutoleh'],
'jenis' => ($panjar['kategori'] == 'Belanja AM - Perubatan') ? 'perubatan' : 'none'
];
@@ -235,8 +236,6 @@ class PanjarServices
$myDateTime = DateTime::createFromFormat('Y-m-d', $request->tarikhbil);
$tarikhbil = $myDateTime->format('dmY');
$tagmodal = $this->checkModal($request->jenismodal);
$bakiperubatan = $this->getPerubatanAmount($request->tuntutan);
$currentbaki = floatval($bakiperubatan) - floatval($request->bayaran);
$panjar = Panjar::on($cawangan['mysql'])
->create([
'tarikh'=> $current->toDateString(),
@@ -245,7 +244,7 @@ class PanjarServices
'tag' => $tagmodal['tag'],
'kategori' => $tagmodal['kategori'],
'id' => $request->kodlaluan,
'bakiperubatan' => $currentbaki,
'bakiperubatan' => 0,
'nobaucer' => $request->baucer,
'nobil' => $tarikhbil,
'tuntutoleh' => $request->tuntutan
@@ -346,11 +345,12 @@ class PanjarServices
$audit->updated_at = $current;
$audit->save();
$totalperubatan = $this->getPerubatanAmount($request->tuntutan);
$array_response = [
'result' => 'success',
'data' => 1,
'bakiperubatan' => $currentbaki,
'totalperubatan' => $totalperubatan,
];
return $array_response;
@@ -0,0 +1,28 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddRecnoToRequestTellerTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
$columns = ['recno'];
$columns_not_exist = array_filter($columns, function ($column) {
return !Schema::connection('mysql7')->hasColumn('requestteller', $column);
});
Schema::connection('mysql7')->table('requestteller', function (Blueprint $table) use ($columns_not_exist) {
array_walk($columns_not_exist, function ($column) use ($table) {
$table->integer($column);
});
});
}
}
+1
View File
@@ -380,6 +380,7 @@ $router->group(['prefix'=>'api'], function () use ($router){
$router->post('requestTeller/{kodcaw}',['uses' => 'TunaiController@createRequestTeller']);
$router->get('requestTeller/get/{kodcaw}',['uses' => 'TunaiController@getRequestTeller']);
$router->get('requestTeller/getlaporan/{kodcaw}',['uses' => 'TunaiController@getRequestTellerLaporanSerahan']);
$router->get('requestTeller/getrekod/{kodcaw}',['uses' => 'TunaiController@getRequestTellerByRecno']);
$router->get('requestTeller/getlaporanberkala/{kodcaw}',['uses' => 'TunaiController@getRequestTellerLaporanSerahanBerkala']);
$router->get('requestTeller/get/{kodcaw}/date',['uses' => 'TunaiController@getRequestTellerByDate']);
$router->put('requestTeller/update/{kodcaw}',['uses' => 'TunaiController@updateRequestTeller']);