fix lejer am

This commit is contained in:
MUHD HAFIFIE
2021-07-04 15:32:26 +08:00
parent a8dde4715f
commit 8db8f17ed8
4 changed files with 118 additions and 32 deletions
+37 -6
View File
@@ -494,15 +494,16 @@ class TebusController extends Controller
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first();
$tebus = Tebus::on($cawangan['mysql'])
->select('tebus.t_tebus', 'gad.t_gadai','Tebus.tagterima', 'tebus.teller','tebus.jenistebus','tebus.pinjaman','tebus.bakiupah','tebus.bakipjm','gad.norujukan','cust.nama','gad.nokp','tebus.jbg')
->join('Gadai as gad','gad.norujukan','=','Tebus.norujukan')
->join('Customer as cust', function($join)
->select('tebus.t_tebus', 'gad.t_gadai','tebus.tagterima', 'tebus.teller','tebus.jenistebus','tebus.pinjaman','tebus.bakiupah','tebus.bakipjm','gad.norujukan','cust.nama','gad.nokp','tebus.jbg')
->join('gadai as gad','gad.norujukan','=','tebus.norujukan')
->join('online_arrahn.customer as cust', function($join)
{
$join->on('gad.nokp', '=', 'cust.kpbaru');
$join->orOn('gad.nokp', '=', 'cust.kplama');
})
->where('Tebus.t_tebus','=',$tarikh)
->orderBy('Tebus.teller')
->where('tebus.t_tebus','=',$tarikh)
->orderBy('tebus.teller')
->orderBy('tebus.sirit')
->get();
return response()->json($tebus);
@@ -1036,6 +1037,34 @@ class TebusController extends Controller
$current = Carbon::now();
$current = new Carbon();
if($request->tarikh < '2021-06-09')
{
$keuntungan = TransaksiKeuntungan::on('mysql7')
->join($cawangan['db_name'].'.gadai as db2','transaksi_keuntungan.norujukan','=','db2.norujukan')
->whereDate('transaksi_keuntungan.tarikh_bayaran', '<', $request->tarikh)
->whereDate('transaksi_keuntungan.tarikh_bayaran' ,'<=', $dateSM)
->whereYear('tarikh_bayaran','=',$current->year)
->whereNotNull('db2.hargajualan')
->sum('bayaran_keuntungan');
$keuntunganreducing = TransaksiKeuntungan::on('mysql7')
->join($cawangan['db_name'].'.gadai as db2','transaksi_keuntungan.norujukan','=','db2.norujukan')
->whereDate('transaksi_keuntungan.tarikh_bayaran' ,'<', $request->tarikh)
->whereDate('transaksi_keuntungan.tarikh_bayaran','>=', $dateSM)
->whereYear('tarikh_bayaran','=',$current->year)
->whereNotNull('db2.hargajualan')
->sum('keuntungan_rebet');
// dd($keuntungan,$keuntunganreducing);
$total = ($keuntungan + $keuntunganreducing);
}else{
$keuntungan = TransaksiKeuntungan::on('mysql7')
->join($cawangan['db_name'].'.gadai as db2','transaksi_keuntungan.norujukan','=','db2.norujukan')
->whereDate('transaksi_keuntungan.tarikh_bayaran', '<=', $request->tarikh)
@@ -1083,7 +1112,9 @@ class TebusController extends Controller
->whereNotNull('db2.hargajualan')
->sum('bayaran_keuntungan');
$total = ($keuntungan + $keuntunganreducing + $ansuran + $bukanansuran);
$total = ($keuntungan + $keuntunganreducing + $ansuran + $bukanansuran);
}
return response($total);
}