-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding cashback feature on sell transaction
- Loading branch information
1 parent
6db263f
commit 04cc44c
Showing
51 changed files
with
34,629 additions
and
264 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
namespace App; | ||
|
||
use Illuminate\Database\Eloquent\Model; | ||
|
||
class Cashback extends Model | ||
{ | ||
public static function kodeFaktur() | ||
{ | ||
$cek = Cashback::where('faktur', 'LIKE', 'CSB%')->get(); | ||
if ($cek->count() > 0) { | ||
$cashback = Cashback::where('faktur', 'LIKE', 'CSB%')->orderBy('id', 'DESC')->first(); | ||
$nourut = (int) substr($cashback->faktur, -8, 8); | ||
$nourut++; | ||
$char = "CSB"; | ||
$number = $char . sprintf("%08s", $nourut); | ||
} else { | ||
$number = "CSB" . "00000001"; | ||
} | ||
return $number; | ||
} | ||
public function transaksi() | ||
{ | ||
return $this->belongsTo(Transaksi::class, 'transaksi_id', 'id'); | ||
} | ||
public function detail_cashback() | ||
{ | ||
return $this->hasMany(Cashback_detail::class, 'cashback_id', 'id'); | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
namespace App; | ||
|
||
use Illuminate\Database\Eloquent\Model; | ||
|
||
class Cascback_detail extends Model | ||
{ | ||
public function detail_transaksi() | ||
{ | ||
return $this->belongsTo(Detail_transaksi::class, 'detail_transaksi_id', 'id'); | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
<?php | ||
|
||
namespace App\Helpers; | ||
|
||
use App\Pembelian; | ||
use App\Return_pembelian; | ||
use App\Return_penjualan; | ||
use App\Transaksi; | ||
|
||
class Rekap | ||
{ | ||
public static function penjualan($start = null, $end = null) | ||
{ | ||
if ($start & $end) { | ||
$data = Transaksi::whereDate('tanggal', ">=", $start) | ||
->whereDate('tanggal', "<=", $end)->sum('total'); | ||
} else { | ||
$data = Transaksi::sum('total'); | ||
} | ||
return $data; | ||
} | ||
public static function return_penjualan($start = null, $end = null) | ||
{ | ||
if ($start & $end) { | ||
$data = Return_penjualan::whereDate('tanggal_return_jual', ">=", $start) | ||
->whereDate('tanggal_return_jual', "<=", $end)->sum('total'); | ||
} else { | ||
$data = Return_penjualan::sum('total_bayar'); | ||
} | ||
return $data; | ||
} | ||
public static function laba_rugi_penjualan($start = null, $end = null) | ||
{ | ||
if ($start & $end) { | ||
$data = Transaksi::whereDate('tanggal', ">=", $start) | ||
->whereDate('tanggal', "<=", $end)->get(); | ||
$value = 0; | ||
foreach ($data as $row) { | ||
if ($row->status == "hutang") { | ||
$value += $row->piutang->piutang_terbayar; | ||
} else { | ||
$value += $row->total; | ||
} | ||
} | ||
} else { | ||
$data = Transaksi::get(); | ||
$value = 0; | ||
foreach ($data as $row) { | ||
if ($row->status == "hutang") { | ||
$value += $row->piutang->piutang_terbayar; | ||
} else { | ||
$value += $row->total; | ||
} | ||
} | ||
} | ||
return $value; | ||
} | ||
public static function pembelian($start = null, $end = null) | ||
{ | ||
if ($start & $end) { | ||
$data = Pembelian::whereDate('tanggal_pembelian', ">=", $start) | ||
->whereDate('tanggal_pembelian', "<=", $end)->sum('total'); | ||
} else { | ||
$data = Pembelian::sum('total'); | ||
} | ||
return $data; | ||
} | ||
public static function return_pembelian($start = null, $end = null) | ||
{ | ||
if ($start & $end) { | ||
$data = Return_pembelian::whereDate('tanggal_return_pembelian', ">=", $start) | ||
->whereDate('tanggal_return_pembelian', "<=", $end)->sum('total'); | ||
} else { | ||
$data = Return_pembelian::sum('total_bayar'); | ||
} | ||
return $data; | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers; | ||
|
||
use App\Helpers\Rekap; | ||
use Illuminate\Http\Request; | ||
|
||
class RekapController extends Controller | ||
{ | ||
public function index() | ||
{ | ||
$penjualan = Rekap::penjualan(); | ||
$return_penjualan = Rekap::return_penjualan(); | ||
$laba_rugi_penjualan = Rekap::laba_rugi_penjualan(); | ||
$pembelian = Rekap::pembelian(); | ||
$return_pembelian = Rekap::return_pembelian(); | ||
return view("pages.report.rekap.index", compact('penjualan', 'return_penjualan', 'laba_rugi_penjualan', 'pembelian', 'return_pembelian')); | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.