diff --git a/Modules/Expense/DataTables/ExpensesDataTable.php b/Modules/Expense/DataTables/ExpensesDataTable.php index 12cfe57e..513a486e 100644 --- a/Modules/Expense/DataTables/ExpensesDataTable.php +++ b/Modules/Expense/DataTables/ExpensesDataTable.php @@ -18,6 +18,9 @@ class ExpensesDataTable extends DataTable ->addColumn('amount', function ($data) { return format_currency($data->amount); }) + ->addColumn('branch_id', function ($data) { + return $data->branch ? $data->branch->name : '-'; + }) ->addColumn('action', function ($data) { return view('expense::expenses.partials.actions', compact('data')); }); @@ -57,9 +60,9 @@ class ExpensesDataTable extends DataTable ->className('text-center align-middle'), Column::make('branch_id') - ->title('Cabang') - ->className('text-center align-middle') - ->visible(false), + ->title('Branch') + ->data('branch_id') + ->className('text-center align-middle'), Column::make('category.category_name') ->title('Kategori') diff --git a/Modules/Sale/Http/Controllers/SaleController.php b/Modules/Sale/Http/Controllers/SaleController.php index 11cef6e2..d40796d7 100644 --- a/Modules/Sale/Http/Controllers/SaleController.php +++ b/Modules/Sale/Http/Controllers/SaleController.php @@ -38,6 +38,7 @@ class SaleController extends Controller if (!$branch_id) { throw new \Exception("Branch belum dipilih."); } + $tax = Cart::instance('sale')->tax(); $discount = Cart::instance('sale')->discount(); $total_amount = 0 - $discount ; @@ -45,9 +46,6 @@ class SaleController extends Controller $total_amount += $item->options->sub_total; // sub_total sudah diskon } - $tax = Cart::instance('sale')->tax(); - - // Total amount hanya total bersih + pajak //$total_amount = $total + $tax + $discount; diff --git a/app/Livewire/Reports/ProfitLossReport.php b/app/Livewire/Reports/ProfitLossReport.php index f0764c4a..65e0a7f6 100644 --- a/app/Livewire/Reports/ProfitLossReport.php +++ b/app/Livewire/Reports/ProfitLossReport.php @@ -10,6 +10,7 @@ use Modules\Sale\Entities\Sale; use Modules\Sale\Entities\SaleDetails; use Modules\Sale\Entities\SalePayment; use Illuminate\Support\Facades\DB; +use Illuminate\Support\Facades\Log; class ProfitLossReport extends Component { diff --git a/app/Livewire/Reports/SalesReport.php b/app/Livewire/Reports/SalesReport.php index 5ccdb7c3..3dd6a935 100644 --- a/app/Livewire/Reports/SalesReport.php +++ b/app/Livewire/Reports/SalesReport.php @@ -28,8 +28,8 @@ class SalesReport extends Component public function mount($customers) { $this->customers = $customers; - $this->month ; - $this->year ; + $this->month = now()->month; + $this->year = now()->year; $this->customer_id = ''; $this->sale_status = ''; $this->payment_status = ''; @@ -37,43 +37,31 @@ class SalesReport extends Component } public function render() { - $query = Sale::query(); - - if ($this->year) { - $query->whereYear('date', $this->year); - } - - if ($this->month) { - $query->whereMonth('date', $this->month); - } - - $query->when($this->customer_id, function ($query) { - return $query->where('customer_id', $this->customer_id); - }); - - $query->when($this->customer_type, function ($query) { - if ($this->customer_type === 'walk_in') { - return $query->where('customer_id', 1); - } elseif ($this->customer_type === 'member') { - return $query->where('customer_id', '!=', 1); - } - }); - - $query->when($this->sale_status, function ($query) { - return $query->where('status', $this->sale_status); - }); - - $query->when($this->payment_status, function ($query) { - return $query->where('payment_status', $this->payment_status); - }); - - $sales = $query->orderBy('date', 'desc')->paginate(10); - + $sales = Sale::whereYear('date', $this->year) + ->whereMonth('date', $this->month) + ->when($this->customer_id, function ($query) { + return $query->where('customer_id', $this->customer_id); + }) + ->when($this->customer_type, function ($query) { + if ($this->customer_type === 'walk_in') { + return $query->where('customer_id', 1); + } elseif ($this->customer_type === 'member') { + return $query->where('customer_id', '!=', 1); + } + return $query; + }) + ->when($this->sale_status, function ($query) { + return $query->where('status', $this->sale_status); + }) + ->when($this->payment_status, function ($query) { + return $query->where('payment_status', $this->payment_status); + }) + ->orderBy('date', 'desc')->paginate(10); + return view('livewire.reports.sales-report', [ 'sales' => $sales ]); } - public function generateReport() { $this->validate(); diff --git a/resources/views/home.blade.php b/resources/views/home.blade.php index 047ff6a7..bd38a956 100644 --- a/resources/views/home.blade.php +++ b/resources/views/home.blade.php @@ -15,48 +15,56 @@