add imbang duga api and lejeram api and fix round down
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Reports;
|
||||
|
||||
use App\Cawangan;
|
||||
use App\CawanganDetail;
|
||||
use App\TransaksiKeuntungan;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class OnePercentService
|
||||
{
|
||||
|
||||
// `B` stands for balance sheet and `L` stands for Ledger
|
||||
|
||||
public function __construct($kod_cawangan)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function getTotalKeuntungan($type = 'B',$start = '2023-12-14',$end = '2023-12-14') : Float{
|
||||
|
||||
if($type == 'B'){
|
||||
$keuntungan = TransaksiKeuntungan::on('mysql7')->sum('onepercent_rebet');
|
||||
}else if($type == 'L'){
|
||||
$keuntungan = TransaksiKeuntungan::on('mysql7')
|
||||
->whereDate('tarikh_bayaran','>=',$start)
|
||||
->whereDate('tarikh_bayaran','<=',$end)
|
||||
->sum('onepercent_rebet');;
|
||||
}
|
||||
|
||||
return $keuntungan;
|
||||
}
|
||||
|
||||
public function getTotalUjrah($type = 'B',$start = '2023-12-14',$end = '2023-12-14') : Float{
|
||||
|
||||
|
||||
if($type == 'B'){
|
||||
$ujrah = TransaksiKeuntungan::on('mysql7')->sum('ujrah_rebet');
|
||||
// $ujrah = TransaksiKeuntungan::on('mysql7')->selectRaw('SUM(ujrah - ujrah_rebet) as total')
|
||||
// ->first();
|
||||
// $ujrah = $ujrah['total'];
|
||||
}else if($type == 'L'){
|
||||
$ujrah = TransaksiKeuntungan::on('mysql7')
|
||||
->whereDate('tarikh_bayaran','>=',$start)
|
||||
->whereDate('tarikh_bayaran','<=',$end)
|
||||
->sum('ujrah_rebet');;
|
||||
}
|
||||
|
||||
return $ujrah;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user