From a3d200c38bb64c488c27ddb41b47130a6d5c132f Mon Sep 17 00:00:00 2001 From: Theo Weijmer Date: Sat, 5 May 2018 20:55:18 +0200 Subject: [PATCH] Diversen nav opmerkingen --- .../controllers/beheer/vatController.php | 5 ++ .../eloquent/queries/Qinvoiceoverview.php | 4 +- application/views/modals/partials/_hours.php | 4 +- .../views/modals/partials/_invoices.php | 2 +- application/views/pages/vat_view.php | 33 ++++++++++ application/views/partials/_js.php | 1 + .../views/reports/invoices/_invoicetable.php | 34 +++++++--- public/js/lib/dataservices/vatDataService.js | 7 +++ public/js/lib/modules/beheer/vatModule.js | 62 +++++++++++++++++++ .../lib/modules/reports/outgoingInvoices.js | 21 ++++++- 10 files changed, 156 insertions(+), 17 deletions(-) create mode 100644 application/views/pages/vat_view.php create mode 100644 public/js/lib/modules/beheer/vatModule.js diff --git a/application/controllers/beheer/vatController.php b/application/controllers/beheer/vatController.php index 5213a82..df9f176 100644 --- a/application/controllers/beheer/vatController.php +++ b/application/controllers/beheer/vatController.php @@ -33,4 +33,9 @@ class vatController extends MY_Controller { $this->json($vats); } + + public function addVat() + { + Vat::create([]); + } } \ No newline at end of file diff --git a/application/models/eloquent/queries/Qinvoiceoverview.php b/application/models/eloquent/queries/Qinvoiceoverview.php index 17a161b..7210d82 100644 --- a/application/models/eloquent/queries/Qinvoiceoverview.php +++ b/application/models/eloquent/queries/Qinvoiceoverview.php @@ -23,7 +23,6 @@ class Qinvoiceoverview { CONCAT(firstname, ' ', middlename, ' ', lastname) AS fullname, ( SELECT vatrate FROM vats WHERE archive = 'F' LIMIT 1 ) AS vatrate, COALESCE(reserved, 0 ) AS reserved, - COALESCE(reservedpayed, 0 ) AS reservedpayed, COALESCE(currentforecast, 0) AS currentforecast, COALESCE(otherforecast, 0) AS otherforecast FROM invoices INV @@ -47,8 +46,7 @@ class Qinvoiceoverview { ON INV.id = Q1.invoice_id LEFT JOIN ( SELECT project_id, - SUM(IF(payed='UNPAYED', reservationamount, 0)) reserved, - SUM(IF(payed='PAYED', reservationamount, 0)) reservedpayed + SUM( reservationamount) reserved FROM reservations GROUP BY project_id ) AS Q2 diff --git a/application/views/modals/partials/_hours.php b/application/views/modals/partials/_hours.php index 8cbab3b..dd1f0c4 100644 --- a/application/views/modals/partials/_hours.php +++ b/application/views/modals/partials/_hours.php @@ -7,7 +7,7 @@
- - - - @@ -43,17 +43,17 @@ - - - - @@ -133,7 +133,7 @@ - @@ -171,6 +171,24 @@ + + + + + +
+ medewerker @@ -16,7 +16,7 @@ declarabel + uren diff --git a/application/views/modals/partials/_invoices.php b/application/views/modals/partials/_invoices.php index 37950a4..dd5e189 100644 --- a/application/views/modals/partials/_invoices.php +++ b/application/views/modals/partials/_invoices.php @@ -4,7 +4,7 @@ uitgaande facturen -
+
diff --git a/application/views/pages/vat_view.php b/application/views/pages/vat_view.php new file mode 100644 index 0000000..7846466 --- /dev/null +++ b/application/views/pages/vat_view.php @@ -0,0 +1,33 @@ +
+
+
+
 
+ + + + + + + + + + + + + + + + + +
percentage
+ + + + + +
+ +
+
+
+ \ No newline at end of file diff --git a/application/views/partials/_js.php b/application/views/partials/_js.php index 094e1cb..ba91985 100644 --- a/application/views/partials/_js.php +++ b/application/views/partials/_js.php @@ -28,6 +28,7 @@ + diff --git a/application/views/reports/invoices/_invoicetable.php b/application/views/reports/invoices/_invoicetable.php index 6fa8e66..a5f9ccf 100644 --- a/application/views/reports/invoices/_invoicetable.php +++ b/application/views/reports/invoices/_invoicetable.php @@ -4,10 +4,10 @@
project
+
klant
+
status afgehandeld
+
nog te factureren (incl.btw)
+
nog te factureren lopend jaar
+
nog te factureren na lopend jaar
-
verschil prognose - werkelijk
+
+
nog te prognotiseren
+ totaal + + + + + + + + + + + + diff --git a/public/js/lib/dataservices/vatDataService.js b/public/js/lib/dataservices/vatDataService.js index 8a6a54b..d2f22b5 100644 --- a/public/js/lib/dataservices/vatDataService.js +++ b/public/js/lib/dataservices/vatDataService.js @@ -12,6 +12,13 @@ dbo.vatDataService = { .done( function ( data ) { callback( data ); } ); + }, + + addVat: function ( callback ) { + $.get( 'index.php/beheer/vatController/addVat' ) + .done( function () { + callback(); + } ); } } diff --git a/public/js/lib/modules/beheer/vatModule.js b/public/js/lib/modules/beheer/vatModule.js new file mode 100644 index 0000000..832a502 --- /dev/null +++ b/public/js/lib/modules/beheer/vatModule.js @@ -0,0 +1,62 @@ +/** + * Created by Pensare Software. + * User: Theo Weijmer + * Date: 05/05/2018 + * Time: 20:15 + */ + + +dbo.vatInit = function () { + + if ( dbo.vatModel !== undefined ) { + + } else { + + dbo.vatModel = { + + vats: ko.observableArray( [] ), + + init: function () { + var vm = dbo.vatModel; + + vm.refreshVat(); + }, + + addVat: function () { + var vm = dbo.vatModel; + dbo.vatDataService.addVat( function () { + vm.refreshVat(); + } ); + }, + + refreshVat: function () { + var vm = dbo.vatModel; + dbo.vatDataService.getVats( 'F', function ( data ) { + vm.vats.removeAll(); + + _.each( data, function ( p ) { + vm.vats( new vm.Vat( p ) ); + } ) + } ); + }, + + toggleEdit: function () { + this.inEdit( !this.inEdit() ); + }, + + Vat: function ( data, inEdit = false ) { + this.id = data.id; + this.vatrate = ko.observable( data.vatrate ); + this.inEdit = ko.observable( inEdit ); + }, + + removeVat : function(){ + + } + } + + dbo.vatModel.init(); + + ko.applyBindings( dbo.vatModel, document.getElementById( 'VAT' ) ); + } +}; \ No newline at end of file diff --git a/public/js/lib/modules/reports/outgoingInvoices.js b/public/js/lib/modules/reports/outgoingInvoices.js index ad841c9..6e5ef6e 100644 --- a/public/js/lib/modules/reports/outgoingInvoices.js +++ b/public/js/lib/modules/reports/outgoingInvoices.js @@ -25,13 +25,17 @@ dbo.outgoinginvoicesInit = function () { totalToInvoiceFuture: ko.observable(), initialize : null, validYear : ko.observable(), + totalToInvoice : ko.observable(), + totalCurrentforecast: ko.observable(), + totalOtherforecast : ko.observable(), + totalMissingForecast: ko.observable(), init: function () { var vm = dbo.outgoinginvoicesModel; vm.selectedYear( (new Date()).getFullYear() ); vm.selectedMonthID( 0 ); - vm.validYear(true); + vm.validYear( true ); vm.initModule(); }, @@ -72,6 +76,9 @@ dbo.outgoinginvoicesInit = function () { } ); vm.totalToInvoice( dbo.helpers.numberWithPoints( Math.round( vm.totalToInvoice() ) ) ); vm.totalToInvoiceFuture( dbo.helpers.numberWithPoints( Math.round( vm.totalToInvoiceFuture() ) ) ); + vm.totalCurrentforecast( dbo.helpers.numberWithPoints( Math.round( vm.totalCurrentforecast() ) ) ); + vm.totalOtherforecast( dbo.helpers.numberWithPoints( Math.round( vm.totalOtherforecast() ) ) ); + vm.totalMissingForecast( dbo.helpers.numberWithPoints( Math.round( vm.totalMissingForecast() ) ) ); } ); }, @@ -79,6 +86,9 @@ dbo.outgoinginvoicesInit = function () { var vm = dbo.outgoinginvoicesModel; vm.totalToInvoice( 0 ); vm.totalToInvoiceFuture( 0 ); + vm.totalCurrentforecast( 0 ); + vm.totalOtherforecast( 0 ); + vm.totalMissingForecast( 0 ); }, Project: function ( data ) { @@ -109,8 +119,9 @@ dbo.outgoinginvoicesInit = function () { 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 ); + var missingForcast = Math.round( totalInvoice - totalInvoiced - data.otherforecast - data.currentforecast ); + console.log( missingForcast ); + self.missingForecast = dbo.helpers.numberWithPoints( missingForcast ); self.months = ko.observableArray( [] ); _.each( data.months, function ( p ) { @@ -123,8 +134,12 @@ dbo.outgoinginvoicesInit = function () { 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 )) ); + vm.totalCurrentforecast( Number( vm.totalCurrentforecast() ) + Number( data.currentforecast ) ); + vm.totalOtherforecast( Number( vm.totalOtherforecast() ) + Number( data.otherforecast ) ); + vm.totalMissingForecast( Number( vm.totalMissingForecast() ) + Number( missingForcast ) ); }, Month: function ( data ) {