@foreach ($data['userData'] as $key => $user) @if (isset($priority) && $user['priority'] != $priority)
{{ $priority }} : Total AMT : {{ abs($gross) }} {{ $priority }} : Total BKRG : {{ $brokerage }} Your {{ $profit > 0 ? 'Profit' : 'Loss' }} ({{ $priority }}) : {{ abs($profit) }}
@endif
{{-- --}} {{-- @foreach ($user['deals'] as $action => $deals) --}} @php $totalBuyDeals = isset($user['deals'][CommonConstants::BILLING_PDF['BUY_VALUE']]) ? count($user['deals'][CommonConstants::BILLING_PDF['BUY_VALUE']]) : 0; $totalSellDeals = isset($user['deals'][CommonConstants::BILLING_PDF['SELL_VALUE']]) ? count($user['deals'][CommonConstants::BILLING_PDF['SELL_VALUE']]) : 0; $maxDealsCount = max($totalBuyDeals, $totalSellDeals); $buyDeals = isset($user['deals'][CommonConstants::BILLING_PDF['BUY_VALUE']]) ? $user['deals'][CommonConstants::BILLING_PDF['BUY_VALUE']] : []; $sellDeals = isset($user['deals'][CommonConstants::BILLING_PDF['SELL_VALUE']]) ? $user['deals'][CommonConstants::BILLING_PDF['SELL_VALUE']] : []; @endphp @for ($i = 0; $i < $maxDealsCount; $i++) {{-- @foreach ($deals as $deal) --}} {{-- Sell data --}} {{-- @if ($action == CommonConstants::BILLING_USERS_DATA['SELL_VALUE']) --}} @if (isset($sellDeals[$i])) @else @endif {{-- @endif --}} {{-- Buy data --}} {{-- @if ($action == CommonConstants::BILLING_USERS_DATA['BUY_VALUE']) --}} @if (isset($buyDeals[$i])) @else @endif {{-- @endif --}} @if ($i == $maxDealsCount - 1) @if ($user['totalBuyPrice'] > $user['totalSellPrice']) @if (isset($user['brokerageType']) && $user['brokerageType'] != null) @endif @else @if (isset($user['brokerageType']) && $user['brokerageType'] != null) @endif @endif @endif {{-- @endforeach --}} @endfor {{-- @endforeach --}}
{{$data['loginId']}} {{$data['name'] ?? $data['loginId']}}
{{$user['symbol']}}, {{now()->endOfWeek()->format('d.m.Y')}} Clg.Rate: {{$user['currentWeekPrice']}}
{{$sellDeals[$i]['total']}} {{$sellDeals[$i]['volume']}} {{number_format($sellDeals[$i]['price'], 2, '.', '')}} {{date('d.m', strtotime($sellDeals[$i]['date']))}} {{$sellDeals[$i]['carryForward']}} {{$buyDeals[$i]['total']}} {{$buyDeals[$i]['volume']}} {{number_format($buyDeals[$i]['price'], 2, '.', '')}} {{date('d.m', strtotime($buyDeals[$i]['date']))}} {{$buyDeals[$i]['carryForward']}}
{{$user['totalSellPrice']}} {{$user['totalSellVolume']}} {{$user['totalBuyPrice']}} {{$user['totalBuyVolume']}}
{{number_format(round(($user['totalSellPrice']) * -1, 2), 2, '.', '')}}
{{number_format(round(($user['profit']) * -1, 2), 2, '.', '')}}
(*){{$user['contractSize']}}
{{number_format(round(($user['totalProfit']) * -1, 2), 2, '.', '')}}
{{number_format(round($user['totalBrokerage'], 2), 2, '.', '')}} (Bkrg:0*{{$user['brokerageValue']}}/1[T])
{{number_format(round($user['finalProfit'] * -1, 2), 2, '.', '')}} Dr (Your Loss)
{{number_format(round($user['totalBuyPrice'] * -1, 2), 2, '.', '')}}
{{number_format(round($user['profit'], 2), 2, '.', '')}}
(*){{$user['contractSize']}}
{{number_format(round($user['totalProfit'], 2), 2, '.', '')}}
{{number_format(round($user['totalBrokerage'] * -1, 2), 2, '.', '')}} (Bkrg:0*{{$user['brokerageValue']}}/1[T])
{{number_format(round($user['finalProfit'], 2), 2, '.', '')}} Cr (Your Profit)
@php if (isset($priority) && $user['priority'] != $priority) { $profit = 0; $gross = 0; $brokerage = 0; } @endphp @php $priority = $user['priority']; $gross += number_format(round(($user['totalProfit']), 2), 2, '.', ''); $totalGross += number_format(round(($user['totalProfit']), 2), 2, '.', ''); $brokerage += abs(number_format(round(($user['totalBrokerage']), 2), 2, '.', '')); $totalBrokerage += abs(number_format(round(($user['totalBrokerage']), 2), 2, '.', '')); $profit += number_format(round(($user['finalProfit']), 2), 2, '.', ''); $finalProfit += number_format(round(($user['finalProfit']), 2), 2, '.', ''); @endphp @if ($loop->last)
{{ $priority }} : Total AMT : {{ abs($gross) }} {{ $priority }} : Total BKRG : {{ $brokerage }} Your {{ $profit > 0 ? 'Profit' : 'Loss' }} ({{ $priority }}) : {{ abs($profit) }}
All Excn Total AMT : {{abs($totalGross)}} All Excn BKRG Total : {{$totalBrokerage}} Your {{ $finalProfit > 0 ? 'Profit' : 'Loss' }} (All Excn) : {{abs($finalProfit)}}
@endif @php if (isset($priority) && $user['priority'] != $priority) { $profit = 0; $gross = 0; $brokerage = 0; } @endphp {{-- @php $priority = $user['priority']; $gross += abs(number_format(round(($user['totalProfit']), 2), 2, '.', '')); $totalGross += abs(number_format(round(($user['totalProfit']), 2), 2, '.', '')); $brokerage += abs(number_format(round(($user['totalBrokerage']), 2), 2, '.', '')); $totalBrokerage += abs(number_format(round(($user['totalBrokerage']), 2), 2, '.', '')); $profit += number_format(round(($user['finalProfit']), 2), 2, '.', ''); $finalProfit += number_format(round(($user['finalProfit']), 2), 2, '.', ''); @endphp --}}
@endforeach @if (isset($data['userData']) && !empty($data['userData'])) @php $filteredData = array_filter($data['userData'], function ($item) { return $item['carryForwardVolume'] != 0; }); if (empty($filteredData)) { return; } @endphp @php $priority = null; $sellAmount = 0; $buyAmount = 0; $totalSellAmount = 0; $totalBuyAmount = 0; @endphp @foreach ($filteredData as $key => $user) @if (!empty($user['deals'])) @foreach ([0, 1] as $action) @if (!empty($user['deals'][$action])) @php $lastObject = end($user['deals'][$action]); $endOfWeekFormatted = Carbon::createFromFormat('d/m/Y', $data['endOfWeek'])->format('d-m-Y'); @endphp @if ($lastObject['carryForward'] == 'K' && $lastObject['date'] == $endOfWeekFormatted) @php $carryForwardAction = $action; @endphp @endif @endif @endforeach @endif @if (isset($priority) && $user['priority'] != $priority) @php // Reset for the next group $sellAmount = 0; $buyAmount = 0; @endphp @endif @if (!isset($priority) || $user['priority'] != $priority) {{-- Add the priority row at the start of the new group --}} @endif @if (isset($carryForwardAction) && $carryForwardAction == '0') @else @endif @if (isset($carryForwardAction) && $carryForwardAction == '0') @else @endif @php // Update group totals if (isset($carryForwardAction) && $carryForwardAction == '0') { $sellAmount += (($user['carryForwardVolume'] * $user['currentWeekPrice']) * $user['contractSize']); $totalSellAmount += (($user['carryForwardVolume'] * $user['currentWeekPrice']) * $user['contractSize']); } else { $buyAmount += (($user['carryForwardVolume'] * $user['currentWeekPrice']) * $user['contractSize']); $totalBuyAmount += (($user['carryForwardVolume'] * $user['currentWeekPrice']) * $user['contractSize']); } $priority = $user['priority']; @endphp @if ($loop->last) @endif @endforeach
Commodity Sell Buy Close Rate Sell Amount Buy Amount
{{$data['loginId']}} : {{$data['name'] ?? $data['loginId']}}
Total Amount : {{ $sellAmount != 0 ? $sellAmount : '' }} {{ $buyAmount != 0 ? $buyAmount : '' }}
{{$user['priority']}}
{{$user['symbol']}}{{$user['carryForwardVolume']}} {{$user['carryForwardVolume']}}{{$user['currentWeekPrice']}}{{ (($user['carryForwardVolume'] * $user['currentWeekPrice']) * $user['contractSize']) }} {{ (($user['carryForwardVolume'] * $user['currentWeekPrice']) * $user['contractSize']) }}
Total Amount : {{ $sellAmount != 0 ? $sellAmount : '' }} {{ $buyAmount != 0 ? $buyAmount : '' }}
Grand Total Amount : {{ $totalSellAmount != 0 ? $totalSellAmount : '' }} {{ $totalBuyAmount != 0 ? $totalBuyAmount : '' }}
@endif