Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
2.0 kB
1
Indexable
Never
/ $sales = DB::table('sale_details')
        //     ->select(DB::raw('SUM(total) as total_sale_amount, SUM(purchase_rate * quantity) as total_cost_of_sale, SUM(discount) as total_discount'))
        //     ->where('status', 'a')
        //     ->get();


        $query = SaleDetail::query();
        $query->select(DB::raw('SUM(total) as total_sale_amount, SUM(purchase_rate * quantity) as total_cost_of_sale, SUM(discount) as total_discount'));
        $r = $query->get();
        return ($r);
// $query = DB::table('sale_details');
        // $query->select(DB::raw('SUM(total) as total_sale_amount, SUM(purchase_rate * quantity) as total_cost_of_sale, SUM(discount) as total_discount'));
        // $query->where('status', 'a');
        // $result = $query->get();

        return $result;


        $query = DB::table('node');
            if ($published == true)
                $query->where('published', '=', 1);
            if (isset($year))
                $query->where('year', '>', $ye
//
--------------------------------------
$query = SaleDetail::query();
        $query->select(DB::raw('SUM(total) as total_sale_amount, SUM(purchase_rate * quantity) as total_cost_of_sale, SUM(discount) as total_discount'));
        $r = $query->get();
        return ($r);
Azhar Ullah10:57 AM
$gross_profit = $sales[0]->total_sale_amount - $sales[0]->total_cost_of_sale - $sales[0]->total_discount;

        return $gross_profit;
// $expense = DB::table('expenses')
        //     ->select('sum(total) as total_expense')
        //     ->where('status', 'a')
        //     ->get();
// $net_profit = $gross_profit - $expense[0]->total_expense;
        // return Response::json([
        //     'total_sale_amount' => $sales[0]->total_sale_amount,
        //     'total_cost_of_sale' => $sales[0]->total_cost_of_sale,
        //     'total_discount' => $sales[0]->total_discount,
        //     'total_sale_return' => $sale_return[0]->total_sale_return,
        // ]);