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 @@