@php $totalPurchase=0; $totalSoldAmount=0; $totalDiscount=0; @endphp @foreach ($invoices->where('type','sale') as $invoice) @php $totalDiscount=$totalDiscount + $invoice->total_discount; @endphp @foreach ($invoice->sale_product as $product) @php $totalPurchasePrice=$product->purchase_price*$product->quantity; $totalSalePrice=$product->sale_price*$product->quantity; $totalProfitLoss=$totalSalePrice-$totalPurchasePrice; $totalPurchase = $totalPurchase + $totalPurchasePrice; $totalSoldAmount = $totalSoldAmount + $totalSalePrice; @endphp @endforeach @endforeach {{-- --}} @php $TotalReturn = $invoices->where('type','sale_return')->sum('total_amount'); @endphp @php $totalDamage=$damageEntry->sum('amount'); @endphp @php $totalSalary= $salaryPayment->sum('payment_amount'); @endphp
Product Id Product Sold Quantity Purchase Rate Purchased Total Sold Amount Profit/Loss
Invoice: {{ $invoice->invoice_no }} | Sales Date: {{ date('d-M-Y', strtotime($invoice->invoice_date)) }} | Customer: {{ $invoice->customer->customer_name }} | Discount: {{ $invoice->total_discount }}
{{$product->product->product_id}} {{$product->product->product_name}} {{$product->quantity}} {{number_format($product->purchase_price,2)}}{{number_format(($totalPurchasePrice),2)}} {{number_format(($totalSalePrice),2)}} {{number_format($totalProfitLoss,2)}}
Total Profit {{number_format( $totalPurchase,2)}} {{number_format( $totalSoldAmount,2)}} {{number_format( ($totalSoldAmount-$totalPurchase),2)}}
Other Income (+) 0.00
Total Discount (-) {{number_format($totalDiscount,2)}}
Total Returned Value (-) {{number_format(($TotalReturn),2)}}
Total Damaged (-) {{number_format($totalDamage,2)}}
Cash Transaction (-) {{number_format($totalCashTransaction,2)}}
Employee Payment (-) {{number_format($totalSalary,2)}}
Profit / Loss @php $totalProfitLoss= (($totalSoldAmount-$totalPurchase)+$totalCashTransaction)-($TotalReturn+$totalDamage+$totalSalary); @endphp {{number_format($totalProfitLoss,2)}}