Diversen dashboard

This commit is contained in:
2020-01-31 15:56:51 +01:00
parent 63ac729032
commit 10d991f4c7
6 changed files with 104 additions and 26 deletions
@@ -42,23 +42,25 @@ class DashboardController extends MY_Controller {
$available += $project['budgetAvailable'];
}
$outstandings = $this->Invoices_model->getTotalsOutstandingPerProject(FALSE);
$outstandings = $this->Invoices_model->getTotalsOutstandingPerProject( FALSE );
$this->json( [
'totalOwp' => round( $totalOwp, 0 ),
'revenuesThisYear' => $this->getRevenuesThisYear(),
'revenuesThisYear' => $this->getRevenuesThisYear(),
'currentFinancialYear' => round( $currentFinancialYear ),
'owpNextyear' => round( $totalOwp - $currentFinancialYear ),
'revenuesNextyear' => round( $currentFinancialYear / 0.4 ),
'totalRevenues' => round( $totalRevenues ),
'outstandings' => $this->getInvoiceOverview(),
'costsToPay' => $this->reservations()
'outstandings' => $this->getInvoiceOverview(),
'costsToPay' => $this->reservations(),
'invoiced' => $this->getInvoiced(),
'totalChance' => $this->getChanceRevenues()
] );
}
private function getRevenuesThisYear()
{
$year = date('Y');
$year = date( 'Y' );
$sql = QEmployeeHours::fire( FALSE, $year );
$query = $this->db->query( $sql );
@@ -66,7 +68,7 @@ class DashboardController extends MY_Controller {
$result = $query->result();
$totalRevenue = 0;
foreach($result as $revenue)
foreach ( $result as $revenue )
{
$totalRevenue += $revenue->revenues;
}
@@ -74,13 +76,13 @@ class DashboardController extends MY_Controller {
return $totalRevenue;
}
private function getInvoiceOverview( )
private function getInvoiceOverview()
{
$projects = Project::whereArchive('F')->get();
$projects = Project::whereArchive( 'F' )->get();
foreach($projects as $project)
foreach ( $projects as $project )
{
$invoiceOverview = new InvoiceOverview( $project, date('Y') );
$invoiceOverview = new InvoiceOverview( $project, date( 'Y' ) );
$invoiceOverviews[] = $invoiceOverview->getProjectDetails();
}
@@ -97,7 +99,7 @@ class DashboardController extends MY_Controller {
$results = $query->result();
$costsToPay = 0;
foreach($results as $result)
foreach ( $results as $result )
{
$toPay = $result->other_revenue - $result->costs + $result->saldoToPay;
$costsToPay += $toPay;
@@ -106,4 +108,33 @@ class DashboardController extends MY_Controller {
return $costsToPay;
}
private function getInvoiced()
{
$invoiced = Invoice::getInvoiced( date( 'Y' ) );
$totalInvoiced = 0;
foreach ( $invoiced as $invoice )
{
$totalInvoiced += ROUND( ( $invoice->invoiceamount * 1.21 ), 0 );
}
return $totalInvoiced;
}
private function getChanceRevenues()
{
$offers = Offer::getAllOffers( FALSE, 'F', '', 'id', 'desc' );
$totalChance = 0;
foreach ( $offers as $offer )
{
$totalChance +=
ROUND(
( $offer->own_revenue + $offer->other_revenue ) *
( $offer->acceptance_chance / 100 ), 0 );
}
return $totalChance;
}
}
+1 -1
View File
@@ -65,7 +65,7 @@ class Invoice extends BaseModel {
public static function getInvoiced( $year )
{
$invoiced = Invoice::selectRaw('invoicenumber, PRJ.projectname, projectnumber, CUS.name, invoicedate, CUS.name, invoiceamount')
$invoiced = Invoice::selectRaw('invoicenumber, PRJ.projectname, projectnumber, CUS.name, invoicedate, CUS.name, ROUND(invoiceamount, 0) AS invoiceamount')
->join('projects AS PRJ', 'PRJ.id', '=', 'invoices.project_id')
->join('customers AS CUS', 'CUS.id', '=', 'PRJ.customer_id')
->whereRaw("DATE_FORMAT(invoicedate, '%Y') = {$year}")
+21 -6
View File
@@ -34,15 +34,19 @@
<div class="db-panel-body" data-bind="width:owp">
<br>
<h4>
<span class="db-panel-label">Omzet komende jaar:</span>
<span class="db-panel-label">Omzet totaal gerealiseerd lopend jaar:</span>
<span class="db-panel-data"><strong data-bind="text:revenuesThisYear"></strong></span>
</h4>
<h4>
<span class="db-panel-label">Minimum omzet lopend jaar:</span>
<span class="db-panel-data"><strong data-bind="text:minimumRevenues"></strong></span>
</h4>
<h4>
<span class="db-panel-label">Verwachte omzet komende 12 maanden:</span>
<span class="db-panel-data">
<strong data-bind="text:revenuesNextyear"></strong>
</span>
</h4>
<h4>
<span class="db-panel-label">Omzet totaal gerealiseerd lopend jaar:</span>
<span class="db-panel-data"><strong data-bind="text:revenuesThisYear"></strong></span>
</h4>
</div>
</div>
</div>
@@ -92,6 +96,13 @@
</div>
<div class="db-panel-body" data-bind="width:owp">
<br>
<h4>
<span class="db-panel-label">Verstuurde facturen lopende jaar (incl btw):</span>
<span class="db-panel-data">
<strong data-bind="text:invoiced">
</strong>
</span>
</h4>
<h4>
<span class="db-panel-label">Openstaande facturen (incl btw):</span>
<span class="db-panel-data">
@@ -116,13 +127,17 @@
<div class="db-panel-body" data-bind="width:owp">
<br>
<h4>
<span class="db-panel-label">Kosten derden (excl btw):</span>
<span class="db-panel-label">Kosten derden (incl btw):</span>
<span class="db-panel-data"><strong data-bind="text:openCosts"></strong></span>
</h4>
<h4>
<span class="db-panel-label">Saldo inkomsten (excl btw):</span>
<span class="db-panel-data"><strong data-bind="text:revenues"></strong></span>
</h4>
<h4>
<span class="db-panel-label">(eigen) omzet * kans (excl btw):</span>
<span class="db-panel-data"><strong data-bind="text:totalChance"></strong></span>
</h4>
<!-- <h4>-->
<!-- <span class="db-panel-label">Omzet lopend jaar (excl btw):</span>-->
<!-- <span class="db-panel-data"><strong data-bind="text:revenueCurrentYear"></strong></span>-->
@@ -51,6 +51,20 @@
</td>
</tr>
</tbody>
<tfoot>
<tr>
<th colspan="4" class="align-right">Totaal</th>
<th class="align-right">
<span data-bind="text:totalInvoiced"></span>
</th>
<th class="align-right">
<span data-bind="text:totalVat"></span>
</th>
<th class="align-right">
<span data-bind="text:totalInclVat"></span>
</th>
</tr>
</tfoot>
</table>
</div>
</div>