mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-30 23:04:34 -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 : '',
|
'purchase_order' => $activity->purchase_order ? $activity->purchase_order : '',
|
||||||
'subscription' => $activity->subscription ? $activity->subscription : '',
|
'subscription' => $activity->subscription ? $activity->subscription : '',
|
||||||
'vendor_contact' => $activity->vendor_contact ? $activity->vendor_contact : '',
|
'vendor_contact' => $activity->vendor_contact ? $activity->vendor_contact : '',
|
||||||
|
'recurring_expense' => $activity->recurring_expense ? $activity->recurring_expense : '',
|
||||||
];
|
];
|
||||||
|
|
||||||
return array_merge($arr, $activity->toArray());
|
return array_merge($arr, $activity->toArray());
|
||||||
|
@ -15,6 +15,7 @@ namespace App\Http\Controllers;
|
|||||||
use App\Events\Subscription\SubscriptionWasCreated;
|
use App\Events\Subscription\SubscriptionWasCreated;
|
||||||
use App\Events\Subscription\SubscriptionWasUpdated;
|
use App\Events\Subscription\SubscriptionWasUpdated;
|
||||||
use App\Factory\SubscriptionFactory;
|
use App\Factory\SubscriptionFactory;
|
||||||
|
use App\Filters\SubscriptionFilters;
|
||||||
use App\Http\Requests\Subscription\CreateSubscriptionRequest;
|
use App\Http\Requests\Subscription\CreateSubscriptionRequest;
|
||||||
use App\Http\Requests\Subscription\DestroySubscriptionRequest;
|
use App\Http\Requests\Subscription\DestroySubscriptionRequest;
|
||||||
use App\Http\Requests\Subscription\EditSubscriptionRequest;
|
use App\Http\Requests\Subscription\EditSubscriptionRequest;
|
||||||
|
@ -61,9 +61,9 @@ class InvoiceTransformer extends BaseTransformer
|
|||||||
'discount' => $this->getFreshbookQuantityFloat($record, 'Discount Percentage'),
|
'discount' => $this->getFreshbookQuantityFloat($record, 'Discount Percentage'),
|
||||||
'is_amount_discount' => false,
|
'is_amount_discount' => false,
|
||||||
'tax_name1' => $this->getString($record, 'Tax 1 Type'),
|
'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_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');
|
$transformed['amount'] += $this->getFreshbookQuantityFloat($record, 'Line Total');
|
||||||
}
|
}
|
||||||
@ -79,6 +79,27 @@ class InvoiceTransformer extends BaseTransformer
|
|||||||
return $transformed;
|
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 */
|
/** @return float */
|
||||||
public function getFreshbookQuantityFloat($data, $field)
|
public function getFreshbookQuantityFloat($data, $field)
|
||||||
{
|
{
|
||||||
|
@ -214,21 +214,33 @@ class Activity extends StaticModel
|
|||||||
'backup',
|
'backup',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
public function getHashedIdAttribute()
|
public function getHashedIdAttribute()
|
||||||
{
|
{
|
||||||
return $this->encodePrimaryKey($this->id);
|
return $this->encodePrimaryKey($this->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
public function getEntityType()
|
public function getEntityType()
|
||||||
{
|
{
|
||||||
return self::class;
|
return self::class;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
public function backup()
|
public function backup()
|
||||||
{
|
{
|
||||||
return $this->hasOne(Backup::class);
|
return $this->hasOne(Backup::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
public function history()
|
public function history()
|
||||||
{
|
{
|
||||||
return $this->hasOne(Backup::class);
|
return $this->hasOne(Backup::class);
|
||||||
@ -266,6 +278,9 @@ class Activity extends StaticModel
|
|||||||
return $this->belongsTo(Invoice::class)->withTrashed();
|
return $this->belongsTo(Invoice::class)->withTrashed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
public function vendor()
|
public function vendor()
|
||||||
{
|
{
|
||||||
return $this->belongsTo(Vendor::class)->withTrashed();
|
return $this->belongsTo(Vendor::class)->withTrashed();
|
||||||
@ -279,6 +294,9 @@ class Activity extends StaticModel
|
|||||||
return $this->belongsTo(RecurringInvoice::class)->withTrashed();
|
return $this->belongsTo(RecurringInvoice::class)->withTrashed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
public function credit()
|
public function credit()
|
||||||
{
|
{
|
||||||
return $this->belongsTo(Credit::class)->withTrashed();
|
return $this->belongsTo(Credit::class)->withTrashed();
|
||||||
@ -308,31 +326,57 @@ class Activity extends StaticModel
|
|||||||
return $this->belongsTo(Payment::class)->withTrashed();
|
return $this->belongsTo(Payment::class)->withTrashed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
public function expense()
|
public function expense()
|
||||||
{
|
{
|
||||||
return $this->belongsTo(Expense::class)->withTrashed();
|
return $this->belongsTo(Expense::class)->withTrashed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function recurring_expense()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(RecurringExpense::class)->withTrashed();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
public function purchase_order()
|
public function purchase_order()
|
||||||
{
|
{
|
||||||
return $this->belongsTo(PurchaseOrder::class)->withTrashed();
|
return $this->belongsTo(PurchaseOrder::class)->withTrashed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
public function vendor_contact()
|
public function vendor_contact()
|
||||||
{
|
{
|
||||||
return $this->belongsTo(VendorContact::class)->withTrashed();
|
return $this->belongsTo(VendorContact::class)->withTrashed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
public function task()
|
public function task()
|
||||||
{
|
{
|
||||||
return $this->belongsTo(Task::class)->withTrashed();
|
return $this->belongsTo(Task::class)->withTrashed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
public function company()
|
public function company()
|
||||||
{
|
{
|
||||||
return $this->belongsTo(Company::class);
|
return $this->belongsTo(Company::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
public function resolveRouteBinding($value, $field = null)
|
public function resolveRouteBinding($value, $field = null)
|
||||||
{
|
{
|
||||||
if (is_numeric($value)) {
|
if (is_numeric($value)) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user