Untitled
unknown
plain_text
2 years ago
1.0 kB
9
Indexable
$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;
$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,
// ]);Editor is loading...