Diverse wijzigingen

This commit is contained in:
2018-05-05 13:22:14 +02:00
parent 860c5db95a
commit b589058437
13 changed files with 105 additions and 41 deletions
@@ -41,6 +41,8 @@ class ProjectsController extends MY_Controller {
$project->invoiceDetails = $project->invoiceDetails =
$this->Invoices_model->getOutstandingPerProject( $project->id ); $this->Invoices_model->getOutstandingPerProject( $project->id );
$project->vatrate = Vat::getCurrentVat();
$this->json( $project ); $this->json( $project );
} }
@@ -18,7 +18,7 @@ class EmployeeTargetValidation extends BaseValidation {
'fieldname' => 'gebruiker' 'fieldname' => 'gebruiker'
], ],
'startmonth' => [ 'startmonth' => [
'validations' => 'required|decimal', 'validations' => 'integer',
'fieldname' => 'startmaand' 'fieldname' => 'startmaand'
], ],
'startyear' => [ 'startyear' => [
@@ -56,7 +56,9 @@ class Employeetarget extends BaseModel {
if( $monthTarget->count() == 0 ) return 0; if( $monthTarget->count() == 0 ) return 0;
return $monthTarget->first()->target; $monthtarget = $monthTarget->first();
return $monthtarget->target;
} }
} }
+9
View File
@@ -27,4 +27,13 @@ class Vat extends BaseModel {
return $vats; return $vats;
} }
public static function getCurrentVat()
{
$currentVat = Vat::whereActive('T')->whereArchive('F')->first();
if( ! $currentVat) return 0;
return $currentVat->vatrate;
}
} }
+22 -16
View File
@@ -27,22 +27,28 @@ class Invoices_model extends MY_Model {
public function getOutstandingPerProject( $projectID ) public function getOutstandingPerProject( $projectID )
{ {
$this->sql = " $this->sql = "
SELECT (own_revenue + other_revenue) AS totalrevenue, SELECT (own_revenue + other_revenue) AS totalrevenue,
ROUND(SUM(INV.invoiceamount * ((100 + vatrate) / 100)), 0) AS totalinvoiced, ROUND(SUM(INV.invoiceamount * ((100 + vatrate) / 100)), 0) AS totalinvoiced,
SUM(payed) AS payed (
FROM invoices INV SELECT SUM(paymentamount) PAYMENTAMOUNT
JOIN projects PRJ FROM payments PAY
ON PRJ.id = INV.project_id JOIN invoices INV
JOIN vats VTS ON INV.id = PAY.invoice_id
ON VTS.id = INV.vat_id WHERE INV.project_id = {$projectID}
JOIN offers OFF ) AS payed
ON PRJ.id = OFF.project_id FROM invoices INV
LEFT JOIN ( JOIN projects PRJ
SELECT SUM(paymentamount) payed, invoice_id ON PRJ.id = INV.project_id
FROM payments JOIN (
) PAY SELECT vatrate, id
ON INV.id = PAY.invoice_id FROM vats
WHERE PRJ.id = {$projectID} "; WHERE active = 'T'
AND archive = 'F'
) VTS
ON VTS.id = INV.vat_id
JOIN offers OFF
ON PRJ.id = OFF.project_id
WHERE PRJ.id = {$projectID} ";
$invoiceDetails = $this->get_query_row(); $invoiceDetails = $this->get_query_row();
@@ -74,7 +74,28 @@
</tr> </tr>
<tr> <tr>
<th colspan="4"> <th colspan="4">
<b><h5>te prognotiseren: <span data-bind="text:toForecast"></span></h5></b> <table class="table table-condensed">
<thead>
<tr>
<th>te factureren</th>
<th>geprognosticeerd</th>
<th>nog te prognosticeren</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<span data-bind="text:outstanding"></span>
</td>
<td>
<span data-bind="text:totalForecast"></span>
</td>
<td>
<span data-bind="text:toForecast"></span>
</td>
</tr>
</tbody>
</table>
</th> </th>
</tr> </tr>
</tfoot> </tfoot>
@@ -88,29 +88,34 @@
<div class="panel panel-bordered panel-primary panel-line"> <div class="panel panel-bordered panel-primary panel-line">
<div class="panel-heading panel-heading-project"> <div class="panel-heading panel-heading-project">
<h3 class=""> <h3 class="">
Financieel Financieel <i class="icon fa-refresh pull-right" title="ververs" data-bind="click:refreshProject"></i>
</h3> </h3>
</div> </div>
<div class="panel-body panel-body-project"> <div class="panel-body panel-body-project">
<label class="col-md-6 col-form-label">eigen omzet</label> <label class="col-md-6 col-form-label">eigen omzet(excl.btw)</label>
<div class="col-md-6"> <div class="col-md-6">
<h4 class="form-control-label"> <h4 class="form-control-label">
<i class="icon fa-euro"> </i><span class="euro-amount" data-bind="text:ownRevenue"></span> <i class="icon fa-euro"> </i><span class="euro-amount" data-bind="text:ownRevenue"></span>
</h4> </h4>
</div> </div>
<div class="divider"></div> <div class="divider"></div>
<label class="col-md-6 col-form-label">overige omzet</label> <label class="col-md-6 col-form-label">overige omzet(excl.btw)</label>
<div class="col-md-6"> <div class="col-md-6">
<h4 class="form-control-label"> <h4 class="form-control-label">
<i class="icon fa-euro"> </i><span class="euro-amount" data-bind="text:otherRevenue"></span> <i class="icon fa-euro"> </i><span class="euro-amount" data-bind="text:otherRevenue"></span>
</h4> </h4>
</div> </div>
<div class="divider"></div> <div class="divider"></div>
<label class="col-md-6 col-form-label">Totaal omzet</label> <label class="col-md-6 col-form-label">Totaal omzet(excl.btw)</label>
<div class="col-md-6"> <div class="col-md-6">
<h4><i class="icon fa-euro"> </i><span class="euro-amount" data-bind="text:totalRevenues"></span></h4> <h4><i class="icon fa-euro"> </i><span class="euro-amount" data-bind="text:totalRevenues"></span></h4>
</div> </div>
<div class="divider"></div> <div class="divider"></div>
<label class="col-md-6 col-form-label">Totaal omzet(incl.btw)</label>
<div class="col-md-6">
<h4><i class="icon fa-euro"> </i><span class="euro-amount" data-bind="text:totalRevenuesIncl"></span></h4>
</div>
<div class="divider"></div>
<label class="col-md-6 col-form-label">Totaal gefactureerd</label> <label class="col-md-6 col-form-label">Totaal gefactureerd</label>
<div class="col-md-6"> <div class="col-md-6">
<h4><i class="icon fa-euro"> </i><span class="euro-amount" data-bind="text:totalInvoiced"></span></h4> <h4><i class="icon fa-euro"> </i><span class="euro-amount" data-bind="text:totalInvoiced"></span></h4>
@@ -10,7 +10,7 @@
<th class="rotate"><div><span>totaal bestede uren</span></div></th> <th class="rotate"><div><span>totaal bestede uren</span></div></th>
<th class="rotate"><div><span>uren jaartarget</span></div></th> <th class="rotate"><div><span>uren jaartarget</span></div></th>
<th class="rotate"><div><span>aandeel uren besteed tov target</span></div></th> <th class="rotate"><div><span>aandeel uren besteed tov target</span></div></th>
<th class="rotate"><div><span>bezettingsgraad totaal<br />aantal gewerkte uren</span></div></th> <th class="rotate"><div><span>percentage declarable<br />tov totaal</span></div></th>
<th class="rotate"><div><span>bezettingsgraad t.o.v. target<br />factureerbare uren</span></div></th> <th class="rotate"><div><span>bezettingsgraad t.o.v. target<br />factureerbare uren</span></div></th>
<th class="rotate"><div><span>omzet</span></div></th> <th class="rotate"><div><span>omzet</span></div></th>
<th class="rotate"><div><span>gemiddeld tarief</span></div></th> <th class="rotate"><div><span>gemiddeld tarief</span></div></th>
@@ -67,6 +67,9 @@
<th class="align-right"> <th class="align-right">
<span data-bind="text:availableRevenue"></span> <span data-bind="text:availableRevenue"></span>
</th> </th>
<th class="align-right">
<span data-bind="text:owp"></span>
</th>
<!-- <td class="align-right">--> <!-- <td class="align-right">-->
<!-- <span data-bind="text:externCosts"></span>--> <!-- <span data-bind="text:externCosts"></span>-->
<!-- </td>--> <!-- </td>-->
@@ -100,6 +103,9 @@
<th class="align-right"> <th class="align-right">
<span data-bind="text:totalAvailableRevenues"></span> <span data-bind="text:totalAvailableRevenues"></span>
</th> </th>
<th class="align-right">
<span data-bind="text:totalOwp"></span>
</th>
<!-- <th class="align-right">--> <!-- <th class="align-right">-->
<!-- <span data-bind="text:totalCosts"></span>--> <!-- <span data-bind="text:totalCosts"></span>-->
<!-- </th>--> <!-- </th>-->
+3 -2
View File
@@ -92,6 +92,7 @@ $( function () {
dbo.employeeTargetDataService.getEmployeeTargets( vm.employeeID, function ( data ) { dbo.employeeTargetDataService.getEmployeeTargets( vm.employeeID, function ( data ) {
vm.employeeTargets.removeAll(); vm.employeeTargets.removeAll();
vm.newTarget( true );
vm.targetLength = data.length vm.targetLength = data.length
var i = 0; var i = 0;
_.each( data, function ( p ) { _.each( data, function ( p ) {
@@ -132,8 +133,8 @@ $( function () {
return false; return false;
} ); } );
if ( ! self.endmonth() ) vm.newTarget( false ); if ( !self.endmonth() ) vm.newTarget( false );
if ( ! self.endyear() ) vm.newTarget( false ); if ( !self.endyear() ) vm.newTarget( false );
} }
}; };
+12 -6
View File
@@ -42,16 +42,16 @@ $( function () {
years : ko.observableArray( dbo.years ), years : ko.observableArray( dbo.years ),
months : ko.observableArray( dbo.monthArray ), months : ko.observableArray( dbo.monthArray ),
outstanding : ko.observable(), outstanding : ko.observable(),
toForecast : ko.observable(),
totalForecast : ko.observable(),
documents : ko.observableArray( [] ), documents : ko.observableArray( [] ),
comments : ko.observableArray( [] ), comments : ko.observableArray( [] ),
activeTab : ko.observable(), activeTab : ko.observable(),
totalRevenues : ko.observable(), totalRevenues : ko.observable(),
totalInvoiced : ko.observable(), totalInvoiced : ko.observable(),
totalRevenuesIncl : ko.observable(),
outstanding : ko.observable(), outstanding : ko.observable(),
outstandingInvoices: ko.observable(), outstandingInvoices: ko.observable(),
payed : ko.observable(), payed : ko.observable(),
totalForecast : ko.observable(),
toForecast : ko.observable(), toForecast : ko.observable(),
toInvoice : 0, toInvoice : 0,
@@ -186,6 +186,7 @@ $( function () {
p.inEdit( false ); p.inEdit( false );
} }
} ); } );
vm.toForecasting();
}, },
editReservation: function () { editReservation: function () {
@@ -724,6 +725,8 @@ $( function () {
vm.busy = true; vm.busy = true;
dbo.projectDataService.getProject( vm.projectID, function ( data ) { dbo.projectDataService.getProject( vm.projectID, function ( data ) {
var totalRevenuesIncl = Math.round( (data.invoiceDetails.totalrevenue * (data.vatrate + 100)) / 100 );
vm.id = data.id vm.id = data.id
vm.projectleaderID( data.projectleader_id ); vm.projectleaderID( data.projectleader_id );
vm.customerID( data.customer_id ); vm.customerID( data.customer_id );
@@ -732,11 +735,12 @@ $( function () {
vm.projectnumber( data.projectnumber ); vm.projectnumber( data.projectnumber );
vm.projectname( data.projectname ); vm.projectname( data.projectname );
vm.totalRevenues( dbo.helpers.numberWithPoints( Math.round( Number( data.invoiceDetails.totalrevenue ) ) ) ); vm.totalRevenues( dbo.helpers.numberWithPoints( Math.round( Number( data.invoiceDetails.totalrevenue ) ) ) );
vm.totalRevenuesIncl( dbo.helpers.numberWithPoints( totalRevenuesIncl ));
vm.totalInvoiced( dbo.helpers.numberWithPoints( Math.round( Number( data.invoiceDetails.totalinvoiced ) ) ) ); vm.totalInvoiced( dbo.helpers.numberWithPoints( Math.round( Number( data.invoiceDetails.totalinvoiced ) ) ) );
vm.outstanding( dbo.helpers.numberWithPoints( Math.round( Number( data.invoiceDetails.totalrevenue ) ) - Math.round( Number( data.invoiceDetails.totalinvoiced ) ) ) ); vm.outstanding( dbo.helpers.numberWithPoints( Math.round( Number( totalRevenuesIncl ) ) - Math.round( Number( data.invoiceDetails.totalinvoiced ) ) ) );
vm.outstandingInvoices( dbo.helpers.numberWithPoints( Math.round( Number( data.invoiceDetails.totalinvoiced ) ) - Math.round( Number( data.invoiceDetails.payed ) ) ) ); vm.outstandingInvoices( dbo.helpers.numberWithPoints( Math.round( Number( data.invoiceDetails.totalinvoiced ) ) - Math.round( Number( data.invoiceDetails.payed ) ) ) );
vm.payed( dbo.helpers.numberWithPoints( Math.round( Number( data.invoiceDetails.payed ) ) ) ); vm.payed( dbo.helpers.numberWithPoints( Math.round( Number( data.invoiceDetails.payed ) ) ) );
vm.toInvoice = Math.round( Number( data.invoiceDetails.totalrevenue ) ) - Math.round( Number( data.invoiceDetails.totalinvoiced ) ); vm.toInvoice = Math.round( totalRevenuesIncl - Number( data.invoiceDetails.totalinvoiced ) );
vm.projectEmployees.removeAll(); vm.projectEmployees.removeAll();
vm.projecthours.removeAll(); vm.projecthours.removeAll();
@@ -793,13 +797,15 @@ $( function () {
toForecasting: function () { toForecasting: function () {
var vm = dbo.editProjectModal; var vm = dbo.editProjectModal;
console.log( vm.toInvoice );
vm.totalForecast(0);
vm.toForecast( vm.toInvoice ); vm.toForecast( vm.toInvoice );
_.each( vm.forecasts(), function ( p ) { _.each( vm.forecasts(), function ( p ) {
console.log( p.forecastamount ); vm.totalForecast( vm.totalForecast() + Number( p.forecastamount() ));
vm.toForecast( vm.toForecast() - Number( p.forecastamount() ) ); vm.toForecast( vm.toForecast() - Number( p.forecastamount() ) );
} ); } );
vm.toForecast( dbo.helpers.numberWithPoints( Number( vm.toForecast() ) ) ); vm.toForecast( dbo.helpers.numberWithPoints( Number( vm.toForecast() ) ) );
vm.totalForecast( dbo.helpers.numberWithPoints( Number( vm.totalForecast() ) ) );
}, },
Projectemployee: function ( data ) { Projectemployee: function ( data ) {
@@ -123,9 +123,9 @@ dbo.employeehoursreportInit = function () {
chartData.averageRate.push( Math.round( (p.revenues / p.profitablehours) * 8 ) ) chartData.averageRate.push( Math.round( (p.revenues / p.profitablehours) * 8 ) )
chartData.hours.push( p.totalhours ); chartData.hours.push( p.totalhours );
} ); } );
vm.occupancyRateTotalTotaal( Math.round( (vm.totalhoursTotaal() / vm.targetTotaal()) * 100 ) ); vm.occupancyRateTotalTotaal( Math.round( (vm.totalhoursTotaal() / vm.targetTotaal()) * 1000 ) / 10 );
vm.occupancyRateHoursTotaal( Math.round( (vm.profitablehoursTotaal() / vm.totalhoursTotaal()) * 100 ) ); vm.occupancyRateHoursTotaal( Math.round( (vm.profitablehoursTotaal() / vm.totalhoursTotaal()) * 1000 ) / 10 );
vm.occupancyRateInvoiceTotaal( Math.round( (vm.profitablehoursTotaal() / vm.targetTotaal()) * 100 ) ); vm.occupancyRateInvoiceTotaal( Math.round( (vm.profitablehoursTotaal() / vm.targetTotaal()) * 1000 ) / 10 );
vm.averageDayRateTotaal( Math.round( Number( vm.revenuesTotaal() ) / Number( vm.profitablehoursTotaal() ) ) * 8 ); vm.averageDayRateTotaal( Math.round( Number( vm.revenuesTotaal() ) / Number( vm.profitablehoursTotaal() ) ) * 8 );
vm.revenuesTotaal( dbo.helpers.thousandSeparator( vm.revenuesTotaal() ) ); vm.revenuesTotaal( dbo.helpers.thousandSeparator( vm.revenuesTotaal() ) );
@@ -151,9 +151,9 @@ dbo.employeehoursreportInit = function () {
this.nonprojecthours = data.nonprojecthours; this.nonprojecthours = data.nonprojecthours;
this.totalhours = Math.round( data.totalhours ); this.totalhours = Math.round( data.totalhours );
this.target = dbo.helpers.numberWithPoints( Math.round( data.targethours ) ); this.target = dbo.helpers.numberWithPoints( Math.round( data.targethours ) );
this.occupancyRateTotal = Math.round( (data.totalhours / data.targethours) * 100 ); this.occupancyRateTotal = Math.round( (data.totalhours / data.targethours) * 1000 ) / 10;
this.occupancyRateHours = Math.round( (data.profitablehours / data.totalhours) * 100 ); this.occupancyRateHours = Math.round( (data.profitablehours / data.totalhours) * 1000 ) / 10;
this.occupancyRateInvoice = Math.round( (data.profitablehours / data.targethours) * 100 ); this.occupancyRateInvoice = Math.round( (data.profitablehours / data.targethours) * 1000 ) / 10;
this.revenues = dbo.helpers.thousandSeparator( data.revenues ); this.revenues = dbo.helpers.thousandSeparator( data.revenues );
this.averageDayRate = Math.round( (data.revenues / data.profitablehours) * 8 ); this.averageDayRate = Math.round( (data.revenues / data.profitablehours) * 8 );
} }
@@ -33,9 +33,10 @@ dbo.monthlyemployeehoursInit = function () {
totalCosts : ko.observable(), totalCosts : ko.observable(),
totalAvailableBudget : ko.observable(), totalAvailableBudget : ko.observable(),
totalSaldo : ko.observable(), totalSaldo : ko.observable(),
totalOwp : ko.observable(),
totalWorkInProgress : ko.observable(), totalWorkInProgress : ko.observable(),
totalInvoicedYear : ko.observableArray( [] ), totalInvoicedYear : ko.observableArray( [] ),
validYear : ko.observable(true), validYear : ko.observable( true ),
init: function () { init: function () {
var vm = dbo.monthlyEmployeeHoursModel; var vm = dbo.monthlyEmployeeHoursModel;
@@ -60,6 +61,7 @@ dbo.monthlyemployeehoursInit = function () {
vm.totalAvailableRevenues( 0 ) vm.totalAvailableRevenues( 0 )
vm.totalEmployeeHours( 0 ); vm.totalEmployeeHours( 0 );
vm.totalEmployeeAvailableHours( 0 ); vm.totalEmployeeAvailableHours( 0 );
vm.totalOwp( 0 );
vm.totalPerEmployee.removeAll(); vm.totalPerEmployee.removeAll();
vm.totalInvoicedYear.removeAll(); vm.totalInvoicedYear.removeAll();
dbo.userDataService.getUniqueProjectEmployees( function ( data ) { dbo.userDataService.getUniqueProjectEmployees( function ( data ) {
@@ -86,7 +88,8 @@ dbo.monthlyemployeehoursInit = function () {
vm.totalSaldo( dbo.helpers.thousandSeparator( vm.totalSaldo() ) ); vm.totalSaldo( dbo.helpers.thousandSeparator( vm.totalSaldo() ) );
vm.totalWorkInProgress( dbo.helpers.thousandSeparator( vm.totalWorkInProgress() ) ); vm.totalWorkInProgress( dbo.helpers.thousandSeparator( vm.totalWorkInProgress() ) );
vm.totalEmployeeRevenues( dbo.helpers.thousandSeparator( vm.totalEmployeeRevenues() ) ); vm.totalEmployeeRevenues( dbo.helpers.thousandSeparator( vm.totalEmployeeRevenues() ) );
vm.totalAvailableRevenues( dbo.helpers.thousandSeparator( vm.totalEmployeeRevenues() < 0 ? 0 :vm.totalEmployeeRevenues() ) ); vm.totalAvailableRevenues( dbo.helpers.thousandSeparator( vm.totalAvailableRevenues() ));
vm.totalOwp( dbo.helpers.thousandSeparator( vm.totalOwp() ) );
vm.totalEmployeeHours( dbo.helpers.thousandSeparator( vm.totalEmployeeHours() ) ); vm.totalEmployeeHours( dbo.helpers.thousandSeparator( vm.totalEmployeeHours() ) );
_.each( vm.totalPerEmployee(), function ( p ) { _.each( vm.totalPerEmployee(), function ( p ) {
p.totalRevenue( dbo.helpers.thousandSeparator( p.totalRevenue() ) ); p.totalRevenue( dbo.helpers.thousandSeparator( p.totalRevenue() ) );
@@ -306,6 +309,7 @@ dbo.monthlyemployeehoursInit = function () {
self.hours = data.hours; self.hours = data.hours;
self.totalEmpoloyeeRevenues = 0; self.totalEmpoloyeeRevenues = 0;
self.availableRevenue = data.own_revenue - data.projectEuros; self.availableRevenue = data.own_revenue - data.projectEuros;
self.owp = self.availableRevenue < 0 ? 0 : self.availableRevenue;
self.externCosts = dbo.helpers.thousandSeparator( data.projectcosts ); self.externCosts = dbo.helpers.thousandSeparator( data.projectcosts );
self.budget = dbo.helpers.thousandSeparator( data.budget ); self.budget = dbo.helpers.thousandSeparator( data.budget );
self.ownRevenue = dbo.helpers.thousandSeparator( data.own_revenue ); self.ownRevenue = dbo.helpers.thousandSeparator( data.own_revenue );
@@ -321,13 +325,15 @@ dbo.monthlyemployeehoursInit = function () {
self.totalEmployeeRevenues = data.projectEuros; self.totalEmployeeRevenues = data.projectEuros;
self.totalEmployeeHours = data.projectHours; self.totalEmployeeHours = data.projectHours;
self.hoursAvailable = data.hoursAvailable; self.hoursAvailable = data.hoursAvailable;
vm.totalAvailableRevenues( vm.totalAvailableRevenues() + self.availableRevenue );
vm.totalEmployeeRevenues( vm.totalEmployeeRevenues() + Number( self.totalEmployeeRevenues ) ); vm.totalEmployeeRevenues( vm.totalEmployeeRevenues() + Number( self.totalEmployeeRevenues ) );
vm.totalEmployeeHours( vm.totalEmployeeHours() + Number( self.totalEmployeeHours ) ); vm.totalEmployeeHours( vm.totalEmployeeHours() + Number( self.totalEmployeeHours ) );
vm.totalEmployeeAvailableHours( vm.totalEmployeeAvailableHours() + Number( self.hoursAvailable ) ); vm.totalEmployeeAvailableHours( vm.totalEmployeeAvailableHours() + Number( self.hoursAvailable ) );
vm.totalAvailableRevenues( Number( vm.totalAvailableRevenues() ) + Number( self.availableRevenue ) );
vm.totalOwp( Number( vm.totalOwp() ) + Number( self.owp ) );
self.totalEmployeeRevenues = dbo.helpers.thousandSeparator( self.totalEmployeeRevenues ); self.totalEmployeeRevenues = dbo.helpers.thousandSeparator( self.totalEmployeeRevenues );
self.availableRevenue = dbo.helpers.thousandSeparator( self.availableRevenue ); self.availableRevenue = dbo.helpers.thousandSeparator( self.availableRevenue );
self.workInProgress = dbo.helpers.thousandSeparator( data.workInProgress ); self.workInProgress = dbo.helpers.thousandSeparator( data.workInProgress );
self.owp = dbo.helpers.thousandSeparator( self.owp );
self.hoursAvailable = data.hoursAvailable; self.hoursAvailable = data.hoursAvailable;
self.invoiced = ko.observableArray( [] ); self.invoiced = ko.observableArray( [] );