closed #2420 Fixed : Document and Transaction recurring template edit issue.

This commit is contained in:
Cüneyt Şentürk 2022-06-03 20:02:54 +03:00
parent 5d409b142a
commit d2d5073efa
3 changed files with 26 additions and 17 deletions

View File

@ -3,6 +3,7 @@
namespace App\Http\Requests\Banking; namespace App\Http\Requests\Banking;
use App\Abstracts\Http\FormRequest; use App\Abstracts\Http\FormRequest;
use App\Models\Banking\Transaction as Model;
use App\Utilities\Date; use App\Utilities\Date;
class Transaction extends FormRequest class Transaction extends FormRequest
@ -14,15 +15,15 @@ class Transaction extends FormRequest
*/ */
public function rules() public function rules()
{ {
$attachment = 'nullable'; $type = $this->request->get('type', Model::INCOME_TYPE);
if ($this->files->get('attachment')) { $type = config('type.transaction.' . $type . '.route.parameter');
$attachment = 'mimes:' . config('filesystems.mimes') . '|between:0,' . config('filesystems.max_size') * 1024;
}
// Check if store or update // Check if store or update
if ($this->getMethod() == 'PATCH') { if ($this->getMethod() == 'PATCH') {
$id = $this->transaction->getAttribute('id'); $model = $this->isApi() ? 'document' : $type;
$id = is_numeric($this->$model) ? $this->$model : $this->{$model}->getAttribute('id');
} else { } else {
$id = null; $id = null;
} }
@ -30,6 +31,12 @@ class Transaction extends FormRequest
// Get company id // Get company id
$company_id = (int) $this->request->get('company_id'); $company_id = (int) $this->request->get('company_id');
$attachment = 'nullable';
if ($this->files->get('attachment')) {
$attachment = 'mimes:' . config('filesystems.mimes') . '|between:0,' . config('filesystems.max_size') * 1024;
}
return [ return [
'type' => 'required|string', 'type' => 'required|string',
'number' => 'required|string|unique:transactions,NULL,' . $id . ',id,company_id,' . $company_id . ',deleted_at,NULL', 'number' => 'required|string|unique:transactions,NULL,' . $id . ',id,company_id,' . $company_id . ',deleted_at,NULL',

View File

@ -89,14 +89,14 @@
</el-option> </el-option>
</el-select> </el-select>
<input type="text" class="w-36 form-element ml-2" v-model="limitDate" v-if="limit == 'after'" @input="change"> <input type="text" class="w-20 form-element ml-2" v-model="limitCount" v-if="limit == 'after'" @input="change">
<div class="pl-2 text-sm" v-if="limit == 'after'"> <div class="pl-2 text-sm" v-if="limit == 'after'">
{{ endText }} {{ endText }}
</div> </div>
<el-date-picker <el-date-picker
class="w-36 ml-2 recurring-invoice-data" class="w-36 ml-2 recurring-invoice-data"
v-model="limitDate" v-model="limitDate"
type="date" type="date"
align="right" align="right"
@ -186,8 +186,8 @@ export default {
}, },
limitCountValue: { limitCountValue: {
type: [Number, String], type: [Number, String],
default: 0, default: 0,
description: "Default reccuring limit" description: "Default reccuring limit"
}, },
@ -211,7 +211,7 @@ export default {
customFrequency: '', customFrequency: '',
started_at: '', started_at: '',
limit: '', limit: '',
limitCount: '', limitCount: 0,
limitDate: '', limitDate: '',
formatDate: 'dd MM YYYY', formatDate: 'dd MM YYYY',
} }
@ -231,10 +231,10 @@ export default {
this.limitDate = this.limitDateValue; this.limitDate = this.limitDateValue;
if (this.limit == 'count') { if (this.limit == 'count') {
if (typeof this.limitDate == 'string') { if (this.limitCount > 0) {
this.limit = 'never';
} else {
this.limit = 'after'; this.limit = 'after';
} else {
this.limit = 'never';
} }
} else { } else {
this.limit = 'on'; this.limit = 'on';
@ -258,10 +258,12 @@ export default {
case 'after': case 'after':
this.$emit('limit', 'count'); this.$emit('limit', 'count');
this.$emit('limit_count', this.limitCount); this.$emit('limit_count', this.limitCount);
this.$emit('limit_date', null);
break; break;
case 'on': case 'on':
this.$emit('limit', 'date'); this.$emit('limit', 'date');
this.$emit('limit_date', this.limitDate); this.$emit('limit_date', this.limitDate);
this.$emit('limit_count', 0);
break; break;
case 'never': case 'never':
default: default:
@ -287,4 +289,4 @@ export default {
.el-input__inner { .el-input__inner {
height: 42px; height: 42px;
} }
</style> </style>

View File

@ -1,11 +1,11 @@
<akaunting-recurring <akaunting-recurring
start-text="{!! trans('recurring.limit_date', ['type' => \Str::replace('-recurring', '', $type)]) !!}" start-text="{!! trans('recurring.limit_date', ['type' => Str::replace('-recurring', '', $type)]) !!}"
:date-range-text="{{ json_encode(trans('general.date_range')) }}" :date-range-text="{{ json_encode(trans('general.date_range')) }}"
middleText="{!! trans('recurring.limit_middle') !!}" middleText="{!! trans('recurring.limit_middle') !!}"
endText="{{ Str::plural($type) }}" end-text="{{ Str::plural(Str::replace('-recurring', '', $type)) }}"
:frequencies="{{ json_encode($frequencies) }}" :frequencies="{{ json_encode($frequencies) }}"
frequency-text="{!! trans('recurring.frequency_type', ['type' => \Str::replace('-recurring', '', $type)]) !!}" frequency-text="{!! trans('recurring.frequency_type', ['type' => Str::replace('-recurring', '', $type)]) !!}"
frequency-every-text="{!! trans('recurring.every') !!}" frequency-every-text="{!! trans('recurring.every') !!}"
frequency-value="{{ $frequency }}" frequency-value="{{ $frequency }}"
:frequency-error="form.errors.get('recurring_frequency')" :frequency-error="form.errors.get('recurring_frequency')"