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;
use App\Abstracts\Http\FormRequest;
use App\Models\Banking\Transaction as Model;
use App\Utilities\Date;
class Transaction extends FormRequest
@ -14,15 +15,15 @@ class Transaction extends FormRequest
*/
public function rules()
{
$attachment = 'nullable';
$type = $this->request->get('type', Model::INCOME_TYPE);
if ($this->files->get('attachment')) {
$attachment = 'mimes:' . config('filesystems.mimes') . '|between:0,' . config('filesystems.max_size') * 1024;
}
$type = config('type.transaction.' . $type . '.route.parameter');
// Check if store or update
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 {
$id = null;
}
@ -30,6 +31,12 @@ class Transaction extends FormRequest
// 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 [
'type' => 'required|string',
'number' => 'required|string|unique:transactions,NULL,' . $id . ',id,company_id,' . $company_id . ',deleted_at,NULL',

View File

@ -89,14 +89,14 @@
</el-option>
</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'">
{{ endText }}
</div>
<el-date-picker
class="w-36 ml-2 recurring-invoice-data"
class="w-36 ml-2 recurring-invoice-data"
v-model="limitDate"
type="date"
align="right"
@ -211,7 +211,7 @@ export default {
customFrequency: '',
started_at: '',
limit: '',
limitCount: '',
limitCount: 0,
limitDate: '',
formatDate: 'dd MM YYYY',
}
@ -231,10 +231,10 @@ export default {
this.limitDate = this.limitDateValue;
if (this.limit == 'count') {
if (typeof this.limitDate == 'string') {
this.limit = 'never';
} else {
if (this.limitCount > 0) {
this.limit = 'after';
} else {
this.limit = 'never';
}
} else {
this.limit = 'on';
@ -258,10 +258,12 @@ export default {
case 'after':
this.$emit('limit', 'count');
this.$emit('limit_count', this.limitCount);
this.$emit('limit_date', null);
break;
case 'on':
this.$emit('limit', 'date');
this.$emit('limit_date', this.limitDate);
this.$emit('limit_count', 0);
break;
case 'never':
default:

View File

@ -1,11 +1,11 @@
<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')) }}"
middleText="{!! trans('recurring.limit_middle') !!}"
endText="{{ Str::plural($type) }}"
end-text="{{ Str::plural(Str::replace('-recurring', '', $type)) }}"
: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-value="{{ $frequency }}"
:frequency-error="form.errors.get('recurring_frequency')"