Spreadsheet
This commit is contained in:
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by Pensare Software.
|
||||
* User: Theo Weijmer
|
||||
* Date: 29/07/2018
|
||||
* Time: 14:23
|
||||
*/
|
||||
|
||||
class MonthForecast {
|
||||
|
||||
private $year;
|
||||
private $project;
|
||||
private $forecast;
|
||||
private $customer;
|
||||
private $projectname;
|
||||
private $forecastMonths;
|
||||
private $projectDetails;
|
||||
private $invoiceForecast;
|
||||
|
||||
public function __construct( InvoiceForecast $invoiceForecast, $project, $year )
|
||||
{
|
||||
$this->project = $project;
|
||||
$this->invoiceForecast = $invoiceForecast;
|
||||
$this->year = $year;
|
||||
|
||||
$this->handle();
|
||||
}
|
||||
|
||||
public function getProjectDetails()
|
||||
{
|
||||
return $this->projectDetails;
|
||||
}
|
||||
|
||||
private function handle()
|
||||
{
|
||||
$this->setProjectname();
|
||||
|
||||
$this->setCustomer();
|
||||
|
||||
$this->setInitialsForecastMonths();
|
||||
|
||||
$this->loopForecasts();
|
||||
|
||||
$this->setProjectDetails();
|
||||
}
|
||||
|
||||
private function setProjectname()
|
||||
{
|
||||
$this->projectname = $this->project->projectname . '(' . $this->project->projectnumber . ')';
|
||||
}
|
||||
|
||||
private function setCustomer()
|
||||
{
|
||||
$this->customer = $this->project->customer->name;
|
||||
}
|
||||
|
||||
private function setInitialsForecastMonths()
|
||||
{
|
||||
for ( $i = 1; $i <= 12; $i ++ )
|
||||
{
|
||||
$this->forecastMonths[ $i ] = ['forecastamount' => 0];
|
||||
}
|
||||
}
|
||||
|
||||
private function loopForecasts()
|
||||
{
|
||||
foreach ( $this->project->forecasts as $this->forecast )
|
||||
{
|
||||
$this->setMonthForecast();
|
||||
}
|
||||
}
|
||||
|
||||
private function setMonthForecast()
|
||||
{
|
||||
if ( $this->forecast->year == $this->year )
|
||||
$this->forecastMonths[ $this->forecast->month_id ]['forecastamount'] += $this->forecast->forecastamount;
|
||||
}
|
||||
|
||||
private function setProjectDetails()
|
||||
{
|
||||
$this->projectDetails = [
|
||||
'projectname' => $this->projectname,
|
||||
'customer' => $this->customer,
|
||||
'needInvoice' => number_format( $this->invoiceForecast->getNeedInvoice(), 0, ',', '.' ),
|
||||
'forecastOtherYears' => number_format( $this->invoiceForecast->getForecastOtherYear(), 0, ',', '.' ),
|
||||
'forecastRemaining' => number_format( $this->invoiceForecast->getForecastRemaining(), 0, ',', '.' ),
|
||||
'forecastMonths' => $this->forecastMonths
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user