fix autotawarruq and imbangduga

This commit is contained in:
Hafifie PKB
2023-12-06 23:41:22 +08:00
parent 43b33c96df
commit 3b6f5c17a4
13 changed files with 153 additions and 56 deletions
+47 -11
View File
@@ -4,6 +4,7 @@ namespace App\Services\Reports;
use App\Cawangan;
use App\CawanganDetail;
use App\Gadai;
use App\TransaksiKeuntungan;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Http\Request;
@@ -13,18 +14,49 @@ class OnePercentService
{
// `B` stands for balance sheet and `L` stands for Ledger
private $kod_cawangan;
private $cawangan;
public function __construct($kod_cawangan){
$this->kod_cawangan = $kod_cawangan;
$this->cawangan = Cawangan::where('kodcaw',$kod_cawangan)->first();
}
public function __construct($kod_cawangan)
{
public function getTotalRounded($type='B',$start = '2023-12-14',$end = '2023-12-14'){
if($type == 'B'){
$rounded = TransaksiKeuntungan::on('mysql7')
->leftJoin('transaction as trans', function($join)
{
$join->on('trans.norujukan', '=', 'transaksi_keuntungan.norujukan');
$join->on('trans.created_at', '=', 'transaksi_keuntungan.tarikh_bayaran');
})
->where('trans.trans_type','T')
->sum('transaksi_keuntungan.rounded');
}else if($type == 'L'){
$rounded = TransaksiKeuntungan::on('mysql7')
->whereDate('tarikh_bayaran','>=',$start)
->whereDate('tarikh_bayaran','<=',$end)
->sum('rounded');;
}
return $rounded;
}
public function getTotalKeuntungan($type = 'B',$start = '2023-12-14',$end = '2023-12-14') : Float{
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'){
$norujukan = Gadai::on($this->cawangan['mysql'])->where('sttebus','T')->where('tagbaru',1)->pluck('norujukan');
$keuntungan = TransaksiKeuntungan::on('mysql7')
->whereIn('norujukan',$norujukan)
->sum('onepercent_rebet');
}else if($type == 'L'){
$norujukan = Gadai::on($this->cawangan['mysql'])->where('sttebus','T')->where('tagbaru',1)->where('t_update','>=',$start)->where('t_update','<=',$end)->pluck('norujukan');
$keuntungan = TransaksiKeuntungan::on('mysql7')
->whereIn('norujukan',$norujukan)
->whereDate('tarikh_bayaran','>=',$start)
->whereDate('tarikh_bayaran','<=',$end)
->sum('onepercent_rebet');;
@@ -37,12 +69,16 @@ class OnePercentService
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'){
$norujukan = Gadai::on($this->cawangan['mysql'])->where('sttebus','T')->where('tagbaru',1)->pluck('norujukan');
$ujrah = TransaksiKeuntungan::on('mysql7')
->whereIn('norujukan',$norujukan)
->sum('ujrah_rebet');
}else if($type == 'L'){
$norujukan = Gadai::on($this->cawangan['mysql'])->where('sttebus','T')->where('tagbaru',1)->pluck('norujukan');
$ujrah = TransaksiKeuntungan::on('mysql7')
->whereIn('norujukan',$norujukan)
->whereDate('tarikh_bayaran','>=',$start)
->whereDate('tarikh_bayaran','<=',$end)
->sum('ujrah_rebet');;
+16
View File
@@ -0,0 +1,16 @@
<?php
namespace App\Services;
use App\KadarUpah;
class TawarruqServices
{
protected $maks_margin = 80;
protected $one_percent = 1;
private function getCalculation(){
}
}