@php $items = $getRecord()->items ?? collect(); // this returns a number, not a Collection $total = $items->sum('base_amount'); $shipping = (float) ($getRecord()->shipping_charges ?? 0); $profit = (float) ($getRecord()->seller_profit_amount ?? 0); $taxes = (float) ($getRecord()->tax_amount ?? 0); // now $total, $shipping, $taxes are floats/ints, safe to add $grand = (float) ($getRecord()->grand_total ?? ($total + $shipping + $taxes)); $net = (float) ($getRecord()->net_total ?? $grand); $advance = 0; // calculate package weight $packageWeight= $items->sum(function ($item) { return (float) ($item->productVariant?->weight ?? 0) * (int) $item->quantity; }); //comma separated tax names $orderTaxes = $getRecord()?->orderTaxes ?? collect(); $taxes_summary = $orderTaxes->map(function ($ot) { if ($ot->type === \App\Models\OrderTax::TYPE_PERCENTAGE) { return "{$ot->tax?->name} ({$ot->rate}% = PKR " . number_format($ot->amount, 2) . ")"; } return "{$ot->tax?->name} (PKR " . number_format($ot->rate, 2) . " = PKR " . number_format($ot->amount, 2) . ")"; })->join(', '); @endphp
Package Weight : {{ $packageWeight }} kg Total {{$items->sum(function ($item) { return $item->quantity; }) }} Qty PKR {{ number_format($total) }}
Shipping Charges PKR {{ number_format($shipping) }}
Seller Profit PKR {{ number_format($profit) }}
{{!empty($taxes_summary)?$taxes_summary:'Taxes'}} PKR {{ number_format($taxes) }}
Grand Total PKR {{ number_format($grand) }}
Net Total PKR {{ number_format($net) }}
Advance Received PKR {{ number_format($advance) }}