diversen opmerkingen Peter

This commit is contained in:
2018-04-02 17:32:20 +02:00
parent 0fd25f359b
commit 1b0ad5de83
5 changed files with 79 additions and 29 deletions
@@ -14,13 +14,15 @@ dbo.outgoinginvoicesInit = function () {
} else {
dbo.outgoinginvoicesModel = {
initialize : null,
years : ko.observableArray( [] ),
selectedYear : ko.observable(),
selectedMonthID: ko.observable(),
projects : ko.observableArray( [] ),
invoiceTab : ko.observable( 'invoice' ),
months : ko.observableArray( dbo.monthArray ),
initialize : null,
years : ko.observableArray( [] ),
selectedYear : ko.observable(),
selectedMonthID : ko.observable(),
projects : ko.observableArray( [] ),
invoiceTab : ko.observable( 'invoice' ),
months : ko.observableArray( dbo.monthArray ),
totalToInvoice : ko.observable(),
totalToInvoiceFuture: ko.observable(),
init: function () {
var vm = dbo.outgoinginvoicesModel;
@@ -56,6 +58,8 @@ dbo.outgoinginvoicesInit = function () {
refreshInvoiceDetails: function () {
var vm = dbo.outgoinginvoicesModel;
vm.resetModel();
if ( vm.initialize ) return;
dbo.invoiceDataService.getInvoiceOverview( vm.selectedYear(), function ( data ) {
@@ -63,9 +67,17 @@ dbo.outgoinginvoicesInit = function () {
_.each( data, function ( p ) {
vm.projects.push( new vm.Project( p ) );
} );
vm.totalToInvoice( dbo.helpers.numberWithPoints( Math.round( vm.totalToInvoice() ) ) );
vm.totalToInvoiceFuture( dbo.helpers.numberWithPoints( Math.round( vm.totalToInvoiceFuture() ) ) );
} );
},
resetModel: function () {
var vm = dbo.outgoinginvoicesModel;
vm.totalToInvoice( 0 );
vm.totalToInvoiceFuture( 0 );
},
Project: function ( data ) {
var vm = dbo.outgoinginvoicesModel;
var self = this;
@@ -88,11 +100,12 @@ dbo.outgoinginvoicesInit = function () {
self.totalInvoiced = dbo.helpers.numberWithPoints( totalInvoiced );
self.invoicedOtherYearsPayed = dbo.helpers.numberWithPoints( Math.round( data.otheryearpayed ) );
self.invoicedCurentYearPayed = dbo.helpers.numberWithPoints( Math.round( data.currentyearpayed ) );
self.totalInvoicedPayed = dbo.helpers.numberWithPoints( totalInvoicedPayed );
self.notPayed = dbo.helpers.numberWithPoints( notPayed );
self.toInvoice = dbo.helpers.numberWithPoints( totalInvoice - totalInvoiced );
self.currentforecast = dbo.helpers.numberWithPoints( data.currentforecast );
self.otherforecast = dbo.helpers.numberWithPoints( data.otherforecast );
self.totalInvoicedPayed = dbo.helpers.numberWithPoints( Math.round( totalInvoicedPayed ) );
self.notPayed = dbo.helpers.numberWithPoints( Math.round( notPayed ) );
self.toInvoice = dbo.helpers.numberWithPoints( Math.round( totalInvoice - totalInvoiced ) );
self.toInvoiceFuture = dbo.helpers.numberWithPoints( Math.round( totalInvoice - totalInvoiced - Number( data.currentforecast ) ) );
self.currentforecast = dbo.helpers.numberWithPoints( Math.round( data.currentforecast ) );
self.otherforecast = dbo.helpers.numberWithPoints( Math.round( data.otherforecast ) );
self.missingForecast =
dbo.helpers.numberWithPoints( totalInvoice - totalInvoiced - data.otherforecast );
@@ -106,6 +119,9 @@ dbo.outgoinginvoicesInit = function () {
if ( !vm['payment' + p.month] ) vm['payment' + p.month] = ko.observable( 0 );
vm['payment' + p.month]( Number( vm['payment' + p.month]() ) + Number( p.paymentamount ) );
} );
vm.totalToInvoice( vm.totalToInvoice() + (totalInvoice - totalInvoiced) );
vm.totalToInvoiceFuture( vm.totalToInvoiceFuture() + (totalInvoice - totalInvoiced - Number( data.currentforecast )) );
},
Month: function ( data ) {