update error
All checks were successful
All checks were successful
This commit is contained in:
@@ -21,13 +21,13 @@ public function view(): View
|
|||||||
// SALES
|
// SALES
|
||||||
$dailySales = DB::table('sales')
|
$dailySales = DB::table('sales')
|
||||||
->select(
|
->select(
|
||||||
DB::raw('DATE(saleDate) as date'),
|
DB::raw('"saleDate"::date as date'),
|
||||||
DB::raw('SUM(actual_total_amount) as total_sales'),
|
DB::raw('SUM(actual_total_amount) as total_sales'),
|
||||||
DB::raw('SUM(lossProfit) as total_sale_income')
|
DB::raw('SUM("lossProfit") as total_sale_income')
|
||||||
)
|
)
|
||||||
->where('business_id', $businessId)
|
->where('business_id', $businessId)
|
||||||
->when($branchId, fn($q) => $q->where('branch_id', $branchId))
|
->when($branchId, fn($q) => $q->where('branch_id', $branchId))
|
||||||
->groupBy(DB::raw('DATE(saleDate)'))
|
->groupBy(DB::raw('"saleDate"::date'))
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
$sale_datas = $dailySales->map(fn($sale) => (object)[
|
$sale_datas = $dailySales->map(fn($sale) => (object)[
|
||||||
@@ -40,12 +40,12 @@ public function view(): View
|
|||||||
// INCOME
|
// INCOME
|
||||||
$dailyIncomes = DB::table('incomes')
|
$dailyIncomes = DB::table('incomes')
|
||||||
->select(
|
->select(
|
||||||
DB::raw('DATE(incomeDate) as date'),
|
DB::raw('"incomeDate"::date as date'),
|
||||||
DB::raw('SUM(amount) as total_incomes')
|
DB::raw('SUM(amount) as total_incomes')
|
||||||
)
|
)
|
||||||
->where('business_id', $businessId)
|
->where('business_id', $businessId)
|
||||||
->when($branchId, fn($q) => $q->where('branch_id', $branchId))
|
->when($branchId, fn($q) => $q->where('branch_id', $branchId))
|
||||||
->groupBy(DB::raw('DATE(incomeDate)'))
|
->groupBy(DB::raw('"incomeDate"::date'))
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
$income_datas = $dailyIncomes->map(fn($income) => (object)[
|
$income_datas = $dailyIncomes->map(fn($income) => (object)[
|
||||||
@@ -71,24 +71,24 @@ public function view(): View
|
|||||||
if (moduleCheck('HrmAddon')) {
|
if (moduleCheck('HrmAddon')) {
|
||||||
$dailyPayrolls = DB::table('payrolls')
|
$dailyPayrolls = DB::table('payrolls')
|
||||||
->select(
|
->select(
|
||||||
DB::raw('DATE(date) as date'),
|
DB::raw('"date"::date as date'),
|
||||||
DB::raw('SUM(amount) as total_payrolls')
|
DB::raw('SUM(amount) as total_payrolls')
|
||||||
)
|
)
|
||||||
->where('business_id', $businessId)
|
->where('business_id', $businessId)
|
||||||
->when($branchId, fn($q) => $q->where('branch_id', $branchId))
|
->when($branchId, fn($q) => $q->where('branch_id', $branchId))
|
||||||
->groupBy(DB::raw('DATE(date)'))
|
->groupBy(DB::raw('"date"::date'))
|
||||||
->get();
|
->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
// EXPENSES
|
// EXPENSES
|
||||||
$dailyExpenses = DB::table('expenses')
|
$dailyExpenses = DB::table('expenses')
|
||||||
->select(
|
->select(
|
||||||
DB::raw('DATE(expenseDate) as date'),
|
DB::raw('"expenseDate"::date as date'),
|
||||||
DB::raw('SUM(amount) as total_expenses_only')
|
DB::raw('SUM(amount) as total_expenses_only')
|
||||||
)
|
)
|
||||||
->where('business_id', $businessId)
|
->where('business_id', $businessId)
|
||||||
->when($branchId, fn($q) => $q->where('branch_id', $branchId))
|
->when($branchId, fn($q) => $q->where('branch_id', $branchId))
|
||||||
->groupBy(DB::raw('DATE(expenseDate)'))
|
->groupBy(DB::raw('"expenseDate"::date'))
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
$mergedExpenseData = collect();
|
$mergedExpenseData = collect();
|
||||||
|
|||||||
@@ -33,14 +33,14 @@ public function lossProfitDetails()
|
|||||||
$query->where('business_id', $businessId);
|
$query->where('business_id', $businessId);
|
||||||
})
|
})
|
||||||
->whereDate('created_at', '<', $today)
|
->whereDate('created_at', '<', $today)
|
||||||
->sum(DB::raw('productPurchasePrice * productStock'));
|
->sum(DB::raw('"productPurchasePrice" * "productStock"'));
|
||||||
|
|
||||||
// Closing stock (up to today) from stocks table
|
// Closing stock (up to today) from stocks table
|
||||||
$closing_stock_by_purchase = Stock::whereHas('product', function ($query) use ($businessId) {
|
$closing_stock_by_purchase = Stock::whereHas('product', function ($query) use ($businessId) {
|
||||||
$query->where('business_id', $businessId);
|
$query->where('business_id', $businessId);
|
||||||
})
|
})
|
||||||
->whereDate('created_at', '<=', $today)
|
->whereDate('created_at', '<=', $today)
|
||||||
->sum(DB::raw('productPurchasePrice * productStock'));
|
->sum(DB::raw('"productPurchasePrice" * "productStock"'));
|
||||||
|
|
||||||
$total_purchase_price = (clone $purchaseQuery)->sum('totalAmount');
|
$total_purchase_price = (clone $purchaseQuery)->sum('totalAmount');
|
||||||
$total_purchase_shipping_charge = (clone $purchaseQuery)->sum('shipping_charge');
|
$total_purchase_shipping_charge = (clone $purchaseQuery)->sum('shipping_charge');
|
||||||
@@ -59,13 +59,13 @@ public function lossProfitDetails()
|
|||||||
$query->where('business_id', $businessId);
|
$query->where('business_id', $businessId);
|
||||||
})
|
})
|
||||||
->whereDate('created_at', '<', $today)
|
->whereDate('created_at', '<', $today)
|
||||||
->sum(DB::raw('productSalePrice * productStock'));
|
->sum(DB::raw('"productSalePrice" * "productStock"'));
|
||||||
|
|
||||||
$closing_stock_by_sale = Stock::whereHas('product', function ($query) use ($businessId) {
|
$closing_stock_by_sale = Stock::whereHas('product', function ($query) use ($businessId) {
|
||||||
$query->where('business_id', $businessId);
|
$query->where('business_id', $businessId);
|
||||||
})
|
})
|
||||||
->whereDate('created_at', '<=', $today)
|
->whereDate('created_at', '<=', $today)
|
||||||
->sum(DB::raw('productSalePrice * productStock'));
|
->sum(DB::raw('"productSalePrice" * "productStock"'));
|
||||||
|
|
||||||
$total_sale_price = (clone $salesQuery)->sum('totalAmount');
|
$total_sale_price = (clone $salesQuery)->sum('totalAmount');
|
||||||
$total_sale_shipping_charge = (clone $salesQuery)->sum('shipping_charge');
|
$total_sale_shipping_charge = (clone $salesQuery)->sum('shipping_charge');
|
||||||
@@ -135,14 +135,14 @@ public function lossProfitFilter(Request $request)
|
|||||||
$q->where('business_id', $businessId);
|
$q->where('business_id', $businessId);
|
||||||
})
|
})
|
||||||
->whereDate('created_at', '<', $startDate)
|
->whereDate('created_at', '<', $startDate)
|
||||||
->sum(DB::raw('productPurchasePrice * productStock'));
|
->sum(DB::raw('"productPurchasePrice" * "productStock"'));
|
||||||
|
|
||||||
// Closing stock by purchase (up to end date)
|
// Closing stock by purchase (up to end date)
|
||||||
$closing_stock_by_purchase = Stock::whereHas('product', function ($q) use ($businessId) {
|
$closing_stock_by_purchase = Stock::whereHas('product', function ($q) use ($businessId) {
|
||||||
$q->where('business_id', $businessId);
|
$q->where('business_id', $businessId);
|
||||||
})
|
})
|
||||||
->whereDate('created_at', '<=', $endDate)
|
->whereDate('created_at', '<=', $endDate)
|
||||||
->sum(DB::raw('productPurchasePrice * productStock'));
|
->sum(DB::raw('"productPurchasePrice" * "productStock"'));
|
||||||
|
|
||||||
$total_purchase_price = (clone $purchaseQuery)->sum('totalAmount');
|
$total_purchase_price = (clone $purchaseQuery)->sum('totalAmount');
|
||||||
$total_purchase_shipping_charge = (clone $purchaseQuery)->sum('shipping_charge');
|
$total_purchase_shipping_charge = (clone $purchaseQuery)->sum('shipping_charge');
|
||||||
@@ -159,14 +159,14 @@ public function lossProfitFilter(Request $request)
|
|||||||
$q->where('business_id', $businessId);
|
$q->where('business_id', $businessId);
|
||||||
})
|
})
|
||||||
->whereDate('created_at', '<', $startDate)
|
->whereDate('created_at', '<', $startDate)
|
||||||
->sum(DB::raw('productSalePrice * productStock'));
|
->sum(DB::raw('"productSalePrice" * "productStock"'));
|
||||||
|
|
||||||
// Closing stock by sale
|
// Closing stock by sale
|
||||||
$closing_stock_by_sale = Stock::whereHas('product', function ($q) use ($businessId) {
|
$closing_stock_by_sale = Stock::whereHas('product', function ($q) use ($businessId) {
|
||||||
$q->where('business_id', $businessId);
|
$q->where('business_id', $businessId);
|
||||||
})
|
})
|
||||||
->whereDate('created_at', '<=', $endDate)
|
->whereDate('created_at', '<=', $endDate)
|
||||||
->sum(DB::raw('productSalePrice * productStock'));
|
->sum(DB::raw('"productSalePrice" * "productStock"'));
|
||||||
|
|
||||||
$total_sale_price = (clone $salesQuery)->sum('totalAmount');
|
$total_sale_price = (clone $salesQuery)->sum('totalAmount');
|
||||||
$total_sale_shipping_charge = (clone $salesQuery)->sum('shipping_charge');
|
$total_sale_shipping_charge = (clone $salesQuery)->sum('shipping_charge');
|
||||||
|
|||||||
@@ -90,14 +90,14 @@ public function index(Request $request)
|
|||||||
if (moduleCheck('HrmAddon')) {
|
if (moduleCheck('HrmAddon')) {
|
||||||
$payrollQuery = DB::table('payrolls')
|
$payrollQuery = DB::table('payrolls')
|
||||||
->select(
|
->select(
|
||||||
DB::raw('DATE(date) as date'),
|
DB::raw('"date"::date as date'),
|
||||||
DB::raw('SUM(amount) as total_payrolls')
|
DB::raw('SUM(amount) as total_payrolls')
|
||||||
)
|
)
|
||||||
->where('business_id', $businessId)
|
->where('business_id', $businessId)
|
||||||
->when($branchId, fn ($q) =>
|
->when($branchId, fn ($q) =>
|
||||||
$q->where('branch_id', $branchId)
|
$q->where('branch_id', $branchId)
|
||||||
)
|
)
|
||||||
->groupBy(DB::raw('DATE(date)'));
|
->groupBy(DB::raw('"date"::date'));
|
||||||
|
|
||||||
$this->applyDateFilter($payrollQuery, $duration, 'date', $request->from_date, $request->to_date);
|
$this->applyDateFilter($payrollQuery, $duration, 'date', $request->from_date, $request->to_date);
|
||||||
$dailyPayrolls = $payrollQuery->get();
|
$dailyPayrolls = $payrollQuery->get();
|
||||||
@@ -262,12 +262,12 @@ public function exportPdf()
|
|||||||
if (moduleCheck('HrmAddon')) {
|
if (moduleCheck('HrmAddon')) {
|
||||||
$dailyPayrolls = DB::table('payrolls')
|
$dailyPayrolls = DB::table('payrolls')
|
||||||
->select(
|
->select(
|
||||||
DB::raw('DATE(date) as date'),
|
DB::raw('"date"::date as date'),
|
||||||
DB::raw('SUM(amount) as total_payrolls')
|
DB::raw('SUM(amount) as total_payrolls')
|
||||||
)
|
)
|
||||||
->where('business_id', $businessId)
|
->where('business_id', $businessId)
|
||||||
->when($branchId, fn ($q) => $q->where('branch_id', $branchId))
|
->when($branchId, fn ($q) => $q->where('branch_id', $branchId))
|
||||||
->groupBy(DB::raw('DATE(date)'))
|
->groupBy(DB::raw('"date"::date'))
|
||||||
->get();
|
->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ public function index()
|
|||||||
// Calculate totals for all stock
|
// Calculate totals for all stock
|
||||||
$total_stock_value = Stock::whereHas('product', function ($q) use ($businessId) {
|
$total_stock_value = Stock::whereHas('product', function ($q) use ($businessId) {
|
||||||
$q->where('business_id', $businessId);
|
$q->where('business_id', $businessId);
|
||||||
})->sum(DB::raw('productPurchasePrice * productStock'));
|
})->sum(DB::raw('"productPurchasePrice" * "productStock"'));
|
||||||
|
|
||||||
$total_qty = Stock::whereHas('product', function ($q) use ($businessId) {
|
$total_qty = Stock::whereHas('product', function ($q) use ($businessId) {
|
||||||
$q->where('business_id', $businessId);
|
$q->where('business_id', $businessId);
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ public function index(Request $request)
|
|||||||
|
|
||||||
$total_stock_value = Stock::whereHas('product', function ($q) use ($businessId) {
|
$total_stock_value = Stock::whereHas('product', function ($q) use ($businessId) {
|
||||||
$q->where('business_id', $businessId);
|
$q->where('business_id', $businessId);
|
||||||
})->sum(DB::raw('productPurchasePrice * productStock'));
|
})->sum(DB::raw('"productPurchasePrice" * "productStock"'));
|
||||||
|
|
||||||
$total_qty = Stock::whereHas('product', function ($q) use ($businessId) {
|
$total_qty = Stock::whereHas('product', function ($q) use ($businessId) {
|
||||||
$q->where('business_id', $businessId);
|
$q->where('business_id', $businessId);
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ public function index(Request $request)
|
|||||||
$query->when(request()->has('branch_id'), function ($q) {
|
$query->when(request()->has('branch_id'), function ($q) {
|
||||||
$q->whereColumn('stocks.branch_id', 'warehouses.branch_id');
|
$q->whereColumn('stocks.branch_id', 'warehouses.branch_id');
|
||||||
});
|
});
|
||||||
}], DB::raw('productStock * productPurchasePrice'))
|
}], DB::raw('"productStock" * "productPurchasePrice"'))
|
||||||
->when($request->branch_id, function ($q) use ($request) {
|
->when($request->branch_id, function ($q) use ($request) {
|
||||||
$q->where('branch_id', $request->branch_id);
|
$q->where('branch_id', $request->branch_id);
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -93,6 +93,10 @@ public function store(Request $request)
|
|||||||
]);
|
]);
|
||||||
} catch (\Throwable $th) {
|
} catch (\Throwable $th) {
|
||||||
DB::rollBack();
|
DB::rollBack();
|
||||||
|
\Log::error('Registration Error: ' . $th->getMessage(), [
|
||||||
|
'exception' => $th,
|
||||||
|
'email' => $request->email
|
||||||
|
]);
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'message' => 'Something went wrong. Please contact the admin.',
|
'message' => 'Something went wrong. Please contact the admin.',
|
||||||
], 403);
|
], 403);
|
||||||
|
|||||||
Reference in New Issue
Block a user