This commit is contained in:
2018-06-11 08:17:01 +02:00
parent c539d03fb6
commit 4954d6fcca
2 changed files with 14 additions and 15 deletions
+6 -4
View File
@@ -16,6 +16,11 @@ class Project extends BaseModel {
return $this->hasMany( 'Offer' );
}
public function offer()
{
return $this->hasOne( 'Offer' );
}
public function projectemployees()
{
return $this->hasMany( 'Projectemployee' );
@@ -105,10 +110,7 @@ class Project extends BaseModel {
'projectleader' => function ( $q ) {
$q->selectRaw( "id, CONCAT(firstname, ' ', middlename, ' ', lastname) AS fullname" );
}] )
->with( [
'offers' => function ( $q ) {
$q->whereArchive( 'F' );
}] )
->with( 'offer' )
->with( [
'projectemployees.user' => function ( $q ) {
$q->selectRaw( "id, CONCAT(firstname, ' ', middlename, ' ', lastname) AS fullname" );
+8 -11
View File
@@ -804,7 +804,6 @@ $( function () {
vm.projectnumber( data.projectnumber );
vm.projectname( data.projectname );
vm.vat_id( data.vat_id );
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.outstanding( dbo.helpers.numberWithPoints( Math.round( Number( totalRevenuesIncl ) ) - Math.round( Number( data.invoiceDetails.totalinvoiced ) ) ) );
@@ -814,6 +813,14 @@ $( function () {
vm.projectEmployees.removeAll();
vm.projecthours.removeAll();
vm.ownRevenue( dbo.helpers.numberWithPoints( Math.round( Number( data.offer.own_revenue ) ) ) );
vm.otherRevenue( dbo.helpers.numberWithPoints( Math.round( Number( data.offer.other_revenue ) ) ) );
vm.costs(dbo.helpers.numberWithPoints( Math.round( Number( data.offer.costs ) ) ) );
var revenues = Number(data.offer.own_revenue) + Number(data.offer.other_revenue) + Number(data.offer.costs);
vm.totalRevenues( dbo.helpers.numberWithPoints( Math.round( revenues ) ) );
_.each( data.projectemployees, function ( p ) {
vm.projectEmployees.push( new vm.Projectemployee( p ) );
} );
@@ -830,16 +837,6 @@ $( function () {
vm.projectcosts.push( new vm.Projectcost( p ) );
} );
vm.offers.removeAll();
_.each( data.offers, function ( p, i ) {
if ( i == 0 ) {
vm.ownRevenue( dbo.helpers.numberWithPoints( Math.round( Number( p.own_revenue ) ) ) );
vm.otherRevenue( dbo.helpers.numberWithPoints( Math.round( Number( p.other_revenue ) ) ) )
vm.costs(dbo.helpers.numberWithPoints( Math.round( Number( p.costs ) ) ) )
}
vm.offers.push( new dbo.offersService.Offer( p ) );
} );
vm.invoices.removeAll();
_.each( data.invoices, function ( p ) {
vm.invoices.push( new vm.Invoice( p ) );