Files
api_arrahn/app/Services/Reports/OnePercentService.php
T

56 lines
1.5 KiB
PHP

<?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;
}
}