refactor: remove redundant blank lines across all services and update dashboard imports
This commit is contained in:
parent
816c2a0e2a
commit
16fe9a3d9f
@ -5,7 +5,6 @@
|
||||
use App\Http\Controllers\Concerns\FlashesEntityMessage;
|
||||
use App\Http\Controllers\Concerns\ParsesDataTableQuery;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\Admin\Finance\ApproveEmployeeAdvanceRequest;
|
||||
use App\Http\Requests\Admin\Finance\DestroyEmployeeAdvanceRequest;
|
||||
use App\Http\Requests\Admin\Finance\EmployeeAdvanceRequest;
|
||||
use App\Http\Requests\Admin\Finance\PayEmployeeAdvanceRequest;
|
||||
|
||||
@ -30,7 +30,6 @@ public function getDefaultAccount(): CashAccount
|
||||
return CashAccount::query()->firstOrFail();
|
||||
}
|
||||
|
||||
|
||||
public function paginateForIndex(CashAccount $cashAccount, array $tableQuery, string $referenceType = ''): LengthAwarePaginator
|
||||
{
|
||||
$query = CashTransaction::query()
|
||||
@ -65,7 +64,6 @@ public function paginateForIndex(CashAccount $cashAccount, array $tableQuery, st
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public function deposit(CashAccount $cashAccount, array $validated, User $user): CashTransaction
|
||||
{
|
||||
try {
|
||||
@ -111,7 +109,6 @@ public function deposit(CashAccount $cashAccount, array $validated, User $user):
|
||||
return $transaction;
|
||||
}
|
||||
|
||||
|
||||
public function withdraw(CashAccount $cashAccount, array $validated, User $user): CashTransaction
|
||||
{
|
||||
try {
|
||||
@ -258,7 +255,6 @@ public function recordIncoming(
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function updateDeposit(CashTransaction $transaction, array $validated): void
|
||||
{
|
||||
$this->ensureEditable($transaction);
|
||||
@ -412,7 +408,6 @@ public function deleteReferencedTransaction(CashTransaction $transaction): void
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private function syncPhotos(CashTransaction $transaction, array $validated): void
|
||||
{
|
||||
$this->mediaService->syncCollection(
|
||||
|
||||
@ -25,7 +25,6 @@ public function __construct(
|
||||
private readonly PushNotificationService $pushNotificationService,
|
||||
) {}
|
||||
|
||||
|
||||
public function outstandingSummary(?User $user = null): array
|
||||
{
|
||||
$query = EmployeeAdvance::query()
|
||||
@ -43,7 +42,6 @@ public function outstandingSummary(?User $user = null): array
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
public function paginateForIndex(array $tableQuery, User $user, string $status = ''): LengthAwarePaginator
|
||||
{
|
||||
$query = EmployeeAdvance::query()
|
||||
@ -70,7 +68,6 @@ public function paginateForIndex(array $tableQuery, User $user, string $status =
|
||||
->withQueryString();
|
||||
}
|
||||
|
||||
|
||||
public function create(array $validated, User $user): void
|
||||
{
|
||||
$employee = $this->resolveAuthenticatedEmployee($user);
|
||||
@ -105,7 +102,6 @@ public function create(array $validated, User $user): void
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public function update(EmployeeAdvance $employeeAdvance, array $validated, User $user): void
|
||||
{
|
||||
try {
|
||||
|
||||
@ -23,7 +23,6 @@ public function __construct(
|
||||
private readonly PushNotificationService $pushNotificationService,
|
||||
) {}
|
||||
|
||||
|
||||
public function paginateForIndex(array $tableQuery): LengthAwarePaginator
|
||||
{
|
||||
$query = Expense::query()
|
||||
@ -50,7 +49,6 @@ public function paginateForIndex(array $tableQuery): LengthAwarePaginator
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public function create(array $validated, User $user): void
|
||||
{
|
||||
try {
|
||||
@ -99,7 +97,6 @@ public function create(array $validated, User $user): void
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public function update(Expense $expense, array $validated): void
|
||||
{
|
||||
try {
|
||||
@ -173,7 +170,6 @@ public function delete(Expense $expense): void
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
private function syncPhotos(Expense $expense, array $validated): void
|
||||
{
|
||||
$this->mediaService->syncCollection(
|
||||
|
||||
@ -29,7 +29,6 @@ public function __construct(
|
||||
private readonly PushNotificationService $pushNotificationService,
|
||||
) {}
|
||||
|
||||
|
||||
public function listPeriods(): Collection
|
||||
{
|
||||
return PayrollPeriod::query()
|
||||
@ -55,7 +54,6 @@ public function resolvePeriod(?int $periodId): ?PayrollPeriod
|
||||
->first();
|
||||
}
|
||||
|
||||
|
||||
public function periodSummary(PayrollPeriod $period, User $user): array
|
||||
{
|
||||
$query = Payroll::query()
|
||||
@ -79,7 +77,6 @@ public function periodSummary(PayrollPeriod $period, User $user): array
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
public function paginateForPeriod(PayrollPeriod $period, array $tableQuery, User $user): LengthAwarePaginator
|
||||
{
|
||||
$query = Payroll::query()
|
||||
@ -206,7 +203,6 @@ public function generatePayrollsForPeriod(PayrollPeriod $period): void
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function addAdjustment(Payroll $payroll, array $validated, User $user): void
|
||||
{
|
||||
|
||||
@ -396,7 +392,6 @@ public function pay(Payroll $payroll, User $user): void
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private function payrollEligibleEmployees(PayrollPeriod $period): Collection
|
||||
{
|
||||
$periodStart = Carbon::create($period->year, $period->month, 1)->startOfMonth();
|
||||
|
||||
@ -46,7 +46,6 @@ public function listForCalendar(
|
||||
->get();
|
||||
}
|
||||
|
||||
|
||||
public function todayAttendanceForEmployee(Employee $employee): ?array
|
||||
{
|
||||
$attendance = Attendance::query()
|
||||
@ -68,7 +67,6 @@ public function isOnLeaveToday(Employee $employee): bool
|
||||
->exists();
|
||||
}
|
||||
|
||||
|
||||
public function checkIn(array $validated, User $user): void
|
||||
{
|
||||
$employee = $this->resolveAuthenticatedEmployee($user);
|
||||
@ -107,7 +105,6 @@ public function checkIn(array $validated, User $user): void
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public function checkOut(array $validated, User $user): void
|
||||
{
|
||||
$employee = $this->resolveAuthenticatedEmployee($user);
|
||||
|
||||
@ -21,7 +21,6 @@ public function __construct(
|
||||
private readonly MediaService $mediaService,
|
||||
) {}
|
||||
|
||||
|
||||
public function paginateForIndex(
|
||||
array $tableQuery,
|
||||
string $role = '',
|
||||
@ -74,7 +73,6 @@ public function findForEdit(User $user): array
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
public function create(array $validated): void
|
||||
{
|
||||
try {
|
||||
@ -120,7 +118,6 @@ public function create(array $validated): void
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function update(User $user, array $validated): void
|
||||
{
|
||||
$employee = $user->employee;
|
||||
@ -132,7 +129,6 @@ public function update(User $user, array $validated): void
|
||||
'username' => $validated['username'],
|
||||
]);
|
||||
|
||||
|
||||
$profile = $user->profile()->updateOrCreate(
|
||||
['user_id' => $user->id],
|
||||
[
|
||||
@ -225,7 +221,6 @@ public function delete(User $user): void
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private function syncProfilePhoto(UserProfile $profile, array $validated): void
|
||||
{
|
||||
$newFiles = ! empty($validated['profile_photo']) ? [$validated['profile_photo']] : [];
|
||||
|
||||
@ -23,7 +23,6 @@ public function __construct(
|
||||
private readonly PushNotificationService $pushNotificationService,
|
||||
) {}
|
||||
|
||||
|
||||
public function paginateForIndex(array $tableQuery, User $user): LengthAwarePaginator
|
||||
{
|
||||
$query = LeaveRequest::query()
|
||||
@ -48,7 +47,6 @@ public function paginateForIndex(array $tableQuery, User $user): LengthAwarePagi
|
||||
->withQueryString();
|
||||
}
|
||||
|
||||
|
||||
public function create(array $validated, User $user): void
|
||||
{
|
||||
$employee = $this->resolveAuthenticatedEmployee($user);
|
||||
@ -85,7 +83,6 @@ public function create(array $validated, User $user): void
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public function update(LeaveRequest $leaveRequest, array $validated, User $user): void
|
||||
{
|
||||
$startDate = Carbon::parse($validated['start_date'])->startOfDay();
|
||||
|
||||
@ -20,7 +20,6 @@ public function resolve(int $productVariantId, PriceType $priceType): ?CuttingRe
|
||||
->first();
|
||||
}
|
||||
|
||||
|
||||
public function latestPricesForVariant(int $productVariantId): array
|
||||
{
|
||||
$prices = [];
|
||||
@ -36,7 +35,6 @@ public function latestPricesForVariant(int $productVariantId): array
|
||||
return $prices;
|
||||
}
|
||||
|
||||
|
||||
public function latestPricesForVariants(array $variantIds): Collection
|
||||
{
|
||||
if (empty($variantIds)) {
|
||||
|
||||
@ -16,7 +16,6 @@
|
||||
use App\Support\Media\MediaPresenter;
|
||||
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Collection as EloquentCollection;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
@ -72,7 +71,6 @@ public function paginateForIndex(array $tableQuery, User $user): LengthAwarePagi
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public function getInProgressCuttings(User $user): Collection
|
||||
{
|
||||
return Cutting::query()
|
||||
@ -98,7 +96,6 @@ public function getInProgressCuttings(User $user): Collection
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public function getCompletedCuttings(User $user): Collection
|
||||
{
|
||||
return Cutting::query()
|
||||
@ -124,7 +121,6 @@ public function getCompletedCuttings(User $user): Collection
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public function rawMaterialCatalog(?Cutting $cutting = null, ?User $user = null): Collection
|
||||
{
|
||||
$selectedPriceIds = $cutting
|
||||
@ -159,7 +155,6 @@ public function rawMaterialCatalog(?Cutting $cutting = null, ?User $user = null)
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public function productCatalog(?Cutting $cutting = null, ?User $user = null): Collection
|
||||
{
|
||||
$selectedVariantIds = $cutting
|
||||
@ -229,7 +224,6 @@ public function findForEdit(Cutting $cutting): Cutting
|
||||
return $cutting;
|
||||
}
|
||||
|
||||
|
||||
public function draftMaterialsForUser(User $user): array
|
||||
{
|
||||
return $this->draftMaterialsQuery($user)
|
||||
@ -243,7 +237,6 @@ public function draftMaterialsForUser(User $user): array
|
||||
->all();
|
||||
}
|
||||
|
||||
|
||||
public function draftResultsForUser(User $user): array
|
||||
{
|
||||
return $this->draftResultsQuery($user)
|
||||
@ -257,7 +250,6 @@ public function draftResultsForUser(User $user): array
|
||||
->all();
|
||||
}
|
||||
|
||||
|
||||
public function syncDraftMaterial(array $validated, User $user): array
|
||||
{
|
||||
$price = RawMaterialPrice::query()
|
||||
@ -291,7 +283,6 @@ public function syncDraftMaterial(array $validated, User $user): array
|
||||
return $this->presentDraftMaterial($item);
|
||||
}
|
||||
|
||||
|
||||
public function syncDraftResult(array $validated, User $user): array
|
||||
{
|
||||
$variant = ProductVariant::query()
|
||||
@ -365,18 +356,16 @@ public function removeDraftResult(User $user, ProductVariant $productVariant): v
|
||||
->delete();
|
||||
}
|
||||
|
||||
|
||||
public function create(array $validated, User $user): Cutting
|
||||
{
|
||||
try {
|
||||
$cutting = DB::transaction(function () use ($validated, $user): Cutting {
|
||||
|
||||
|
||||
$draftMaterials = $this->draftMaterialsQuery($user)
|
||||
->with('rawMaterialPrice.rawMaterial')
|
||||
->lockForUpdate()
|
||||
->get();
|
||||
|
||||
|
||||
$draftResults = $this->draftResultsQuery($user)
|
||||
->lockForUpdate()
|
||||
->get();
|
||||
@ -440,7 +429,6 @@ public function create(array $validated, User $user): Cutting
|
||||
return $cutting;
|
||||
}
|
||||
|
||||
|
||||
public function update(Cutting $cutting, array $validated): void
|
||||
{
|
||||
if (! $cutting->status->isEditable()) {
|
||||
@ -651,7 +639,6 @@ public function transitionStatus(
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
private function buildMaterials(array $materials): array
|
||||
{
|
||||
return collect($materials)
|
||||
@ -682,7 +669,6 @@ private function buildMaterials(array $materials): array
|
||||
->all();
|
||||
}
|
||||
|
||||
|
||||
private function buildResults(array $results): array
|
||||
{
|
||||
return collect($results)
|
||||
@ -834,7 +820,6 @@ private function applySorting(Builder $query, string $sort, string $direction):
|
||||
$query->latest();
|
||||
}
|
||||
|
||||
|
||||
private function draftMaterialsQuery(User $user): Builder
|
||||
{
|
||||
return CuttingMaterial::query()
|
||||
@ -842,7 +827,6 @@ private function draftMaterialsQuery(User $user): Builder
|
||||
->where('user_id', $user->id);
|
||||
}
|
||||
|
||||
|
||||
private function draftResultsQuery(User $user): Builder
|
||||
{
|
||||
return CuttingResult::query()
|
||||
@ -850,7 +834,6 @@ private function draftResultsQuery(User $user): Builder
|
||||
->where('user_id', $user->id);
|
||||
}
|
||||
|
||||
|
||||
private function presentDraftMaterial(CuttingMaterial $item): array
|
||||
{
|
||||
$price = $item->rawMaterialPrice;
|
||||
@ -868,7 +851,6 @@ private function presentDraftMaterial(CuttingMaterial $item): array
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
private function presentDraftResult(CuttingResult $item): array
|
||||
{
|
||||
$variant = $item->productVariant;
|
||||
@ -956,7 +938,6 @@ public function calculateCostPerUnit(Cutting $cutting): int
|
||||
return (int) round($this->calculateTotalProductionCost($cutting) / $totalPieces);
|
||||
}
|
||||
|
||||
|
||||
private function storeResultPrices(Cutting $cutting, array $resultPrices): void
|
||||
{
|
||||
$costPerUnit = (int) ($cutting->cost_per_unit ?? $this->calculateCostPerUnit($cutting));
|
||||
|
||||
@ -56,7 +56,6 @@ public function stockColumn(ProductStockQuality $quality): string
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
public function paginateForIndex(array $tableQuery, User $user): LengthAwarePaginator
|
||||
{
|
||||
$query = Order::query()
|
||||
@ -105,7 +104,6 @@ public function paginateForIndex(array $tableQuery, User $user): LengthAwarePagi
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public function customerOptions(): array
|
||||
{
|
||||
return Customer::query()
|
||||
@ -118,7 +116,6 @@ public function customerOptions(): array
|
||||
->all();
|
||||
}
|
||||
|
||||
|
||||
public function marketingOptions(): array
|
||||
{
|
||||
return User::query()
|
||||
@ -134,7 +131,6 @@ public function marketingOptions(): array
|
||||
->all();
|
||||
}
|
||||
|
||||
|
||||
public function storePriceTypeOptions(): array
|
||||
{
|
||||
return collect(PriceType::cases())
|
||||
@ -147,7 +143,6 @@ public function storePriceTypeOptions(): array
|
||||
->all();
|
||||
}
|
||||
|
||||
|
||||
public function catalogItems(?Order $order = null, ?User $user = null): Collection
|
||||
{
|
||||
$orderVariantIds = $order
|
||||
@ -283,7 +278,6 @@ public function findForShow(Order $order): Order
|
||||
return $order;
|
||||
}
|
||||
|
||||
|
||||
public function draftItemsForUser(User $user): array
|
||||
{
|
||||
return $this->draftItemsQuery($user)
|
||||
@ -297,7 +291,6 @@ public function draftItemsForUser(User $user): array
|
||||
->all();
|
||||
}
|
||||
|
||||
|
||||
public function syncDraftItem(array $validated, User $user): array
|
||||
{
|
||||
// Force retail price type and stock quality for cashier role
|
||||
@ -355,7 +348,6 @@ public function removeDraftItem(User $user, ProductVariant $productVariant, Prod
|
||||
->delete();
|
||||
}
|
||||
|
||||
|
||||
public function resyncDraftPrices(User $user, string $priceTypeValue): array
|
||||
{
|
||||
// Force retail price type for cashier role
|
||||
@ -388,7 +380,6 @@ public function resyncDraftPrices(User $user, string $priceTypeValue): array
|
||||
return $this->draftItemsForUser($user);
|
||||
}
|
||||
|
||||
|
||||
public function create(array $validated, User $user): Order
|
||||
{
|
||||
try {
|
||||
@ -403,7 +394,6 @@ public function create(array $validated, User $user): Order
|
||||
$order = DB::transaction(function () use ($validated, $user): Order {
|
||||
$priceType = $this->resolvePriceType($validated['channel'], $validated['price_type']);
|
||||
|
||||
|
||||
$draftItems = $this->draftItemsQuery($user)
|
||||
->lockForUpdate()
|
||||
->get();
|
||||
@ -509,7 +499,6 @@ public function create(array $validated, User $user): Order
|
||||
return $order;
|
||||
}
|
||||
|
||||
|
||||
public function update(Order $order, array $validated): void
|
||||
{
|
||||
$order->ensureEditable();
|
||||
@ -694,7 +683,6 @@ public function transitionStatus(Order $order, OrderStatus $status): void
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
private function buildLineItems(array $items, PriceType $priceType): array
|
||||
{
|
||||
return collect($items)
|
||||
@ -753,7 +741,6 @@ private function resolvePriceType(string $channel, string $priceType): PriceType
|
||||
return $priceTypeEnum;
|
||||
}
|
||||
|
||||
|
||||
private function draftItemsQuery(User $user): Builder
|
||||
{
|
||||
return OrderItem::query()
|
||||
@ -761,7 +748,6 @@ private function draftItemsQuery(User $user): Builder
|
||||
->where('user_id', $user->id);
|
||||
}
|
||||
|
||||
|
||||
private function presentDraftItem(OrderItem $item): array
|
||||
{
|
||||
$variant = $item->productVariant;
|
||||
@ -778,7 +764,6 @@ private function presentDraftItem(OrderItem $item): array
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
private function applyDraftPrices(EloquentCollection $items, PriceType $priceType): void
|
||||
{
|
||||
foreach ($items as $index => $item) {
|
||||
@ -817,7 +802,6 @@ private function availableStock(ProductVariant $variant, ProductStockQuality $st
|
||||
return (int) $variant->{$this->stockColumn($stockQuality)};
|
||||
}
|
||||
|
||||
|
||||
private function syncPhotos(Order $order, array $validated): void
|
||||
{
|
||||
$paymentType = $validated['payment_type'] ?? null;
|
||||
@ -834,7 +818,6 @@ private function syncPhotos(Order $order, array $validated): void
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
private function lineItemsForSnapshot(EloquentCollection|array $items): array
|
||||
{
|
||||
return collect($items)
|
||||
@ -870,7 +853,6 @@ private function resolveUnitPrice(int $variantId, PriceType $priceType, ?string
|
||||
return (int) $price->price;
|
||||
}
|
||||
|
||||
|
||||
private function presentVariantPrices(int $variantId): array
|
||||
{
|
||||
return collect($this->cuttingResultPriceResolver->latestPricesForVariant($variantId))
|
||||
|
||||
@ -15,10 +15,10 @@
|
||||
use App\Services\Master\ProductService;
|
||||
use App\Services\Master\RawMaterialService;
|
||||
use App\Services\System\PushNotificationService;
|
||||
use App\Support\ActivityLog\ModelLabel;
|
||||
use App\Support\OwnerVerification\VerificationChangeFormatter;
|
||||
use App\Services\System\Setting\MarketplaceService;
|
||||
use App\Settings\MarketplaceSettings;
|
||||
use App\Support\ActivityLog\ModelLabel;
|
||||
use App\Support\OwnerVerification\VerificationChangeFormatter;
|
||||
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Pagination\LengthAwarePaginator as Paginator;
|
||||
@ -47,7 +47,6 @@ public function hasPendingMarketplaceVerification(): bool
|
||||
->exists();
|
||||
}
|
||||
|
||||
|
||||
public function paginateForIndex(
|
||||
User $user,
|
||||
array $tableQuery,
|
||||
@ -101,7 +100,6 @@ public function paginateForIndex(
|
||||
->through(fn (OwnerVerificationRequest $request) => $this->presentRequestRow($request));
|
||||
}
|
||||
|
||||
|
||||
private function pendingCuttingRows(User $user, array $tableQuery): Collection
|
||||
{
|
||||
$rows = $this->stockService
|
||||
@ -143,7 +141,6 @@ public function pendingCountForUser(User $user): int
|
||||
return $requestCount + Cutting::query()->pendingVerification()->count();
|
||||
}
|
||||
|
||||
|
||||
public function subjectTypeOptions(User $user): array
|
||||
{
|
||||
$options = OwnerVerificationRequest::query()
|
||||
@ -317,7 +314,6 @@ private function clearVerificationRequestMedia(OwnerVerificationRequest $request
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
private function presentRequestRow(OwnerVerificationRequest $request): array
|
||||
{
|
||||
$payload = is_array($request->payload) ? $request->payload : [];
|
||||
@ -347,7 +343,6 @@ private function presentRequestRow(OwnerVerificationRequest $request): array
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
private function presentCuttingRow(Cutting $cutting): array
|
||||
{
|
||||
$totalPieces = $cutting->results->sum('cutting_result');
|
||||
@ -379,7 +374,6 @@ private function presentCuttingRow(Cutting $cutting): array
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
private function buildVerificationRequestQuery(
|
||||
User $user,
|
||||
array $tableQuery,
|
||||
@ -454,7 +448,6 @@ private function shouldIncludeCuttings(
|
||||
return Cutting::query()->pendingVerification()->exists();
|
||||
}
|
||||
|
||||
|
||||
private function makePaginator(
|
||||
Collection $items,
|
||||
int $total,
|
||||
@ -490,7 +483,7 @@ private function requestTitle(OwnerVerificationRequest $request): string
|
||||
$payload = is_array($request->payload) ? $request->payload : [];
|
||||
$newData = $payload['new'] ?? [];
|
||||
|
||||
return ($newData['product_name'] ?? 'Produk') . ' - ' . ($newData['variant_name'] ?? $request->subject->name);
|
||||
return ($newData['product_name'] ?? 'Produk').' - '.($newData['variant_name'] ?? $request->subject->name);
|
||||
}
|
||||
|
||||
$payload = is_array($request->payload) ? $request->payload : [];
|
||||
|
||||
@ -16,7 +16,6 @@
|
||||
use App\Support\Media\MediaPresenter;
|
||||
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Collection as EloquentCollection;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
@ -31,7 +30,6 @@ public function __construct(
|
||||
private readonly PushNotificationService $pushNotificationService,
|
||||
) {}
|
||||
|
||||
|
||||
public function paginateForIndex(array $tableQuery): LengthAwarePaginator
|
||||
{
|
||||
$query = Purchase::query()
|
||||
@ -76,7 +74,6 @@ public function paginateForIndex(array $tableQuery): LengthAwarePaginator
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public function supplierOptions(): array
|
||||
{
|
||||
return Supplier::query()
|
||||
@ -89,7 +86,6 @@ public function supplierOptions(): array
|
||||
->all();
|
||||
}
|
||||
|
||||
|
||||
public function catalogItems(?Purchase $purchase = null, ?User $user = null): Collection
|
||||
{
|
||||
$purchasePriceIds = $purchase
|
||||
@ -150,7 +146,6 @@ public function findForEdit(Purchase $purchase): Purchase
|
||||
return $purchase;
|
||||
}
|
||||
|
||||
|
||||
public function draftItemsForUser(User $user): array
|
||||
{
|
||||
return $this->draftItemsQuery($user)
|
||||
@ -164,7 +159,6 @@ public function draftItemsForUser(User $user): array
|
||||
->all();
|
||||
}
|
||||
|
||||
|
||||
public function syncDraftItem(array $validated, User $user): array
|
||||
{
|
||||
$price = RawMaterialPrice::query()
|
||||
@ -205,12 +199,11 @@ public function removeDraftItem(User $user, RawMaterialPrice $rawMaterialPrice):
|
||||
->delete();
|
||||
}
|
||||
|
||||
|
||||
public function create(array $validated, User $user): Purchase
|
||||
{
|
||||
try {
|
||||
$purchase = DB::transaction(function () use ($validated, $user): Purchase {
|
||||
|
||||
|
||||
$draftItems = $this->draftItemsQuery($user)
|
||||
->lockForUpdate()
|
||||
->get();
|
||||
@ -282,7 +275,6 @@ public function create(array $validated, User $user): Purchase
|
||||
return $purchase;
|
||||
}
|
||||
|
||||
|
||||
public function update(Purchase $purchase, array $validated, User $user): void
|
||||
{
|
||||
$purchase->load(['supplier', 'items.rawMaterialPrice.rawMaterial:id,name']);
|
||||
@ -434,7 +426,6 @@ public function applyDelete(OwnerVerificationRequest $verificationRequest): void
|
||||
$this->executeDelete($purchase);
|
||||
}
|
||||
|
||||
|
||||
private function buildLineItems(array $items): array
|
||||
{
|
||||
return collect($items)
|
||||
@ -461,7 +452,6 @@ private function buildLineItems(array $items): array
|
||||
->all();
|
||||
}
|
||||
|
||||
|
||||
private function syncPhotos(Purchase $purchase, array $validated): void
|
||||
{
|
||||
$this->mediaService->syncCollection(
|
||||
@ -475,7 +465,6 @@ private function syncPhotos(Purchase $purchase, array $validated): void
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
private function draftItemsQuery(User $user): Builder
|
||||
{
|
||||
return PurchaseItem::query()
|
||||
@ -483,7 +472,6 @@ private function draftItemsQuery(User $user): Builder
|
||||
->where('user_id', $user->id);
|
||||
}
|
||||
|
||||
|
||||
private function presentDraftItem(PurchaseItem $item): array
|
||||
{
|
||||
$price = $item->rawMaterialPrice;
|
||||
@ -561,7 +549,6 @@ private function executeDelete(Purchase $purchase): void
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private function applyPayloadToPurchase(
|
||||
Purchase $purchase,
|
||||
array $payload,
|
||||
@ -601,7 +588,6 @@ private function applyPayloadToPurchase(
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private function snapshotPurchase(Purchase $purchase): array
|
||||
{
|
||||
$purchase->load([
|
||||
@ -631,7 +617,6 @@ private function snapshotPurchase(Purchase $purchase): array
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
private function buildPayloadFromValidated(array $validated): array
|
||||
{
|
||||
$lineItems = $this->enrichLineItems($this->buildLineItems($validated['items']));
|
||||
@ -654,7 +639,6 @@ private function buildPayloadFromValidated(array $validated): array
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
private function enrichLineItems(array $lineItems): array
|
||||
{
|
||||
$prices = RawMaterialPrice::query()
|
||||
@ -675,7 +659,6 @@ private function enrichLineItems(array $lineItems): array
|
||||
->all();
|
||||
}
|
||||
|
||||
|
||||
private function syncRequestPhotos(OwnerVerificationRequest $verificationRequest, array $validated): void
|
||||
{
|
||||
$this->mediaService->syncCollection(
|
||||
@ -689,7 +672,6 @@ private function syncRequestPhotos(OwnerVerificationRequest $verificationRequest
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
private function applyRequestPhotos(
|
||||
OwnerVerificationRequest $verificationRequest,
|
||||
Purchase $purchase,
|
||||
@ -710,7 +692,6 @@ private function applyRequestPhotos(
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private function payloadNew(OwnerVerificationRequest $verificationRequest): array
|
||||
{
|
||||
$payload = $verificationRequest->payload ?? [];
|
||||
|
||||
@ -19,7 +19,6 @@ public function __construct(
|
||||
private readonly PushNotificationService $pushNotificationService,
|
||||
) {}
|
||||
|
||||
|
||||
public function transfer(int $variantId, int $quantity, User $user, ?string $notes = null): OwnerVerificationRequest
|
||||
{
|
||||
if ($quantity <= 0) {
|
||||
@ -100,7 +99,6 @@ public function transfer(int $variantId, int $quantity, User $user, ?string $not
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function applyStockRetailTransfer(OwnerVerificationRequest $request): void
|
||||
{
|
||||
$payload = $request->payload ?? [];
|
||||
@ -137,7 +135,6 @@ public function applyStockRetailTransfer(OwnerVerificationRequest $request): voi
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public function rejectStockRetailTransfer(OwnerVerificationRequest $request): void
|
||||
{
|
||||
// No-op: nothing was changed yet, so nothing to rollback.
|
||||
|
||||
@ -20,7 +20,6 @@ public function __construct(
|
||||
private readonly PushNotificationService $pushNotificationService,
|
||||
) {}
|
||||
|
||||
|
||||
public function getPendingVerificationCuttings(User $user): Collection
|
||||
{
|
||||
return Cutting::query()
|
||||
@ -39,7 +38,6 @@ public function getPendingVerificationCuttings(User $user): Collection
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public function getPendingApprovalCuttings(User $user): Collection
|
||||
{
|
||||
return Cutting::query()
|
||||
@ -60,7 +58,6 @@ public function getPendingApprovalCuttings(User $user): Collection
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public function submitVerification(
|
||||
Cutting $cutting,
|
||||
User $user,
|
||||
@ -125,7 +122,6 @@ public function submitVerification(
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public function approveVerification(
|
||||
Cutting $cutting,
|
||||
User $user,
|
||||
@ -176,7 +172,6 @@ public function approveVerification(
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public function rejectVerification(
|
||||
Cutting $cutting,
|
||||
User $user,
|
||||
@ -245,7 +240,6 @@ private function applyProductStockOnVerify(Cutting $cutting): void
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private function storeResultPrices(Cutting $cutting, array $resultPrices): void
|
||||
{
|
||||
// Extract harga_modal from the first variant's prices and set as cost_per_unit
|
||||
@ -285,7 +279,6 @@ private function storeResultPrices(Cutting $cutting, array $resultPrices): void
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private function applyResultPricesToProducts(Cutting $cutting): void
|
||||
{
|
||||
$resultPrices = $cutting->resultPrices()->with('productVariant')->get();
|
||||
|
||||
@ -4,6 +4,7 @@
|
||||
|
||||
use App\Enums\StokOpnameStatus;
|
||||
use App\Models\Product;
|
||||
use App\Models\ProductVariant;
|
||||
use App\Models\StokOpname;
|
||||
use App\Models\User;
|
||||
use App\Services\System\PushNotificationService;
|
||||
@ -19,7 +20,6 @@ public function __construct(
|
||||
private readonly PushNotificationService $pushNotificationService,
|
||||
) {}
|
||||
|
||||
|
||||
public function paginateForIndex(array $tableQuery): LengthAwarePaginator
|
||||
{
|
||||
$query = StokOpname::query()
|
||||
@ -44,7 +44,6 @@ public function paginateForIndex(array $tableQuery): LengthAwarePaginator
|
||||
->withQueryString();
|
||||
}
|
||||
|
||||
|
||||
public function catalogItems(): array
|
||||
{
|
||||
return Product::query()
|
||||
@ -69,7 +68,6 @@ public function catalogItems(): array
|
||||
->toArray();
|
||||
}
|
||||
|
||||
|
||||
public function findForEdit(StokOpname $stokOpname): array
|
||||
{
|
||||
$stokOpname->load(['items.productVariant.product', 'createdBy.profile']);
|
||||
@ -96,7 +94,6 @@ public function findForEdit(StokOpname $stokOpname): array
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
public function create(array $validated, User $user): StokOpname
|
||||
{
|
||||
try {
|
||||
@ -125,7 +122,6 @@ public function create(array $validated, User $user): StokOpname
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function update(StokOpname $stokOpname, array $validated): void
|
||||
{
|
||||
if ($stokOpname->status !== StokOpnameStatus::DRAFT && $stokOpname->status !== StokOpnameStatus::REJECTED) {
|
||||
@ -183,7 +179,6 @@ public function delete(StokOpname $stokOpname): void
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function submit(StokOpname $stokOpname, User $user): void
|
||||
{
|
||||
if ($stokOpname->status !== StokOpnameStatus::DRAFT && $stokOpname->status !== StokOpnameStatus::REJECTED) {
|
||||
@ -224,7 +219,6 @@ public function submit(StokOpname $stokOpname, User $user): void
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public function verify(StokOpname $stokOpname, User $user, ?string $verificationNotes = null): void
|
||||
{
|
||||
if ($stokOpname->status !== StokOpnameStatus::PENDING) {
|
||||
@ -269,7 +263,6 @@ public function verify(StokOpname $stokOpname, User $user, ?string $verification
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public function reject(StokOpname $stokOpname, User $user, string $reason): void
|
||||
{
|
||||
if ($stokOpname->status !== StokOpnameStatus::PENDING) {
|
||||
@ -306,7 +299,6 @@ public function reject(StokOpname $stokOpname, User $user, string $reason): void
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public function autoSave(array $validated, User $user): StokOpname
|
||||
{
|
||||
try {
|
||||
@ -345,13 +337,12 @@ public function autoSave(array $validated, User $user): StokOpname
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private function syncItems(StokOpname $stokOpname, array $items): void
|
||||
{
|
||||
$stokOpname->items()->delete();
|
||||
|
||||
foreach ($items as $item) {
|
||||
$systemStock = \App\Models\ProductVariant::find($item['product_variant_id'])?->stock ?? 0;
|
||||
$systemStock = ProductVariant::find($item['product_variant_id'])?->stock ?? 0;
|
||||
|
||||
$stokOpname->items()->create([
|
||||
'product_variant_id' => $item['product_variant_id'],
|
||||
|
||||
@ -27,7 +27,6 @@ public function __construct(
|
||||
private readonly PushNotificationService $pushNotificationService,
|
||||
) {}
|
||||
|
||||
|
||||
public function paginateForIndex(array $tableQuery, string $isActive, string $categoryId = '', string $stockStatus = ''): LengthAwarePaginator
|
||||
{
|
||||
$query = Product::query()
|
||||
@ -114,7 +113,6 @@ public function findForEdit(Product $product): Product
|
||||
return $product;
|
||||
}
|
||||
|
||||
|
||||
public function create(array $validated, User $user): void
|
||||
{
|
||||
try {
|
||||
@ -169,7 +167,6 @@ public function create(array $validated, User $user): void
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public function update(Product $product, array $validated, User $user): void
|
||||
{
|
||||
try {
|
||||
@ -243,7 +240,6 @@ public function delete(Product $product, User $user): void
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public function toggleStatus(Product $product, array $validated, User $user): void
|
||||
{
|
||||
try {
|
||||
@ -348,7 +344,6 @@ public function applyUpdate(OwnerVerificationRequest $verificationRequest): void
|
||||
$this->applyPayloadToProduct($product, $this->payloadNew($verificationRequest), $verificationRequest);
|
||||
}
|
||||
|
||||
|
||||
private function applyPayloadToProduct(
|
||||
Product $product,
|
||||
array $payload,
|
||||
@ -500,7 +495,6 @@ private function rollbackUpdate(OwnerVerificationRequest $verificationRequest):
|
||||
$this->applyPayloadToProduct($product, $oldPayload);
|
||||
}
|
||||
|
||||
|
||||
private function payloadOld(OwnerVerificationRequest $verificationRequest): array
|
||||
{
|
||||
$payload = $verificationRequest->payload ?? [];
|
||||
@ -512,7 +506,6 @@ private function payloadOld(OwnerVerificationRequest $verificationRequest): arra
|
||||
return [];
|
||||
}
|
||||
|
||||
|
||||
private function payloadNew(OwnerVerificationRequest $verificationRequest): array
|
||||
{
|
||||
$payload = $verificationRequest->payload ?? [];
|
||||
@ -524,7 +517,6 @@ private function payloadNew(OwnerVerificationRequest $verificationRequest): arra
|
||||
return $payload;
|
||||
}
|
||||
|
||||
|
||||
private function snapshotProduct(Product $product): array
|
||||
{
|
||||
$product->load(['categories', 'variants']);
|
||||
@ -545,7 +537,6 @@ private function snapshotProduct(Product $product): array
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
private function enrichPayload(array $data): array
|
||||
{
|
||||
$categoryIds = $data['category_ids'] ?? [];
|
||||
@ -557,7 +548,6 @@ private function enrichPayload(array $data): array
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
private function buildPayloadFromValidated(array $validated): array
|
||||
{
|
||||
return [
|
||||
@ -576,7 +566,6 @@ private function buildPayloadFromValidated(array $validated): array
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
private function syncVariantImages(
|
||||
ProductVariant $variant,
|
||||
array $variantData,
|
||||
@ -593,7 +582,6 @@ private function syncVariantImages(
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
private function syncRequestVariantImages(
|
||||
OwnerVerificationRequest $verificationRequest,
|
||||
array $variantData,
|
||||
@ -613,7 +601,6 @@ private function syncRequestVariantImages(
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
private function applyVariantImageChanges(
|
||||
OwnerVerificationRequest $verificationRequest,
|
||||
ProductVariant $variant,
|
||||
|
||||
@ -27,7 +27,6 @@ public function __construct(
|
||||
private readonly PushNotificationService $pushNotificationService,
|
||||
) {}
|
||||
|
||||
|
||||
public function paginateForIndex(array $tableQuery, string $isActive, string $stockStatus = ''): LengthAwarePaginator
|
||||
{
|
||||
$query = RawMaterial::query()
|
||||
@ -108,7 +107,6 @@ public function findForEdit(RawMaterial $rawMaterial): RawMaterial
|
||||
return $rawMaterial;
|
||||
}
|
||||
|
||||
|
||||
public function create(array $validated, User $user): void
|
||||
{
|
||||
try {
|
||||
@ -155,7 +153,6 @@ public function create(array $validated, User $user): void
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public function update(RawMaterial $rawMaterial, array $validated, User $user): void
|
||||
{
|
||||
try {
|
||||
@ -229,7 +226,6 @@ public function delete(RawMaterial $rawMaterial, User $user): void
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public function toggleStatus(RawMaterial $rawMaterial, array $validated, User $user): void
|
||||
{
|
||||
try {
|
||||
@ -387,7 +383,6 @@ public function applyToggleStatus(OwnerVerificationRequest $verificationRequest)
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
private function applyPayloadToRawMaterial(
|
||||
RawMaterial $rawMaterial,
|
||||
array $payload,
|
||||
@ -482,7 +477,6 @@ private function rollbackUpdate(OwnerVerificationRequest $verificationRequest):
|
||||
$this->applyPayloadToRawMaterial($rawMaterial, $oldPayload);
|
||||
}
|
||||
|
||||
|
||||
private function payloadOld(OwnerVerificationRequest $verificationRequest): array
|
||||
{
|
||||
$payload = $verificationRequest->payload ?? [];
|
||||
@ -494,7 +488,6 @@ private function payloadOld(OwnerVerificationRequest $verificationRequest): arra
|
||||
return [];
|
||||
}
|
||||
|
||||
|
||||
private function payloadNew(OwnerVerificationRequest $verificationRequest): array
|
||||
{
|
||||
$payload = $verificationRequest->payload ?? [];
|
||||
@ -506,7 +499,6 @@ private function payloadNew(OwnerVerificationRequest $verificationRequest): arra
|
||||
return $payload;
|
||||
}
|
||||
|
||||
|
||||
private function snapshotRawMaterial(RawMaterial $rawMaterial): array
|
||||
{
|
||||
$rawMaterial->load(['prices']);
|
||||
@ -526,7 +518,6 @@ private function snapshotRawMaterial(RawMaterial $rawMaterial): array
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
private function enrichPayload(array $data): array
|
||||
{
|
||||
if (isset($data['unit'])) {
|
||||
@ -541,7 +532,6 @@ private function enrichPayload(array $data): array
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
private function buildPayloadFromValidated(array $validated): array
|
||||
{
|
||||
return [
|
||||
@ -570,7 +560,6 @@ private function applySorting(Builder $query, string $sort, string $direction):
|
||||
$query->latest();
|
||||
}
|
||||
|
||||
|
||||
private function createPrice(RawMaterial $rawMaterial, array $priceData, int $index): RawMaterialPrice
|
||||
{
|
||||
$price = $rawMaterial->prices()->create([
|
||||
@ -584,7 +573,6 @@ private function createPrice(RawMaterial $rawMaterial, array $priceData, int $in
|
||||
return $price;
|
||||
}
|
||||
|
||||
|
||||
private function syncPriceImages(RawMaterialPrice $price, array $priceData, int $index): void
|
||||
{
|
||||
$this->mediaService->syncCollection(
|
||||
@ -598,7 +586,6 @@ private function syncPriceImages(RawMaterialPrice $price, array $priceData, int
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
private function syncRequestPriceImages(
|
||||
OwnerVerificationRequest $verificationRequest,
|
||||
array $priceData,
|
||||
@ -618,7 +605,6 @@ private function syncRequestPriceImages(
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
private function applyPriceImageChanges(
|
||||
OwnerVerificationRequest $verificationRequest,
|
||||
RawMaterialPrice $price,
|
||||
|
||||
@ -12,7 +12,6 @@
|
||||
|
||||
class MediaService
|
||||
{
|
||||
|
||||
public function syncCollection(
|
||||
HasMedia $model,
|
||||
string $collection,
|
||||
@ -115,7 +114,6 @@ public function replaceSingleFile(
|
||||
return $this->addUploadedFile($model, $file, $collection, $type);
|
||||
}
|
||||
|
||||
|
||||
private function customProperties(HasMedia $model, ?string $type): array
|
||||
{
|
||||
$properties = [
|
||||
|
||||
@ -293,7 +293,7 @@ public function getExpenseSummary(?Carbon $startDate = null, ?Carbon $endDate =
|
||||
->first();
|
||||
|
||||
$purchaseTotal = (int) ($purchase->total ?? 0);
|
||||
if (auth()->user()?->hasRole(\App\Enums\Role::ADMIN_TOKO->value)) {
|
||||
if (auth()->user()?->hasRole(Role::ADMIN_TOKO->value)) {
|
||||
$purchaseTotal = 0;
|
||||
}
|
||||
$expenseTotal = (int) ($expenses->total ?? 0);
|
||||
@ -352,7 +352,7 @@ public function getMonthlyExpense(?Carbon $startDate = null, ?Carbon $endDate =
|
||||
$monthLabel = $current->locale('id')->translatedFormat('M Y');
|
||||
|
||||
$purchaseAmount = (int) ($purchases->firstWhere('month_key', $key)->total ?? 0);
|
||||
if (auth()->user()?->hasRole(\App\Enums\Role::ADMIN_TOKO->value)) {
|
||||
if (auth()->user()?->hasRole(Role::ADMIN_TOKO->value)) {
|
||||
$purchaseAmount = 0;
|
||||
}
|
||||
$expenseAmount = (int) ($expenses->firstWhere('month_key', $key)->total ?? 0);
|
||||
@ -433,7 +433,7 @@ public function getProfitMetrics(?Carbon $startDate = null, ?Carbon $endDate = n
|
||||
->when($startDate && $endDate, fn ($q) => $q->whereBetween('purchases.created_at', [$startDate, $endDate]))
|
||||
->sum('total');
|
||||
|
||||
if (auth()->user()?->hasRole(\App\Enums\Role::ADMIN_TOKO->value)) {
|
||||
if (auth()->user()?->hasRole(Role::ADMIN_TOKO->value)) {
|
||||
$purchaseTotal = 0;
|
||||
}
|
||||
|
||||
|
||||
@ -5,6 +5,7 @@
|
||||
use App\Enums\OrderChannel;
|
||||
use App\Enums\OrderStatus;
|
||||
use App\Enums\PaymentType;
|
||||
use App\Enums\Role;
|
||||
use App\Models\Attendance;
|
||||
use App\Models\CashAccount;
|
||||
use App\Models\CashTransaction;
|
||||
@ -19,7 +20,6 @@
|
||||
|
||||
class DashboardService
|
||||
{
|
||||
|
||||
public function getTodayAttendanceForUser(User $user): ?array
|
||||
{
|
||||
$employee = $user->employee;
|
||||
@ -160,7 +160,7 @@ public function getExpenseSummary(): array
|
||||
->first();
|
||||
|
||||
$purchaseTotal = (int) ($purchase->total ?? 0);
|
||||
if (auth()->user()?->hasRole(\App\Enums\Role::ADMIN_TOKO->value)) {
|
||||
if (auth()->user()?->hasRole(Role::ADMIN_TOKO->value)) {
|
||||
$purchaseTotal = 0;
|
||||
}
|
||||
$expenseTotal = (int) ($expenses->total ?? 0);
|
||||
|
||||
@ -6,19 +6,16 @@
|
||||
|
||||
class PushNotificationService
|
||||
{
|
||||
|
||||
public function sendToRoles(string $title, string $body, array $roles, string $url = '/admin/dashboard'): void
|
||||
{
|
||||
SendPushNotificationJob::dispatch($title, $body, $url, $roles);
|
||||
}
|
||||
|
||||
|
||||
public function sendToUser(string $title, string $body, int $userId, string $url = '/admin/dashboard'): void
|
||||
{
|
||||
SendPushNotificationJob::dispatch($title, $body, $url, [], $userId);
|
||||
}
|
||||
|
||||
|
||||
public function sendToAll(string $title, string $body, string $url = '/admin/dashboard'): void
|
||||
{
|
||||
SendPushNotificationJob::dispatch($title, $body, $url, []);
|
||||
|
||||
@ -6,7 +6,6 @@
|
||||
|
||||
class PushSubscriptionService
|
||||
{
|
||||
|
||||
public function updateOrCreateSubscription(array $validated, int $userId): void
|
||||
{
|
||||
PushSubscription::updateOrCreate(
|
||||
@ -21,7 +20,6 @@ public function updateOrCreateSubscription(array $validated, int $userId): void
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public function deleteSubscription(string $endpoint, int $userId): void
|
||||
{
|
||||
PushSubscription::where('user_id', $userId)
|
||||
|
||||
@ -2,8 +2,8 @@
|
||||
|
||||
namespace App\Services\System;
|
||||
|
||||
use App\Enums\Role as EnumsRole;
|
||||
use App\Enums\Permission as PermissionEnum;
|
||||
use App\Enums\Role as EnumsRole;
|
||||
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
@ -20,7 +20,6 @@ public function __construct(
|
||||
private readonly PushNotificationService $pushNotificationService,
|
||||
) {}
|
||||
|
||||
|
||||
private function tiktokFeeKeys(): array
|
||||
{
|
||||
return [
|
||||
@ -33,7 +32,6 @@ private function tiktokFeeKeys(): array
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
private function shopeeFeeKeys(): array
|
||||
{
|
||||
return [
|
||||
@ -153,7 +151,6 @@ public function applyVerificationRequest(OwnerVerificationRequest $request): voi
|
||||
$this->saveSettings($newPayload);
|
||||
}
|
||||
|
||||
|
||||
public function buildOrderSnapshot(OrderChannel $channel, int $totalAmount, array $lineItems, bool $isAffiliate = false): ?array
|
||||
{
|
||||
$feeSnapshot = $this->feeRulesForChannel($channel);
|
||||
@ -186,7 +183,6 @@ public function buildOrderSnapshot(OrderChannel $channel, int $totalAmount, arra
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
private function excludeAffiliateFee(array $fees, OrderChannel $channel): array
|
||||
{
|
||||
$affiliateKey = match ($channel) {
|
||||
@ -206,7 +202,6 @@ private function excludeAffiliateFee(array $fees, OrderChannel $channel): array
|
||||
return $fees;
|
||||
}
|
||||
|
||||
|
||||
private function feeRulesForChannel(OrderChannel $channel): ?array
|
||||
{
|
||||
$settings = app(MarketplaceSettings::class);
|
||||
@ -241,13 +236,11 @@ private function feeRulesForChannel(OrderChannel $channel): ?array
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
private function presentFeeRule(array $data): array
|
||||
{
|
||||
return MarketplaceFeeRule::fromArray($data)->toArray();
|
||||
}
|
||||
|
||||
|
||||
private function normalizeFeeRule(array $data): array
|
||||
{
|
||||
return MarketplaceFeeRule::fromArray($data)->toArray();
|
||||
|
||||
@ -31,6 +31,7 @@
|
||||
use App\Models\SystemConfiguration;
|
||||
use App\Models\User;
|
||||
use App\Models\UserProfile;
|
||||
use App\Settings\MarketplaceSettings;
|
||||
|
||||
class ModelLabel
|
||||
{
|
||||
@ -67,7 +68,7 @@ class ModelLabel
|
||||
SystemConfiguration::class => 'Konfigurasi Sistem',
|
||||
User::class => 'Pengguna',
|
||||
UserProfile::class => 'Profil Pengguna',
|
||||
\App\Settings\MarketplaceSettings::class => 'Pengaturan Marketplace',
|
||||
MarketplaceSettings::class => 'Pengaturan Marketplace',
|
||||
];
|
||||
|
||||
public static function for(?string $modelClass): string
|
||||
|
||||
@ -134,8 +134,8 @@ private static function presentValue(string $field, mixed $value): mixed
|
||||
|
||||
$val = $value['value'];
|
||||
$formattedValue = $value['value_type'] === 'percent'
|
||||
? rtrim(rtrim(number_format($val, 2, ',', '.'), '0'), ',') . '%'
|
||||
: 'Rp ' . number_format($val, 0, ',', '.');
|
||||
? rtrim(rtrim(number_format($val, 2, ',', '.'), '0'), ',').'%'
|
||||
: 'Rp '.number_format($val, 0, ',', '.');
|
||||
|
||||
$scopeStr = $value['scope'] === 'item' ? 'per Item' : 'per Transaksi';
|
||||
|
||||
|
||||
@ -21,17 +21,17 @@
|
||||
use App\Http\Controllers\Admin\Manage\OwnerVerificationController;
|
||||
use App\Http\Controllers\Admin\Manage\Purchase\PurchaseController;
|
||||
use App\Http\Controllers\Admin\Manage\Purchase\PurchaseDraftItemController;
|
||||
use App\Http\Controllers\Admin\Manage\StokOpnameController;
|
||||
use App\Http\Controllers\Admin\Manage\Stock\StockController;
|
||||
use App\Http\Controllers\Admin\Manage\Stock\StockRetailController;
|
||||
use App\Http\Controllers\Admin\Manage\StokOpnameController;
|
||||
use App\Http\Controllers\Admin\Master\CategoryController;
|
||||
use App\Http\Controllers\Admin\Master\CustomerController;
|
||||
use App\Http\Controllers\Admin\Master\ProductController;
|
||||
use App\Http\Controllers\Admin\Master\RawMaterialController;
|
||||
use App\Http\Controllers\Admin\Master\SupplierController;
|
||||
use App\Http\Controllers\Admin\NotificationController;
|
||||
use App\Http\Controllers\Admin\System\ActivityLogController;
|
||||
use App\Http\Controllers\Admin\System\RoleController;
|
||||
use App\Http\Controllers\Admin\NotificationController;
|
||||
use App\Http\Controllers\Admin\System\SettingController;
|
||||
use App\Http\Controllers\Auth\LoginController;
|
||||
use App\Http\Controllers\Auth\LogoutController;
|
||||
|
||||
@ -4,7 +4,6 @@
|
||||
use App\Enums\OwnerVerificationStatus;
|
||||
use App\Enums\Permission as PermissionEnum;
|
||||
use App\Enums\RawMaterialUnit;
|
||||
use App\Models\OwnerVerificationRequest;
|
||||
use App\Models\RawMaterial;
|
||||
use App\Models\RawMaterialPrice;
|
||||
use App\Models\User;
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
use App\Models\OwnerVerificationRequest;
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Tests\TestCase;
|
||||
|
||||
@ -49,9 +51,9 @@ function something()
|
||||
// ..
|
||||
}
|
||||
|
||||
function approveLatestOwnerVerificationRequest(\App\Models\User $verifier): \App\Models\OwnerVerificationRequest
|
||||
function approveLatestOwnerVerificationRequest(User $verifier): OwnerVerificationRequest
|
||||
{
|
||||
$verificationRequest = \App\Models\OwnerVerificationRequest::query()->pending()->latest()->firstOrFail();
|
||||
$verificationRequest = OwnerVerificationRequest::query()->pending()->latest()->firstOrFail();
|
||||
|
||||
test()->actingAs($verifier)
|
||||
->post(route('admin.manage.owner_verifications.approve_request', $verificationRequest))
|
||||
|
||||
Loading…
Reference in New Issue
Block a user