Spreadsheet
This commit is contained in:
@@ -59,26 +59,22 @@ class ReportsController extends MY_Controller {
|
||||
$this->json( $result );
|
||||
}
|
||||
|
||||
public function getInvoiceOverview( $year )
|
||||
public function getInvoiceOverview( $year = FALSE )
|
||||
{
|
||||
$sql = Qinvoiceoverview::fire( $year );
|
||||
$invoices = new Invoices( $year );
|
||||
|
||||
$query = $this->db->query( $sql );
|
||||
$invoiceReport = $invoices->getInvoiceReport();
|
||||
|
||||
$result = $query->result();
|
||||
$this->json( $invoiceReport );
|
||||
}
|
||||
|
||||
foreach ( $result as $project )
|
||||
{
|
||||
$sql = QinvoiceMonthOverview::fire( $project->id, $year );
|
||||
public function createInvoicesSpreadsheet( $year = FALSE )
|
||||
{
|
||||
$invoices = new Invoices( $year );
|
||||
|
||||
$query = $this->db->query( $sql );
|
||||
$invoiceReport = $invoices->getInvoiceReport();
|
||||
|
||||
$months = $query->result();
|
||||
|
||||
$project->months = $months;
|
||||
}
|
||||
|
||||
$this->json( $result );
|
||||
new InvoiceSpreadsheet($invoiceReport);
|
||||
}
|
||||
|
||||
public function saveCurrentFinnacialYear( $projectID )
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by Pensare Software.
|
||||
* User: Theo Weijmer
|
||||
* Date: 29/07/2018
|
||||
* Time: 20:40
|
||||
*/
|
||||
|
||||
class InvoiceSheet {
|
||||
|
||||
const HEADERS = [
|
||||
'A' => 'project',
|
||||
'B' => 'klant',
|
||||
'C' => 'Totaal te factureren excl. btw',
|
||||
'D' => 'Totaal te factureren incl. btw',
|
||||
'E' => 'Gefactureerd overige jaren incl. btw',
|
||||
'F' => 'Gefactureerd lopende boekjaar incl. btw',
|
||||
'G' => 'Gefactureerd totaal incl. btw',
|
||||
'H' => 'Nog te factureren incl. btw'
|
||||
];
|
||||
|
||||
private $invoiceOverview;
|
||||
private $sheet;
|
||||
private $row;
|
||||
|
||||
public function __construct( $invoiceOverview, $sheet )
|
||||
{
|
||||
$this->invoiceOverview = $invoiceOverview;
|
||||
$this->sheet = $sheet;
|
||||
|
||||
$this->handle();
|
||||
}
|
||||
|
||||
private function handle()
|
||||
{
|
||||
$this->setHeader();
|
||||
|
||||
$this->setBody();
|
||||
|
||||
$this->setTotals();
|
||||
}
|
||||
|
||||
private function setHeader()
|
||||
{
|
||||
foreach ( self::HEADERS as $cell => $header )
|
||||
{
|
||||
$this->sheet->setCellValue( $cell . '1', $header );
|
||||
$this->sheet->getColumnDimension( $cell )->setAutoSize( TRUE );
|
||||
}
|
||||
}
|
||||
|
||||
private function setBody()
|
||||
{
|
||||
$this->row = 2;
|
||||
foreach ( $this->invoiceOverview AS $project )
|
||||
{
|
||||
$this->sheet->setCellValue( 'A' . $this->row, $project['projectname'] );
|
||||
$this->sheet->setCellValue( 'B' . $this->row, $project['customer'] );
|
||||
$this->sheet->setCellValue( 'C' . $this->row, str_replace( '.', '', $project['totalToInvoicingExcl'] ) );
|
||||
$this->sheet->setCellValue( 'D' . $this->row, str_replace( '.', '', $project['totalToInvoicingIncl'] ) );
|
||||
$this->sheet->setCellValue( 'E' . $this->row, str_replace( '.', '', $project['totalInvoicedOtherYears'] ) );
|
||||
$this->sheet->setCellValue( 'F' . $this->row, str_replace( '.', '', $project['totalInvoicedThisYear'] ) );
|
||||
$this->sheet->setCellValue( 'G' . $this->row, str_replace( '.', '', $project['invoicesTotal'] ) );
|
||||
$this->sheet->setCellValue( 'H' . $this->row, str_replace( '.', '', $project['needInvoice'] ) );
|
||||
|
||||
$this->row ++;
|
||||
}
|
||||
}
|
||||
|
||||
private function setTotals()
|
||||
{
|
||||
$lastRow = $this->row - 1;
|
||||
$this->sheet->setCellValue( 'C' . $this->row, '=SUM(C2:C' . $lastRow . ')' );
|
||||
$this->sheet->setCellValue( 'D' . $this->row, '=SUM(D2:D' . $lastRow . ')' );
|
||||
$this->sheet->setCellValue( 'E' . $this->row, '=SUM(E2:E' . $lastRow . ')' );
|
||||
$this->sheet->setCellValue( 'F' . $this->row, '=SUM(F2:F' . $lastRow . ')' );
|
||||
$this->sheet->setCellValue( 'G' . $this->row, '=SUM(G2:G' . $lastRow . ')' );
|
||||
$this->sheet->setCellValue( 'H' . $this->row, '=SUM(H2:H' . $lastRow . ')' );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by Pensare Software.
|
||||
* User: Theo Weijmer
|
||||
* Date: 29/07/2018
|
||||
* Time: 20:04
|
||||
*/
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
|
||||
|
||||
class InvoiceSpreadsheet {
|
||||
|
||||
private $invoiceReport;
|
||||
private $spreadsheet;
|
||||
private $invoiceSheet;
|
||||
private $fullpathname;
|
||||
private $filename;
|
||||
private $ci;
|
||||
|
||||
public function __construct( $invoiceReport )
|
||||
{
|
||||
$this->ci =& get_instance();
|
||||
|
||||
$this->invoiceReport = $invoiceReport;
|
||||
|
||||
$this->ci->load->helper( 'download' );
|
||||
|
||||
$this->handle();
|
||||
}
|
||||
|
||||
private function handle()
|
||||
{
|
||||
$this->setSpreadsheet();
|
||||
|
||||
$this->setInvoiceSheet();
|
||||
|
||||
$this->setFilename();
|
||||
|
||||
$this->setFullPathname();
|
||||
|
||||
$this->createFile();
|
||||
|
||||
$this->downloadSpreadsheet();
|
||||
}
|
||||
|
||||
private function setSpreadsheet()
|
||||
{
|
||||
$this->spreadsheet = new Spreadsheet();
|
||||
}
|
||||
|
||||
private function setInvoiceSheet()
|
||||
{
|
||||
$invoiceSheet = new Worksheet( $this->spreadsheet, 'Facturen' );
|
||||
|
||||
$this->invoiceSheet =
|
||||
$this->spreadsheet->addSheet( $invoiceSheet );
|
||||
|
||||
new InvoiceSheet( $this->invoiceReport['invoiceOverview'], $this->invoiceSheet );
|
||||
}
|
||||
|
||||
private function setFilename()
|
||||
{
|
||||
$this->filename = 'facturen' . date( 'YmdHis' ) . '.xlsx';
|
||||
}
|
||||
|
||||
private function setFullPathname()
|
||||
{
|
||||
$this->fullpathname = MYROOTPATH . 'documents/spreadsheets/' . $this->filename;
|
||||
}
|
||||
|
||||
private function createFile()
|
||||
{
|
||||
$writer = new Xlsx( $this->spreadsheet );
|
||||
|
||||
$writer->save( $this->fullpathname );
|
||||
}
|
||||
|
||||
private function downloadSpreadsheet()
|
||||
{
|
||||
$data = file_get_contents( $this->fullpathname );
|
||||
|
||||
force_download( $this->filename, $data );
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by Pensare Software.
|
||||
* User: Theo Weijmer
|
||||
* Date: 29/07/2018
|
||||
* Time: 13:14
|
||||
*/
|
||||
|
||||
class InvoiceForecast {
|
||||
|
||||
private $year;
|
||||
private $project;
|
||||
private $customer;
|
||||
private $forecast;
|
||||
private $currentYear;
|
||||
private $projectname;
|
||||
private $needInvoice;
|
||||
private $projectDetails;
|
||||
private $forecastThisYear = 0;
|
||||
private $forecastRemaining;
|
||||
private $forecastOtherYears = 0;
|
||||
|
||||
public function __construct( $project, $needInvoice, $year )
|
||||
{
|
||||
$this->project = $project;
|
||||
$this->needInvoice = $needInvoice;
|
||||
$this->year = $year;
|
||||
|
||||
$this->handle();
|
||||
}
|
||||
|
||||
public function getProjectDetails()
|
||||
{
|
||||
return $this->projectDetails;
|
||||
}
|
||||
|
||||
public function getNeedInvoice()
|
||||
{
|
||||
return $this->needInvoice;
|
||||
}
|
||||
|
||||
public function getForecastOtherYear()
|
||||
{
|
||||
return $this->forecastOtherYears;
|
||||
}
|
||||
|
||||
public function getForecastRemaining()
|
||||
{
|
||||
return $this->forecastRemaining;
|
||||
}
|
||||
|
||||
private function handle()
|
||||
{
|
||||
$this->setCurrentyear();
|
||||
|
||||
$this->setProjectname();
|
||||
|
||||
$this->setCustomer();
|
||||
|
||||
$this->loopForecasts();
|
||||
|
||||
$this->setForecastRemaining();
|
||||
|
||||
$this->setProjectDetails();
|
||||
}
|
||||
|
||||
private function setCurrentyear()
|
||||
{
|
||||
$this->currentYear = date( 'Y' );
|
||||
}
|
||||
|
||||
private function setProjectname()
|
||||
{
|
||||
$this->projectname = $this->project->projectname . '(' . $this->project->projectnumber . ')';
|
||||
}
|
||||
|
||||
private function setCustomer()
|
||||
{
|
||||
$this->customer = $this->project->customer->name;
|
||||
}
|
||||
|
||||
private function loopForecasts()
|
||||
{
|
||||
if ( is_null( $this->project->forecasts ) ) return $this->forecastThisYear = 0;
|
||||
|
||||
foreach ( $this->project->forecasts as $this->forecast )
|
||||
{
|
||||
$this->setForecastThisYear();
|
||||
|
||||
$this->setForecastOtherYears();
|
||||
}
|
||||
}
|
||||
|
||||
private function setForecastThisYear()
|
||||
{
|
||||
if ( $this->forecast->year == $this->year )
|
||||
$this->forecastThisYear += $this->forecast->forecastamount;
|
||||
}
|
||||
|
||||
private function setForecastOtherYears()
|
||||
{
|
||||
if ( $this->forecast->year != $this->year )
|
||||
$this->forecastOtherYears += $this->forecast->forecastamount;
|
||||
}
|
||||
|
||||
private function setForecastRemaining()
|
||||
{
|
||||
$this->forecastRemaining =
|
||||
$this->needInvoice - $this->forecastThisYear - $this->forecastOtherYears;
|
||||
}
|
||||
|
||||
private function setProjectDetails()
|
||||
{
|
||||
$this->projectDetails = [
|
||||
'projectname' => $this->projectname,
|
||||
'customer' => $this->customer,
|
||||
'needInvoice' => number_format( $this->needInvoice, 0, ',', '.' ),
|
||||
'forecastThisYear' => number_format( $this->forecastThisYear, 0, ',', '.' ),
|
||||
'forecastOtherYears' => number_format( $this->forecastOtherYears, 0, ',', '.' ),
|
||||
'forecastRemaining' => number_format( $this->forecastRemaining, 0, ',', '.' ),
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by Pensare Software.
|
||||
* User: Theo Weijmer
|
||||
* Date: 29/07/2018
|
||||
* Time: 10:29
|
||||
*/
|
||||
|
||||
class InvoiceOverview {
|
||||
|
||||
private $project;
|
||||
private $currentYear;
|
||||
private $projectname;
|
||||
private $customer;
|
||||
private $totalToInvoicingExcl;
|
||||
private $totalToInvoicingIncl;
|
||||
private $totalInvoicedOtherYears;
|
||||
private $totalInvoicedThisYear;
|
||||
private $invoicesTotal;
|
||||
private $needInvoice;
|
||||
private $projectDetails;
|
||||
|
||||
public function __construct( $project )
|
||||
{
|
||||
$this->project = $project;
|
||||
|
||||
$this->handle();
|
||||
}
|
||||
|
||||
public function getProjectDetails()
|
||||
{
|
||||
return $this->projectDetails;
|
||||
}
|
||||
|
||||
public function getNeedinvoice( )
|
||||
{
|
||||
return $this->needInvoice;
|
||||
}
|
||||
|
||||
private function handle()
|
||||
{
|
||||
$this->setCurrentyear();
|
||||
|
||||
$this->setProjectname();
|
||||
|
||||
$this->setCustomer();
|
||||
|
||||
$this->setTotalToInvoicingExcl();
|
||||
|
||||
$this->setTotalToInvoicingIncl();
|
||||
|
||||
$this->setTotalInvoicedOtherYears();
|
||||
|
||||
$this->setTotalInvoicedThisYear();
|
||||
|
||||
$this->setInvoicesTotal();
|
||||
|
||||
$this->setNeedInvoice();
|
||||
|
||||
$this->setProjectDetails();
|
||||
}
|
||||
|
||||
private function setCurrentyear()
|
||||
{
|
||||
$this->currentYear = date( 'Y' );
|
||||
}
|
||||
|
||||
private function setProjectname()
|
||||
{
|
||||
$this->projectname = $this->project->projectname . '(' . $this->project->projectnumber . ')';
|
||||
}
|
||||
|
||||
private function setCustomer()
|
||||
{
|
||||
$this->customer = $this->project->customer->name;
|
||||
}
|
||||
|
||||
private function setTotalToInvoicingExcl()
|
||||
{
|
||||
$offer = $this->project->offer;
|
||||
|
||||
$this->totalToInvoicingExcl =
|
||||
$offer->own_revenue + $offer->other_revenue + $offer->costs;
|
||||
}
|
||||
|
||||
private function setTotalToInvoicingIncl()
|
||||
{
|
||||
$this->totalToInvoicingIncl =
|
||||
$this->totalToInvoicingExcl * ( 1 + ( $this->project->vat->vatrate / 100 ) );
|
||||
}
|
||||
|
||||
private function setTotalInvoicedOtherYears()
|
||||
{
|
||||
$this->totalInvoicedOtherYears =
|
||||
Invoice::invoicePerYear( $this->project->id, $this->currentYear, FALSE );
|
||||
}
|
||||
|
||||
private function setTotalInvoicedThisYear()
|
||||
{
|
||||
$this->totalInvoicedThisYear =
|
||||
Invoice::invoicePerYear( $this->project->id, $this->currentYear, TRUE );
|
||||
}
|
||||
|
||||
private function setInvoicesTotal()
|
||||
{
|
||||
$this->invoicesTotal =
|
||||
$this->totalInvoicedOtherYears + $this->totalInvoicedThisYear;
|
||||
}
|
||||
|
||||
private function setNeedInvoice()
|
||||
{
|
||||
$this->needInvoice =
|
||||
$this->totalToInvoicingIncl - $this->invoicesTotal;
|
||||
}
|
||||
|
||||
private function setProjectDetails()
|
||||
{
|
||||
$this->projectDetails = [
|
||||
'projectname' => $this->projectname,
|
||||
'customer' => $this->customer,
|
||||
'totalToInvoicingExcl' => number_format( $this->totalToInvoicingExcl, 0, ',', '.' ),
|
||||
'totalToInvoicingIncl' => number_format( $this->totalToInvoicingIncl, 0, ',', '.' ),
|
||||
'totalInvoicedOtherYears' => number_format( $this->totalInvoicedOtherYears, 0, ',', '.' ),
|
||||
'totalInvoicedThisYear' => number_format( $this->totalInvoicedThisYear, 0, ',', '.' ),
|
||||
'invoicesTotal' => number_format( $this->invoicesTotal, 0, ',', '.' ),
|
||||
'needInvoice' => number_format( $this->needInvoice, 0, ',', '.' )
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by Pensare Software.
|
||||
* User: Theo Weijmer
|
||||
* Date: 29/07/2018
|
||||
* Time: 10:19
|
||||
*/
|
||||
|
||||
class Invoices {
|
||||
|
||||
private $year;
|
||||
private $project;
|
||||
private $projects;
|
||||
private $monthPayment;
|
||||
private $monthPayments;
|
||||
private $monthForecast;
|
||||
private $monthForecasts;
|
||||
private $invoiceOverview;
|
||||
private $invoiceForecast;
|
||||
private $invoiceForecasts;
|
||||
private $invoiceOverviews = [];
|
||||
private $invoiceReport = [];
|
||||
|
||||
public function __construct( $year )
|
||||
{
|
||||
$this->year = $year;
|
||||
|
||||
$this->handle();
|
||||
}
|
||||
|
||||
public function getInvoiceReport()
|
||||
{
|
||||
return $this->invoiceReport;
|
||||
}
|
||||
|
||||
private function handle()
|
||||
{
|
||||
$this->setProjects();
|
||||
|
||||
$this->loopProjects();
|
||||
|
||||
$this->setInvoiceReport();
|
||||
}
|
||||
|
||||
private function setProjects()
|
||||
{
|
||||
$this->projects = Project::getProjectsForReport();
|
||||
}
|
||||
|
||||
private function loopProjects()
|
||||
{
|
||||
foreach ( $this->projects as $this->project )
|
||||
{
|
||||
$this->setInvoiceOverview();
|
||||
|
||||
$this->setInvoiceForecasts();
|
||||
|
||||
$this->setMonthForecasts();
|
||||
|
||||
$this->setMonthPayments();
|
||||
}
|
||||
}
|
||||
|
||||
private function setInvoiceOverview()
|
||||
{
|
||||
$this->invoiceOverview = new InvoiceOverview( $this->project, $this->year );
|
||||
|
||||
$this->invoiceOverviews[] = $this->invoiceOverview->getProjectDetails();
|
||||
}
|
||||
|
||||
private function setInvoiceForecasts()
|
||||
{
|
||||
$this->invoiceForecast =
|
||||
new InvoiceForecast( $this->project, $this->invoiceOverview->getNeedinvoice(), $this->year );
|
||||
|
||||
$this->invoiceForecasts[] = $this->invoiceForecast->getProjectDetails();
|
||||
}
|
||||
|
||||
public function setMonthForecasts()
|
||||
{
|
||||
$this->monthForecast =
|
||||
new MonthForecast( $this->invoiceForecast, $this->project, $this->year );
|
||||
|
||||
$this->monthForecasts[] = $this->monthForecast->getProjectDetails();
|
||||
}
|
||||
|
||||
public function setMonthPayments()
|
||||
{
|
||||
$this->monthPayment =
|
||||
new MonthPayments( $this->project, $this->year );
|
||||
|
||||
$this->monthPayments[] = $this->monthPayment->getProjectDetails();
|
||||
}
|
||||
|
||||
private function setInvoiceReport()
|
||||
{
|
||||
$this->invoiceReport = [
|
||||
'invoiceOverview' => $this->invoiceOverviews,
|
||||
'forecasts' => $this->invoiceForecasts,
|
||||
'monthForecasts' => $this->monthForecasts,
|
||||
'monthPayments' => $this->monthPayments
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by Pensare Software.
|
||||
* User: Theo Weijmer
|
||||
* Date: 29/07/2018
|
||||
* Time: 14:23
|
||||
*/
|
||||
|
||||
class MonthPayments {
|
||||
|
||||
private $year;
|
||||
private $project;
|
||||
private $payment;
|
||||
private $customer;
|
||||
private $projectname;
|
||||
private $monthPayments;
|
||||
private $projectDetails;
|
||||
private $totalProjectPayments;
|
||||
|
||||
public function __construct( $project, $year )
|
||||
{
|
||||
$this->project = $project;
|
||||
$this->year = $year;
|
||||
|
||||
$this->handle();
|
||||
}
|
||||
|
||||
public function getProjectDetails()
|
||||
{
|
||||
return $this->projectDetails;
|
||||
}
|
||||
|
||||
private function handle()
|
||||
{
|
||||
$this->setProjectname();
|
||||
|
||||
$this->setCustomer();
|
||||
|
||||
$this->setInitialsMonthPayments();
|
||||
|
||||
$this->loopPayments();
|
||||
|
||||
$this->setProjectDetails();
|
||||
}
|
||||
|
||||
private function setProjectname()
|
||||
{
|
||||
$this->projectname = $this->project->projectname . '(' . $this->project->projectnumber . ')';
|
||||
}
|
||||
|
||||
private function setCustomer()
|
||||
{
|
||||
$this->customer = $this->project->customer->name;
|
||||
}
|
||||
|
||||
private function setInitialsMonthPayments()
|
||||
{
|
||||
for ( $i = 1; $i <= 12; $i ++ )
|
||||
{
|
||||
$this->monthPayments[ $i ] = ['paymentamount' => 0];
|
||||
}
|
||||
}
|
||||
|
||||
private function loopPayments()
|
||||
{
|
||||
foreach ( $this->project->invoices as $invoice )
|
||||
{
|
||||
foreach($invoice->payments as $this->payment)
|
||||
{
|
||||
$this->setMonthPayments();
|
||||
|
||||
$this->setTotalProjectPayments();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function setMonthPayments()
|
||||
{
|
||||
$paymentYear = date( 'Y', strtotime( $this->payment->paymentdate ) );
|
||||
$paymentMonth = date( 'n', strtotime( $this->payment->paymentdate ) );
|
||||
|
||||
if ( $paymentYear == $this->year )
|
||||
$this->monthPayments[ $paymentMonth ]['paymentamount'] += $this->payment->paymentamount;
|
||||
}
|
||||
|
||||
private function setTotalProjectPayments()
|
||||
{
|
||||
$this->totalProjectPayments += $this->payment->paymentamount;
|
||||
}
|
||||
|
||||
private function setProjectDetails()
|
||||
{
|
||||
$this->projectDetails = [
|
||||
'projectname' => $this->projectname,
|
||||
'customer' => $this->customer,
|
||||
'monthPayments' => $this->monthPayments,
|
||||
'totalProjectPayments' => number_format( $this->totalProjectPayments, 0, ',', '.' )
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -24,6 +24,28 @@ class Invoice extends BaseModel {
|
||||
return $this->belongsTo( 'Vat' );
|
||||
}
|
||||
|
||||
public static function invoicePerYear( $projectID, $year, $thatYear = TRUE )
|
||||
{
|
||||
$invoices = Invoice::selectRAW( 'SUM(invoiceamount * ( 1 +(vatrate / 100))) AS invoicetotal' )
|
||||
->join( 'vats', 'vats.id', '=', 'invoices.vat_id' )
|
||||
->whereProjectId( $projectID );
|
||||
|
||||
if ( $thatYear )
|
||||
{
|
||||
$invoices = $invoices->whereRaw( "YEAR(invoicedate) = {$year}" );
|
||||
}
|
||||
else
|
||||
{
|
||||
$invoices = $invoices->whereRaw( "YEAR(invoicedate) != {$year}" );
|
||||
}
|
||||
|
||||
if ( $invoices->count() == 0 ) return 0;
|
||||
|
||||
$invoices = $invoices->first();
|
||||
|
||||
return $invoices->invoicetotal;
|
||||
}
|
||||
|
||||
public static function saveInvoice( $invoiceID, $invoice )
|
||||
{
|
||||
$invoice = (array) $invoice;
|
||||
|
||||
@@ -104,6 +104,13 @@ class Project extends BaseModel {
|
||||
return $projects;
|
||||
}
|
||||
|
||||
public static function getProjectsForReport()
|
||||
{
|
||||
$projects = self::getBaseProject()->get();
|
||||
|
||||
return $projects;
|
||||
}
|
||||
|
||||
public static function getBaseProject()
|
||||
{
|
||||
$project = Project::with( [
|
||||
@@ -115,6 +122,7 @@ class Project extends BaseModel {
|
||||
'projectemployees.user' => function ( $q ) {
|
||||
$q->selectRaw( "id, CONCAT(firstname, ' ', middlename, ' ', lastname) AS fullname" );
|
||||
}] )
|
||||
->with('vat')
|
||||
->with(['forecasts'])
|
||||
->with(['reservations'])
|
||||
->with( 'projectemployees.projecthours' )
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
<div id="INVOICEREPORT">
|
||||
<div class="row">
|
||||
<div class="col-md-1">
|
||||
<label>jaar</label>
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<input type="text" class="form-control" data-bind="textInput:selectedYear, event:{keyup:checkYear}">
|
||||
<div class="invalid-feedback" data-bind="visible: ! validYear()">geen geldig jaar</div>
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<button class="btn btn-success" data-bind="click:createSpreadsheet">
|
||||
maak spreadsheet
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="nav-tabs-horizontal">
|
||||
<ul class="nav nav-tabs nav-tabs-solid">
|
||||
<li class="nav-item"
|
||||
data-bind="click:setActivetab.bind($data, 'invoice')" style="z-index:10">
|
||||
<a class="nav-link"
|
||||
data-bind="css:{'active':invoiceTab() == 'invoice'}">facturen</a>
|
||||
</li>
|
||||
<li class="nav-item" data-bind="click:setActivetab.bind($data, 'forecast')" style="z-index:10">
|
||||
<a class="nav-link"
|
||||
data-bind="css:{'active':invoiceTab() == 'forecast'}">prognoses</a>
|
||||
</li>
|
||||
<li class="nav-item" data-bind="click:setActivetab.bind($data, 'monthforecast')" style="z-index:10">
|
||||
<a class="nav-link"
|
||||
data-bind="css:{'active':invoiceTab() == 'monthforecast'}">maand prognoses</a>
|
||||
</li>
|
||||
<li class="nav-item" data-bind="click:setActivetab.bind($data, 'monthpayments')" style="z-index:10">
|
||||
<a class="nav-link" data-bind="css:{'active':invoiceTab() == 'monthpayments'}">maand betalingen</a>
|
||||
</li>
|
||||
<li class="nav-item" data-bind="click:setActivetab.bind($data, 'externals')" style="z-index:10">
|
||||
<a class="nav-link" data-bind="css:{'active':invoiceTab() == 'externals'}">onderaannemers</a>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="tab-content">
|
||||
<div data-bind="visible:invoiceTab() == 'invoice'">
|
||||
<?php $this->load->view('reports/invoices/invoiceoverview_report'); ?>
|
||||
</div>
|
||||
<div id="invoiceforecast" data-bind="visible:invoiceTab() == 'forecast'">
|
||||
<?php $this->load->view('reports/invoices/invoiceforecast_report'); ?>
|
||||
</div>
|
||||
<div id="invoiceforecast" data-bind="visible:invoiceTab() == 'monthforecast'">
|
||||
<?php $this->load->view('reports/invoices/monthforecast_report'); ?>
|
||||
</div>
|
||||
<div id="invoiceforecast" data-bind="visible:invoiceTab() == 'monthpayments'">
|
||||
<?php $this->load->view('reports/invoices/monthpayment_report'); ?>
|
||||
</div>
|
||||
<div id="invoiceforecast" data-bind="visible:invoiceTab() == 'externals'">
|
||||
<?php $this->load->view('reports/invoices/contractors_report'); ?>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1,37 +0,0 @@
|
||||
<div id="OUTGOINGINVOICES">
|
||||
<div class="row">
|
||||
<div class="col-md-1">
|
||||
<label>jaar</label>
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<input type="text" class="form-control" data-bind="textInput:selectedYear, event:{keyup:checkYear}">
|
||||
<div class="invalid-feedback" data-bind="visible: ! validYear()">geen geldig jaar</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="nav-tabs-horizontal">
|
||||
<ul class="nav nav-tabs nav-tabs-solid">
|
||||
<li class="nav-item" data-bind="click:setActivetab.bind($data, 'invoice')" style="z-index:10">
|
||||
<a class="nav-link" data-bind="css:{'active':invoiceTab() == 'invoice'}">facturen</a>
|
||||
</li>
|
||||
<li class="nav-item" data-bind="click:setActivetab.bind($data, 'forecast')" style="z-index:10">
|
||||
<a class="nav-link" data-bind="css:{'active':invoiceTab() == 'forecast'}">prognoses</a>
|
||||
</li>
|
||||
<li class="nav-item" data-bind="click:setActivetab.bind($data, 'monthforecast')" style="z-index:10">
|
||||
<a class="nav-link" data-bind="css:{'active':invoiceTab() == 'monthforecast'}">maand prognoses</a>
|
||||
</li>
|
||||
<li class="nav-item" data-bind="click:setActivetab.bind($data, 'monthpayments')" style="z-index:10">
|
||||
<a class="nav-link" data-bind="css:{'active':invoiceTab() == 'monthpayments'}">maand betalingen</a>
|
||||
</li>
|
||||
<li class="nav-item" data-bind="click:setActivetab.bind($data, 'externals')" style="z-index:10">
|
||||
<a class="nav-link" data-bind="css:{'active':invoiceTab() == 'externals'}">onderaannemers</a>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="tab-content">
|
||||
<?php $this->load->view('reports/invoices/_invoicetable'); ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -44,7 +44,7 @@
|
||||
<script src="js/lib/modules/projects/employeehoursModule.js?version=<?= $this->version ?>"></script>
|
||||
<script src="js/lib/modules/reports/monthlyEmployeeHoursModule.js?version=<?= $this->version ?>"></script>
|
||||
<script src="js/lib/modules/reports/employeeHours.js?version=<?= $this->version ?>"></script>
|
||||
<script src="js/lib/modules/reports/outgoingInvoices.js?version=<?= $this->version ?>"></script>
|
||||
<script src="js/lib/modules/reports/invoicereport.js?version=<?= $this->version ?>"></script>
|
||||
<script src="js/lib/modules/reports/reservations.js?version=<?= $this->version ?>"></script>
|
||||
|
||||
<!-- ***********MODALS************* -->
|
||||
|
||||
@@ -1,218 +0,0 @@
|
||||
<table class="table table-condensed" style="font-size:0.8em;">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="rotate">
|
||||
<div><span>project</span></div>
|
||||
</th>
|
||||
<th class="rotate" width="150px">
|
||||
<div><span>klant</span></div>
|
||||
</th>
|
||||
<th class="rotate" width="100px">
|
||||
<div><span>status afgehandeld</span></div>
|
||||
</th>
|
||||
<!-- <th class="rotate">-->
|
||||
<!-- <div><span>projectleider</span></div>-->
|
||||
<!-- </th>-->
|
||||
<!-- ko if:$root.invoiceTab() == 'invoice' -->
|
||||
<th class="rotate">
|
||||
<div><span>te factureren(excl btw)</span></div>
|
||||
</th>
|
||||
<th class="rotate">
|
||||
<div><span>te factureren(incl btw)</span></div>
|
||||
</th>
|
||||
<th class="rotate">
|
||||
<div><span>gefactureerd <br />voorgaande jaren(incl btw)</span></div>
|
||||
</th>
|
||||
<th class="rotate">
|
||||
<div><span>gefactureerd <br />lopend jaar(incl btw)</span></div>
|
||||
</th>
|
||||
<th class="rotate">
|
||||
<div><span>totaal gefactureerd</span></div>
|
||||
</th>
|
||||
<th class="rotate">
|
||||
<div><span>betaald voorgaande jaren</span></div>
|
||||
</th>
|
||||
<th class="rotate">
|
||||
<div><span>betaald lopend jaar</span></div>
|
||||
</th>
|
||||
<th class="rotate">
|
||||
<div><span>totaal betaald</span></div>
|
||||
</th>
|
||||
<th class="rotate">
|
||||
<div><span>nog niet betaald</span></div>
|
||||
</th>
|
||||
<!-- /ko -->
|
||||
<!-- ko if:$root.invoiceTab() == 'forecast' -->
|
||||
<th class="rotate" width="100px">
|
||||
<div><span>nog te factureren (incl.btw)</span></div>
|
||||
</th>
|
||||
<th class="rotate" width="100px">
|
||||
<div><span>nog te factureren lopend jaar</span></div>
|
||||
</th>
|
||||
<th class="rotate" width="100px">
|
||||
<div><span>nog te factureren na lopend jaar</span></div>
|
||||
</th>
|
||||
<th class="rotate" width="100px">
|
||||
<div><span>nog te prognotiseren</span></div>
|
||||
</th>
|
||||
<!-- /ko -->
|
||||
<!-- ko if:$root.invoiceTab() == 'monthforecast' -->
|
||||
<th class="rotate">
|
||||
<div><span>te factureren(incl btw)</span></div>
|
||||
</th>
|
||||
<!-- ko foreach:months -->
|
||||
<th class="rotate"><div><span data-bind="text:month"></span></div></th>
|
||||
<!-- /ko -->
|
||||
<th class="rotate">
|
||||
<div><span>te factureren volgende jaren</span></div>
|
||||
</th>
|
||||
<!-- /ko -->
|
||||
<!-- ko if:$root.invoiceTab() == 'monthpayments' -->
|
||||
<!-- ko foreach:months -->
|
||||
<th class="rotate"><div><span data-bind="text:month"></span></div></th>
|
||||
<!-- /ko -->
|
||||
<!-- /ko -->
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<!-- ko foreach: projects -->
|
||||
<tr>
|
||||
<td><span data-bind="text:projectnumber"></span></td>
|
||||
<td><span data-bind="text:customername"></span></td>
|
||||
<td><span data-bind="text:statusProject == 'CLOSED' ? 'afgesloten' : 'open'"></span></td>
|
||||
<!-- <td><span data-bind="text:fullname"></span>-->
|
||||
</td>
|
||||
<!-- ko if:$root.invoiceTab() == 'invoice' -->
|
||||
<td class="align-right">
|
||||
<i class="icon fa-euro"></i>
|
||||
<span data-bind="text:revenues"></span>
|
||||
</td>
|
||||
<td class="align-right">
|
||||
<i class="icon fa-euro"></i>
|
||||
<span data-bind="text:totalInvoice"></span>
|
||||
</td>
|
||||
<td class="align-right">
|
||||
<i class="icon fa-euro"></i>
|
||||
<span data-bind="text:invoicedOtherYears"></span>
|
||||
</td>
|
||||
<td class="align-right">
|
||||
<i class="icon fa-euro"></i>
|
||||
<span data-bind="text:invoicedCurentYear"></span>
|
||||
</td>
|
||||
<th class="align-right focus-green">
|
||||
<i class="icon fa-euro"></i>
|
||||
<span data-bind="text:totalInvoiced"></span>
|
||||
</th>
|
||||
<td class="align-right">
|
||||
<i class="icon fa-euro"></i>
|
||||
<span data-bind="text:invoicedOtherYearsPayed"></span>
|
||||
</td>
|
||||
<td class="align-right">
|
||||
<i class="icon fa-euro"></i>
|
||||
<span data-bind="text:invoicedCurentYearPayed"></span>
|
||||
</td>
|
||||
<th class="align-right focus-green">
|
||||
<i class="icon fa-euro"></i>
|
||||
<span data-bind="text:totalInvoicedPayed"></span>
|
||||
</th>
|
||||
<th class="align-right">
|
||||
<i class="icon fa-euro"></i>
|
||||
<span data-bind="text:notPayed"></span>
|
||||
</th>
|
||||
<!-- /ko -->
|
||||
<!-- ko if:$root.invoiceTab() == 'forecast' -->
|
||||
<td class="align-right">
|
||||
<i class="icon fa-euro"></i>
|
||||
<span data-bind="text:toInvoice"></span>
|
||||
</td>
|
||||
<td class="align-right">
|
||||
<i class="icon fa-euro"></i>
|
||||
<span data-bind="text:currentforecast"></span>
|
||||
</td>
|
||||
<td class="align-right">
|
||||
<i class="icon fa-euro"></i>
|
||||
<span data-bind="text:otherforecast"></span>
|
||||
</td>
|
||||
<th class="align-right focus-green">
|
||||
<i class="icon fa-euro"></i>
|
||||
<span data-bind="text:missingForecast"></span>
|
||||
</th>
|
||||
<!-- /ko -->
|
||||
<!-- ko if:$root.invoiceTab() == 'monthforecast' -->
|
||||
<td class="align-right">
|
||||
<i class="icon fa-euro"></i>
|
||||
<span data-bind="text:toInvoice"></span>
|
||||
</td>
|
||||
<!-- ko foreach:months -->
|
||||
<td class="align-right">
|
||||
<span data-bind="text:forecastamount">
|
||||
</span>
|
||||
</td>
|
||||
<!-- /ko -->
|
||||
<td class="align-right">
|
||||
<i class="icon fa-euro"></i>
|
||||
<span data-bind="text:toInvoiceFuture">
|
||||
</span>
|
||||
</td>
|
||||
<!-- /ko -->
|
||||
<!-- ko if:$root.invoiceTab() == 'monthpayments' -->
|
||||
<!-- ko foreach:months -->
|
||||
<td class="align-right">
|
||||
<span data-bind="text:paymentamount">
|
||||
</span>
|
||||
</td>
|
||||
<!-- /ko -->
|
||||
<!-- /ko -->
|
||||
</tr>
|
||||
<!-- /ko -->
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<th colspan="3" class="align-right">
|
||||
totaal
|
||||
</th>
|
||||
<!-- ko if:$root.invoiceTab() == 'forecast' -->
|
||||
<th class="align-right">
|
||||
<i class="icon fa-euro"></i>
|
||||
<span data-bind="text:totalToInvoice"></span>
|
||||
</th>
|
||||
<th class="align-right">
|
||||
<i class="icon fa-euro"></i>
|
||||
<span data-bind="text:totalCurrentforecast"></span>
|
||||
</th>
|
||||
<th class="align-right">
|
||||
<i class="icon fa-euro"></i>
|
||||
<span data-bind="text:totalOtherforecast"></span>
|
||||
</th>
|
||||
<th class="align-right focus-green">
|
||||
<i class="icon fa-euro"></i>
|
||||
<span data-bind="text:totalMissingForecast"></span>
|
||||
</th>
|
||||
<!-- /ko -->
|
||||
<!-- ko if:$root.invoiceTab() == 'monthforecast' -->
|
||||
<th class="align-right">
|
||||
<i class="icon fa-euro"></i>
|
||||
<span data-bind="text:totalToInvoice"></span>
|
||||
</th>
|
||||
<!-- ko foreach:months -->
|
||||
<th class="align-right">
|
||||
<span data-bind="text:dbo.helpers.numberWithPoints($root['forecast' + month]())">
|
||||
</span>
|
||||
</th>
|
||||
<!-- /ko -->
|
||||
<th class="align-right">
|
||||
<i class="icon fa-euro"></i>
|
||||
<span data-bind="text:totalToInvoiceFuture"></span>
|
||||
</th>
|
||||
<!-- /ko -->
|
||||
<!-- ko if:$root.invoiceTab() == 'monthpayments' -->
|
||||
<!-- ko foreach:months -->
|
||||
<th class="align-right">
|
||||
<span data-bind="text:dbo.helpers.numberWithPoints($root['payment' + month]())">
|
||||
</span>
|
||||
</th>
|
||||
<!-- /ko -->
|
||||
<!-- /ko -->
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by Pensare Software.
|
||||
* User: Theo Weijmer
|
||||
* Date: 29/07/2018
|
||||
* Time: 13:21
|
||||
*/
|
||||
@@ -0,0 +1,55 @@
|
||||
<table class="table table-condensed" style="font-size:0.8em;">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="rotate">
|
||||
<div><span>project</span></div>
|
||||
</th>
|
||||
<th class="rotate">
|
||||
<div><span>klant</span></div>
|
||||
</th>
|
||||
<th class="rotate">
|
||||
<div><span>Nog te factureren<br />incl. btw</span></div>
|
||||
</th>
|
||||
<th class="rotate">
|
||||
<div><span>Nog te factureren<br />lopend boekjaar incl. btw</span></div>
|
||||
</th>
|
||||
<th class="rotate">
|
||||
<div><span>Nog te factureren<br /> na lopend boekjaar incl. btw</span></div>
|
||||
</th>
|
||||
<th class="rotate">
|
||||
<div><span>Nog te prognotiseren<br />incl. btw</span></div>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<!-- ko foreach: forecasts -->
|
||||
<tr>
|
||||
<td><span data-bind="text:projectname"></span></td>
|
||||
<td><span data-bind="text:customer"></span></td>
|
||||
<td class="align-right"><span data-bind="text:needInvoice"></span></td>
|
||||
<td class="align-right"><span data-bind="text:forecastThisYear"></span></td>
|
||||
<td class="align-right"><span data-bind="text:forecastOtherYears"></span></td>
|
||||
<td class="align-right focus-green"><span data-bind="text:forecastRemaining"></span></td>
|
||||
</tr>
|
||||
<!-- /ko -->
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<th colspan="2" class="align-right">
|
||||
totaal
|
||||
</th>
|
||||
<th class="align-right">
|
||||
<span data-bind="text:needInvoice"></span>
|
||||
</th>
|
||||
<th class="align-right">
|
||||
<span data-bind="text:forecastThisYear"></span>
|
||||
</th>
|
||||
<th class="align-right">
|
||||
<span data-bind="text:forecastOtherYears"></span>
|
||||
</th>
|
||||
<th class="align-right focus-green">
|
||||
<span data-bind="text:forecastRemaining"></span>
|
||||
</th>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
@@ -0,0 +1,69 @@
|
||||
<table class="table table-condensed" style="font-size:0.8em;">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="rotate">
|
||||
<div><span>project</span></div>
|
||||
</th>
|
||||
<th class="rotate">
|
||||
<div><span>klant</span></div>
|
||||
</th>
|
||||
<th class="rotate">
|
||||
<div><span>Totaal te factureren<br />excl. btw</span></div>
|
||||
</th>
|
||||
<th class="rotate">
|
||||
<div><span>Totaal te factureren<br />incl. btw</span></div>
|
||||
</th>
|
||||
<th class="rotate">
|
||||
<div><span>Gefactureerd overige jaren<br />incl. btw</span></div>
|
||||
</th>
|
||||
<th class="rotate">
|
||||
<div><span>Gefactureerd lopende boekjaar<br />incl. btw</span></div>
|
||||
</th>
|
||||
<th class="rotate">
|
||||
<div><span>Gefactureerd totaal<br />incl. btw</span></div>
|
||||
</th>
|
||||
<th class="rotate">
|
||||
<div><span>Nog te factureren<br />incl. btw</span></div>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<!-- ko foreach: invoiceOverview -->
|
||||
<tr>
|
||||
<td><span data-bind="text:projectname"></span></td>
|
||||
<td><span data-bind="text:customer"></span></td>
|
||||
<td class="align-right"><span data-bind="text:totalToInvoicingExcl"></span></td>
|
||||
<td class="align-right"><span data-bind="text:totalToInvoicingIncl"></span></td>
|
||||
<td class="align-right"><span data-bind="text:totalInvoicedOtherYears"></span></td>
|
||||
<td class="align-right"><span data-bind="text:totalInvoicedThisYear"></span></td>
|
||||
<td class="align-right"><span data-bind="text:invoicesTotal"></span></td>
|
||||
<td class="align-right focus-green"><span data-bind="text:needInvoice"></span></td>
|
||||
</tr>
|
||||
<!-- /ko -->
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<th colspan="2" class="align-right">
|
||||
totaal
|
||||
</th>
|
||||
<th class="align-right">
|
||||
<span data-bind="text:totalToInvoicingExcl"></span>
|
||||
</th>
|
||||
<th class="align-right">
|
||||
<span data-bind="text:totalToInvoicingIncl"></span>
|
||||
</th>
|
||||
<th class="align-right">
|
||||
<span data-bind="text:totalInvoicedOtherYears"></span>
|
||||
</th>
|
||||
<th class="align-right">
|
||||
<span data-bind="text:totalInvoicedThisYear"></span>
|
||||
</th>
|
||||
<th class="align-right">
|
||||
<span data-bind="text:invoicesTotal"></span>
|
||||
</th>
|
||||
<th class="align-right focus-green">
|
||||
<span data-bind="text:needInvoice"></span>
|
||||
</th>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
@@ -0,0 +1,61 @@
|
||||
<table class="table table-condensed" style="font-size:0.8em;">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="rotate">
|
||||
<div><span>project</span></div>
|
||||
</th>
|
||||
<th class="rotate">
|
||||
<div><span>klant</span></div>
|
||||
</th>
|
||||
<th class="rotate">
|
||||
<div><span>Nog te factureren<br />incl. btw</span></div>
|
||||
</th>
|
||||
<!-- ko foreach:months -->
|
||||
<th class="rotate">
|
||||
<div><span data-bind="text:month"></span></div>
|
||||
</th>
|
||||
<!-- /ko -->
|
||||
<th class="rotate">
|
||||
<div><span>Nog te factureren<br /> na lopend boekjaar incl. btw</span></div>
|
||||
</th>
|
||||
<th class="rotate">
|
||||
<div><span>Nog te prognotiseren<br />incl. btw</span></div>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<!-- ko foreach: monthForecasts -->
|
||||
<tr>
|
||||
<td><span data-bind="text:projectname"></span></td>
|
||||
<td><span data-bind="text:customer"></span></td>
|
||||
<td class="align-right focus-green"><span data-bind="text:needInvoice"></span></td>
|
||||
<!-- ko foreach : forecastMonths -->
|
||||
<td class="align-right"><span data-bind="text:forecastamount"></span></td>
|
||||
<!-- /ko -->
|
||||
<td class="align-right"><span data-bind="text:forecastOtherYears"></span></td>
|
||||
<td class="align-right focus-green"><span data-bind="text:forecastRemaining"></span></td>
|
||||
</tr>
|
||||
<!-- /ko -->
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<th colspan="2" class="align-right">
|
||||
|
||||
</th>
|
||||
<th class="align-right focus-green">
|
||||
<span data-bind="text:needInvoice"></span>
|
||||
</th>
|
||||
<!-- ko foreach:monthTotals -->
|
||||
<th class="align-right">
|
||||
<span data-bind="text:forecastamount()"></span>
|
||||
</th>
|
||||
<!-- /ko -->
|
||||
<th class="align-right">
|
||||
<span data-bind="text:forecastOtherYears"></span>
|
||||
</th>
|
||||
<th class="align-right focus-green">
|
||||
<span data-bind="text:forecastRemaining"></span>
|
||||
</th>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
@@ -0,0 +1,47 @@
|
||||
<table class="table table-condensed" style="font-size:0.8em;">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="rotate">
|
||||
<div><span>project</span></div>
|
||||
</th>
|
||||
<th class="rotate">
|
||||
<div><span>klant</span></div>
|
||||
</th>
|
||||
<!-- ko foreach:months -->
|
||||
<th class="rotate">
|
||||
<div><span data-bind="text:month"></span></div>
|
||||
</th>
|
||||
<!-- /ko -->
|
||||
<th class="rotate">
|
||||
<div><span>Totaal gefactureerd<br />lopend boekjaar incl. btw</span></div>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<!-- ko foreach: monthPayments -->
|
||||
<tr>
|
||||
<td><span data-bind="text:projectname"></span></td>
|
||||
<td><span data-bind="text:customer"></span></td>
|
||||
<!-- ko foreach : paymentMonths -->
|
||||
<td class="align-right"><span data-bind="text:paymentamount"></span></td>
|
||||
<!-- /ko -->
|
||||
<td class="align-right focus-green"><span data-bind="text:totalProjectPayments"></span></td>
|
||||
</tr>
|
||||
<!-- /ko -->
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<th colspan="2" class="align-right">
|
||||
totaal
|
||||
</th>
|
||||
<!-- ko foreach:monthPaymentTotals -->
|
||||
<th class="align-right">
|
||||
<span data-bind="text:paymentamount"></span>
|
||||
</th>
|
||||
<!-- /ko -->
|
||||
<th class="align-right focus-green">
|
||||
<span data-bind="text:totalProjectPayments"></span>
|
||||
</th>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
+2
-1
@@ -14,7 +14,8 @@
|
||||
"php": ">=5.3.7",
|
||||
"vlucas/phpdotenv": "^2.4",
|
||||
"illuminate/database": "5.1.16",
|
||||
"symfony/var-dumper": "^3.4"
|
||||
"symfony/var-dumper": "^3.4",
|
||||
"phpoffice/phpspreadsheet": "^1.3"
|
||||
},
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
|
||||
+1
-1
@@ -108,7 +108,7 @@ th.rotate > div > span {
|
||||
height:20px;
|
||||
border:1px solid #777;
|
||||
}
|
||||
th.focus-green{
|
||||
.focus-green{
|
||||
background-color:#dcf7b0;
|
||||
border:0;
|
||||
font-weight: bold;
|
||||
|
||||
Binary file not shown.
@@ -13,5 +13,9 @@ dbo.invoiceDataService = {
|
||||
.done( function ( data ) {
|
||||
callback( data );
|
||||
} );
|
||||
},
|
||||
|
||||
createSpreadsheet : function(year){
|
||||
$.get( 'index.php/reports/reportsController/createInvoicesSpreadsheet/' + year )
|
||||
}
|
||||
};
|
||||
@@ -48,6 +48,8 @@ $( function () {
|
||||
vm[page]( true );
|
||||
|
||||
var func = page.toLowerCase() + 'Init';
|
||||
console.log( func );
|
||||
|
||||
|
||||
window.dbo[func]();
|
||||
},
|
||||
|
||||
@@ -0,0 +1,220 @@
|
||||
/**
|
||||
* Created by Pensare Software.
|
||||
* User: Theo Weijmer
|
||||
* Date: 02/03/2018
|
||||
* Time: 11:43
|
||||
*/
|
||||
|
||||
|
||||
dbo.invoicereportInit = function () {
|
||||
|
||||
if ( dbo.invoicereport !== undefined ) {
|
||||
|
||||
dbo.invoicereport.initModule();
|
||||
|
||||
} else {
|
||||
dbo.invoicereport = {
|
||||
|
||||
selectedYear : ko.observable(),
|
||||
invoiceOverview : ko.observableArray( [] ),
|
||||
forecasts : ko.observableArray( [] ),
|
||||
monthForecasts : ko.observableArray( [] ),
|
||||
monthPayments : ko.observableArray( [] ),
|
||||
months : ko.observableArray( [] ),
|
||||
monthTotals : ko.observableArray( [] ),
|
||||
monthPaymentTotals : ko.observableArray( [] ),
|
||||
validYear : ko.observable(),
|
||||
invoiceTab : ko.observable(),
|
||||
totalToInvoicingExcl : ko.observable(),
|
||||
totalToInvoicingIncl : ko.observable(),
|
||||
totalInvoicedOtherYears: ko.observable(),
|
||||
totalInvoicedThisYear : ko.observable(),
|
||||
invoicesTotal : ko.observable(),
|
||||
needInvoice : ko.observable(),
|
||||
forecastThisYear : ko.observable(),
|
||||
forecastOtherYears : ko.observable(),
|
||||
forecastRemaining : ko.observable(),
|
||||
totalProjectPayments : ko.observable(),
|
||||
|
||||
init: function () {
|
||||
var vm = dbo.invoicereport;
|
||||
|
||||
vm.selectedYear( (new Date()).getFullYear() );
|
||||
vm.invoiceTab( 'invoice' );
|
||||
vm.validYear( true );
|
||||
vm.months( dbo.monthArray );
|
||||
|
||||
vm.initModule();
|
||||
},
|
||||
|
||||
initModule: function () {
|
||||
var vm = dbo.invoicereport;
|
||||
|
||||
vm.resetTotals();
|
||||
|
||||
dbo.invoiceDataService.getInvoiceOverview( vm.selectedYear(), function ( data ) {
|
||||
vm.invoiceOverview( data.invoiceOverview );
|
||||
vm.setInvoiceOverviewTotals( data.invoiceOverview );
|
||||
|
||||
vm.forecasts( data.forecasts );
|
||||
vm.setForecastsTotals( data.forecasts );
|
||||
|
||||
vm.monthForecasts.removeAll();
|
||||
_.each( data.monthForecasts, function ( p ) {
|
||||
vm.monthForecasts.push( new vm.Monthforecast( p ) );
|
||||
} );
|
||||
_.each( vm.monthTotals(), function ( p ) {
|
||||
p.forecastamount( dbo.helpers.thousandSeparator( p.forecastamount() ) );
|
||||
} );
|
||||
|
||||
vm.monthPayments.removeAll();
|
||||
_.each( data.monthPayments, function ( p ) {
|
||||
vm.monthPayments.push( new vm.Monthpayment( p ) );
|
||||
vm.totalProjectPayments( Number( vm.totalProjectPayments() ) + Number(p.totalProjectPayments.replace('.', '')) );
|
||||
console.log( vm.totalProjectPayments() );
|
||||
} );
|
||||
vm.totalProjectPayments( dbo.helpers.thousandSeparator( vm.totalProjectPayments() ) );
|
||||
_.each( vm.monthPaymentTotals(), function ( p ) {
|
||||
p.paymentamount( dbo.helpers.thousandSeparator( p.paymentamount() ) );
|
||||
} );
|
||||
|
||||
} );
|
||||
},
|
||||
|
||||
resetTotals: function () {
|
||||
var vm = dbo.invoicereport;
|
||||
|
||||
vm.totalToInvoicingExcl( 0 );
|
||||
vm.totalToInvoicingIncl( 0 );
|
||||
vm.totalInvoicedOtherYears( 0 );
|
||||
vm.totalInvoicedThisYear( 0 );
|
||||
vm.invoicesTotal( 0 );
|
||||
vm.needInvoice( 0 );
|
||||
vm.forecastThisYear( 0 );
|
||||
vm.forecastOtherYears( 0 );
|
||||
vm.forecastRemaining( 0 );
|
||||
vm.totalProjectPayments( 0 );
|
||||
|
||||
for ( var i = 1; i <= 12; i++ ) {
|
||||
vm.monthTotals.push( {monthID: i, forecastamount: ko.observable( 0 )} );
|
||||
vm.monthPaymentTotals.push( {monthID: i, paymentamount: ko.observable( 0 )} );
|
||||
}
|
||||
},
|
||||
|
||||
setInvoiceOverviewTotals: function ( data ) {
|
||||
var vm = dbo.invoicereport;
|
||||
|
||||
_.each( data, function ( p ) {
|
||||
vm.totalToInvoicingExcl( vm.totalToInvoicingExcl() + Number( p.totalToInvoicingExcl.replace( '.', '' ) ) );
|
||||
vm.totalToInvoicingIncl( vm.totalToInvoicingIncl() + Number( p.totalToInvoicingIncl.replace( '.', '' ) ) );
|
||||
vm.totalInvoicedOtherYears( vm.totalInvoicedOtherYears() + Number( p.totalInvoicedOtherYears.replace( '.', '' ) ) );
|
||||
vm.totalInvoicedThisYear( vm.totalInvoicedThisYear() + Number( p.totalInvoicedThisYear.replace( '.', '' ) ) );
|
||||
vm.invoicesTotal( vm.invoicesTotal() + Number( p.invoicesTotal.replace( '.', '' ) ) );
|
||||
vm.needInvoice( vm.needInvoice() + Number( p.needInvoice.replace( '.', '' ) ) );
|
||||
} );
|
||||
|
||||
vm.totalToInvoicingExcl( dbo.helpers.thousandSeparator( vm.totalToInvoicingExcl() ) );
|
||||
vm.totalToInvoicingIncl( dbo.helpers.thousandSeparator( vm.totalToInvoicingIncl() ) );
|
||||
vm.totalInvoicedOtherYears( dbo.helpers.thousandSeparator( vm.totalInvoicedOtherYears() ) );
|
||||
vm.totalInvoicedThisYear( dbo.helpers.thousandSeparator( vm.totalInvoicedThisYear() ) );
|
||||
vm.invoicesTotal( dbo.helpers.thousandSeparator( vm.invoicesTotal() ) );
|
||||
vm.needInvoice( dbo.helpers.thousandSeparator( vm.needInvoice() ) );
|
||||
},
|
||||
|
||||
setForecastsTotals: function ( data ) {
|
||||
var vm = dbo.invoicereport;
|
||||
|
||||
_.each( data, function ( p ) {
|
||||
vm.forecastThisYear( vm.forecastThisYear() + Number( p.forecastThisYear.replace( '.', '' ) ) );
|
||||
vm.forecastOtherYears( vm.forecastOtherYears() + Number( p.forecastOtherYears.replace( '.', '' ) ) );
|
||||
vm.forecastRemaining( vm.forecastRemaining() + Number( p.forecastRemaining.replace( '.', '' ) ) );
|
||||
} );
|
||||
vm.forecastThisYear( dbo.helpers.thousandSeparator( vm.forecastThisYear() ) );
|
||||
vm.forecastOtherYears( dbo.helpers.thousandSeparator( vm.forecastOtherYears() ) );
|
||||
vm.forecastRemaining( dbo.helpers.thousandSeparator( vm.forecastRemaining() ) );
|
||||
},
|
||||
|
||||
setForecastMonthsTotals: function ( data ) {
|
||||
var vm = dbo.invoicereport;
|
||||
|
||||
_.each( data, function ( p ) {
|
||||
_.each( p.forecastMonths(), function ( q ) {
|
||||
vm.forecastMonths( vm.forecastMonths() + q );
|
||||
} );
|
||||
} );
|
||||
},
|
||||
|
||||
checkYear: function () {
|
||||
var vm = dbo.invoicereport;
|
||||
if ( !Number.isInteger( Number( vm.selectedYear() ) ) ) return vm.validYear( false );
|
||||
if ( Number( vm.selectedYear() ) > 2100 ) return vm.validYear( false );
|
||||
if ( Number( vm.selectedYear() ) < 2000 ) return vm.validYear( false );
|
||||
vm.validYear( true );
|
||||
|
||||
vm.initModule();
|
||||
},
|
||||
|
||||
setActivetab: function ( page ) {
|
||||
var vm = dbo.invoicereport;
|
||||
|
||||
vm.invoiceTab( page );
|
||||
},
|
||||
|
||||
Monthforecast: function ( data ) {
|
||||
var vm = dbo.invoicereport;
|
||||
var self = this;
|
||||
self.projectname = data.projectname;
|
||||
self.customer = data.customer;
|
||||
self.needInvoice = data.needInvoice;
|
||||
self.forecastOtherYears = data.forecastOtherYears;
|
||||
self.forecastRemaining = data.forecastRemaining;
|
||||
|
||||
self.forecastMonths = ko.observableArray( [] );
|
||||
_.each( data.forecastMonths, function ( p, i ) {
|
||||
self.forecastMonths.push( new vm.ForecastMonth( p ) );
|
||||
_.each( vm.monthTotals(), function ( q ) {
|
||||
if ( q.monthID == i ) q.forecastamount( Number( q.forecastamount() ) + p.forecastamount );
|
||||
} );
|
||||
} );
|
||||
},
|
||||
|
||||
ForecastMonth: function ( data ) {
|
||||
this.forecastamount = dbo.helpers.thousandSeparator( data.forecastamount );
|
||||
},
|
||||
|
||||
Monthpayment: function ( data ) {
|
||||
var vm = dbo.invoicereport;
|
||||
var self = this;
|
||||
self.projectname = data.projectname;
|
||||
self.customer = data.customer;
|
||||
self.totalProjectPayments = data.totalProjectPayments;
|
||||
|
||||
self.paymentMonths = ko.observableArray( [] );
|
||||
_.each( data.monthPayments, function ( p, i ) {
|
||||
self.paymentMonths.push( new vm.PaymentMonth( p ) );
|
||||
_.each( vm.monthPaymentTotals(), function ( q ) {
|
||||
if ( q.monthID == i ) q.paymentamount( Number( q.paymentamount() ) + p.paymentamount );
|
||||
} );
|
||||
} );
|
||||
},
|
||||
|
||||
PaymentMonth: function ( data ) {
|
||||
this.paymentamount = dbo.helpers.thousandSeparator( data.paymentamount );
|
||||
},
|
||||
|
||||
createSpreadsheet:function(){
|
||||
var vm = dbo.invoicereport;
|
||||
dbo.invoiceDataService.createSpreadsheet(vm.selectedYear());
|
||||
}
|
||||
}
|
||||
|
||||
dbo.invoicereport.init();
|
||||
|
||||
ko.applyBindings(
|
||||
dbo.invoicereport, document.getElementById( "INVOICEREPORT" ) );
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,160 +0,0 @@
|
||||
/**
|
||||
* Created by Pensare Software.
|
||||
* User: Theo Weijmer
|
||||
* Date: 02/03/2018
|
||||
* Time: 11:43
|
||||
*/
|
||||
|
||||
|
||||
dbo.outgoinginvoicesInit = function () {
|
||||
|
||||
if ( dbo.outgoinginvoicesModel !== undefined ) {
|
||||
|
||||
|
||||
} else {
|
||||
dbo.outgoinginvoicesModel = {
|
||||
|
||||
initialize : null,
|
||||
years : ko.observableArray( [] ),
|
||||
selectedYear : ko.observable(),
|
||||
selectedMonthID : ko.observable(),
|
||||
projects : ko.observableArray( [] ),
|
||||
invoiceTab : ko.observable( 'invoice' ),
|
||||
months : ko.observableArray( dbo.monthArray ),
|
||||
totalToInvoice : ko.observable(),
|
||||
totalToInvoiceFuture: ko.observable(),
|
||||
initialize : null,
|
||||
validYear : ko.observable(),
|
||||
totalToInvoice : ko.observable(),
|
||||
totalCurrentforecast: ko.observable(),
|
||||
totalOtherforecast : ko.observable(),
|
||||
totalMissingForecast: ko.observable(),
|
||||
|
||||
init: function () {
|
||||
var vm = dbo.outgoinginvoicesModel;
|
||||
|
||||
vm.selectedYear( (new Date()).getFullYear() );
|
||||
vm.selectedMonthID( 0 );
|
||||
vm.validYear( true );
|
||||
|
||||
vm.initModule();
|
||||
},
|
||||
|
||||
setActivetab: function ( tab ) {
|
||||
var vm = dbo.outgoinginvoicesModel;
|
||||
|
||||
vm.invoiceTab( tab );
|
||||
},
|
||||
|
||||
initModule: function () {
|
||||
var vm = dbo.outgoinginvoicesModel;
|
||||
|
||||
vm.refreshInvoiceDetails();
|
||||
},
|
||||
|
||||
checkYear: function () {
|
||||
var vm = dbo.outgoinginvoicesModel;
|
||||
if ( !Number.isInteger( Number( vm.selectedYear() ) ) ) return vm.validYear( false );
|
||||
if ( Number( vm.selectedYear() ) > 2100 ) return vm.validYear( false );
|
||||
if ( Number( vm.selectedYear() ) < 2000 ) return vm.validYear( false );
|
||||
vm.validYear( true );
|
||||
|
||||
vm.initModule();
|
||||
},
|
||||
|
||||
refreshInvoiceDetails: function () {
|
||||
var vm = dbo.outgoinginvoicesModel;
|
||||
|
||||
vm.resetModel();
|
||||
|
||||
if ( vm.initialize ) return;
|
||||
|
||||
dbo.invoiceDataService.getInvoiceOverview( vm.selectedYear(), function ( data ) {
|
||||
vm.projects.removeAll();
|
||||
_.each( data, function ( p ) {
|
||||
vm.projects.push( new vm.Project( p ) );
|
||||
} );
|
||||
vm.totalToInvoice( dbo.helpers.numberWithPoints( Math.round( vm.totalToInvoice() ) ) );
|
||||
vm.totalToInvoiceFuture( dbo.helpers.numberWithPoints( Math.round( vm.totalToInvoiceFuture() ) ) );
|
||||
vm.totalCurrentforecast( dbo.helpers.numberWithPoints( Math.round( vm.totalCurrentforecast() ) ) );
|
||||
vm.totalOtherforecast( dbo.helpers.numberWithPoints( Math.round( vm.totalOtherforecast() ) ) );
|
||||
vm.totalMissingForecast( dbo.helpers.numberWithPoints( Math.round( vm.totalMissingForecast() ) ) );
|
||||
} );
|
||||
},
|
||||
|
||||
resetModel: function () {
|
||||
var vm = dbo.outgoinginvoicesModel;
|
||||
vm.totalToInvoice( 0 );
|
||||
vm.totalToInvoiceFuture( 0 );
|
||||
vm.totalCurrentforecast( 0 );
|
||||
vm.totalOtherforecast( 0 );
|
||||
vm.totalMissingForecast( 0 );
|
||||
},
|
||||
|
||||
Project: function ( data ) {
|
||||
var vm = dbo.outgoinginvoicesModel;
|
||||
var self = this;
|
||||
var openstaand = data.revenues - (Number( data.currentyear ) + Number( data.otheryear ));
|
||||
var totalInvoice = data.revenues * (1 + (data.vatrate / 100));
|
||||
var totalInvoiced = Math.round( data.currentyear ) + Math.round( data.otheryear );
|
||||
var totalInvoicedPayed = Math.round( data.currentyearpayed ) + Math.round( data.otheryearpayed );
|
||||
var notPayed = totalInvoiced - totalInvoicedPayed;
|
||||
|
||||
self.projectnumber = data.projectnumber;
|
||||
self.customername = data.customername;
|
||||
self.statusProject = Math.abs( openstaand ) > 2 ? 'OPEN' : 'CLOSED';
|
||||
self.fullname = data.fullname;
|
||||
self.revenues = dbo.helpers.numberWithPoints( Number(data.revenues).toFixed(0) );
|
||||
self.totalInvoice = dbo.helpers.numberWithPoints( Number(totalInvoice).toFixed(0) );
|
||||
self.openstaand = dbo.helpers.numberWithPoints( Math.round( openstaand ) );
|
||||
self.openstaandIncl = dbo.helpers.numberWithPoints( Math.round( openstaand * 1.21 ) );
|
||||
self.invoicedOtherYears = dbo.helpers.numberWithPoints( Math.round( data.otheryear ) );
|
||||
self.invoicedCurentYear = dbo.helpers.numberWithPoints( Math.round( data.currentyear ) );
|
||||
self.totalInvoiced = dbo.helpers.numberWithPoints( totalInvoiced );
|
||||
self.invoicedOtherYearsPayed = dbo.helpers.numberWithPoints( Math.round( data.otheryearpayed ) );
|
||||
self.invoicedCurentYearPayed = dbo.helpers.numberWithPoints( Math.round( data.currentyearpayed ) );
|
||||
self.totalInvoicedPayed = dbo.helpers.numberWithPoints( Math.round( totalInvoicedPayed ) );
|
||||
self.notPayed = dbo.helpers.numberWithPoints( Math.round( notPayed ) );
|
||||
self.toInvoice = dbo.helpers.numberWithPoints( Math.round( totalInvoice - totalInvoiced ) );
|
||||
self.toInvoiceFuture = dbo.helpers.numberWithPoints( Math.round( totalInvoice - totalInvoiced - Number( data.currentforecast ) ) );
|
||||
self.currentforecast = dbo.helpers.numberWithPoints( Math.round( data.currentforecast ) );
|
||||
self.otherforecast = dbo.helpers.numberWithPoints( Math.round( data.otherforecast ) );
|
||||
var missingForcast = Math.round( totalInvoice - totalInvoiced - data.otherforecast - data.currentforecast );
|
||||
console.log( missingForcast );
|
||||
self.missingForecast = dbo.helpers.numberWithPoints( missingForcast );
|
||||
|
||||
self.months = ko.observableArray( [] );
|
||||
_.each( data.months, function ( p ) {
|
||||
self.months.push( new vm.Month( p ) );
|
||||
|
||||
if ( !vm['forecast' + p.month] ) vm['forecast' + p.month] = ko.observable( 0 );
|
||||
vm['forecast' + p.month]( Number( vm['forecast' + p.month]() ) + Number( p.forecastamount ) );
|
||||
|
||||
if ( !vm['payment' + p.month] ) vm['payment' + p.month] = ko.observable( 0 );
|
||||
vm['payment' + p.month]( Number( vm['payment' + p.month]() ) + Number( p.paymentamount ) );
|
||||
} );
|
||||
|
||||
|
||||
vm.totalToInvoice( vm.totalToInvoice() + (totalInvoice - totalInvoiced) );
|
||||
vm.totalToInvoiceFuture( vm.totalToInvoiceFuture() + (totalInvoice - totalInvoiced - Number( data.currentforecast )) );
|
||||
vm.totalCurrentforecast( Number( vm.totalCurrentforecast() ) + Number( data.currentforecast ) );
|
||||
vm.totalOtherforecast( Number( vm.totalOtherforecast() ) + Number( data.otherforecast ) );
|
||||
vm.totalMissingForecast( Number( vm.totalMissingForecast() ) + Number( missingForcast ) );
|
||||
},
|
||||
|
||||
Month: function ( data ) {
|
||||
this.forecastamount = dbo.helpers.numberWithPoints( Number( data.forecastamount ).toFixed( 0 ) );
|
||||
this.paymentamount = dbo.helpers.numberWithPoints( Number( data.paymentamount ).toFixed( 0 ) );
|
||||
}
|
||||
}
|
||||
|
||||
dbo.outgoinginvoicesModel.init();
|
||||
|
||||
ko.applyBindings(
|
||||
dbo.outgoinginvoicesModel, document.getElementById( "OUTGOINGINVOICES" ) );
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user