diff --git a/app/Models/Document/DocumentHistory.php b/app/Models/Document/DocumentHistory.php index dd51b1f8c..b4ce0fef2 100644 --- a/app/Models/Document/DocumentHistory.php +++ b/app/Models/Document/DocumentHistory.php @@ -17,7 +17,7 @@ class DocumentHistory extends Model public function document() { - return $this->belongsTo('App\Models\Document\Document'); + return $this->belongsTo('App\Models\Document\Document')->where('type', $this->type); } public function scopeType(Builder $query, string $type) diff --git a/app/Models/Document/DocumentItem.php b/app/Models/Document/DocumentItem.php index 8317fc1f1..0093ddda1 100644 --- a/app/Models/Document/DocumentItem.php +++ b/app/Models/Document/DocumentItem.php @@ -61,7 +61,7 @@ class DocumentItem extends Model public function document() { - return $this->belongsTo('App\Models\Document\Document'); + return $this->belongsTo('App\Models\Document\Document')->where('type', $this->type); } public function item() @@ -126,7 +126,7 @@ class DocumentItem extends Model $tax_ids = []; foreach ($this->taxes as $tax) { - $tax_ids[] = (string)$tax->tax_id; + $tax_ids[] = (string) $tax->tax_id; } $this->setAttribute('tax_ids', $tax_ids); diff --git a/app/Models/Document/DocumentItemTax.php b/app/Models/Document/DocumentItemTax.php index e71c03019..a94ba08ce 100644 --- a/app/Models/Document/DocumentItemTax.php +++ b/app/Models/Document/DocumentItemTax.php @@ -6,7 +6,6 @@ use App\Abstracts\Model; use App\Traits\Currencies; use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Relations\BelongsTo; -use Znck\Eloquent\Relations\BelongsToThrough as BelongsToThroughRelation; use Znck\Eloquent\Traits\BelongsToThrough; class DocumentItemTax extends Model @@ -28,7 +27,7 @@ class DocumentItemTax extends Model public function document() { - return $this->belongsTo('App\Models\Document\Document'); + return $this->belongsTo('App\Models\Document\Document')->where('type', $this->type); } public function item() diff --git a/app/Models/Document/DocumentTotal.php b/app/Models/Document/DocumentTotal.php index 7304e83c2..51fb62513 100644 --- a/app/Models/Document/DocumentTotal.php +++ b/app/Models/Document/DocumentTotal.php @@ -29,7 +29,7 @@ class DocumentTotal extends Model public function document() { - return $this->belongsTo('App\Models\Document\Document'); + return $this->belongsTo('App\Models\Document\Document')->where('type', $this->type); } public function scopeType(Builder $query, string $type) diff --git a/resources/assets/js/views/common/documents.js b/resources/assets/js/views/common/documents.js index bb70a29da..069f31745 100644 --- a/resources/assets/js/views/common/documents.js +++ b/resources/assets/js/views/common/documents.js @@ -601,6 +601,10 @@ const app = new Vue({ this.onCalculateTotal(); }, + onBindingItemField(item_index, field_name) { + this.form.items[item_index][field_name] = this.items[item_index][field_name]; + }, + async onPayment() { let document_id = document.getElementById('document_id').value; diff --git a/resources/views/partials/form/multi_select_add_new_group.blade.php b/resources/views/partials/form/multi_select_add_new_group.blade.php index 6540c8763..a19c1599f 100644 --- a/resources/views/partials/form/multi_select_add_new_group.blade.php +++ b/resources/views/partials/form/multi_select_add_new_group.blade.php @@ -67,6 +67,10 @@ @change="{{ $attributes['change'] }}($event)" @endif + @if (!empty($attributes['visible-change'])) + @visible-change="{{ $attributes['visible-change'] }}" + @endif + @if (isset($attributes['readonly'])) :readonly="{{ $attributes['readonly'] }}" @endif diff --git a/resources/views/partials/form/multi_select_group.blade.php b/resources/views/partials/form/multi_select_group.blade.php index bc3e15c91..bbc7c9e46 100644 --- a/resources/views/partials/form/multi_select_group.blade.php +++ b/resources/views/partials/form/multi_select_group.blade.php @@ -45,6 +45,10 @@ @change="{{ $attributes['change'] }}($event)" @endif + @if (!empty($attributes['visible-change'])) + @visible-change="{{ $attributes['visible-change'] }}" + @endif + @if (isset($attributes['readonly'])) :readonly="{{ $attributes['readonly'] }}" @endif diff --git a/resources/views/partials/form/multi_select_remote_add_new_group.blade.php b/resources/views/partials/form/multi_select_remote_add_new_group.blade.php index f031af80b..8f6e25580 100644 --- a/resources/views/partials/form/multi_select_remote_add_new_group.blade.php +++ b/resources/views/partials/form/multi_select_remote_add_new_group.blade.php @@ -69,6 +69,10 @@ @change="{{ $attributes['change'] }}($event)" @endif + @if (!empty($attributes['visible-change'])) + @visible-change="{{ $attributes['visible-change'] }}" + @endif + @if (isset($attributes['readonly'])) :readonly="{{ $attributes['readonly'] }}" @endif diff --git a/resources/views/partials/form/multi_select_remote_group.blade.php b/resources/views/partials/form/multi_select_remote_group.blade.php index aa25aa606..a462a4132 100644 --- a/resources/views/partials/form/multi_select_remote_group.blade.php +++ b/resources/views/partials/form/multi_select_remote_group.blade.php @@ -47,6 +47,10 @@ @change="{{ $attributes['change'] }}($event)" @endif + @if (!empty($attributes['visible-change'])) + @visible-change="{{ $attributes['visible-change'] }}" + @endif + @if (isset($attributes['readonly'])) :readonly="{{ $attributes['readonly'] }}" @endif diff --git a/resources/views/partials/form/select_add_new_group.blade.php b/resources/views/partials/form/select_add_new_group.blade.php index e34cc828c..4c0540c40 100644 --- a/resources/views/partials/form/select_add_new_group.blade.php +++ b/resources/views/partials/form/select_add_new_group.blade.php @@ -61,6 +61,10 @@ @change="{{ $attributes['change'] }}($event)" @endif + @if (!empty($attributes['visible-change'])) + @visible-change="{{ $attributes['visible-change'] }}" + @endif + @if (isset($attributes['readonly'])) :readonly="{{ $attributes['readonly'] }}" @endif diff --git a/resources/views/partials/form/select_group.blade.php b/resources/views/partials/form/select_group.blade.php index f9b0f31cc..3b96d963c 100644 --- a/resources/views/partials/form/select_group.blade.php +++ b/resources/views/partials/form/select_group.blade.php @@ -39,6 +39,10 @@ @change="{{ $attributes['change'] }}($event)" @endif + @if (!empty($attributes['visible-change'])) + @visible-change="{{ $attributes['visible-change'] }}" + @endif + @if (isset($attributes['readonly'])) :readonly="{{ $attributes['readonly'] }}" @endif diff --git a/resources/views/partials/form/select_group_add_new_group.blade.php b/resources/views/partials/form/select_group_add_new_group.blade.php index a713a66c4..c16bba08b 100644 --- a/resources/views/partials/form/select_group_add_new_group.blade.php +++ b/resources/views/partials/form/select_group_add_new_group.blade.php @@ -63,6 +63,10 @@ @change="{{ $attributes['change'] }}($event)" @endif + @if (!empty($attributes['visible-change'])) + @visible-change="{{ $attributes['visible-change'] }}" + @endif + @if (isset($attributes['readonly'])) :readonly="{{ $attributes['readonly'] }}" @endif diff --git a/resources/views/partials/form/select_group_group.blade.php b/resources/views/partials/form/select_group_group.blade.php index 17b161fe0..b539e3c85 100644 --- a/resources/views/partials/form/select_group_group.blade.php +++ b/resources/views/partials/form/select_group_group.blade.php @@ -41,6 +41,10 @@ @change="{{ $attributes['change'] }}($event)" @endif + @if (!empty($attributes['visible-change'])) + @visible-change="{{ $attributes['visible-change'] }}" + @endif + @if (isset($attributes['readonly'])) :readonly="{{ $attributes['readonly'] }}" @endif diff --git a/resources/views/partials/form/select_remote_add_new_group.blade.php b/resources/views/partials/form/select_remote_add_new_group.blade.php index edf4c1f9a..004efbfbf 100644 --- a/resources/views/partials/form/select_remote_add_new_group.blade.php +++ b/resources/views/partials/form/select_remote_add_new_group.blade.php @@ -63,6 +63,10 @@ @change="{{ $attributes['change'] }}($event)" @endif + @if (!empty($attributes['visible-change'])) + @visible-change="{{ $attributes['visible-change'] }}" + @endif + @if (isset($attributes['readonly'])) :readonly="{{ $attributes['readonly'] }}" @endif diff --git a/resources/views/partials/form/select_remote_group.blade.php b/resources/views/partials/form/select_remote_group.blade.php index 46371c00d..358f28cac 100644 --- a/resources/views/partials/form/select_remote_group.blade.php +++ b/resources/views/partials/form/select_remote_group.blade.php @@ -41,6 +41,10 @@ @change="{{ $attributes['change'] }}($event)" @endif + @if (!empty($attributes['visible-change'])) + @visible-change="{{ $attributes['visible-change'] }}" + @endif + @if (isset($attributes['readonly'])) :readonly="{{ $attributes['readonly'] }}" @endif