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\Lelong;
|
||||
use App\Transaction;
|
||||
use App\Vault;
|
||||
use App\Tunai;
|
||||
use App\TransaksiKeuntungan;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||
@@ -431,6 +433,41 @@ class ImbangDugaService
|
||||
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()
|
||||
{
|
||||
@@ -443,13 +480,14 @@ class ImbangDugaService
|
||||
$pend_terakru = $this->getPendapatanTerakru();
|
||||
$keun_sebenar = $this->getKeuntunganSebenar();
|
||||
$accrual = $this->getOnePercentUjrah();
|
||||
$tunaiditangan = $this->getTunaiDiTangan();
|
||||
$ujrah = $accrual['ujrah'];
|
||||
$onepercent = $accrual['onepercent'];
|
||||
|
||||
$totalharta = imbangdugabackup::on($cawangan['mysql'])->where('tarikh', $this->tarikh)
|
||||
->get()
|
||||
->map(function ($ig) use ($keuntungan_penggadai) {
|
||||
return $ig['tunaiditangan'] + $ig['pembiayaantawarruq'] + $ig['bayaranpendahuluan'] + $ig['pinjamankoop'] + $ig['emaspalsu']
|
||||
->map(function ($ig) use ($keuntungan_penggadai,$tunaiditangan) {
|
||||
return $tunaiditangan + $ig['pembiayaantawarruq'] + $ig['bayaranpendahuluan'] + $ig['pinjamankoop'] + $ig['emaspalsu']
|
||||
+ $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([
|
||||
'tunaiditangan' => $tunaiditangan,
|
||||
'keun_penggadai' => $keuntungan_penggadai,
|
||||
'keun_sebenar' => $keun_sebenar,
|
||||
'pend_terakru' => $pend_terakru,
|
||||
|
||||
Reference in New Issue
Block a user