feat: filter product stock calculation by price type and ensure data integrity with null checks
This commit is contained in:
parent
85269935f6
commit
ce26551666
@ -3,6 +3,7 @@
|
||||
namespace App\Services\System;
|
||||
|
||||
use App\Enums\OrderStatus;
|
||||
use App\Enums\PriceType;
|
||||
use App\Enums\Role;
|
||||
use App\Models\Attendance;
|
||||
use App\Models\CashAccount;
|
||||
@ -553,6 +554,9 @@ public function getProductStock(): array
|
||||
|
||||
$totalValue = \DB::table('product_prices')
|
||||
->join('product_variants', 'product_prices.variant_id', '=', 'product_variants.id')
|
||||
->where('product_prices.type', PriceType::HARGA_MODAL->value)
|
||||
->whereNull('product_variants.deleted_at')
|
||||
->whereNull('product_prices.deleted_at')
|
||||
->selectRaw('SUM(product_variants.stock * product_prices.price) as total')
|
||||
->value('total');
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user