Merged in hotfix/lejeram (pull request #203)
added tunaiditangan in imbangduga
This commit is contained in:
@@ -9,6 +9,8 @@ use App\Gadai;
|
|||||||
use App\imbangdugabackup;
|
use App\imbangdugabackup;
|
||||||
use App\Lelong;
|
use App\Lelong;
|
||||||
use App\Transaction;
|
use App\Transaction;
|
||||||
|
use App\Vault;
|
||||||
|
use App\Tunai;
|
||||||
use App\TransaksiKeuntungan;
|
use App\TransaksiKeuntungan;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||||
@@ -431,6 +433,41 @@ class ImbangDugaService
|
|||||||
return ['onepercent' => $onepercent_akru, 'ujrah' => $ujrah_akru];
|
return ['onepercent' => $onepercent_akru, 'ujrah' => $ujrah_akru];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getTunaiDiTangan(){
|
||||||
|
$current = Carbon::now();
|
||||||
|
$current = new Carbon();
|
||||||
|
|
||||||
|
$totalbakiakhirtunai = 0;
|
||||||
|
|
||||||
|
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$this->kodcaw)->first();
|
||||||
|
$vault=Vault::on($cawangan['mysql'])
|
||||||
|
->where('kodcaw','=',$this->kodcaw)
|
||||||
|
->where('tarikh','<=', $this->tarikh)
|
||||||
|
->orderby('tarikh','desc')->first();
|
||||||
|
|
||||||
|
$tunai = Tunai::on($cawangan['mysql'])
|
||||||
|
->where('kodcaw','=',$this->kodcaw)
|
||||||
|
->where('tarikh','=', $this->tarikh)
|
||||||
|
->get();
|
||||||
|
|
||||||
|
$total = 0;
|
||||||
|
foreach($tunai as $index=>$money)
|
||||||
|
{
|
||||||
|
$total+=$money['baki'];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if($total != 0)
|
||||||
|
{
|
||||||
|
$totalbakiakhirtunai = $vault['bakiakhir'] + $total;
|
||||||
|
}else
|
||||||
|
{
|
||||||
|
$totalbakiakhirtunai = $vault['bakiakhir'];
|
||||||
|
}
|
||||||
|
|
||||||
|
return response()->json($totalbakiakhirtunai);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public function setImbangDugaBackup()
|
public function setImbangDugaBackup()
|
||||||
{
|
{
|
||||||
@@ -443,13 +480,14 @@ class ImbangDugaService
|
|||||||
$pend_terakru = $this->getPendapatanTerakru();
|
$pend_terakru = $this->getPendapatanTerakru();
|
||||||
$keun_sebenar = $this->getKeuntunganSebenar();
|
$keun_sebenar = $this->getKeuntunganSebenar();
|
||||||
$accrual = $this->getOnePercentUjrah();
|
$accrual = $this->getOnePercentUjrah();
|
||||||
|
$tunaiditangan = $this->getTunaiDiTangan();
|
||||||
$ujrah = $accrual['ujrah'];
|
$ujrah = $accrual['ujrah'];
|
||||||
$onepercent = $accrual['onepercent'];
|
$onepercent = $accrual['onepercent'];
|
||||||
|
|
||||||
$totalharta = imbangdugabackup::on($cawangan['mysql'])->where('tarikh', $this->tarikh)
|
$totalharta = imbangdugabackup::on($cawangan['mysql'])->where('tarikh', $this->tarikh)
|
||||||
->get()
|
->get()
|
||||||
->map(function ($ig) use ($keuntungan_penggadai) {
|
->map(function ($ig) use ($keuntungan_penggadai,$tunaiditangan) {
|
||||||
return $ig['tunaiditangan'] + $ig['pembiayaantawarruq'] + $ig['bayaranpendahuluan'] + $ig['pinjamankoop'] + $ig['emaspalsu']
|
return $tunaiditangan + $ig['pembiayaantawarruq'] + $ig['bayaranpendahuluan'] + $ig['pinjamankoop'] + $ig['emaspalsu']
|
||||||
+ $ig['pindahkekpkb'] + $ig['penghutangkaki'] + $ig['phapuskira'] + $ig['belian1stop'] + $keuntungan_penggadai + $ig['serahan'];
|
+ $ig['pindahkekpkb'] + $ig['penghutangkaki'] + $ig['phapuskira'] + $ig['belian1stop'] + $keuntungan_penggadai + $ig['serahan'];
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -472,6 +510,7 @@ class ImbangDugaService
|
|||||||
|
|
||||||
|
|
||||||
imbangdugabackup::on($cawangan['mysql'])->where('tarikh', $this->tarikh)->update([
|
imbangdugabackup::on($cawangan['mysql'])->where('tarikh', $this->tarikh)->update([
|
||||||
|
'tunaiditangan' => $tunaiditangan,
|
||||||
'keun_penggadai' => $keuntungan_penggadai,
|
'keun_penggadai' => $keuntungan_penggadai,
|
||||||
'keun_sebenar' => $keun_sebenar,
|
'keun_sebenar' => $keun_sebenar,
|
||||||
'pend_terakru' => $pend_terakru,
|
'pend_terakru' => $pend_terakru,
|
||||||
|
|||||||
Reference in New Issue
Block a user