added generate imbangduga specific date
This commit is contained in:
@@ -5,7 +5,9 @@ namespace App\Http\Controllers\Reports;
|
||||
use App\Cawangan;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\imbangdugabackup;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Services\Reports\ImbangDugaService;
|
||||
|
||||
class BalanceSheetsController extends Controller
|
||||
{
|
||||
@@ -19,4 +21,13 @@ class BalanceSheetsController extends Controller
|
||||
|
||||
return json_encode($list_imbangan);
|
||||
}
|
||||
|
||||
public function insertBalanceSheets(Request $request){
|
||||
$igService = new ImbangDugaService($request->kodcaw,$request->tarikh);
|
||||
|
||||
$insert_imbangduga = $igService->setImbangDugaBackup();
|
||||
|
||||
return $insert_imbangduga;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,490 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Reports;
|
||||
|
||||
use App\AkruNet;
|
||||
use App\AkruNetPecahan;
|
||||
use App\Cawangan;
|
||||
use App\Gadai;
|
||||
use App\imbangdugabackup;
|
||||
use App\Lelong;
|
||||
use App\Transaction;
|
||||
use App\TransaksiKeuntungan;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class ImbangDugaService
|
||||
{
|
||||
private $kodcaw;
|
||||
private $tarikh;
|
||||
|
||||
/* ImbangDuga Variable */
|
||||
private $keuntungan_penggadai;
|
||||
|
||||
public function __construct(String $kodcaw, $tarikh)
|
||||
{
|
||||
$this->kodcaw = $kodcaw;
|
||||
$this->tarikh = $tarikh;
|
||||
}
|
||||
|
||||
/* External Method */
|
||||
|
||||
private function log($message)
|
||||
{
|
||||
Log::debug($message);
|
||||
}
|
||||
|
||||
private function logerror($message)
|
||||
{
|
||||
Log::error($message);
|
||||
}
|
||||
|
||||
private function transactionExecute(callable $callablefunc)
|
||||
{
|
||||
try {
|
||||
DB::beginTransaction();
|
||||
$callablefunc();
|
||||
return 'success';
|
||||
DB::commit();
|
||||
} catch (\Exception $e) {
|
||||
$this->log($e->getMessage());
|
||||
return 'error';
|
||||
DB::rollback();
|
||||
}
|
||||
}
|
||||
|
||||
private function stokAuditClass(String $month)
|
||||
{
|
||||
$className = "App\StokAudit{$month}";
|
||||
|
||||
if (class_exists($className))
|
||||
return $className;
|
||||
else {
|
||||
$this->logerror('not found StokAudit');
|
||||
throw new \Exception('[500]: An exception found - not found stok audit -' . $month, Response::HTTP_INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
private function cawanganInfo()
|
||||
{
|
||||
try {
|
||||
return Cawangan::on('mysql7')->where('kodcaw', '=', $this->kodcaw)->firstOrFail();
|
||||
} catch (ModelNotFoundException $e) {
|
||||
$this->logerror($e->getMessage());
|
||||
throw new \Exception('[500]: Cawangan not found', Response::HTTP_NOT_FOUND);
|
||||
} catch (\Exception $e) {
|
||||
$this->logerror($e->getMessage());
|
||||
throw new \Exception('[500]: An exception found', Response::HTTP_INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Calculation Method */
|
||||
|
||||
private function calculateAkruBersih($currentClass, $previousClass, $date, $cawangan)
|
||||
{
|
||||
$currentMonth = (clone $date)->month;
|
||||
$currentYear = (clone $date)->year;
|
||||
|
||||
$previousDate = (clone $date)->subMonthNoOverflow();
|
||||
$previousMonth = $previousDate->month;
|
||||
$previousYear = $previousDate->year;
|
||||
|
||||
$totalCurrent = $currentClass::on($cawangan['mysql'])
|
||||
->where('tahun', $currentYear)
|
||||
->where('bulan', $currentMonth)
|
||||
->sum('upahblmbyar');
|
||||
|
||||
$totalPrevious = $previousClass::on($cawangan['mysql'])
|
||||
->where('tahun', $previousYear)
|
||||
->where('bulan', $previousMonth)
|
||||
->sum('upahblmbyar');
|
||||
|
||||
$currentProfit = $this->calculateKeuntunganSemasa($date);
|
||||
|
||||
$akru_net = abs(($totalPrevious - $currentProfit) - $totalCurrent);
|
||||
|
||||
return $akru_net;
|
||||
}
|
||||
|
||||
private function calculateKeuntunganSemasa($currentDate)
|
||||
{
|
||||
$cawangan = Cawangan::on('mysql7')->where('kodcaw', '=', $this->kodcaw)->first();
|
||||
|
||||
$firstMonth = (clone $currentDate)->firstOfMonth();
|
||||
$lastMonth = (clone $currentDate)->endOfMonth();
|
||||
|
||||
/* Start Keuntungan Semasa Calculation */
|
||||
$get_norujukan = Gadai::on($cawangan['mysql'])
|
||||
->selectRaw("norujukan,CASE WHEN (YEAR(t_gadai) = YEAR(t_update) and MONTH(t_gadai) = MONTH(t_update)) THEN '1' ELSE '0' END AS result")
|
||||
->whereNotNull('hargajualan')->where('tagbaru', 0)->having('result', '=', 0)->pluck('norujukan');
|
||||
|
||||
$summation = Transaction::on('mysql7')
|
||||
->selectRaw("SUM(CASE WHEN (transaction.trans_type) <> 'A' THEN (trans.keuntungan_rebet) ELSE 0 END) AS sum_keun,SUM(CASE WHEN (transaction.trans_type) = 'A' THEN (trans.bayaran_keuntungan) ELSE 0 END) AS sum_bayaran")
|
||||
->leftJoin('transaksi_keuntungan as trans', function ($join) {
|
||||
$join->on('transaction.norujukan', '=', 'trans.norujukan');
|
||||
$join->on('transaction.created_at', '=', 'trans.tarikh_bayaran');
|
||||
})
|
||||
->whereIn('trans.norujukan', $get_norujukan)
|
||||
->whereDate('trans.tarikh_bayaran', '>=', $firstMonth)
|
||||
->whereDate('trans.tarikh_bayaran', '<=', $lastMonth)
|
||||
->whereYear('tarikh_bayaran', '=', $currentDate->year)
|
||||
->where('trans.kodcaw', $this->kodcaw)
|
||||
->get()->toArray();
|
||||
|
||||
$upahlelong = Lelong::on($cawangan['mysql'])
|
||||
->where([['t_jual', '>=', $firstMonth], ['t_jual', '<=', $lastMonth], ['t_jual', '>', '2022-07-24']])
|
||||
->whereYear('t_jual', '=', $currentDate->year)
|
||||
->sum('bakiupah');
|
||||
|
||||
$sum_keuntungan = ($summation) ? $summation[0]['sum_keun'] : 0;
|
||||
$sum_bayaran = ($summation) ? $summation[0]['sum_bayaran'] : 0;
|
||||
|
||||
$total_keuntungan_semasa = ($sum_keuntungan + $sum_bayaran + $upahlelong);
|
||||
|
||||
/* End Keuntungan Semasa Calculation */
|
||||
return $total_keuntungan_semasa;
|
||||
}
|
||||
|
||||
private function filterCollection($collection, $type, $sumtype): Float
|
||||
{
|
||||
|
||||
$array_type = ['T', 'S', 'P', 'AT'];
|
||||
return $collection->filter(function ($item) use ($type, $array_type) {
|
||||
if ($type == 'T')
|
||||
return in_array($item->trans_type, $array_type);
|
||||
|
||||
return $item->trans_type === $type;
|
||||
})->sum($sumtype);
|
||||
}
|
||||
|
||||
private function CurrentProfit($start, $end, $kodcaw)
|
||||
{
|
||||
|
||||
$start = new Carbon($start);
|
||||
$year = $start->format('Y');
|
||||
|
||||
$cawangan = Cawangan::on('mysql7')->where('kodcaw', '=', $kodcaw)->first();
|
||||
|
||||
$collection_trans = TransaksiKeuntungan::on('mysql7')
|
||||
->leftJoin('transaction as trans', function ($join) {
|
||||
$join->on('transaksi_keuntungan.norujukan', '=', 'trans.norujukan');
|
||||
$join->on('transaksi_keuntungan.tarikh_bayaran', '=', 'trans.created_at');
|
||||
})
|
||||
->where('trans.kodcaw', '=', $kodcaw)
|
||||
->whereDate('transaksi_keuntungan.tarikh_bayaran', '<=', $end)
|
||||
->whereDate('transaksi_keuntungan.tarikh_bayaran', '>=', $start)
|
||||
->whereYear('transaksi_keuntungan.tarikh_bayaran', '=', $year)
|
||||
->get();
|
||||
|
||||
$array_norujukan = $collection_trans->pluck('norujukan')->toArray();
|
||||
|
||||
$collection_gadai = Gadai::on($cawangan['mysql'])->whereIn('norujukan', $array_norujukan)->get();
|
||||
|
||||
/* filtering untuk gadai yang ditebus pada bukan bulan yang sama */
|
||||
$keuntungan_semasa_collection = $collection_trans->filter(function ($trans) use ($collection_gadai) {
|
||||
|
||||
foreach ($collection_gadai as $gadai) {
|
||||
if ($gadai->norujukan === $trans->norujukan) {
|
||||
$t_gadai = Carbon::parse($gadai->t_gadai);
|
||||
$t_bayaran = Carbon::parse($trans->tarikh_bayaran);
|
||||
|
||||
if ($t_gadai->month === $t_bayaran->month) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
|
||||
$ujrah = $this->filterCollection($keuntungan_semasa_collection, 'A', 'ujrah');
|
||||
$onepercent = $this->filterCollection($keuntungan_semasa_collection, 'A', 'onepercent');
|
||||
$ujrah_rebet = $this->filterCollection($keuntungan_semasa_collection, 'T', 'ujrah_rebet');
|
||||
$onepercent_rebet = $this->filterCollection($keuntungan_semasa_collection, 'T', 'onepercent_rebet');
|
||||
|
||||
$total_onepercent = $onepercent + $onepercent_rebet;
|
||||
$total_ujrah = $ujrah + $ujrah_rebet;
|
||||
|
||||
return ['ujrah' => $total_ujrah, 'onepercent' => $total_onepercent];
|
||||
}
|
||||
|
||||
/* Getter Method */
|
||||
|
||||
public function getKeuntunganPenggadai()
|
||||
{
|
||||
$date = new Carbon($this->tarikh);
|
||||
$month = (clone $date)->month;
|
||||
$year = (clone $date)->year;
|
||||
|
||||
try {
|
||||
$className = $this->stokAuditClass($month);
|
||||
$cawangan = $this->cawanganInfo();
|
||||
} catch (\Exception $e) {
|
||||
$this->logerror($e->getMessage());
|
||||
return response()->json([
|
||||
'status' => 'error',
|
||||
'message' => $e->getMessage()
|
||||
], $e->getCode() ?: 500);
|
||||
}
|
||||
|
||||
/* Algorithm to get the data */
|
||||
|
||||
$stokaudit = $className::on($cawangan['mysql'])
|
||||
->where('tahun', $year)
|
||||
->selectRaw('SUM(upahblmbyar) as upah, SUM(ujrah) as ujrah, SUM(utgonepercent) as onepercent')
|
||||
->first();
|
||||
|
||||
$keuntungan_penggadai = $stokaudit->upah + $stokaudit->ujrah + $stokaudit->onepercent;
|
||||
|
||||
$this->keuntungan_penggadai = $keuntungan_penggadai;
|
||||
|
||||
return $keuntungan_penggadai;
|
||||
}
|
||||
|
||||
public function getPendapatanTerakru()
|
||||
{
|
||||
$date = new Carbon($this->tarikh);
|
||||
$current_month = (clone $date)->month;
|
||||
$current_year = (clone $date)->year;
|
||||
|
||||
$previousDate = (clone $date)->subMonthNoOverflow();
|
||||
$previous_month = $previousDate->month;
|
||||
try {
|
||||
$currentClassName = $this->stokAuditClass($current_month);
|
||||
$previousClassName = $this->stokAuditClass($previous_month);
|
||||
|
||||
$cawangan = $this->cawanganInfo();
|
||||
} catch (\Exception $e) {
|
||||
$this->logerror($e->getMessage());
|
||||
return response()->json([
|
||||
'status' => 'error',
|
||||
'message' => $e->getMessage()
|
||||
], $e->getCode() ?: 500);
|
||||
}
|
||||
/* Algorithm to get the data */
|
||||
$akru = AkruNet::on($cawangan['mysql'])->where('tahun', $current_year)->where('bulan', '<', $current_month)->sum('jumlah');
|
||||
$akru_bersih_bulan = $this->calculateAkruBersih($currentClassName, $previousClassName, $date, $cawangan);
|
||||
|
||||
AkruNet::on($cawangan['mysql'])->where('tahun',$current_year)->where('bulan','=',$current_month)->update([
|
||||
'jumlah' => $akru_bersih_bulan,
|
||||
]);
|
||||
|
||||
$total_akru = $akru + $akru_bersih_bulan;
|
||||
return $total_akru;
|
||||
}
|
||||
public function getKeuntunganSebenar()
|
||||
{
|
||||
$cawangan = Cawangan::on('mysql7')->where('kodcaw', '=', $this->kodcaw)->first();
|
||||
|
||||
$tarikh = new Carbon($this->tarikh);
|
||||
$year = (clone $tarikh)->year;
|
||||
$month = (clone $tarikh)->month;
|
||||
|
||||
$get_norujukan = Gadai::on($cawangan['mysql'])
|
||||
->selectRaw("norujukan,CASE WHEN (YEAR(t_gadai) = YEAR(t_update) and MONTH(t_gadai) = MONTH(t_update)) THEN '1' ELSE '0' END AS result")
|
||||
->whereNotNull('hargajualan')
|
||||
->having('result', '=', 1)
|
||||
->whereYear('t_gadai', '=', $year)
|
||||
->whereMonth('t_gadai', '<=', $month)
|
||||
->where('sttebus', '<>', '')
|
||||
->pluck('norujukan');
|
||||
|
||||
|
||||
|
||||
$sum_keun = Transaction::on('mysql7')
|
||||
->selectRaw("trans.norujukan,SUM(CASE WHEN (transaction.trans_type) <> 'A' THEN (trans.keuntungan_rebet) ELSE 0 END) AS sum_keun,SUM(CASE WHEN (transaction.trans_type) = 'A' AND (trans.margin_semasa) = 0 THEN (trans.bayaran_keuntungan) ELSE 0 END) AS sum_bayaran")
|
||||
// ->select('trans.norujukan','transaction.trans_type','trans.keuntungan_rebet','trans.bayaran_keuntungan','trans.margin_semasa')
|
||||
->leftJoin('transaksi_keuntungan as trans', function ($join) {
|
||||
$join->on('transaction.norujukan', '=', 'trans.norujukan');
|
||||
$join->on('transaction.created_at', '=', 'trans.tarikh_bayaran');
|
||||
})
|
||||
->whereIn('trans.norujukan', $get_norujukan)->get()->toArray();
|
||||
|
||||
$sum_keuntungan = ($sum_keun) ? $sum_keun[0]['sum_keun'] : 0;
|
||||
$sum_bayaran = ($sum_keun) ? $sum_keun[0]['sum_bayaran'] : 0;
|
||||
|
||||
/* Ansuran masuk dalam ni */
|
||||
|
||||
// $get_norujukan_ansuran = Gadai::on($cawangan['mysql'])
|
||||
// ->selectRaw("norujukan,CASE WHEN (YEAR(t_gadai) = YEAR(t_update) and MONTH(t_gadai) = MONTH(t_update)) THEN '1' ELSE '0' END AS result")
|
||||
// ->whereNotNull('hargajualan')
|
||||
// ->having('result','=',1)
|
||||
// ->whereYear('t_gadai', '=', $year)
|
||||
// ->whereMonth('t_gadai', '<=', $month)
|
||||
// ->where('sttebus','=','')
|
||||
// ->where('tagbaru','=',1)
|
||||
// ->pluck('norujukan');
|
||||
|
||||
// $summation_ansuran = TransaksiKeuntungan::on('mysql7')
|
||||
// ->whereIn('norujukan',$get_norujukan_ansuran)->sum('bayaran_keuntungan');
|
||||
|
||||
$collection_trans = Transaction::on('mysql7')
|
||||
->leftJoin('transaksi_keuntungan as trans', function ($join) {
|
||||
$join->on('transaction.norujukan', '=', 'trans.norujukan');
|
||||
$join->on('transaction.created_at', '=', 'trans.tarikh_bayaran');
|
||||
})
|
||||
->where('transaction.trans_type', 'A')
|
||||
->where('transaction.kodcaw', $this->kodcaw)
|
||||
->where('trans.margin_semasa','>',0)
|
||||
->whereYear('transaction.created_at', '=', $year)
|
||||
->whereMonth('transaction.created_at', '<=', $month)
|
||||
->get();
|
||||
|
||||
$array_norujukan = $collection_trans->pluck('norujukan')->toArray();
|
||||
|
||||
$collection_gadai = Gadai::on($cawangan['mysql'])->whereIn('norujukan', $array_norujukan)->where('tagbaru',1)->get();
|
||||
|
||||
$keuntungan_semasa_collection = $collection_trans->filter(function ($trans) use ($collection_gadai) {
|
||||
|
||||
foreach ($collection_gadai as $gadai) {
|
||||
if ($gadai->norujukan === $trans->norujukan) {
|
||||
$t_gadai = Carbon::parse($gadai->t_gadai);
|
||||
$t_bayaran = Carbon::parse($trans->tarikh_bayaran);
|
||||
|
||||
if ($t_gadai->month !== $t_bayaran->month) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
$summation_ansuran = $keuntungan_semasa_collection->sum('bayaran_keuntungan');
|
||||
|
||||
|
||||
$total = $sum_keuntungan + $sum_bayaran + $summation_ansuran;
|
||||
// $total = $sum_keuntungan + $sum_bayaran;
|
||||
return $total;
|
||||
}
|
||||
|
||||
public function getOnePercentUjrah()
|
||||
{
|
||||
$cawangan = Cawangan::on('mysql7')->where('kodcaw', '=', $this->kodcaw)->first();
|
||||
|
||||
$date = new Carbon($this->tarikh);
|
||||
$date_sebelum = clone $date;
|
||||
|
||||
$date_sebelum = $date_sebelum->firstOfMonth();
|
||||
$month_sebelum = $date_sebelum->subMonth()->format('n');
|
||||
$year_sebelum = $date_sebelum->format('Y');
|
||||
|
||||
$month_sekarang = $date->format('n');
|
||||
$year_generate = $date->format('Y');
|
||||
|
||||
/* generate for month */
|
||||
$first_month_current = new Carbon($this->tarikh);
|
||||
$first_month_current = $first_month_current->firstOfMonth();
|
||||
$last_month_current = new Carbon($this->tarikh);
|
||||
$last_month_current = $last_month_current->lastOfMonth();
|
||||
|
||||
$class_audit_current = $this->stokAuditClass($month_sekarang);
|
||||
$result_audit_current = $class_audit_current::on($cawangan['mysql'])
|
||||
->where('tahun', $year_generate);
|
||||
|
||||
// $result_audit_current = $this->StokAuditGenerateTerakru($month_sekarang, $cawangan, $year_generate);
|
||||
$onepercent_current = $result_audit_current->sum('utgonepercent');
|
||||
$ujrah_current = $result_audit_current->sum('ujrah');
|
||||
|
||||
/* B */
|
||||
$class_audit_previous = $this->stokAuditClass($month_sebelum);
|
||||
$result_audit_previous = $class_audit_previous::on($cawangan['mysql'])
|
||||
->where('tahun', $year_sebelum);
|
||||
|
||||
$onepercent_previous = $result_audit_previous->sum('utgonepercent');
|
||||
$ujrah_previous = $result_audit_previous->sum('ujrah');
|
||||
|
||||
/* C */
|
||||
$keuntungan_semasa = $this->CurrentProfit($first_month_current->toDateString(), $last_month_current->toDateString(), $this->kodcaw);
|
||||
|
||||
/* D & E */
|
||||
$accrual_income_onepercent = $onepercent_current - ($onepercent_previous - $keuntungan_semasa['onepercent']);
|
||||
$accrual_income_ujrah = $ujrah_current - ($ujrah_previous - $keuntungan_semasa['ujrah']);
|
||||
|
||||
$available_akru = AkruNetPecahan::on($cawangan['mysql'])
|
||||
->where('bulan', '<', (int)$month_sekarang)
|
||||
->where('tahun', $year_generate);
|
||||
|
||||
AkruNetPecahan::on($cawangan['mysql'])
|
||||
->where('bulan', '=', (int)$month_sekarang)
|
||||
->where('tahun', $year_generate)
|
||||
->update([
|
||||
'persen_semasa' => $onepercent_current,
|
||||
'ujrah_semasa' => $ujrah_current,
|
||||
'persen_sebelum' => $onepercent_previous,
|
||||
'ujrah_sebelum' => $ujrah_previous,
|
||||
'keuntungan_semasa_1persen' => $keuntungan_semasa['onepercent'],
|
||||
'keuntungan_semasa_ujrah' => $keuntungan_semasa['ujrah'],
|
||||
'baki_keun_blm_byr_1persen' => ($onepercent_previous - $keuntungan_semasa['onepercent']),
|
||||
'baki_keun_blm_byr_ujrah' => ($ujrah_previous - $keuntungan_semasa['ujrah']),
|
||||
'pend_akru_1persen' => $accrual_income_onepercent,
|
||||
'pend_akru_ujrah' => $accrual_income_ujrah,
|
||||
]);
|
||||
|
||||
|
||||
$onepercent_akru = $available_akru->sum('pend_akru_1persen') + $accrual_income_onepercent;
|
||||
$ujrah_akru = $available_akru->sum('pend_akru_ujrah') + $accrual_income_ujrah;
|
||||
|
||||
return ['onepercent' => $onepercent_akru, 'ujrah' => $ujrah_akru];
|
||||
}
|
||||
|
||||
|
||||
public function setImbangDugaBackup()
|
||||
{
|
||||
|
||||
$funcInsert = function () {
|
||||
|
||||
$cawangan = Cawangan::on('mysql7')->where('kodcaw', '=', $this->kodcaw)->first();
|
||||
|
||||
$keuntungan_penggadai = $this->getKeuntunganPenggadai();
|
||||
$pend_terakru = $this->getPendapatanTerakru();
|
||||
$keun_sebenar = $this->getKeuntunganSebenar();
|
||||
$accrual = $this->getOnePercentUjrah();
|
||||
$ujrah = $accrual['ujrah'];
|
||||
$onepercent = $accrual['onepercent'];
|
||||
|
||||
$totalharta = imbangdugabackup::on($cawangan['mysql'])->where('tarikh', $this->tarikh)
|
||||
->get()
|
||||
->map(function ($ig) use ($keuntungan_penggadai) {
|
||||
return $ig['tunaiditangan'] + $ig['pembiayaantawarruq'] + $ig['bayaranpendahuluan'] + $ig['pinjamankoop'] + $ig['emaspalsu']
|
||||
+ $ig['pindahkekpkb'] + $ig['penghutangkaki'] + $ig['phapuskira'] + $ig['belian1stop'] + $keuntungan_penggadai + $ig['serahan'];
|
||||
});
|
||||
|
||||
$totaltanggungan = imbangdugabackup::on($cawangan['mysql'])->where('tarikh', $this->tarikh)
|
||||
->get()
|
||||
->map(function ($ig) use ($ujrah, $onepercent, $keun_sebenar, $pend_terakru) {
|
||||
return $pend_terakru + $ig['bds'] + $ig['perubatan'] + $ig['keraian'] + $ig['rugilelong'] + $ig['bakilelong']
|
||||
+ $ig['wtd'] + $ig['untungrugiterkumpul'] + $keun_sebenar + $ig['pendahuluan'] + $ig['cajlelong']
|
||||
+ $ig['cajperkhidmatan'] + $ig['cajlelongxtra'] + $ig['upahsimpanxtra'] + $ig['bakilelongxtra'] + $ig['rugilelongxtra']
|
||||
+ $ig['utgterkumpulxtra'] + $ig['jualan1stop'] + $ig['hapuskira'] + $ujrah + $onepercent;
|
||||
});
|
||||
|
||||
$booltally = false;
|
||||
|
||||
if (round($totalharta[0], 2) == round($totaltanggungan[0], 2)) {
|
||||
$booltally = true;
|
||||
} else {
|
||||
$booltally = false;
|
||||
}
|
||||
|
||||
|
||||
imbangdugabackup::on($cawangan['mysql'])->where('tarikh', $this->tarikh)->update([
|
||||
'keun_penggadai' => $keuntungan_penggadai,
|
||||
'keun_sebenar' => $keun_sebenar,
|
||||
'pend_terakru' => $pend_terakru,
|
||||
'ujrah' => $ujrah,
|
||||
'onepercent' => $onepercent,
|
||||
'totalharta' => round($totalharta[0], 2),
|
||||
'totaltanggungan' => round($totaltanggungan[0], 2),
|
||||
'tagtally' => $booltally,
|
||||
'updated_at' => Carbon::now()->toDateTimeString(),
|
||||
]);
|
||||
};
|
||||
|
||||
|
||||
return $this->transactionExecute($funcInsert);
|
||||
}
|
||||
}
|
||||
@@ -27,5 +27,7 @@ $router->group(['prefix' => 'api/reports'], function () use ($router) {
|
||||
$router->get('stokaudit/get',['uses' => 'OnePercentController@getStokAuditBackdate']);
|
||||
|
||||
$router->get('balancesheets/get',['uses' => 'BalanceSheetsController@getBalanceSheetsList']);
|
||||
|
||||
$router->get('updateig',['uses' => 'BalanceSheetsController@insertBalanceSheets']);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user