diff --git a/app/Jobs/Document/CreateDocumentItemsAndTotals.php b/app/Jobs/Document/CreateDocumentItemsAndTotals.php index 5f6e2b299..3670b1bc9 100644 --- a/app/Jobs/Document/CreateDocumentItemsAndTotals.php +++ b/app/Jobs/Document/CreateDocumentItemsAndTotals.php @@ -168,15 +168,20 @@ class CreateDocumentItemsAndTotals extends Job } if (empty($item['item_id'])) { - $new_item = $this->dispatch(new CreateItem([ + $new_item_request = [ 'company_id' => $this->request['company_id'], 'name' => $item['name'], 'description' => $item['description'], 'sale_price' => $item['price'], 'purchase_price' => $item['price'], - 'tax_ids' => $item['tax_ids'], 'enabled' => '1' - ])); + ]; + + if (!empty($item['tax_ids'])) { + $new_item_request['tax_ids'] = $item['tax_ids']; + } + + $new_item = $this->dispatch(new CreateItem($new_item_request)); $item['item_id'] = $new_item->id; } diff --git a/resources/assets/js/components/AkauntingSelect.vue b/resources/assets/js/components/AkauntingSelect.vue index 779141695..7616e2295 100644 --- a/resources/assets/js/components/AkauntingSelect.vue +++ b/resources/assets/js/components/AkauntingSelect.vue @@ -605,17 +605,71 @@ export default { selected: function (selected) { if (!this.multiple) { this.selected = selected.toString(); + } else { + if (Array.isArray(this.selected) && !this.selected.length) { + this.selected = selected; + } else { + let is_string = false; + let pre_value = []; + + selected.forEach(item => { + if (typeof item != 'string') { + is_string = true; + pre_value.push(item.toString()); + } + }); + + if (is_string) { + this.selected = pre_value; + } + } } }, value: function (selected) { - this.selected = selected; + if (!this.multiple) { + this.selected = selected.toString(); + } else { + if (Array.isArray(this.selected) && !this.selected.length) { + this.selected = selected; + } else { + let is_string = false; + let pre_value = []; + + selected.forEach(item => { + if (typeof item != 'string') { + is_string = true; + pre_value.push(item.toString()); + } + }); + + if (is_string) { + this.selected = pre_value; + } + } + } this.change(); }, model: function (selected) { - this.selected = selected; + if (!this.multiple) { + this.selected = selected.toString(); + } else { + let is_string = false; + let pre_value = []; + + selected.forEach(item => { + if (typeof item != 'string') { + is_string = true; + pre_value.push(item.toString()); + } + }); + + if (is_string) { + this.selected = pre_value; + } + } this.change(); }, diff --git a/resources/assets/js/components/AkauntingSelectRemote.vue b/resources/assets/js/components/AkauntingSelectRemote.vue index ce1a0895c..e69466d9e 100644 --- a/resources/assets/js/components/AkauntingSelectRemote.vue +++ b/resources/assets/js/components/AkauntingSelectRemote.vue @@ -817,11 +817,41 @@ export default { selected: function (selected) { if (!this.multiple) { this.selected = selected.toString(); + } else { + let is_string = false; + let pre_value = []; + + selected.forEach(item => { + if (typeof item != 'string') { + is_string = true; + pre_value.push(item.toString()); + } + }); + + if (is_string) { + this.selected = pre_value; + } } }, value: function (selected) { - this.selected = selected; + if (!this.multiple) { + this.selected = selected; + } else { + let is_string = false; + let pre_value = []; + + selected.forEach(item => { + if (typeof item != 'string') { + is_string = true; + pre_value.push(item.toString()); + } + }); + + if (is_string) { + this.selected = pre_value; + } + } this.change(); }, diff --git a/resources/assets/js/views/common/documents.js b/resources/assets/js/views/common/documents.js index 5f07bea4c..bb70a29da 100644 --- a/resources/assets/js/views/common/documents.js +++ b/resources/assets/js/views/common/documents.js @@ -73,7 +73,7 @@ const app = new Vue({ let grand_total = 0; // items calculate - this.items.forEach(function(item) { + this.items.forEach(function(item, index) { let discount = 0; item.total = item.price * item.quantity; @@ -188,6 +188,12 @@ const app = new Vue({ sub_total += item.total; grand_total += item.grand_total; + + this.form.items[index].description = item.description; + this.form.items[index].quantity = item.quantity; + this.form.items[index].price = item.price; + this.form.items[index].discount = item.discount; + this.form.items[index].total = item.total; }, this); this.totals.sub = sub_total;