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