added recurring scope to document models
This commit is contained in:
parent
10a39de970
commit
a6a13481fe
@ -30,8 +30,24 @@ class DocumentHistory extends Model
|
|||||||
return $query->where($this->qualifyColumn('type'), '=', Document::INVOICE_TYPE);
|
return $query->where($this->qualifyColumn('type'), '=', Document::INVOICE_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function scopeInvoiceRecurring(Builder $query): Builder
|
||||||
|
{
|
||||||
|
return $query->where($this->qualifyColumn('type'), '=', Document::INVOICE_RECURRING_TYPE)
|
||||||
|
->whereHas('document.recurring', function (Builder $query) {
|
||||||
|
$query->whereNull('deleted_at');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public function scopeBill(Builder $query)
|
public function scopeBill(Builder $query)
|
||||||
{
|
{
|
||||||
return $query->where($this->qualifyColumn('type'), '=', Document::BILL_TYPE);
|
return $query->where($this->qualifyColumn('type'), '=', Document::BILL_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function scopeBillRecurring(Builder $query): Builder
|
||||||
|
{
|
||||||
|
return $query->where($this->qualifyColumn('type'), '=', Document::BILL_RECURRING_TYPE)
|
||||||
|
->whereHas('document.recurring', function (Builder $query) {
|
||||||
|
$query->whereNull('deleted_at');
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -100,11 +100,27 @@ class DocumentItem extends Model
|
|||||||
return $query->where($this->qualifyColumn('type'), '=', Document::INVOICE_TYPE);
|
return $query->where($this->qualifyColumn('type'), '=', Document::INVOICE_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function scopeInvoiceRecurring(Builder $query): Builder
|
||||||
|
{
|
||||||
|
return $query->where($this->qualifyColumn('type'), '=', Document::INVOICE_RECURRING_TYPE)
|
||||||
|
->whereHas('document.recurring', function (Builder $query) {
|
||||||
|
$query->whereNull('deleted_at');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public function scopeBill(Builder $query)
|
public function scopeBill(Builder $query)
|
||||||
{
|
{
|
||||||
return $query->where($this->qualifyColumn('type'), '=', Document::BILL_TYPE);
|
return $query->where($this->qualifyColumn('type'), '=', Document::BILL_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function scopeBillRecurring(Builder $query): Builder
|
||||||
|
{
|
||||||
|
return $query->where($this->qualifyColumn('type'), '=', Document::BILL_RECURRING_TYPE)
|
||||||
|
->whereHas('document.recurring', function (Builder $query) {
|
||||||
|
$query->whereNull('deleted_at');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public function getDiscountAttribute(): string
|
public function getDiscountAttribute(): string
|
||||||
{
|
{
|
||||||
if (setting('localisation.percent_position', 'after') === 'after') {
|
if (setting('localisation.percent_position', 'after') === 'after') {
|
||||||
|
@ -41,11 +41,27 @@ class DocumentItemTax extends Model
|
|||||||
return $query->where($this->qualifyColumn('type'), '=', Document::INVOICE_TYPE);
|
return $query->where($this->qualifyColumn('type'), '=', Document::INVOICE_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function scopeInvoiceRecurring(Builder $query): Builder
|
||||||
|
{
|
||||||
|
return $query->where($this->qualifyColumn('type'), '=', Document::INVOICE_RECURRING_TYPE)
|
||||||
|
->whereHas('document.recurring', function (Builder $query) {
|
||||||
|
$query->whereNull('deleted_at');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public function scopeBill(Builder $query)
|
public function scopeBill(Builder $query)
|
||||||
{
|
{
|
||||||
return $query->where($this->qualifyColumn('type'), '=', Document::BILL_TYPE);
|
return $query->where($this->qualifyColumn('type'), '=', Document::BILL_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function scopeBillRecurring(Builder $query): Builder
|
||||||
|
{
|
||||||
|
return $query->where($this->qualifyColumn('type'), '=', Document::BILL_RECURRING_TYPE)
|
||||||
|
->whereHas('document.recurring', function (Builder $query) {
|
||||||
|
$query->whereNull('deleted_at');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public function onCloned($src)
|
public function onCloned($src)
|
||||||
{
|
{
|
||||||
$document_item = DocumentItem::find($this->document_item_id);
|
$document_item = DocumentItem::find($this->document_item_id);
|
||||||
|
@ -33,11 +33,27 @@ class DocumentTotal extends Model
|
|||||||
return $query->where($this->qualifyColumn('type'), '=', Document::INVOICE_TYPE);
|
return $query->where($this->qualifyColumn('type'), '=', Document::INVOICE_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function scopeInvoiceRecurring(Builder $query): Builder
|
||||||
|
{
|
||||||
|
return $query->where($this->qualifyColumn('type'), '=', Document::INVOICE_RECURRING_TYPE)
|
||||||
|
->whereHas('document.recurring', function (Builder $query) {
|
||||||
|
$query->whereNull('deleted_at');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public function scopeBill(Builder $query)
|
public function scopeBill(Builder $query)
|
||||||
{
|
{
|
||||||
return $query->where($this->qualifyColumn('type'), '=', Document::BILL_TYPE);
|
return $query->where($this->qualifyColumn('type'), '=', Document::BILL_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function scopeBillRecurring(Builder $query): Builder
|
||||||
|
{
|
||||||
|
return $query->where($this->qualifyColumn('type'), '=', Document::BILL_RECURRING_TYPE)
|
||||||
|
->whereHas('document.recurring', function (Builder $query) {
|
||||||
|
$query->whereNull('deleted_at');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public function scopeCode($query, $code)
|
public function scopeCode($query, $code)
|
||||||
{
|
{
|
||||||
return $query->where('code', '=', $code);
|
return $query->where('code', '=', $code);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user