diff --git a/resources/assets/js/components/AkauntingContactCard.vue b/resources/assets/js/components/AkauntingContactCard.vue index 714fbe406..8f66383a2 100644 --- a/resources/assets/js/components/AkauntingContactCard.vue +++ b/resources/assets/js/components/AkauntingContactCard.vue @@ -169,6 +169,7 @@ export default { }, error: { type: String, + default: '', description: "Input error (below input)" }, selected: { @@ -593,7 +594,7 @@ export default { this.$emit('change', this.contact); } - } , + }, computed: { sortContacts() { diff --git a/resources/assets/js/mixins/global.js b/resources/assets/js/mixins/global.js index 0c111958c..b17e26608 100644 --- a/resources/assets/js/mixins/global.js +++ b/resources/assets/js/mixins/global.js @@ -70,7 +70,7 @@ export default { "symbol_first":1, "decimal_mark":".", "thousands_separator":",", - } + }, } }, @@ -414,13 +414,15 @@ export default { // Change Contact Card set form fields.. onChangeContactCard(contact) { this.form.contact_id = contact.id; - this.form.contact_name = contact.name; - this.form.contact_email = contact.email; - this.form.contact_tax_number = contact.tax_number; - this.form.contact_phone = contact.phone; - this.form.contact_address = contact.address; + this.form.contact_name = (contact.title) ? contact.title : (contact.display_name) ? contact.display_name : contact.name; + this.form.contact_email = (contact.email) ? contact.email : ''; + this.form.contact_tax_number = (contact.tax_number) ? contact.tax_number : ''; + this.form.contact_phone = (contact.phone) ? contact.phone : ''; + this.form.contact_address = (contact.address) ? contact.address : ''; - this.form.currency_code = contact.currency_code; + let currency_code = (contact.currency_code) ? contact.currency_code : this.form.currency_code; + + this.onChangeCurrency(currency_code); } } } \ No newline at end of file diff --git a/resources/assets/js/views/common/documents.js b/resources/assets/js/views/common/documents.js index 5c9bc7190..981ed9d04 100644 --- a/resources/assets/js/views/common/documents.js +++ b/resources/assets/js/views/common/documents.js @@ -50,10 +50,10 @@ const app = new Vue({ discounts: [], tax_id: [], - items: [], taxes: [], page_loaded: false, + currencies: [], } }, @@ -61,6 +61,10 @@ const app = new Vue({ if ((document.getElementById('items') != null) && (document.getElementById('items').rows)) { this.colspan = document.getElementById("items").rows[0].cells.length - 1; } + + if (document_currencies) { + this.currencies = document_currencies; + } }, methods: { @@ -513,6 +517,31 @@ const app = new Vue({ // always executed }); }, + + // Change currency get money + onChangeCurrency(currency_code) { + if (!this.currencies.length) { + let currency_promise = Promise.resolve(window.axios.get((url + '/settings/currencies'))); + + currency_promise.then(response => { + if ( response.data.success) { + this.currencies = response.data.data; + } + }) + .catch(error => { + this.onChangeCurrency(); + }); + } + + this.currencies.forEach(function (currency, index) { + if (currency_code == currency.code) { + this.currency = currency; + + this.form.currency_code = currency.code; + this.form.currency_rate = currency.rate; + } + }, this); + }, }, created() {