Spreadsheet
This commit is contained in:
@@ -24,6 +24,28 @@ class Invoice extends BaseModel {
|
||||
return $this->belongsTo( 'Vat' );
|
||||
}
|
||||
|
||||
public static function invoicePerYear( $projectID, $year, $thatYear = TRUE )
|
||||
{
|
||||
$invoices = Invoice::selectRAW( 'SUM(invoiceamount * ( 1 +(vatrate / 100))) AS invoicetotal' )
|
||||
->join( 'vats', 'vats.id', '=', 'invoices.vat_id' )
|
||||
->whereProjectId( $projectID );
|
||||
|
||||
if ( $thatYear )
|
||||
{
|
||||
$invoices = $invoices->whereRaw( "YEAR(invoicedate) = {$year}" );
|
||||
}
|
||||
else
|
||||
{
|
||||
$invoices = $invoices->whereRaw( "YEAR(invoicedate) != {$year}" );
|
||||
}
|
||||
|
||||
if ( $invoices->count() == 0 ) return 0;
|
||||
|
||||
$invoices = $invoices->first();
|
||||
|
||||
return $invoices->invoicetotal;
|
||||
}
|
||||
|
||||
public static function saveInvoice( $invoiceID, $invoice )
|
||||
{
|
||||
$invoice = (array) $invoice;
|
||||
|
||||
@@ -104,6 +104,13 @@ class Project extends BaseModel {
|
||||
return $projects;
|
||||
}
|
||||
|
||||
public static function getProjectsForReport()
|
||||
{
|
||||
$projects = self::getBaseProject()->get();
|
||||
|
||||
return $projects;
|
||||
}
|
||||
|
||||
public static function getBaseProject()
|
||||
{
|
||||
$project = Project::with( [
|
||||
@@ -115,6 +122,7 @@ class Project extends BaseModel {
|
||||
'projectemployees.user' => function ( $q ) {
|
||||
$q->selectRaw( "id, CONCAT(firstname, ' ', middlename, ' ', lastname) AS fullname" );
|
||||
}] )
|
||||
->with('vat')
|
||||
->with(['forecasts'])
|
||||
->with(['reservations'])
|
||||
->with( 'projectemployees.projecthours' )
|
||||
|
||||
Reference in New Issue
Block a user