Invoiced report
This commit is contained in:
@@ -27,6 +27,7 @@ class ReservationsController extends MY_Controller {
|
||||
{
|
||||
$projects[ $result->projectID ] = [
|
||||
'projectnumber' => $result->projectnumber,
|
||||
'projectname' => $result->projectname,
|
||||
'costs' => 0,
|
||||
'reservation' => 0,
|
||||
'payed' => 0,
|
||||
|
||||
@@ -40,7 +40,9 @@ class InvoiceSpreadsheet {
|
||||
|
||||
$this->setMonthForecast();
|
||||
|
||||
$this->setMonthPayment();
|
||||
$this->setMonthPayment();
|
||||
|
||||
$this->setInvoiced();
|
||||
|
||||
$this->setFilename();
|
||||
|
||||
@@ -86,15 +88,25 @@ class InvoiceSpreadsheet {
|
||||
new MonthForecastSheet( $this->invoiceReport['monthForecasts'], $this->invoiceSheet );
|
||||
}
|
||||
|
||||
private function setMonthPayment()
|
||||
{
|
||||
$invoiceSheet = new Worksheet( $this->spreadsheet, 'maand betalingen' );
|
||||
private function setMonthPayment()
|
||||
{
|
||||
$invoiceSheet = new Worksheet( $this->spreadsheet, 'maand betalingen' );
|
||||
|
||||
$this->invoiceSheet =
|
||||
$this->spreadsheet->addSheet( $invoiceSheet );
|
||||
$this->invoiceSheet =
|
||||
$this->spreadsheet->addSheet( $invoiceSheet );
|
||||
|
||||
new MonthPaymentSheet( $this->invoiceReport['monthPayments'], $this->invoiceSheet );
|
||||
}
|
||||
new MonthPaymentSheet( $this->invoiceReport['monthPayments'], $this->invoiceSheet );
|
||||
}
|
||||
|
||||
private function setInvoiced()
|
||||
{
|
||||
$invoiceSheet = new Worksheet( $this->spreadsheet, 'ontvangen facturen' );
|
||||
|
||||
$this->invoiceSheet =
|
||||
$this->spreadsheet->addSheet( $invoiceSheet );
|
||||
|
||||
new InvoicedSheet( $this->invoiceReport['invoiced'], $this->invoiceSheet );
|
||||
}
|
||||
|
||||
private function setFilename()
|
||||
{
|
||||
@@ -121,4 +133,4 @@ class InvoiceSpreadsheet {
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by Pensare Software.
|
||||
* User: Theo Weijmer
|
||||
* Date: 30/07/2018
|
||||
* Time: 10:48
|
||||
*/
|
||||
|
||||
class InvoicedSheet {
|
||||
|
||||
const HEADERS = [
|
||||
'A' => 'factuurnummer',
|
||||
'B' => 'project',
|
||||
'C' => 'klant',
|
||||
'D' => 'factuurdatum',
|
||||
'E' => 'exc btw',
|
||||
'F' => 'btw',
|
||||
'G' => 'incl btw'
|
||||
];
|
||||
|
||||
private $invoiced;
|
||||
private $sheet;
|
||||
private $row;
|
||||
|
||||
public function __construct( $invoiced, $sheet )
|
||||
{
|
||||
$this->invoiced = $invoiced;
|
||||
$this->sheet = $sheet;
|
||||
|
||||
$this->handle();
|
||||
}
|
||||
|
||||
private function handle()
|
||||
{
|
||||
$this->setHeader();
|
||||
|
||||
$this->setBody();
|
||||
}
|
||||
|
||||
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->invoiced AS $invoice )
|
||||
{
|
||||
$vat = ROUND($invoice->invoiceamount * 0.21, 2);
|
||||
$this->sheet->setCellValue( 'A' . $this->row, $invoice->invoicenumber );
|
||||
$this->sheet->setCellValue( 'B' . $this->row, ($invoice->projectnumber . ' ' . $invoice['projectname']));
|
||||
$this->sheet->setCellValue( 'C' . $this->row, $invoice->name );
|
||||
$this->sheet->setCellValue( 'D' . $this->row, $invoice->invoicenumber );
|
||||
$this->sheet->setCellValue( 'E' . $this->row, $invoice->invoiceamount );
|
||||
$this->sheet->setCellValue( 'F' . $this->row, $vat );
|
||||
$this->sheet->setCellValue( 'G' . $this->row, $invoice->invoiceamount + $vat );
|
||||
|
||||
$this->row ++;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -23,6 +23,8 @@ class Invoices {
|
||||
private $orderType;
|
||||
private $orderDirection;
|
||||
private $archive;
|
||||
private $invoicedYears;
|
||||
private $invoiced;
|
||||
|
||||
public function __construct( $year, $orderType, $orderDirection, $archive )
|
||||
{
|
||||
@@ -48,6 +50,10 @@ class Invoices {
|
||||
//only projects with payments also archived projects
|
||||
$this->setMonthPayments();
|
||||
|
||||
$this->setInvoicedyears();
|
||||
|
||||
$this->setInvoiced();
|
||||
|
||||
$this->setInvoiceReport();
|
||||
}
|
||||
|
||||
@@ -95,18 +101,33 @@ class Invoices {
|
||||
public function setMonthPayments()
|
||||
{
|
||||
$monthPayment = new MonthPayments(
|
||||
$this->year, $this->orderType, $this->orderDirection );
|
||||
$this->year, $this->orderType, $this->orderDirection );
|
||||
|
||||
$this->monthPayments = $monthPayment->getProjectDetails();
|
||||
}
|
||||
|
||||
private function setInvoiced()
|
||||
{
|
||||
$this->invoiced = Invoice::getInvoiced( $this->year );
|
||||
}
|
||||
|
||||
private function setInvoicedYears()
|
||||
{
|
||||
$this->invoicedYears = Invoice::selectRaw( 'DATE_FORMAT(invoicedate, "%Y") AS years' )
|
||||
->distinct()
|
||||
->orderBy( 'invoicedate' )
|
||||
->lists( 'years' );
|
||||
}
|
||||
|
||||
private function setInvoiceReport()
|
||||
{
|
||||
$this->invoiceReport = [
|
||||
'invoiceOverview' => $this->invoiceOverviews,
|
||||
'forecasts' => $this->invoiceForecasts,
|
||||
'monthForecasts' => $this->monthForecasts,
|
||||
'monthPayments' => $this->monthPayments
|
||||
'monthPayments' => $this->monthPayments,
|
||||
'invoicedYears' => $this->invoicedYears,
|
||||
'invoiced' => $this->invoiced
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,4 +62,16 @@ class Invoice extends BaseModel {
|
||||
|
||||
return $invoiceID;
|
||||
}
|
||||
}
|
||||
|
||||
public static function getInvoiced( $year )
|
||||
{
|
||||
$invoiced = Invoice::selectRaw('invoicenumber, PRJ.projectname, projectnumber, CUS.name, invoicedate, CUS.name, 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}")
|
||||
->orderBy('invoicedate')
|
||||
->get();
|
||||
|
||||
return $invoiced;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,8 @@ class ReservationTotals {
|
||||
public static function fire()
|
||||
{
|
||||
// UNION ALL wordt gebruikt voor een full outer join
|
||||
$sql = " SELECT PRJ.id AS projectID, external_id AS externalID,
|
||||
$sql = "SELECT PRJ.id AS projectID, external_id AS externalID,
|
||||
PRJ.projectname,
|
||||
COALESCE(fromreservation, 0) AS fromreservation,
|
||||
COALESCE(Q5.costs, 0) AS costs, COALESCE(reservation, 0) AS reservation,
|
||||
COALESCE(payed, 0) AS payed, (COALESCE(reservation, 0) - COALESCE(fromreservation, 0)) AS saldo,
|
||||
|
||||
@@ -48,9 +48,12 @@
|
||||
<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, '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, 'invoices')" style="z-index:10">
|
||||
<a class="nav-link" data-bind="css:{'active':invoiceTab() == 'invoices'}">ontvangen facturen</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>-->
|
||||
@@ -65,9 +68,12 @@
|
||||
<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() == 'monthpayments'">
|
||||
<?php $this->load->view('reports/invoices/monthpayment_report'); ?>
|
||||
</div>
|
||||
<div id="invoiceforecast" data-bind="visible:invoiceTab() == 'invoices'">
|
||||
<?php $this->load->view('reports/invoices/invoices_report'); ?>
|
||||
</div>
|
||||
<!-- <div id="invoiceforecast" data-bind="visible:invoiceTab() == 'externals'">-->
|
||||
<!-- --><?php //$this->load->view('reports/invoices/contractors_report'); ?>
|
||||
<!-- </div>-->
|
||||
@@ -76,4 +82,4 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -7,16 +7,16 @@
|
||||
<table class="table table-condensed">
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="3%"> </th>
|
||||
<th width="17%">project</th>
|
||||
<th width="10%" class="align-right">Kosten derden</th>
|
||||
<th width="10%" class="align-right">factuur INK</th>
|
||||
<th width="10%" class="align-right">gereserveerd op<br/>spaarrekening</th>
|
||||
<th width="10%" class="align-right">betaald</th>
|
||||
<th width="10%" class="align-right">saldo te<br />betalen</th>
|
||||
<th width="10%" class="align-right">betaald via<br />reserveringen</th>
|
||||
<th width="10%" class="align-right">saldo reservering</th>
|
||||
<th width="10%" class="align-right">saldo facturen INK</th>
|
||||
<th width="2%"> </th>
|
||||
<th width="34%">project</th>
|
||||
<th width="8%" class="align-right">Kosten derden</th>
|
||||
<th width="8%" class="align-right">factuur INK</th>
|
||||
<th width="8%" class="align-right">gereserveerd op<br/>spaarrekening</th>
|
||||
<th width="8%" class="align-right">betaald</th>
|
||||
<th width="8%" class="align-right">nog te betalen<br />facturen</th>
|
||||
<th width="8%" class="align-right">betaald via<br />reserveringen</th>
|
||||
<th width="8%" class="align-right">saldo reservering</th>
|
||||
<th width="8%" class="align-right">saldo facturen INK</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<!-- ko foreach:projects -->
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
<table class="table table-striped table-condensed">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
factuurnummer
|
||||
</th>
|
||||
<th>
|
||||
project
|
||||
</th>
|
||||
<th>
|
||||
klant
|
||||
</th>
|
||||
<th>
|
||||
factuur datum
|
||||
</th>
|
||||
<th>
|
||||
excl btw
|
||||
</th>
|
||||
<th>
|
||||
btw
|
||||
</th>
|
||||
<th>
|
||||
incl btw
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody data-bind="foreach:invoiced">
|
||||
<tr>
|
||||
<td>
|
||||
<span data-bind="text:invoicenumber"></span>
|
||||
</td>
|
||||
<td>
|
||||
<span data-bind="text:project"></span>
|
||||
</td>
|
||||
<td>
|
||||
<span data-bind="text:name"></span>
|
||||
</td>
|
||||
<td>
|
||||
<span data-bind="text:invoicedate"></span>
|
||||
</td>
|
||||
<td class="align-right">
|
||||
<span data-bind="text:invoiceamount"></span>
|
||||
</td>
|
||||
<td class="align-right">
|
||||
<span data-bind="text:vat"></span>
|
||||
</td>
|
||||
<td class="align-right">
|
||||
<span data-bind="text:inclVat"></span>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
Reference in New Issue
Block a user