Last active
June 1, 2022 04:16
-
-
Save xicond/b10cd1650ef471e42f5d6612208984a2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$schedule->call(function () { | |
//Hari Ini | |
$v_now = Order::where('sisa', 0)->where('dp', '>', 0) | |
->whereHas('nota', function($nota) { | |
$nota->whereDate('notas.updated_at', Carbon::today()); | |
}); | |
$pengeluaran_now = Pengeluaran::whereDate('updated_at', Carbon::today()); | |
$saldo_now = $v_now->sum('jumlah') - $pengeluaran_now->sum('jlh_uang'); | |
$omset_now = Nota::whereDate('tgl_dp', Carbon::today())->sum('total'); | |
$hutang_now = $pengeluaran_now->where('status', 'Hutang')->sum('jlh_uang'); | |
$k_standard = Order::where('sisa', 0)->where('dp', '>', 0) | |
->whereHas('nota', function($nota) { | |
$nota->whereDate('notas.updated_at', Carbon::today()); | |
})->whereHas('barang', function($barang) { | |
$barang->where('nama_barang', 'LIKE', '%standard uk%'); | |
}); | |
$k_tebal = Order::where('sisa', 0)->where('dp', '>', 0) | |
->whereHas('nota', function($nota) { | |
$nota->whereDate('notas.updated_at', Carbon::today()); | |
})->whereHas('barang', function($barang) { | |
$barang->where('nama_barang', 'LIKE', '%tebal uk%'); | |
}); | |
// log(dd($k_standard)); | |
//insert pemasukan | |
$row = [ | |
'total_kubik' => 'Standard('.$k_standard->sum('t_kubik').') dan Tebal('.$k_tebal->sum('t_kubik').')', | |
'total_pemasukan' => $v_now->sum('jumlah'), | |
'saldo' => $saldo_now, | |
'omset' => $omset_now, | |
'hutang' => $hutang_now | |
]; | |
Pemasukan::create($row); | |
})->dailyAt('20:20'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment