mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Add subscription filters
This commit is contained in:
parent
dc4e0b9c96
commit
c5de8de343
@ -112,6 +112,7 @@ class ActivityController extends BaseController
|
||||
'purchase_order' => $activity->purchase_order ? $activity->purchase_order : '',
|
||||
'subscription' => $activity->subscription ? $activity->subscription : '',
|
||||
'vendor_contact' => $activity->vendor_contact ? $activity->vendor_contact : '',
|
||||
'recurring_expense' => $activity->recurring_expense ? $activity->recurring_expense : '',
|
||||
];
|
||||
|
||||
return array_merge($arr, $activity->toArray());
|
||||
|
@ -15,6 +15,7 @@ namespace App\Http\Controllers;
|
||||
use App\Events\Subscription\SubscriptionWasCreated;
|
||||
use App\Events\Subscription\SubscriptionWasUpdated;
|
||||
use App\Factory\SubscriptionFactory;
|
||||
use App\Filters\SubscriptionFilters;
|
||||
use App\Http\Requests\Subscription\CreateSubscriptionRequest;
|
||||
use App\Http\Requests\Subscription\DestroySubscriptionRequest;
|
||||
use App\Http\Requests\Subscription\EditSubscriptionRequest;
|
||||
|
@ -61,9 +61,9 @@ class InvoiceTransformer extends BaseTransformer
|
||||
'discount' => $this->getFreshbookQuantityFloat($record, 'Discount Percentage'),
|
||||
'is_amount_discount' => false,
|
||||
'tax_name1' => $this->getString($record, 'Tax 1 Type'),
|
||||
'tax_rate1' => $this->getFreshbookQuantityFloat($record, 'Tax 1 Amount'),
|
||||
'tax_rate1' => $this->calcTaxRate($record, 'Tax 1 Amount'),
|
||||
'tax_name2' => $this->getString($record, 'Tax 2 Type'),
|
||||
'tax_rate2' => $this->getFreshbookQuantityFloat($record, 'Tax 2 Amount'),
|
||||
'tax_rate2' => $this->calcTaxRate($record, 'Tax 2 Amount'),
|
||||
];
|
||||
$transformed['amount'] += $this->getFreshbookQuantityFloat($record, 'Line Total');
|
||||
}
|
||||
@ -79,6 +79,27 @@ class InvoiceTransformer extends BaseTransformer
|
||||
return $transformed;
|
||||
}
|
||||
|
||||
//Line Subtotal
|
||||
public function calcTaxRate($record, $field)
|
||||
{
|
||||
if(isset($record['Line Subtotal']) && $record['Line Subtotal'] > 0)
|
||||
return ($record[$field] / $record['Line Subtotal']) * 100;
|
||||
|
||||
$tax_amount1 = isset($record['Tax 1 Amount']) ? $record['Tax 1 Amount'] : 0;
|
||||
|
||||
$tax_amount2 = isset($record['Tax 2 Amount']) ? $record['Tax 2 Amount'] : 0;
|
||||
|
||||
$line_total = isset($record['Line Total']) ? $record['Line Total'] : 0;
|
||||
|
||||
$subtotal = $line_total - $tax_amount2 - $tax_amount1;
|
||||
|
||||
if($subtotal > 0)
|
||||
return $record[$field] / $subtotal * 100;
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
/** @return float */
|
||||
public function getFreshbookQuantityFloat($data, $field)
|
||||
{
|
||||
|
@ -214,21 +214,33 @@ class Activity extends StaticModel
|
||||
'backup',
|
||||
];
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getHashedIdAttribute()
|
||||
{
|
||||
return $this->encodePrimaryKey($this->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getEntityType()
|
||||
{
|
||||
return self::class;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function backup()
|
||||
{
|
||||
return $this->hasOne(Backup::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function history()
|
||||
{
|
||||
return $this->hasOne(Backup::class);
|
||||
@ -266,6 +278,9 @@ class Activity extends StaticModel
|
||||
return $this->belongsTo(Invoice::class)->withTrashed();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function vendor()
|
||||
{
|
||||
return $this->belongsTo(Vendor::class)->withTrashed();
|
||||
@ -279,6 +294,9 @@ class Activity extends StaticModel
|
||||
return $this->belongsTo(RecurringInvoice::class)->withTrashed();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function credit()
|
||||
{
|
||||
return $this->belongsTo(Credit::class)->withTrashed();
|
||||
@ -308,31 +326,57 @@ class Activity extends StaticModel
|
||||
return $this->belongsTo(Payment::class)->withTrashed();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function expense()
|
||||
{
|
||||
return $this->belongsTo(Expense::class)->withTrashed();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function recurring_expense()
|
||||
{
|
||||
return $this->belongsTo(RecurringExpense::class)->withTrashed();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function purchase_order()
|
||||
{
|
||||
return $this->belongsTo(PurchaseOrder::class)->withTrashed();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function vendor_contact()
|
||||
{
|
||||
return $this->belongsTo(VendorContact::class)->withTrashed();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function task()
|
||||
{
|
||||
return $this->belongsTo(Task::class)->withTrashed();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function company()
|
||||
{
|
||||
return $this->belongsTo(Company::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function resolveRouteBinding($value, $field = null)
|
||||
{
|
||||
if (is_numeric($value)) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user