Invoiced report
This commit is contained in:
@@ -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
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user