Diversen nav opmerkingen

This commit is contained in:
2018-05-06 20:39:59 +02:00
parent a3d200c38b
commit c7846f9a80
16 changed files with 126 additions and 82 deletions
+6
View File
@@ -41,6 +41,11 @@ class Project extends BaseModel {
return $this->hasMany( 'Reservation' );
}
public function vat()
{
return $this->belongsTo('Vat');
}
public function projectleader()
{
return $this->belongsTo( 'User', 'projectleader_id' );
@@ -112,6 +117,7 @@ class Project extends BaseModel {
->with( 'projectcosts.external' )
->with( 'invoices.payments' )
->with( 'invoices.vat' )
->with( 'vat' )
->with( 'customer' );
return $project;
@@ -14,7 +14,12 @@ class ReservationTotals {
$sql = "SELECT Q5.project_id AS projectID, external_id AS externalID,
costs, reservation, payed, (reservation - payed) AS saldo,
(costs - payed) AS saldoToPay, PRJ.projectnumber, EXT.contactperson,
ROUND(( (other_revenue * (100 + (SELECT vatrate from vats where active='T' LIMIT 1))) / 100 ), 0) other_revenue
ROUND(( (other_revenue * (100 + (
SELECT vatrate
FROM vats VTS
JOIN projects P
ON VTS.id = P.vat_id
WHERE P.id = PRJ.id LIMIT 1))) / 100 ), 0) other_revenue
FROM (
SELECT COALESCE(reservation, 0) AS reservation, costs, payed, Q2.external_id, Q2.project_id
FROM (