invoice report

This commit is contained in:
2018-03-02 17:06:41 +01:00
parent fad71498dd
commit f540bab261
8 changed files with 285 additions and 11 deletions
@@ -0,0 +1,18 @@
/**
* Created by Pensare Software.
* User: Theo Weijmer
* Date: 02/03/2018
* Time: 16:00
*/
dbo.invoiceDataService = {
getInvoiceOverview: function ( year, callback ) {
$.getJSON( 'index.php/reports/employeeHoursController/getInvoiceOverview/' + year )
.done( function ( data ) {
callback( data );
} );
}
}
@@ -14,6 +14,7 @@ dbo.employeehoursreportInit = function () {
dbo.employeeHoursreportModel = {
months : ko.observableArray( [
{monthID: 0, monthName : 'totaal'},
{monthID: 1, monthName: 'jan'},
{monthID: 2, monthName: 'febr'},
{monthID: 3, monthName: 'mrt'},
@@ -55,7 +56,7 @@ dbo.employeehoursreportInit = function () {
} );
vm.selectedYear( (new Date()).getFullYear() );
vm.selectedMonthID( 1 );
vm.selectedMonthID( 0 );
vm.initialize = false;
@@ -103,10 +104,10 @@ dbo.employeehoursreportInit = function () {
_.each( data, function ( p ) {
vm.employees.push( new vm.Employee( p ) );
vm.profitablehoursTotaal( vm.profitablehoursTotaal() + Number( p.profitablehours ) );
vm.nonprofitablehoursTotaal( vm.nonprofitablehoursTotaal() + Number( p.nonprofitablehours ) );
vm.nonprojecthoursTotaal( vm.nonprojecthoursTotaal() + Number( p.nonprojecthours ) );
vm.totalhoursTotaal( vm.totalhoursTotaal() + Number( p.totalhours ) );
vm.profitablehoursTotaal( Math.round(vm.profitablehoursTotaal() + Number( p.profitablehours )) );
vm.nonprofitablehoursTotaal( Math.round(vm.nonprofitablehoursTotaal() + Number( p.nonprofitablehours ) ));
vm.nonprojecthoursTotaal( Math.round(vm.nonprojecthoursTotaal() + Number( p.nonprojecthours ) ));
vm.totalhoursTotaal( Math.round(vm.totalhoursTotaal() + Number( p.totalhours )) );
vm.targetTotaal( Math.round( vm.targetTotaal() + Number( p.targethours / 12 ) ) );
vm.revenuesTotaal( Number( vm.revenuesTotaal() ) + Number( p.revenues ) );
@@ -141,7 +142,7 @@ dbo.employeehoursreportInit = function () {
this.profitablehours = data.profitablehours;
this.nonprofitablehours = data.nonprofitablehours;
this.nonprojecthours = data.nonprojecthours;
this.totalhours = data.totalhours;
this.totalhours = Math.round(data.totalhours);
this.target = Math.round( data.targethours / 12 );
this.occupancyRateTotal = Math.round( (data.totalhours / (data.targethours / 12)) * 100 );
this.occupancyRateHours = Math.round( (data.profitablehours / data.totalhours ) * 100 );
@@ -0,0 +1,91 @@
/**
* 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( [] ),
init: function () {
var vm = dbo.outgoinginvoicesModel;
vm.initialize = true;
dbo.reportsDataService.getUsedYears( function ( data ) {
vm.years.removeAll();
_.each( data, function ( p ) {
vm.years.push( {id: p.year, year: p.year} );
} );
vm.selectedYear( (new Date()).getFullYear() );
vm.selectedMonthID( 0 );
vm.initialize = false;
vm.initModule();
} );
},
initModule: function () {
var vm = dbo.outgoinginvoicesModel;
vm.refreshInvoiceDetails();
},
refreshInvoiceDetails: function () {
var vm = dbo.outgoinginvoicesModel;
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 ) );
} );
} );
},
Project: function ( data ) {
var openstaand = data.revenues - (Number( data.currentyear ) + Number( data.otheryear ));
this.projectnumber = data.projectnumber;
this.customername = data.customername;
this.statusProject = Math.abs( openstaand ) > 2 ? 'OPEN' : 'CLOSED';
this.fullname = data.fullname;
this.openstaand = dbo.helpers.numberWithPoints(Math.round(openstaand));
this.openstaandIncl = dbo.helpers.numberWithPoints(Math.round(openstaand * 1.21));
this.invoicedOtherYears = dbo.helpers.numberWithPoints(Math.round(data.otheryear));
this.invoicedCurentYear = dbo.helpers.numberWithPoints(Math.round(data.currentyear));
this.totalInvoiced = dbo.helpers.numberWithPoints(Math.round(data.currentyear) + Math.round(data.otheryear));
this.invoicedOtherYearsPayed = dbo.helpers.numberWithPoints(Math.round(data.otheryearpayed));
this.invoicedCurentYearPayed = dbo.helpers.numberWithPoints(Math.round(data.currentyearpayed));
this.totalInvoicedPayed = dbo.helpers.numberWithPoints(Math.round(data.currentyearpayed) + Math.round(data.otheryearpayed));
}
}
dbo.outgoinginvoicesModel.init();
ko.applyBindings(
dbo.outgoinginvoicesModel, document.getElementById( "OUTGOINGINVOICES" ) );
}
}