invoice added new columns

This commit is contained in:
2019-04-30 19:07:18 +02:00
parent ecb2d3437c
commit ddea739199
5 changed files with 55 additions and 2 deletions
+13
View File
@@ -15,6 +15,19 @@ class Payment extends BaseModel {
return $this->belongsTo( 'Invoice' );
}
public static function getPaymentPerProject( $projectID )
{
$projectPayment = self::selectRAW( 'id, invoice_id, SUM(paymentamount) as payment' )
->whereHas( 'invoice', function ( $q ) use ( $projectID ) {
$q->whereProjectId( $projectID );
} )
->first();
if( ! $projectPayment) return 0;
return $projectPayment->payment;
}
public static function savePayment( $paymentID, $payment )
{
$payment = (array) $payment;