feat(overview, analysa): memberikan pengecekan untuk stats
- type label untuk chart - membuat permission baru
This commit is contained in:
parent
c63ec1b30e
commit
4988fe4420
@ -24,7 +24,7 @@ public function mount(array $outlets)
|
||||
foreach ($outlets as $id => $name) {
|
||||
$expenseTotal = Expense::where('outlet_id', $id)->sum('amount');
|
||||
|
||||
$purchaseTotal = Purchase::where('outlet_id', $id)->sum('total');
|
||||
$purchaseTotal = auth()->user()?->hasPermissionTo('view cogs') ? Purchase::where('outlet_id', $id)->sum('total') : 0;
|
||||
|
||||
$payrollTotal = Payroll::whereHas('user.outlets', fn ($q) => $q->where('outlet_id', $id))->sum('total_salary');
|
||||
|
||||
|
||||
@ -163,7 +163,7 @@ protected function loadData()
|
||||
],
|
||||
];
|
||||
|
||||
$this->orders = [
|
||||
$this->orders = array_filter([
|
||||
[
|
||||
'title' => 'Total Order',
|
||||
'value' => currency(
|
||||
@ -181,7 +181,8 @@ protected function loadData()
|
||||
'Rp'
|
||||
),
|
||||
],
|
||||
[
|
||||
|
||||
auth()->user()?->hasPermissionTo('view cogs') ? [
|
||||
'title' => 'HPP',
|
||||
'value' => currency(
|
||||
Order::when(! empty($outletIds), fn ($q) => $q->whereIn('outlet_id', $outletIds))
|
||||
@ -189,7 +190,8 @@ protected function loadData()
|
||||
->sum('cogs'),
|
||||
'Rp'
|
||||
),
|
||||
],
|
||||
] : null,
|
||||
|
||||
[
|
||||
'title' => 'Diskon',
|
||||
'value' => currency(
|
||||
@ -231,9 +233,9 @@ protected function loadData()
|
||||
->sum('quantity')
|
||||
).' pcs',
|
||||
],
|
||||
];
|
||||
]);
|
||||
|
||||
$this->expenses = [
|
||||
$this->expenses = array_filter([
|
||||
[
|
||||
'title' => 'Beban Toko',
|
||||
'value' => currency(
|
||||
@ -243,7 +245,8 @@ protected function loadData()
|
||||
'Rp'
|
||||
),
|
||||
],
|
||||
[
|
||||
|
||||
auth()->user()?->hasPermissionTo('view cogs') ? [
|
||||
'title' => 'Belanja Barang',
|
||||
'value' => currency(
|
||||
Purchase::when(! empty($outletIds), fn ($q) => $q->whereIn('outlet_id', $outletIds))
|
||||
@ -251,7 +254,8 @@ protected function loadData()
|
||||
->sum('total'),
|
||||
'Rp'
|
||||
),
|
||||
],
|
||||
] : null,
|
||||
|
||||
[
|
||||
'title' => 'Penggajian',
|
||||
'value' => currency(
|
||||
@ -261,7 +265,7 @@ protected function loadData()
|
||||
'Rp'
|
||||
),
|
||||
],
|
||||
];
|
||||
]);
|
||||
|
||||
$this->topPerfumes = Perfume::with(['items' => function ($query) use ($outletIds, $dateQuery, $startDate, $endDate, $filterDate) {
|
||||
$query->whereNotNull('order_id')
|
||||
|
||||
@ -127,7 +127,7 @@ protected function loadStats()
|
||||
->with('orderable')
|
||||
->first();
|
||||
|
||||
$this->stats = [
|
||||
$this->stats = array_filter([
|
||||
[
|
||||
'title' => 'Total Order',
|
||||
'value' => $todayOrder,
|
||||
@ -147,7 +147,8 @@ protected function loadStats()
|
||||
'trendUp' => $todayIncome > $yesterdayIncome,
|
||||
'formatted' => currency($todayIncome, 'Rp'),
|
||||
],
|
||||
[
|
||||
|
||||
auth()->user()?->hasPermissionTo('view cogs') ? [
|
||||
'title' => 'HPP',
|
||||
'value' => currency($todayCogs, 'Rp'),
|
||||
'previous' => currency($yesterdayCogs, 'Rp'),
|
||||
@ -156,7 +157,8 @@ protected function loadStats()
|
||||
: '∞%',
|
||||
'trendUp' => $todayCogs > $yesterdayCogs,
|
||||
'formatted' => currency($todayCogs, 'Rp'),
|
||||
],
|
||||
] : null,
|
||||
|
||||
[
|
||||
'title' => 'Diskon',
|
||||
'value' => currency($todayDiscount, 'Rp'),
|
||||
@ -185,7 +187,9 @@ protected function loadStats()
|
||||
: '∞%',
|
||||
'trendUp' => $todayExpense > $yesterdayExpense,
|
||||
],
|
||||
[
|
||||
|
||||
auth()->user()?->hasPermissionTo('view cogs') ? [
|
||||
|
||||
'title' => 'Laba Kotor',
|
||||
'value' => currency($todayGrossProfit, 'Rp'),
|
||||
'previous' => currency($yesterdayGrossProfit, 'Rp'),
|
||||
@ -193,8 +197,9 @@ protected function loadStats()
|
||||
? round((($todayGrossProfit - $yesterdayGrossProfit) / $yesterdayGrossProfit) * 100, 1).'%'
|
||||
: '∞%',
|
||||
'trendUp' => $todayGrossProfit > $yesterdayGrossProfit,
|
||||
],
|
||||
[
|
||||
] : null,
|
||||
|
||||
auth()->user()?->hasPermissionTo('view cogs') ? [
|
||||
'title' => 'Laba Bersih',
|
||||
'value' => currency($todayNetProfit, 'Rp'),
|
||||
'previous' => currency($yesterdayNetProfit, 'Rp'),
|
||||
@ -202,7 +207,8 @@ protected function loadStats()
|
||||
? round((($todayNetProfit - $yesterdayNetProfit) / $yesterdayNetProfit) * 100, 1).'%'
|
||||
: '∞%',
|
||||
'trendUp' => $todayNetProfit > $yesterdayNetProfit,
|
||||
],
|
||||
] : null,
|
||||
|
||||
[
|
||||
'title' => 'Parfum Terjual',
|
||||
'value' => $todaySoldPerfume.' ml',
|
||||
@ -221,7 +227,7 @@ protected function loadStats()
|
||||
: '∞%',
|
||||
'trendUp' => ($todayTopPerfume?->total_sold ?? 0) > ($yesterdayTopPerfume?->total_sold ?? 0),
|
||||
],
|
||||
];
|
||||
]);
|
||||
}
|
||||
|
||||
public function render()
|
||||
|
||||
@ -158,6 +158,9 @@ public function run(): void
|
||||
|
||||
// partner
|
||||
'view partner overview',
|
||||
|
||||
// other
|
||||
'view cogs',
|
||||
];
|
||||
|
||||
foreach ($permissions as $permission) {
|
||||
@ -260,12 +263,16 @@ public function run(): void
|
||||
|
||||
'view social settings',
|
||||
'update social settings',
|
||||
|
||||
'view cogs',
|
||||
]));
|
||||
|
||||
$admin->syncPermissions(array_diff($permissions, [
|
||||
'view member overview',
|
||||
'view partner overview',
|
||||
|
||||
'view analysis',
|
||||
|
||||
'view member voucher',
|
||||
'view member membership',
|
||||
|
||||
@ -356,6 +363,8 @@ public function run(): void
|
||||
|
||||
'view social settings',
|
||||
'update social settings',
|
||||
|
||||
'view cogs',
|
||||
]));
|
||||
|
||||
$partner->syncPermissions([
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
<div>
|
||||
<h3>Pengeluaran per Outlet</h3>
|
||||
<h3>Pendapatan Vs Pengeluaran</h3>
|
||||
<flux:card class="mb-6 mt-2 bg-zinc-200 dark:bg-zinc-700">
|
||||
<canvas id="outletRevenueExpenseChart" width="400" height="200"></canvas>
|
||||
</flux:card>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user