From 1b0ad5de83b1a27aace074ef18fa78a99b932e70 Mon Sep 17 00:00:00 2001 From: Theo Weijmer Date: Mon, 2 Apr 2018 17:32:20 +0200 Subject: [PATCH] diversen opmerkingen Peter --- .../eloquent/queries/Qinvoiceoverview.php | 6 ++- .../employeehours/employeemonthhours_view.php | 2 +- .../views/reports/invoices/_invoicetable.php | 46 +++++++++++++++---- public/js/lib/modals/offerModal.js | 14 ++++-- .../lib/modules/reports/outgoingInvoices.js | 40 +++++++++++----- 5 files changed, 79 insertions(+), 29 deletions(-) diff --git a/application/models/eloquent/queries/Qinvoiceoverview.php b/application/models/eloquent/queries/Qinvoiceoverview.php index 650727c..e2dd8f2 100644 --- a/application/models/eloquent/queries/Qinvoiceoverview.php +++ b/application/models/eloquent/queries/Qinvoiceoverview.php @@ -16,8 +16,8 @@ class Qinvoiceoverview { PRJ.projectname, (own_revenue + other_revenue ) AS revenues, CUS.name AS customername, - SUM(IF( YEAR(invoicedate) = {$year},invoiceamount, 0)) AS currentyear, - SUM(IF( YEAR(invoicedate) != {$year},invoiceamount, 0)) AS otheryear, + SUM(IF( YEAR(invoicedate) = {$year}, invoiceamount* ((100 + vts.vatrate)/100), 0)) AS currentyear, + SUM(IF( YEAR(invoicedate) != {$year}, invoiceamount * ((100 + vts.vatrate)/100), 0)) AS otheryear, SUM(COALESCE(Q1.currentyearpayed, 0)) AS currentyearpayed, SUM(COALESCE(Q1.otheryearpayed, 0)) AS otheryearpayed, CONCAT(firstname, ' ', middlename, ' ', lastname) AS fullname, @@ -35,6 +35,8 @@ class Qinvoiceoverview { ON CUS.id = PRJ.customer_id JOIN users USR ON USR.id = PRJ.projectleader_id + JOIN vats VTS + ON VTS.id = INV.vat_id LEFT JOIN ( SELECT invoice_id, SUM(IF(YEAR(paymentdate) = {$year},paymentamount, 0)) AS currentyearpayed, diff --git a/application/views/reports/employeehours/employeemonthhours_view.php b/application/views/reports/employeehours/employeemonthhours_view.php index e104855..5df4703 100644 --- a/application/views/reports/employeehours/employeemonthhours_view.php +++ b/application/views/reports/employeehours/employeemonthhours_view.php @@ -27,7 +27,7 @@ % % - + % diff --git a/application/views/reports/invoices/_invoicetable.php b/application/views/reports/invoices/_invoicetable.php index e3381e5..89f22bf 100644 --- a/application/views/reports/invoices/_invoicetable.php +++ b/application/views/reports/invoices/_invoicetable.php @@ -10,9 +10,9 @@
status afgehandeld
- -
projectleider
- + + +
te factureren(excl btw)
@@ -27,7 +27,7 @@
gefactureerd lopend jaar(incl btw)
-
totaal gefactureerd(incl btw)
+
totaal gefactureerd
betaald voorgaande jaren
@@ -44,7 +44,7 @@ -
nog te factureren
+
nog te factureren (incl.btw)
nog te factureren lopend jaar
@@ -56,9 +56,20 @@
verschil prognose - werkelijk
- + + +
te factureren(incl btw)
+ - +
+ + +
te factureren volgende jaren
+ + + + +
@@ -69,7 +80,7 @@ - + @@ -128,12 +139,21 @@ + + + + + + + + + @@ -148,16 +168,24 @@ - + totaal + + + + + + + + diff --git a/public/js/lib/modals/offerModal.js b/public/js/lib/modals/offerModal.js index 076bfe1..46d6a3d 100644 --- a/public/js/lib/modals/offerModal.js +++ b/public/js/lib/modals/offerModal.js @@ -23,19 +23,23 @@ $( function () { other_revenue : ko.observable(), hasProject : ko.observable(), - init: function () { + init: function ( callback = false ) { dbo.editOfferModal.refreshCustomers(); dbo.editOfferModal.refreshUsers(); + + if ( typeof(callback) == 'function' ) callback(); }, newEditOffer: function ( offer, projectID = false, customerID = false, hasProject = false, callback ) { var vm = dbo.editOfferModal; vm.callback = typeof(callback) == 'function' ? callback : null; - vm.showOfferModal(); + vm.init( function () { + vm.showOfferModal(); - vm.setOffer( offer, projectID, customerID, hasProject ); + vm.setOffer( offer, projectID, customerID, hasProject ); + } ); }, getCustomerProjects: function () { @@ -77,7 +81,7 @@ $( function () { title : 'project aangemaakt', message : 'er is een project aangemaakt met nummer: ' + data.projectnumber, modalClass: 'modal-success' - }, function(){ + }, function () { vm.hideOfferModal(); vm.callback(); } ); @@ -104,7 +108,7 @@ $( function () { message : errorMessage, modalClass: 'modal-danger' } ); - }else{ + } else { vm.hideOfferModal(); vm.callback(); } diff --git a/public/js/lib/modules/reports/outgoingInvoices.js b/public/js/lib/modules/reports/outgoingInvoices.js index 987434c..be2adf8 100644 --- a/public/js/lib/modules/reports/outgoingInvoices.js +++ b/public/js/lib/modules/reports/outgoingInvoices.js @@ -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 ) {