From c520c3386a50f2b4329e773948232252c0524b04 Mon Sep 17 00:00:00 2001 From: Theo Weijmer Date: Tue, 31 Jul 2018 13:47:47 +0200 Subject: [PATCH] Debug 6 /reservation --- .../reports/invoice/InvoiceOverview.php | 17 ++++------ .../reports/invoice/MonthPayments.php | 5 ++- .../eloquent/queries/ReservationTotals.php | 2 ++ .../views/modals/partials/_projectcosts.php | 19 ++++++++--- .../reports/invoices/monthforecast_report.php | 2 +- public/js/lib/modals/projectModal.js | 32 ++++++++++++++----- 6 files changed, 52 insertions(+), 25 deletions(-) diff --git a/application/libraries/reports/invoice/InvoiceOverview.php b/application/libraries/reports/invoice/InvoiceOverview.php index b0f1397..af23524 100644 --- a/application/libraries/reports/invoice/InvoiceOverview.php +++ b/application/libraries/reports/invoice/InvoiceOverview.php @@ -9,7 +9,7 @@ class InvoiceOverview { private $project; - private $currentYear; + private $year; private $projectname; private $customer; private $totalToInvoicingExcl; @@ -20,10 +20,12 @@ class InvoiceOverview { private $needInvoice; private $projectDetails; - public function __construct( $project ) + public function __construct( $project, $year ) { $this->project = $project; + $this->year = $year; + $this->handle(); } @@ -39,8 +41,6 @@ class InvoiceOverview { private function handle() { - $this->setCurrentyear(); - $this->setProjectname(); $this->setCustomer(); @@ -60,11 +60,6 @@ class InvoiceOverview { $this->setProjectDetails(); } - private function setCurrentyear() - { - $this->currentYear = date( 'Y' ); - } - private function setProjectname() { $this->projectname = $this->project->projectname . '(' . $this->project->projectnumber . ')'; @@ -92,13 +87,13 @@ class InvoiceOverview { private function setTotalInvoicedOtherYears() { $this->totalInvoicedOtherYears = - Invoice::invoicePerYear( $this->project->id, $this->currentYear, FALSE ); + Invoice::invoicePerYear( $this->project->id, $this->year, FALSE ); } private function setTotalInvoicedThisYear() { $this->totalInvoicedThisYear = - Invoice::invoicePerYear( $this->project->id, $this->currentYear, TRUE ); + Invoice::invoicePerYear( $this->project->id, $this->year, TRUE ); } private function setInvoicesTotal() diff --git a/application/libraries/reports/invoice/MonthPayments.php b/application/libraries/reports/invoice/MonthPayments.php index 023e25f..12eed37 100644 --- a/application/libraries/reports/invoice/MonthPayments.php +++ b/application/libraries/reports/invoice/MonthPayments.php @@ -85,7 +85,10 @@ class MonthPayments { private function setTotalProjectPayments() { - $this->totalProjectPayments += $this->payment->paymentamount; + $paymentYear = date( 'Y', strtotime( $this->payment->paymentdate ) ); + + if ( $paymentYear == $this->year ) + $this->totalProjectPayments += $this->payment->paymentamount; } private function setProjectDetails() diff --git a/application/models/eloquent/queries/ReservationTotals.php b/application/models/eloquent/queries/ReservationTotals.php index 2b0ec39..9c7d4a3 100644 --- a/application/models/eloquent/queries/ReservationTotals.php +++ b/application/models/eloquent/queries/ReservationTotals.php @@ -30,6 +30,7 @@ class ReservationTotals { ( SELECT SUM(costs) AS costs, SUM(payed) AS payed, external_id, project_id FROM projectcosts + WHERE from_reservation = 'T' GROUP BY external_id, project_id ) Q2 ON Q1.external_id = Q2.external_id AND Q1.project_id = Q2.project_id @@ -44,6 +45,7 @@ class ReservationTotals { ( SELECT SUM(costs) AS costs, SUM(payed) AS payed, external_id, project_id, id FROM projectcosts + WHERE from_reservation = 'T' GROUP BY external_id, project_id ) Q4 ON Q3.external_id = Q4.external_id AND Q3.project_id = Q4.project_id diff --git a/application/views/modals/partials/_projectcosts.php b/application/views/modals/partials/_projectcosts.php index 8277740..0a1d63a 100644 --- a/application/views/modals/partials/_projectcosts.php +++ b/application/views/modals/partials/_projectcosts.php @@ -22,12 +22,13 @@ betaald + + via
reservering + te betalen - -   - +   @@ -85,6 +86,16 @@ data-bind="textInput:payed, visible:inEdit, event:{change:$root.saveProjectcosts,keyup:$root.validateNumber.bind($data, 'payed')}"/> + + +   + + +   + + @@ -100,7 +111,7 @@ - + diff --git a/application/views/reports/invoices/monthforecast_report.php b/application/views/reports/invoices/monthforecast_report.php index 1bafc8f..af2aba0 100644 --- a/application/views/reports/invoices/monthforecast_report.php +++ b/application/views/reports/invoices/monthforecast_report.php @@ -16,7 +16,7 @@ -
Nog te factureren
na lopend boekjaar incl. btw
+
Nog te factureren
overige boekjaren incl. btw
Nog te prognotiseren
incl. btw
diff --git a/public/js/lib/modals/projectModal.js b/public/js/lib/modals/projectModal.js index 66f135d..224fad9 100644 --- a/public/js/lib/modals/projectModal.js +++ b/public/js/lib/modals/projectModal.js @@ -107,6 +107,15 @@ $( function () { sessionStorage.setItem( "showPayment", showPayments ); }, + toggleFromReservation: function () { + var vm = dbo.editProjectModal; + var self = this; + + self.fromReservation( !self.fromReservation() ); + + vm.saveProjectCost(self); + }, + editProjectemployee: function () { var self = this; var vm = dbo.editProjectModal; @@ -476,16 +485,22 @@ $( function () { saveProjectcosts: function () { var vm = dbo.editProjectModal; - var self = this; + + vm.saveProjectCost( this ); + }, + + saveProjectCost: function ( self ) { + var vm = dbo.editProjectModal; var submitDATA = { - id : self.id, - project_id : vm.projectID, - external_id: self.external_id(), - description: self.description(), - date : self.date(), - costs : self.costs(), - payed : self.payed() + id : self.id, + project_id : vm.projectID, + external_id : self.external_id(), + description : self.description(), + date : self.date(), + costs : self.costs(), + payed : self.payed(), + from_reservation: self.fromReservation() ? 'T' : 'F' }; dbo.projectDataService.saveProjectcost( submitDATA, function ( data ) { @@ -925,6 +940,7 @@ $( function () { self.costs = ko.observable( data.costs ); self.payed = ko.observable( data.payed ); self.inEdit = ko.observable( data.inEdit || false ); + self.fromReservation = ko.observable( data.from_reservation == 'T' ? true : false ); this.toPay = ko.pureComputed( function () { if ( isNaN( self.costs() ) ) return 0;