From d1f1deac35e2fab60a4bbd8a8e896a0e3483ad12 Mon Sep 17 00:00:00 2001 From: farhantock Date: Wed, 13 Dec 2023 21:48:39 +0700 Subject: [PATCH] update func getInvoiceOutstanding --- .../Controllers/DashboardBoDController.php | 22 +++++++++++++------ routes/web.php | 2 +- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/app/Http/Controllers/DashboardBoDController.php b/app/Http/Controllers/DashboardBoDController.php index 9b77805..cabc763 100644 --- a/app/Http/Controllers/DashboardBoDController.php +++ b/app/Http/Controllers/DashboardBoDController.php @@ -111,22 +111,30 @@ class DashboardBoDController extends Controller } // integrasi - public function getInvoiceOutstanding($year = '%') + public function getInvoiceOutstanding($year = '%', $company_id, $all_project, $hierarchy) { $year = $this->interpolateYear($year); - $projects = Project::where('mulai_proyek', 'like', $year) - /* ->orWhere('akhir_proyek', 'like', $year) */ - ->get(); + $projects = null; + if ($all_project) { + $projects = Project::where('mulai_proyek', 'like', $year) + ->where('company_id', $company_id) + ->get(); + } else { + $projects = Project::where('mulai_proyek', 'like', $year) + ->where('created_by_id', $hierarchy) + ->get(); + } + $return = []; foreach ($projects as $project) { $resp = null; if ($project->kode_sortname != "") { - $resp = $this->getInvoiceIntegration($project->kode_sortname); + // $resp = $this->getInvoiceIntegration($project->kode_sortname); array_push($return, [ 'project' => $project->nama, 'project_code' => $project->kode_sortname, - 'invoiced' => $resp->data->total_invoice_amount ?? 0, - 'paid' => $resp->data->total_invoice_paid_amount ?? 0, + 'invoiced' => 0, + 'paid' => 0, 'response' => $resp, ]); } diff --git a/routes/web.php b/routes/web.php index 77ce518..4d69afb 100644 --- a/routes/web.php +++ b/routes/web.php @@ -24,7 +24,7 @@ $router->group(['prefix' => 'api', 'middleware' => 'cors'], function () use ($ro $router->group(['middleware' => ['auth', 'cors']], function () use ($router) { $router->get('/dashboard/get-company-cashflow/{year}/{company_id}/{all_project}/{hierarchy}', 'DashboardBoDController@getCompanyCashFlow'); // project expenditure - $router->get('/dashboard/get-invoice-outstanding[/{year}]', 'DashboardBoDController@getInvoiceOutstanding'); // project invoice vs cash in + $router->get('/dashboard/get-invoice-outstanding/{year}/{company_id}/{all_project}/{hierarchy}', 'DashboardBoDController@getInvoiceOutstanding'); // project invoice vs cash in $router->get('/dashboard/get-total-project-per-schedule-health/{year}/{company_id}/{all_project}/{hierarchy}', 'DashboardBoDController@getTotalProjectPerScheduleHealth'); $router->get('/dashboard/get-total-project-per-budget-health/{year}/{company_id}/{all_project}/{hierarchy}', 'DashboardBoDController@getTotalProjectPerBudgetHealth'); $router->get('/dashboard/get-total-project-schedule-health-per-division/{year}/{company_id}/{all_project}/{hierarchy}', 'DashboardBoDController@getTotalProjectScheduleHealthPerDivision');