Merge pull request #2304 from sevannerse/CU-1pbthq3_Make-Recurring-Easier-to-Find--Edit_Sevan-Nerse

Make recurring easier to find
This commit is contained in:
Cüneyt Şentürk
2021-11-11 14:22:21 +03:00
committed by GitHub
17 changed files with 230 additions and 25 deletions

View File

@ -314,6 +314,12 @@ abstract class TransactionShow extends Base
/** @var string */
public $classFooterHistories;
/** @var string */
public $textRecurringType;
/** @var bool */
public $hideRecurringMessage;
/**
* Create a new component instance.
*
@ -346,7 +352,7 @@ abstract class TransactionShow extends Base
bool $hideAttachment = false, $attachment = [],
bool $hideFooter = false, bool $hideFooterHistories = false, $histories = [],
string $textHistories = '', string $classFooterHistories = ''
string $textHistories = '', string $classFooterHistories = '', string $textRecurringType = '', bool $hideRecurringMessage = false
) {
$this->type = $type;
$this->transaction = $transaction;
@ -354,6 +360,8 @@ abstract class TransactionShow extends Base
$this->logo = $this->getLogo($logo);
$this->payment_methods = ($payment_methods) ?: Modules::getPaymentMethods('all');
$this->date_format = $this->getCompanyDateFormat();
$this->textRecurringType = $this->getTextRecurringType($type, $textRecurringType);
$this->hideRecurringMessage = $hideRecurringMessage;
// Navbar Hide
$this->hideButtonAddNew = $hideButtonAddNew;
@ -1276,4 +1284,21 @@ abstract class TransactionShow extends Base
return 'col-sm-6 col-md-6 col-lg-6 col-xl-6';
}
protected function getTextRecurringType($type, $textRecurringType)
{
if (!empty($textRecurringType)) {
return $textRecurringType;
}
$default_key = config('type.' . $type . '.translation.prefix');
$translation = $this->getTextFromConfig($type, 'recurring_tye', $default_key);
if (!empty($translation)) {
return $translation;
}
return 'general.revenues';
}
}

View File

@ -32,6 +32,8 @@ class Transaction extends FormRequest
'category_id' => 'required|integer',
'payment_method' => 'required|string',
'attachment.*' => $attachment,
'recurring_count' => 'gte:0',
'recurring_interval' => 'exclude_unless:recurring_frequency,custom|gt:0',
];
}

View File

@ -61,6 +61,8 @@ class Document extends FormRequest
'category_id' => 'required|integer',
'company_logo' => $company_logo,
'attachment.*' => $attachment,
'recurring_count' => 'gte:0',
'recurring_interval' => 'exclude_unless:recurring_frequency,custom|gt:0',
];
$items = $this->request->get('items');

View File

@ -126,6 +126,11 @@ class Transaction extends Model
return $this->belongsTo('App\Models\Auth\User', 'contact_id', 'id');
}
public function parent()
{
return $this->belongsTo('App\Models\Banking\Transaction', 'parent_id');
}
/**
* Scope to only include contacts of a given type.
*

View File

@ -144,6 +144,11 @@ class Document extends Model
return $this->totals()->orderBy('sort_order');
}
public function parent()
{
return $this->belongsTo('App\Models\Document\Document', 'parent_id');
}
public function scopeLatest(Builder $query)
{
return $query->orderBy('issued_at', 'desc');

View File

@ -89,12 +89,12 @@ class SearchString extends Component
$column = $options['key'];
}
if (isset($options['relationship'])) {
if (isset($options['foreign_key'])) {
$column .= '.' . $options['foreign_key'];
} else {
$column .= '.id';
}
if (isset($options['relationship']) && isset($options['foreign_key']) && !empty($options['foreign_key'])) {
$column .= '.' . $options['foreign_key'];
}
if (isset($options['relationship']) && !isset($options['foreign_key'])) {
$column .= '.id';
}
return $column;