finished panjar and tunai, also added migration for recno in requestteller
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user