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 {
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()
@@ -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()
@@ -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
@@ -22,12 +22,13 @@
<th class="table-cyanish-header align-right">
betaald
</th>
<th class="table-cyanish-header align-right">
via<br />reservering
</th>
<th class="table-cyanish-header align-right">
te betalen
</th>
<th class="table-cyanish-header" width="50px">
&nbsp;
</th>
<th class="table-cyanish-header align-right">&nbsp;</th>
</thead>
<tbody data-bind="foreach:projectcosts">
<tr>
@@ -85,6 +86,16 @@
data-bind="textInput:payed, visible:inEdit,
event:{change:$root.saveProjectcosts,keyup:$root.validateNumber.bind($data, 'payed')}"/>
</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">
<span>
<i class="icon fa-euro"></i>
@@ -100,7 +111,7 @@
</tbody>
<tfoot>
<tr>
<td colspan="7">
<td colspan="8">
<button class="btn btn-primary btn-round btn-sm" data-bind="click:newProjectcost">
nieuwe projectkosten
</button>
@@ -16,7 +16,7 @@
</th>
<!-- /ko -->
<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 class="rotate">
<div><span>Nog te prognotiseren<br />incl. btw</span></div>
+24 -8
View File
@@ -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;