Debug 6 /reservation

This commit is contained in:
2018-07-31 13:47:47 +02:00
parent 2da7fdd9cc
commit c520c3386a
6 changed files with 52 additions and 25 deletions
@@ -9,7 +9,7 @@
class InvoiceOverview { class InvoiceOverview {
private $project; private $project;
private $currentYear; private $year;
private $projectname; private $projectname;
private $customer; private $customer;
private $totalToInvoicingExcl; private $totalToInvoicingExcl;
@@ -20,10 +20,12 @@ class InvoiceOverview {
private $needInvoice; private $needInvoice;
private $projectDetails; private $projectDetails;
public function __construct( $project ) public function __construct( $project, $year )
{ {
$this->project = $project; $this->project = $project;
$this->year = $year;
$this->handle(); $this->handle();
} }
@@ -39,8 +41,6 @@ class InvoiceOverview {
private function handle() private function handle()
{ {
$this->setCurrentyear();
$this->setProjectname(); $this->setProjectname();
$this->setCustomer(); $this->setCustomer();
@@ -60,11 +60,6 @@ class InvoiceOverview {
$this->setProjectDetails(); $this->setProjectDetails();
} }
private function setCurrentyear()
{
$this->currentYear = date( 'Y' );
}
private function setProjectname() private function setProjectname()
{ {
$this->projectname = $this->project->projectname . '(' . $this->project->projectnumber . ')'; $this->projectname = $this->project->projectname . '(' . $this->project->projectnumber . ')';
@@ -92,13 +87,13 @@ class InvoiceOverview {
private function setTotalInvoicedOtherYears() private function setTotalInvoicedOtherYears()
{ {
$this->totalInvoicedOtherYears = $this->totalInvoicedOtherYears =
Invoice::invoicePerYear( $this->project->id, $this->currentYear, FALSE ); Invoice::invoicePerYear( $this->project->id, $this->year, FALSE );
} }
private function setTotalInvoicedThisYear() private function setTotalInvoicedThisYear()
{ {
$this->totalInvoicedThisYear = $this->totalInvoicedThisYear =
Invoice::invoicePerYear( $this->project->id, $this->currentYear, TRUE ); Invoice::invoicePerYear( $this->project->id, $this->year, TRUE );
} }
private function setInvoicesTotal() private function setInvoicesTotal()
@@ -85,7 +85,10 @@ class MonthPayments {
private function setTotalProjectPayments() 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() private function setProjectDetails()
@@ -30,6 +30,7 @@ class ReservationTotals {
( (
SELECT SUM(costs) AS costs, SUM(payed) AS payed, external_id, project_id SELECT SUM(costs) AS costs, SUM(payed) AS payed, external_id, project_id
FROM projectcosts FROM projectcosts
WHERE from_reservation = 'T'
GROUP BY external_id, project_id GROUP BY external_id, project_id
) Q2 ) Q2
ON Q1.external_id = Q2.external_id AND Q1.project_id = Q2.project_id 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 SELECT SUM(costs) AS costs, SUM(payed) AS payed, external_id, project_id, id
FROM projectcosts FROM projectcosts
WHERE from_reservation = 'T'
GROUP BY external_id, project_id GROUP BY external_id, project_id
) Q4 ) Q4
ON Q3.external_id = Q4.external_id AND Q3.project_id = Q4.project_id ON Q3.external_id = Q4.external_id AND Q3.project_id = Q4.project_id
@@ -22,12 +22,13 @@
<th class="table-cyanish-header align-right"> <th class="table-cyanish-header align-right">
betaald betaald
</th> </th>
<th class="table-cyanish-header align-right">
via<br />reservering
</th>
<th class="table-cyanish-header align-right"> <th class="table-cyanish-header align-right">
te betalen te betalen
</th> </th>
<th class="table-cyanish-header" width="50px"> <th class="table-cyanish-header align-right">&nbsp;</th>
&nbsp;
</th>
</thead> </thead>
<tbody data-bind="foreach:projectcosts"> <tbody data-bind="foreach:projectcosts">
<tr> <tr>
@@ -85,6 +86,16 @@
data-bind="textInput:payed, visible:inEdit, data-bind="textInput:payed, visible:inEdit,
event:{change:$root.saveProjectcosts,keyup:$root.validateNumber.bind($data, 'payed')}"/> event:{change:$root.saveProjectcosts,keyup:$root.validateNumber.bind($data, 'payed')}"/>
</td> </td>
<td class="align-center">
<!-- ko if:fromReservation() -->
&nbsp;<i class="icon fa-check pointer"
data-bind="click:$root.toggleFromReservation"></i>
<!-- /ko -->
<!-- ko if: ! fromReservation() -->
&nbsp;<i class="icon fa-square-o pointer"
data-bind="click:$root.toggleFromReservation"></i>
<!-- /ko -->
</td>
<td class="align-right"> <td class="align-right">
<span> <span>
<i class="icon fa-euro"></i> <i class="icon fa-euro"></i>
@@ -100,7 +111,7 @@
</tbody> </tbody>
<tfoot> <tfoot>
<tr> <tr>
<td colspan="7"> <td colspan="8">
<button class="btn btn-primary btn-round btn-sm" data-bind="click:newProjectcost"> <button class="btn btn-primary btn-round btn-sm" data-bind="click:newProjectcost">
nieuwe projectkosten nieuwe projectkosten
</button> </button>
@@ -16,7 +16,7 @@
</th> </th>
<!-- /ko --> <!-- /ko -->
<th class="rotate"> <th class="rotate">
<div><span>Nog te factureren<br /> na lopend boekjaar incl. btw</span></div> <div><span>Nog te factureren<br /> overige boekjaren incl. btw</span></div>
</th> </th>
<th class="rotate"> <th class="rotate">
<div><span>Nog te prognotiseren<br />incl. btw</span></div> <div><span>Nog te prognotiseren<br />incl. btw</span></div>
+24 -8
View File
@@ -107,6 +107,15 @@ $( function () {
sessionStorage.setItem( "showPayment", showPayments ); sessionStorage.setItem( "showPayment", showPayments );
}, },
toggleFromReservation: function () {
var vm = dbo.editProjectModal;
var self = this;
self.fromReservation( !self.fromReservation() );
vm.saveProjectCost(self);
},
editProjectemployee: function () { editProjectemployee: function () {
var self = this; var self = this;
var vm = dbo.editProjectModal; var vm = dbo.editProjectModal;
@@ -476,16 +485,22 @@ $( function () {
saveProjectcosts: function () { saveProjectcosts: function () {
var vm = dbo.editProjectModal; var vm = dbo.editProjectModal;
var self = this;
vm.saveProjectCost( this );
},
saveProjectCost: function ( self ) {
var vm = dbo.editProjectModal;
var submitDATA = { var submitDATA = {
id : self.id, id : self.id,
project_id : vm.projectID, project_id : vm.projectID,
external_id: self.external_id(), external_id : self.external_id(),
description: self.description(), description : self.description(),
date : self.date(), date : self.date(),
costs : self.costs(), costs : self.costs(),
payed : self.payed() payed : self.payed(),
from_reservation: self.fromReservation() ? 'T' : 'F'
}; };
dbo.projectDataService.saveProjectcost( submitDATA, function ( data ) { dbo.projectDataService.saveProjectcost( submitDATA, function ( data ) {
@@ -925,6 +940,7 @@ $( function () {
self.costs = ko.observable( data.costs ); self.costs = ko.observable( data.costs );
self.payed = ko.observable( data.payed ); self.payed = ko.observable( data.payed );
self.inEdit = ko.observable( data.inEdit || false ); self.inEdit = ko.observable( data.inEdit || false );
self.fromReservation = ko.observable( data.from_reservation == 'T' ? true : false );
this.toPay = ko.pureComputed( function () { this.toPay = ko.pureComputed( function () {
if ( isNaN( self.costs() ) ) return 0; if ( isNaN( self.costs() ) ) return 0;