update marketing
All checks were successful
All checks were successful
This commit is contained in:
@@ -4,36 +4,42 @@
|
||||
|
||||
use App\Models\PaymentType;
|
||||
use App\Models\Product;
|
||||
use App\Traits\DateFilterTrait;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Maatwebsite\Excel\Concerns\FromView;
|
||||
|
||||
class ExportBalanceSheet implements FromView
|
||||
{
|
||||
use DateFilterTrait;
|
||||
|
||||
public function view(): View
|
||||
{
|
||||
$businessId = auth()->user()->business_id;
|
||||
$duration = request('custom_days') ? : 'today';
|
||||
$fromDate = request('from_date');
|
||||
$toDate = request('to_date');
|
||||
$perPage = request('per_page') ?? 20;
|
||||
|
||||
// PRODUCT
|
||||
$productQuery = Product::select('id', 'business_id', 'productName', 'product_type', 'created_at')
|
||||
->with(['stocks:id,business_id,product_id,productStock,productPurchasePrice', 'combo_products.stock'])
|
||||
->where('business_id', $businessId);
|
||||
$this->applyDateFilter($productQuery, $duration, 'created_at', $fromDate, $toDate);
|
||||
$products = $productQuery->get()
|
||||
->map(function ($item) {
|
||||
$item->source = 'product';
|
||||
return $item;
|
||||
});
|
||||
|
||||
// BANK
|
||||
$bankQuery = PaymentType::where('business_id', $businessId);
|
||||
$this->applyDateFilter($bankQuery, $duration, 'opening_date', $fromDate, $toDate);
|
||||
$banks = $bankQuery->get()
|
||||
->map(function ($item) {
|
||||
$item->source = 'bank';
|
||||
return $item;
|
||||
});
|
||||
|
||||
$asset_datas = $products->merge($banks);
|
||||
$asset_datas = $products->merge($banks)->take($perPage);
|
||||
|
||||
// TOTAL STOCK VALUE
|
||||
$total_stock_value = 0;
|
||||
foreach ($products as $product) {
|
||||
if (in_array($product->product_type, ['single', 'variant'])) {
|
||||
|
||||
Reference in New Issue
Block a user