lejer am fix

This commit is contained in:
fifi97
2021-07-04 09:00:01 +08:00
parent 53dd80daac
commit a8dde4715f
6 changed files with 415 additions and 9 deletions
+111
View File
@@ -868,6 +868,56 @@ class TebusController extends Controller
return response()->json($total,200);
}
public function calculationKeuntunganSebenarLejer($kodcaw,Request $request)
{
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first();
$current = new Carbon($request->tarikh);
$total = 0;
$keuntunganselepastawarruq = 0;
$keuntungansebelumtawarruq = 0;
$daterequest = new Carbon($request->tarikh);
$daterequest->addDays(1);
//Keuntungan Selepas Tawarruq
$keuntungan = TransaksiKeuntungan::on('mysql7')
->join($cawangan['db_name'].'.gadai as db2','transaksi_keuntungan.norujukan','=','db2.norujukan')
->whereDate('transaksi_keuntungan.tarikh_bayaran' ,'>=', $request->mula)
->whereDate('transaksi_keuntungan.tarikh_bayaran' ,'<=', $request->hingga)
->whereYear('transaksi_keuntungan.tarikh_bayaran','=',$current->year)
->whereNull('db2.hargajualan')
->sum('bayaran_keuntungan');
$upahtebus = Tebus::on($cawangan['mysql'])
->where([['t_tebus','>=',$request->mula],['t_tebus','<=',$request->hingga],['t_tebus','>','2013-12-31']])
->whereYear('t_tebus','=',$current->year)
->sum('upahdibayar');
$upahlelong = Lelong::on($cawangan['mysql'])
->where([['t_jual','>=',$request->mula],['t_jual','<=',$request->hingga],['t_jual','>','2013-12-31']])
->whereYear('t_jual','=',$current->year)
->sum('bakiupah');
$upahansur = Advansur::on($cawangan['mysql'])
->where('tarikh','>=',$request->mula)
->where('tarikh','<=',$request->hingga)
->whereYear('tarikh','=',$current->year)
->sum('upahdibayar');
$keuntungansebelumtawarruq = $upahtebus + $upahlelong + $upahansur;
// $keuntunganselepastawarruq = $keuntunganselepastawarruqupah;
// $total = $keuntungansebelumtawarruq + $keuntunganselepastawarruq;
$total = $keuntungansebelumtawarruq + $keuntungan;
return response()->json($total,200);
}
public function calculationUntungRugiTerkumpul($kodcaw,Request $request)
{
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first();
@@ -1038,6 +1088,52 @@ class TebusController extends Controller
return response($total);
}
public function untungrugicalculationLejer($kodcaw,Request $request)
{
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$request->kodcaw)->first();
// $datetawarruq = new Carbon('2021-04-14');
$daterequest = new Carbon($request->tarikh);
$daterequest->addDays(1);
$dateSM = '2021-04-24';
$current = Carbon::now();
$current = new Carbon();
$bukanansuran = TransaksiKeuntungan::on('mysql7')
->join($cawangan['db_name'].'.gadai as db2','transaksi_keuntungan.norujukan','=','db2.norujukan')
->leftJoin('transaction as trans', function($join)
{
$join->on('transaksi_keuntungan.norujukan', '=', 'trans.norujukan');
$join->on('transaksi_keuntungan.tarikh_bayaran', '=', 'trans.created_at');
})
->where('trans.trans_type','!=','A')
->whereDate('transaksi_keuntungan.tarikh_bayaran' ,'>=', $request->mula)
->whereDate('transaksi_keuntungan.tarikh_bayaran' ,'<=', $request->hingga)
->whereYear('tarikh_bayaran','=',$current->year)
->whereNotNull('db2.hargajualan')
->sum('keuntungan_rebet');
$ansuran = TransaksiKeuntungan::on('mysql7')
->join($cawangan['db_name'].'.gadai as db2','transaksi_keuntungan.norujukan','=','db2.norujukan')
->leftJoin('transaction as trans', function($join)
{
$join->on('transaksi_keuntungan.norujukan', '=', 'trans.norujukan');
$join->on('transaksi_keuntungan.tarikh_bayaran', '=', 'trans.created_at');
})
->where('trans.trans_type','=','A')
->whereDate('transaksi_keuntungan.tarikh_bayaran' ,'>=', $request->mula)
->whereDate('transaksi_keuntungan.tarikh_bayaran' ,'<=', $request->hingga)
->whereYear('tarikh_bayaran','=',$current->year)
->whereNotNull('db2.hargajualan')
->sum('bayaran_keuntungan');
$total = ($ansuran + $bukanansuran);
return response($total);
}
public function RebetCalculation($kodcaw,Request $request)
{
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$request->kodcaw)->first();
@@ -1053,4 +1149,19 @@ class TebusController extends Controller
return response($rebet);
}
public function RebetCalculationLejer($kodcaw,Request $request)
{
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$request->kodcaw)->first();
$rebet = Tebus::on($cawangan['mysql'])
->join($cawangan['db_name'].'.gadai as db2','tebus.norujukan','=','db2.norujukan')
->where('tebus.t_tebus','>=',$request->mula)
->where('tebus.t_tebus','<=',$request->hingga)
->where('db2.hargajualan','>','0')
->whereNotNull('db2.hargajualan')
->sum('rebate');
return response($rebet);
}
}