Invoiced report

This commit is contained in:
2020-01-10 17:42:25 +01:00
parent b4d69d272c
commit 5594865554
11 changed files with 384 additions and 190 deletions
@@ -27,6 +27,7 @@ class ReservationsController extends MY_Controller {
{ {
$projects[ $result->projectID ] = [ $projects[ $result->projectID ] = [
'projectnumber' => $result->projectnumber, 'projectnumber' => $result->projectnumber,
'projectname' => $result->projectname,
'costs' => 0, 'costs' => 0,
'reservation' => 0, 'reservation' => 0,
'payed' => 0, 'payed' => 0,
@@ -42,6 +42,8 @@ class InvoiceSpreadsheet {
$this->setMonthPayment(); $this->setMonthPayment();
$this->setInvoiced();
$this->setFilename(); $this->setFilename();
$this->setFullPathname(); $this->setFullPathname();
@@ -96,6 +98,16 @@ class InvoiceSpreadsheet {
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() private function setFilename()
{ {
$this->filename = 'facturen' . date( 'YmdHis' ) . '.xlsx'; $this->filename = 'facturen' . date( 'YmdHis' ) . '.xlsx';
@@ -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 $orderType;
private $orderDirection; private $orderDirection;
private $archive; private $archive;
private $invoicedYears;
private $invoiced;
public function __construct( $year, $orderType, $orderDirection, $archive ) public function __construct( $year, $orderType, $orderDirection, $archive )
{ {
@@ -48,6 +50,10 @@ class Invoices {
//only projects with payments also archived projects //only projects with payments also archived projects
$this->setMonthPayments(); $this->setMonthPayments();
$this->setInvoicedyears();
$this->setInvoiced();
$this->setInvoiceReport(); $this->setInvoiceReport();
} }
@@ -100,13 +106,28 @@ class Invoices {
$this->monthPayments = $monthPayment->getProjectDetails(); $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() private function setInvoiceReport()
{ {
$this->invoiceReport = [ $this->invoiceReport = [
'invoiceOverview' => $this->invoiceOverviews, 'invoiceOverview' => $this->invoiceOverviews,
'forecasts' => $this->invoiceForecasts, 'forecasts' => $this->invoiceForecasts,
'monthForecasts' => $this->monthForecasts, 'monthForecasts' => $this->monthForecasts,
'monthPayments' => $this->monthPayments 'monthPayments' => $this->monthPayments,
'invoicedYears' => $this->invoicedYears,
'invoiced' => $this->invoiced
]; ];
} }
} }
+12
View File
@@ -62,4 +62,16 @@ class Invoice extends BaseModel {
return $invoiceID; 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;
}
} }
@@ -12,6 +12,7 @@ class ReservationTotals {
{ {
// UNION ALL wordt gebruikt voor een full outer join // 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(fromreservation, 0) AS fromreservation,
COALESCE(Q5.costs, 0) AS costs, COALESCE(reservation, 0) AS reservation, COALESCE(Q5.costs, 0) AS costs, COALESCE(reservation, 0) AS reservation,
COALESCE(payed, 0) AS payed, (COALESCE(reservation, 0) - COALESCE(fromreservation, 0)) AS saldo, COALESCE(payed, 0) AS payed, (COALESCE(reservation, 0) - COALESCE(fromreservation, 0)) AS saldo,
@@ -51,6 +51,9 @@
<li class="nav-item" data-bind="click:setActivetab.bind($data, 'monthpayments')" style="z-index:10"> <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> <a class="nav-link" data-bind="css:{'active':invoiceTab() == 'monthpayments'}">maand betalingen</a>
</li> </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">--> <!-- <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>--> <!-- <a class="nav-link" data-bind="css:{'active':invoiceTab() == 'externals'}">onderaannemers</a>-->
<!-- </li>--> <!-- </li>-->
@@ -68,6 +71,9 @@
<div id="invoiceforecast" data-bind="visible:invoiceTab() == 'monthpayments'"> <div id="invoiceforecast" data-bind="visible:invoiceTab() == 'monthpayments'">
<?php $this->load->view('reports/invoices/monthpayment_report'); ?> <?php $this->load->view('reports/invoices/monthpayment_report'); ?>
</div> </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'">--> <!-- <div id="invoiceforecast" data-bind="visible:invoiceTab() == 'externals'">-->
<!-- --><?php //$this->load->view('reports/invoices/contractors_report'); ?> <!-- --><?php //$this->load->view('reports/invoices/contractors_report'); ?>
<!-- </div>--> <!-- </div>-->
+10 -10
View File
@@ -7,16 +7,16 @@
<table class="table table-condensed"> <table class="table table-condensed">
<thead> <thead>
<tr> <tr>
<th width="3%">&nbsp;</th> <th width="2%">&nbsp;</th>
<th width="17%">project</th> <th width="34%">project</th>
<th width="10%" class="align-right">Kosten derden</th> <th width="8%" class="align-right">Kosten derden</th>
<th width="10%" class="align-right">factuur INK</th> <th width="8%" class="align-right">factuur INK</th>
<th width="10%" class="align-right">gereserveerd op<br/>spaarrekening</th> <th width="8%" class="align-right">gereserveerd op<br/>spaarrekening</th>
<th width="10%" class="align-right">betaald</th> <th width="8%" class="align-right">betaald</th>
<th width="10%" class="align-right">saldo te<br />betalen</th> <th width="8%" class="align-right">nog te betalen<br />facturen</th>
<th width="10%" class="align-right">betaald via<br />reserveringen</th> <th width="8%" class="align-right">betaald via<br />reserveringen</th>
<th width="10%" class="align-right">saldo reservering</th> <th width="8%" class="align-right">saldo reservering</th>
<th width="10%" class="align-right">saldo facturen INK</th> <th width="8%" class="align-right">saldo facturen INK</th>
</tr> </tr>
</thead> </thead>
<!-- ko foreach:projects --> <!-- 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>
+144 -126
View File
@@ -5,16 +5,16 @@
* Time: 11:43 * Time: 11:43
*/ */
dbo.invoicereportInit = function () { dbo.invoicereportInit = function () {
if (dbo.invoicereport !== undefined) { if (dbo.invoicereport !== undefined) {
dbo.invoicereport.initModule(); dbo.invoicereport.initModule()
} else { } else {
dbo.invoicereport = { dbo.invoicereport = {
years : ko.observableArray([]),
selectedYear : ko.observable(), selectedYear : ko.observable(),
invoiceOverview : ko.observableArray([]), invoiceOverview : ko.observableArray([]),
forecasts : ko.observableArray([]), forecasts : ko.observableArray([]),
@@ -40,220 +40,238 @@ dbo.invoicereportInit = function () {
orderType : 'projectnumber', orderType : 'projectnumber',
orderDirection : false, orderDirection : false,
archive : ko.observable(false), archive : ko.observable(false),
recievedInvoices : ko.observableArray([]),
invoiced : ko.observableArray([]),
init: function () { init: function () {
var vm = dbo.invoicereport; var vm = dbo.invoicereport
vm.selectedYear( (new Date()).getFullYear() ); vm.selectedYear((new Date()).getFullYear())
vm.invoiceTab( 'invoice' ); vm.invoiceTab('invoice')
vm.validYear( true ); vm.validYear(true)
vm.months( dbo.monthArray ); vm.months(dbo.monthArray)
vm.initModule(); vm.initModule()
}, },
initModule: function () { initModule: function () {
var vm = dbo.invoicereport; var vm = dbo.invoicereport
vm.resetTotals(); vm.resetTotals()
var orderDirection = vm.orderDirection ? 'ASC' : 'DESC'; var orderDirection = vm.orderDirection ? 'ASC' : 'DESC'
var archive = vm.archive() ? 'T' : 'F'; var archive = vm.archive() ? 'T' : 'F'
dbo.invoiceDataService.getInvoiceOverview(vm.selectedYear(), vm.orderType, orderDirection, archive, function (data) { dbo.invoiceDataService.getInvoiceOverview(vm.selectedYear(), vm.orderType, orderDirection, archive, function (data) {
vm.invoiceOverview( data.invoiceOverview ); vm.invoiceOverview(data.invoiceOverview)
vm.setInvoiceOverviewTotals( data.invoiceOverview ); vm.setInvoiceOverviewTotals(data.invoiceOverview)
vm.forecasts( data.forecasts ); vm.forecasts(data.forecasts)
vm.setForecastsTotals( data.forecasts ); vm.setForecastsTotals(data.forecasts)
vm.monthForecasts.removeAll(); vm.monthForecasts.removeAll()
_.each(data.monthForecasts, function (p) { _.each(data.monthForecasts, function (p) {
vm.monthForecasts.push( new vm.Monthforecast( p ) ); vm.monthForecasts.push(new vm.Monthforecast(p))
} ); })
_.each(vm.monthTotals(), function (p) { _.each(vm.monthTotals(), function (p) {
p.forecastamount( dbo.helpers.thousandSeparator( p.forecastamount() ) ); p.forecastamount(dbo.helpers.thousandSeparator(p.forecastamount()))
} ); })
vm.monthPayments.removeAll(); vm.monthPayments.removeAll()
_.each(data.monthPayments, function (p) { _.each(data.monthPayments, function (p) {
vm.monthPayments.push( new vm.Monthpayment( p ) ); vm.monthPayments.push(new vm.Monthpayment(p))
vm.totalProjectPayments( Number( vm.totalProjectPayments() ) + Number( p.totalProjectPayments.replace( '.', '' ) ) ); vm.totalProjectPayments(Number(vm.totalProjectPayments()) + Number(p.totalProjectPayments.replace('.', '')))
} ); })
vm.totalProjectPayments( dbo.helpers.thousandSeparator( vm.totalProjectPayments() ) ); vm.totalProjectPayments(dbo.helpers.thousandSeparator(vm.totalProjectPayments()))
_.each(vm.monthPaymentTotals(), function (p) { _.each(vm.monthPaymentTotals(), function (p) {
p.paymentamount( dbo.helpers.thousandSeparator( p.paymentamount() ) ); p.paymentamount(dbo.helpers.thousandSeparator(p.paymentamount()))
})
vm.years(data.invoicedYears);
vm.invoiced.removeAll()
_.each(data.invoiced, function(p){
vm.invoiced.push( new vm.Invoice(p));
}); });
} ); })
}, },
toggleArchive: function () { toggleArchive: function () {
var vm = dbo.invoicereport; var vm = dbo.invoicereport
vm.archive( !vm.archive() ); vm.archive(!vm.archive())
vm.initModule(); vm.initModule()
}, },
sortList: function (orderType) { sortList: function (orderType) {
var vm = dbo.invoicereport; var vm = dbo.invoicereport
vm.orderType = orderType; vm.orderType = orderType
vm.orderDirection = !vm.orderDirection; vm.orderDirection = !vm.orderDirection
vm.initModule(); vm.initModule()
}, },
resetTotals: function () { resetTotals: function () {
var vm = dbo.invoicereport; var vm = dbo.invoicereport
vm.totalToInvoicingExcl( 0 ); vm.totalToInvoicingExcl(0)
vm.totalToInvoicingIncl( 0 ); vm.totalToInvoicingIncl(0)
vm.totalInvoicedOtherYears( 0 ); vm.totalInvoicedOtherYears(0)
vm.totalInvoicedThisYear( 0 ); vm.totalInvoicedThisYear(0)
vm.invoicesTotal( 0 ); vm.invoicesTotal(0)
vm.totalPayment( 0 ); vm.totalPayment(0)
vm.totalToPay( 0 ); vm.totalToPay(0)
vm.needInvoice( Number( 0 ) ); vm.needInvoice(Number(0))
vm.forecastThisYear( 0 ); vm.forecastThisYear(0)
vm.forecastOtherYears( 0 ); vm.forecastOtherYears(0)
vm.forecastRemaining( 0 ); vm.forecastRemaining(0)
vm.totalProjectPayments( 0 ); vm.totalProjectPayments(0)
vm.monthTotals.removeAll(); vm.monthTotals.removeAll()
vm.monthPaymentTotals.removeAll(); vm.monthPaymentTotals.removeAll()
for (var i = 1; i <= 12; i++) { for (var i = 1; i <= 12; i++) {
vm.monthTotals.push( {monthID: i, forecastamount: ko.observable( 0 )} ); vm.monthTotals.push({ monthID: i, forecastamount: ko.observable(0) })
vm.monthPaymentTotals.push( {monthID: i, paymentamount: ko.observable( 0 )} ); vm.monthPaymentTotals.push({ monthID: i, paymentamount: ko.observable(0) })
} }
}, },
setInvoiceOverviewTotals: function (data) { setInvoiceOverviewTotals: function (data) {
var vm = dbo.invoicereport; var vm = dbo.invoicereport
_.each(data, function (p) { _.each(data, function (p) {
vm.totalToInvoicingExcl( vm.totalToInvoicingExcl() + Number( p.totalToInvoicingExcl.replace( '.', '' ) ) ); vm.totalToInvoicingExcl(vm.totalToInvoicingExcl() + Number(p.totalToInvoicingExcl.replace('.', '')))
vm.totalToInvoicingIncl( vm.totalToInvoicingIncl() + Number( p.totalToInvoicingIncl.replace( '.', '' ) ) ); vm.totalToInvoicingIncl(vm.totalToInvoicingIncl() + Number(p.totalToInvoicingIncl.replace('.', '')))
vm.totalInvoicedOtherYears( vm.totalInvoicedOtherYears() + Number( p.totalInvoicedOtherYears.replace( '.', '' ) ) ); vm.totalInvoicedOtherYears(vm.totalInvoicedOtherYears() + Number(p.totalInvoicedOtherYears.replace('.', '')))
vm.totalInvoicedThisYear( vm.totalInvoicedThisYear() + Number( p.totalInvoicedThisYear.replace( '.', '' ) ) ); vm.totalInvoicedThisYear(vm.totalInvoicedThisYear() + Number(p.totalInvoicedThisYear.replace('.', '')))
vm.invoicesTotal( vm.invoicesTotal() + Number( p.invoicesTotal.replace( '.', '' ) ) ); vm.invoicesTotal(vm.invoicesTotal() + Number(p.invoicesTotal.replace('.', '')))
vm.totalPayment( vm.totalPayment() + Number( p.projectPayment.replace( '.', '' ) ) ); vm.totalPayment(vm.totalPayment() + Number(p.projectPayment.replace('.', '')))
vm.totalToPay( vm.totalToPay() + Number( p.invoiceToPay.replace( '.', '' ) ) ); vm.totalToPay(vm.totalToPay() + Number(p.invoiceToPay.replace('.', '')))
vm.needInvoice( Number( vm.needInvoice() ) + Number( p.needInvoice.replace( '.', '' ) ) ); vm.needInvoice(Number(vm.needInvoice()) + Number(p.needInvoice.replace('.', '')))
} ); })
vm.totalToInvoicingExcl( dbo.helpers.thousandSeparator( vm.totalToInvoicingExcl() ) ); vm.totalToInvoicingExcl(dbo.helpers.thousandSeparator(vm.totalToInvoicingExcl()))
vm.totalToInvoicingIncl( dbo.helpers.thousandSeparator( vm.totalToInvoicingIncl() ) ); vm.totalToInvoicingIncl(dbo.helpers.thousandSeparator(vm.totalToInvoicingIncl()))
vm.totalInvoicedOtherYears( dbo.helpers.thousandSeparator( vm.totalInvoicedOtherYears() ) ); vm.totalInvoicedOtherYears(dbo.helpers.thousandSeparator(vm.totalInvoicedOtherYears()))
vm.totalInvoicedThisYear( dbo.helpers.thousandSeparator( vm.totalInvoicedThisYear() ) ); vm.totalInvoicedThisYear(dbo.helpers.thousandSeparator(vm.totalInvoicedThisYear()))
vm.invoicesTotal( dbo.helpers.thousandSeparator( vm.invoicesTotal() ) ); vm.invoicesTotal(dbo.helpers.thousandSeparator(vm.invoicesTotal()))
vm.totalPayment( dbo.helpers.thousandSeparator( vm.totalPayment() ) ); vm.totalPayment(dbo.helpers.thousandSeparator(vm.totalPayment()))
vm.totalToPay( dbo.helpers.thousandSeparator( vm.totalToPay() ) ); vm.totalToPay(dbo.helpers.thousandSeparator(vm.totalToPay()))
vm.needInvoice( dbo.helpers.thousandSeparator( vm.needInvoice() ) ); vm.needInvoice(dbo.helpers.thousandSeparator(vm.needInvoice()))
}, },
setForecastsTotals: function (data) { setForecastsTotals: function (data) {
var vm = dbo.invoicereport; var vm = dbo.invoicereport
_.each(data, function (p) { _.each(data, function (p) {
vm.forecastThisYear( vm.forecastThisYear() + Number( p.forecastThisYear.replace( '.', '' ) ) ); vm.forecastThisYear(vm.forecastThisYear() + Number(p.forecastThisYear.replace('.', '')))
vm.forecastOtherYears( vm.forecastOtherYears() + Number( p.forecastOtherYears.replace( '.', '' ) ) ); vm.forecastOtherYears(vm.forecastOtherYears() + Number(p.forecastOtherYears.replace('.', '')))
vm.forecastRemaining( vm.forecastRemaining() + Number( p.forecastRemaining.replace( '.', '' ) ) ); vm.forecastRemaining(vm.forecastRemaining() + Number(p.forecastRemaining.replace('.', '')))
} ); })
vm.forecastThisYear( dbo.helpers.thousandSeparator( vm.forecastThisYear() ) ); vm.forecastThisYear(dbo.helpers.thousandSeparator(vm.forecastThisYear()))
vm.forecastOtherYears( dbo.helpers.thousandSeparator( vm.forecastOtherYears() ) ); vm.forecastOtherYears(dbo.helpers.thousandSeparator(vm.forecastOtherYears()))
vm.forecastRemaining( dbo.helpers.thousandSeparator( vm.forecastRemaining() ) ); vm.forecastRemaining(dbo.helpers.thousandSeparator(vm.forecastRemaining()))
}, },
setForecastMonthsTotals: function (data) { setForecastMonthsTotals: function (data) {
console.log( data ); console.log(data)
var vm = dbo.invoicereport; var vm = dbo.invoicereport
_.each(data, function (p) { _.each(data, function (p) {
_.each(p.forecastMonths(), function (q) { _.each(p.forecastMonths(), function (q) {
vm.forecastMonths( vm.forecastMonths() + q ); vm.forecastMonths(vm.forecastMonths() + q)
} ); })
} ); })
}, },
checkYear: function () { checkYear: function () {
var vm = dbo.invoicereport; var vm = dbo.invoicereport
if ( !Number.isInteger( Number( vm.selectedYear() ) ) ) return vm.validYear( false ); if (!Number.isInteger(Number(vm.selectedYear()))) return vm.validYear(false)
if ( Number( vm.selectedYear() ) > 2100 ) return vm.validYear( false ); if (Number(vm.selectedYear()) > 2100) return vm.validYear(false)
if ( Number( vm.selectedYear() ) < 2000 ) return vm.validYear( false ); if (Number(vm.selectedYear()) < 2000) return vm.validYear(false)
vm.validYear( true ); vm.validYear(true)
vm.initModule(); vm.initModule()
}, },
setActivetab: function (page) { setActivetab: function (page) {
var vm = dbo.invoicereport; var vm = dbo.invoicereport
vm.invoiceTab( page ); vm.invoiceTab(page)
}, },
Monthforecast: function (data) { Monthforecast: function (data) {
console.log( data ); var vm = dbo.invoicereport
var vm = dbo.invoicereport; var self = this
var self = this; self.projectnumber = data.projectnumber
self.projectnumber = data.projectnumber; self.projectname = data.projectname
self.projectname = data.projectname; self.customer = data.customer
self.customer = data.customer; self.needInvoice = data.needInvoice
self.needInvoice = data.needInvoice; self.forecastOtherYears = data.forecastOtherYears
self.forecastOtherYears = data.forecastOtherYears; self.forecastRemaining = data.forecastRemaining
self.forecastRemaining = data.forecastRemaining;
self.forecastMonths = ko.observableArray( [] ); self.forecastMonths = ko.observableArray([])
_.each(data.forecastMonths, function (p, i) { _.each(data.forecastMonths, function (p, i) {
self.forecastMonths.push( new vm.ForecastMonth( p ) ); self.forecastMonths.push(new vm.ForecastMonth(p))
_.each(vm.monthTotals(), function (q) { _.each(vm.monthTotals(), function (q) {
if ( q.monthID == (i + 1) ) q.forecastamount( Math.round( Number( q.forecastamount() ) ) + Math.round( Number( p.forecastamount ) ) ); if (q.monthID == (i + 1)) q.forecastamount(Math.round(Number(q.forecastamount())) + Math.round(Number(p.forecastamount)))
} ); })
} ); })
}, },
ForecastMonth: function (data) { ForecastMonth: function (data) {
this.forecastamount = dbo.helpers.thousandSeparator( Math.round( data.forecastamount ) ); this.forecastamount = dbo.helpers.thousandSeparator(Math.round(data.forecastamount))
}, },
Monthpayment: function (data) { Monthpayment: function (data) {
var vm = dbo.invoicereport; var vm = dbo.invoicereport
var self = this; var self = this
self.projectname = data.projectname; self.projectname = data.projectname
self.customer = data.customer; self.customer = data.customer
self.totalProjectPayments = data.totalProjectPayments; self.totalProjectPayments = data.totalProjectPayments
self.paymentMonths = ko.observableArray( [] ); self.paymentMonths = ko.observableArray([])
_.each(data.monthPayments, function (p, i) { _.each(data.monthPayments, function (p, i) {
self.paymentMonths.push( new vm.PaymentMonth( p ) ); self.paymentMonths.push(new vm.PaymentMonth(p))
_.each(vm.monthPaymentTotals(), function (q) { _.each(vm.monthPaymentTotals(), function (q) {
if ( q.monthID == i ) q.paymentamount( Math.round(Number( q.paymentamount()) ) + Math.round(Number( p.paymentamount ) )); if (q.monthID == i) q.paymentamount(Math.round(Number(q.paymentamount())) + Math.round(Number(p.paymentamount)))
} ); })
} ); })
}, },
PaymentMonth: function (data) { PaymentMonth: function (data) {
this.paymentamount = dbo.helpers.thousandSeparator( Math.round(data.paymentamount) ); this.paymentamount = dbo.helpers.thousandSeparator(Math.round(data.paymentamount))
},
Invoice : function(data){
var vat = Math.round((data.invoiceamount * 21) / 100);
var inclVat = vat + Number(data.invoiceamount);
this.invoiceamount = dbo.helpers.thousandSeparator(data.invoiceamount)
this.vat = dbo.helpers.thousandSeparator(vat)
this.inclVat = dbo.helpers.thousandSeparator(inclVat)
this.project = data.projectnumber + ' ' + data.projectname
this.invoicedate = data.invoicedate
this.name = data.name
this.invoicenumber = ko.observable(data.invoicenumber)
}, },
createSpreadsheet: function () { createSpreadsheet: function () {
var vm = dbo.invoicereport; var vm = dbo.invoicereport
var orderDirection = vm.orderDirection ? 'ASC' : 'DESC'; var orderDirection = vm.orderDirection ? 'ASC' : 'DESC'
var archive = vm.archive() ? 'T' : 'F'; var archive = vm.archive() ? 'T' : 'F'
var url = 'index.php/reports/reportsController/createInvoicesSpreadsheet/' + vm.selectedYear() + '/' + vm.orderType + '/' + orderDirection + '/' + archive; var url = 'index.php/reports/reportsController/createInvoicesSpreadsheet/' + vm.selectedYear() + '/' + vm.orderType + '/' + orderDirection + '/' + archive
window.open( url, '_blank' ); window.open(url, '_blank')
} }
} }
dbo.invoicereport.init(); dbo.invoicereport.init()
ko.applyBindings( ko.applyBindings(
dbo.invoicereport, document.getElementById( "INVOICEREPORT" ) ); dbo.invoicereport, document.getElementById('INVOICEREPORT'))
} }
} }
@@ -68,7 +68,7 @@ dbo.reservationsInit = function () {
var vm = dbo.reservationsModel; var vm = dbo.reservationsModel;
var self = this; var self = this;
self.projectnumber = data.projectnumber; self.projectnumber = data.projectnumber + ' ' + data.projectname;
self.costs = dbo.helpers.numberWithPoints( data.costs ); self.costs = dbo.helpers.numberWithPoints( data.costs );
self.reservation = dbo.helpers.numberWithPoints( data.reservation ); self.reservation = dbo.helpers.numberWithPoints( data.reservation );
self.payed = dbo.helpers.numberWithPoints( data.payed ); self.payed = dbo.helpers.numberWithPoints( data.payed );